annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/cache/ThematicDataCacheCleaner.java @ 1117:dec4257ad570

Changed imports to fit new positions of XMLUtils and Config gnv-artifacts/trunk@1478 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 15 Mar 2011 16:13:39 +0000
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 870
diff changeset
8
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 *
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 package de.intevation.gnv.state.cache;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import java.util.ArrayList;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import java.util.Collection;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import java.util.Iterator;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 import java.util.List;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import net.sf.ehcache.Cache;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import org.apache.log4j.Logger;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Document;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.Element;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import org.w3c.dom.NodeList;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25
1117
dec4257ad570 Changed imports to fit new positions of XMLUtils and Config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1115
diff changeset
26 import de.intevation.artifacts.common.utils.Config;
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.artifacts.cache.CacheFactory;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import de.intevation.gnv.geobackend.base.query.cache.CacheCleaner;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import de.intevation.gnv.state.StateBase;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import de.intevation.gnv.utils.ArtifactXMLUtilities;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 * Extended Class of the CacheCleaner.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 * This Cleaner has the job to cleanup the ThematicData-Cache if it
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * is necessary.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 *
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 public class ThematicDataCacheCleaner extends CacheCleaner {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 * the logger, used to log exceptions and additonaly information
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 private static Logger log = Logger.getLogger(ThematicDataCacheCleaner.class);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
49
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
50 private final static String XPATH_ARTIFACTS =
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 "/artifact-database/artifacts/artifact";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 private final static String XPATH_STATES = "states/state";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 private final static String XPATH_STATEID = "id";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 private final static String XPATH_QUERYID = "queryID";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 * The Queries that should be Cleaned with its links to the
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 * StateIds.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 private Collection<QueryObject> queryObjects = null;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 public ThematicDataCacheCleaner() {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 public ThematicDataCacheCleaner(Runnable arg0) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 public ThematicDataCacheCleaner(String arg0) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 public ThematicDataCacheCleaner(ThreadGroup arg0, String arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 public ThematicDataCacheCleaner(Runnable arg0, String arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 * @param arg2
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1, String arg2) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 * @param arg2
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127 * @param arg3
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 String arg2, long arg3) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 * Initializes the QueryObjects.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 * The Queryobjects will be read from the Configuration.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 * Only Queries which are defined in <code>queryID</code>-Elements
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 * are used.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139 * The other Queries are currently not put into the Cache.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 @Override
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 protected void setUp(){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 super.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
144 this.queryObjects = new ArrayList<QueryObject>();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 Document configuration = Config.getConfig();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 NodeList artifactList = Config.getNodeSetXPath(configuration,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 XPATH_ARTIFACTS);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 log.debug("ThematicDataCacheCleaner.setUp()");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 if (artifactList != null && artifactList.getLength() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 for (int i = 0; i < artifactList.getLength(); i++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 Element currentArtifactNode = (Element)artifactList.item(i);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
152
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 String link = currentArtifactNode.getAttribute("xlink:href");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 if (link != null && link.length() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 String absolutFileName = Config.replaceConfigDir(link);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 currentArtifactNode = (Element)new ArtifactXMLUtilities()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 .readConfiguration(absolutFileName);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159 NodeList stateList = Config.getNodeSetXPath(currentArtifactNode,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160 XPATH_STATES);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 if (stateList != null && stateList.getLength() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 for (int j = 0; j < stateList.getLength() ; j++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 Element currentStateNode = (Element)stateList.item(j);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 String stateId = currentStateNode
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165 .getAttribute(XPATH_STATEID);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
166 String queryID = Config.getStringXPath(currentStateNode,
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 XPATH_QUERYID);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 try {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 if (queryID != null){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 String query = QueryContainerFactory
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 .getInstance()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 .getQueryContainer()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 .getQuery(queryID);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174 QueryObject qo = new QueryObject(stateId, query);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175 queryObjects.add(qo);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177 } catch (QueryContainerException e) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 log.error(e,e);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
183 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
184 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186 @Override
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187 protected void cleanup() {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 log.debug("ThematicDataCacheCleaner.cleanup");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 try {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 if (queryObjects != null && queryObjects.size() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 String[] tableNames = this.getUpdatedTableNames();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 if (tableNames != null && tableNames.length > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193 Iterator<QueryObject> it = queryObjects.iterator();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 while (it.hasNext()){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 QueryObject qo = it.next();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 for (int i = 0; i < tableNames.length; i++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 if (qo.queryContainsTableName(tableNames[i])){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 String stateId = qo.getStateId();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 this.cleanUpCache(stateId);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 break;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 }else{
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 log.debug("No Tables found to cleanup.");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 }else{
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 log.warn("No Queries to clean");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 } catch (QueryException e) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 log.error(e,e);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 * Removes the Entries which Keys matches to the <code>stateId</code>
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 * from the Cache.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
218 * @param stateId The Id of the State which Entries has to be removed.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 private void cleanUpCache(String stateId){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 log.debug("ThematicDataCacheCleaner.cleanUpCache "+stateId);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 CacheFactory factory = CacheFactory.getInstance();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 Cache cache = factory.getCache();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 List<String> keys = cache.getKeys();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 String keySample = StateBase.HASH_ID_SEPARATOR +
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
226 stateId +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
227 StateBase.HASH_ID_SEPARATOR;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 if (keys != null && keys.size() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 Iterator<String> it = keys.iterator();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
230 while (it.hasNext()){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 String key = it.next();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 if (key != null && key.contains(keySample)){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 boolean removed = cache.remove(key);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 if (!removed){
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
235 log.warn("Object with Key " +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 key + "could not be removed from Cache");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 }else{
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
238 log.debug("Object with Key " +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
239 key + "has been removed from Cache");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
240 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
241 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
242 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
243 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
244 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
245 }

http://dive4elements.wald.intevation.org