Revision 45
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/package.info | ||
---|---|---|
1 | 1 |
# |
2 |
#Mon Dec 19 09:33:39 CET 2011
|
|
2 |
#Tue Dec 20 09:01:29 CET 2011
|
|
3 | 3 |
state=devel |
4 | 4 |
name=org.gvsig.educa.thematicmap.app.viewer |
5 | 5 |
buildNumber=0 |
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/src/main/java/org/gvsig/educa/thematicmap/app/viewer/ThematicMapDocument.java | ||
---|---|---|
22 | 22 |
package org.gvsig.educa.thematicmap.app.viewer; |
23 | 23 |
|
24 | 24 |
import org.apache.commons.lang3.ObjectUtils; |
25 |
import org.apache.commons.lang3.StringUtils; |
|
26 | 25 |
|
27 | 26 |
import org.gvsig.app.project.documents.AbstractDocument; |
28 | 27 |
import org.gvsig.app.project.documents.DocumentManager; |
... | ... | |
153 | 152 |
String id = state.getString("id"); |
154 | 153 |
String name = state.getString("name"); |
155 | 154 |
String comment = state.getString("comment"); |
156 |
String version = state.getString("version");
|
|
155 |
int version = state.getInt("version");
|
|
157 | 156 |
ViewDocument sourceView = (ViewDocument) state.get("sourceView"); |
158 | 157 |
int bn = state.getInt("buildNumber"); |
159 | 158 |
|
... | ... | |
168 | 167 |
} |
169 | 168 |
ThematicMapInformation info = map.getInformation(); |
170 | 169 |
|
171 |
if (!StringUtils.equals(info.getVersion(), version)) {
|
|
170 |
if (info.getVersion() != version) {
|
|
172 | 171 |
// XXX Make anything else |
173 | 172 |
LOG.warn( |
174 | 173 |
"Version number of ThematicMap {} no match: in project '{}', installed '{}'", |
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/src/main/java/org/gvsig/educa/thematicmap/app/viewer/exception/ThematicMapNotFoundException.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
private final String id; |
47 | 47 |
|
48 |
private final String version;
|
|
48 |
private final int version;
|
|
49 | 49 |
|
50 | 50 |
private final int buildNumber; |
51 | 51 |
|
52 | 52 |
/** |
53 | 53 |
* |
54 | 54 |
*/ |
55 |
public ThematicMapNotFoundException(String id, String version, |
|
56 |
int buildNumber) { |
|
55 |
public ThematicMapNotFoundException(String id, int version, int buildNumber) { |
|
57 | 56 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
58 | 57 |
this.id = id; |
59 | 58 |
this.version = version; |
... | ... | |
67 | 66 |
return id; |
68 | 67 |
} |
69 | 68 |
|
70 |
protected String getVersion() {
|
|
69 |
protected int getVersion() {
|
|
71 | 70 |
return version; |
72 | 71 |
} |
73 | 72 |
|
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/src/main/java/org/gvsig/educa/thematicmap/app/viewer/exception/ThematicMapLoadingException.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
private final String id; |
44 | 44 |
|
45 |
private final String version;
|
|
45 |
private final int version;
|
|
46 | 46 |
|
47 | 47 |
private final int buildNumber; |
48 | 48 |
|
49 | 49 |
/** |
50 | 50 |
* |
51 | 51 |
*/ |
52 |
public ThematicMapLoadingException(Exception ex, String id, String version,
|
|
52 |
public ThematicMapLoadingException(Exception ex, String id, int version,
|
|
53 | 53 |
int buildNumber) { |
54 | 54 |
super(MESSAGE_FORMAT, ex, MESSAGE_KEY, serialVersionUID); |
55 | 55 |
this.id = id; |
... | ... | |
64 | 64 |
return id; |
65 | 65 |
} |
66 | 66 |
|
67 |
protected String getVersion() {
|
|
67 |
protected int getVersion() {
|
|
68 | 68 |
return version; |
69 | 69 |
} |
70 | 70 |
|
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/pom.xml | ||
---|---|---|
22 | 22 |
<gvsig.ui.version>2.0.1-SNAPSHOT</gvsig.ui.version> |
23 | 23 |
<gvsig.tools.version>3.0.0-SNAPSHOT</gvsig.tools.version> |
24 | 24 |
<gvsig.timesupport>1.0.0-SNAPSHOT</gvsig.timesupport> |
25 |
<gvsig.installer.version>1.0.1-SNAPSHOT</gvsig.installer.version> |
|
25 | 26 |
<apache.commons-io.version>1.3.2</apache.commons-io.version> |
26 | 27 |
<apache.commons-lang3.version>3.1</apache.commons-lang3.version> |
27 | 28 |
</properties> |
... | ... | |
269 | 270 |
<classifier>store.mysql</classifier> |
270 | 271 |
<scope>runtime</scope> |
271 | 272 |
</dependency> |
273 |
<dependency> |
|
274 |
<groupId>org.gvsig</groupId> |
|
275 |
<artifactId>org.gvsig.installer.lib.api</artifactId> |
|
276 |
<version>${gvsig.installer.version}</version> |
|
277 |
</dependency> |
|
278 |
<dependency> |
|
279 |
<groupId>org.gvsig</groupId> |
|
280 |
<artifactId>org.gvsig.installer.lib.impl</artifactId> |
|
281 |
<version>${gvsig.installer.version}</version> |
|
282 |
<scope>runtime</scope> |
|
283 |
</dependency> |
|
272 | 284 |
|
273 | 285 |
|
274 | 286 |
<!-- apache commons --> |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/src/main/java/org/gvsig/educa/thematicmap/main/Main.java | ||
---|---|---|
570 | 570 |
if (resul.getStatus() == ThematicMapCompilerStatus.Status.finished_ok) { |
571 | 571 |
winManager.showMessageDialog(mainFrame, "Compile Thematic Map", |
572 | 572 |
"<html>Process successful:<br>" |
573 |
+ resul.getGeneratedFile().getAbsolutePath() + "</html>", |
|
573 |
+ resul.getGeneratedThematicMapFile().getAbsolutePath() + "</html>",
|
|
574 | 574 |
MESSAGE_DIALOG_TYPE.INFO); |
575 | 575 |
|
576 | 576 |
} else { |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.main/pom.xml | ||
---|---|---|
168 | 168 |
<classifier>store.mysql</classifier> |
169 | 169 |
<scope>runtime</scope> |
170 | 170 |
</dependency> |
171 |
<dependency> |
|
172 |
<groupId>org.gvsig</groupId> |
|
173 |
<artifactId>org.gvsig.installer.lib.impl</artifactId> |
|
174 |
</dependency> |
|
171 | 175 |
|
176 |
|
|
172 | 177 |
</dependencies> |
173 | 178 |
|
174 | 179 |
</project> |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/pom.xml | ||
---|---|---|
68 | 68 |
<classifier>se</classifier> |
69 | 69 |
<scope>test</scope> |
70 | 70 |
</dependency> |
71 |
<dependency>
|
|
72 |
<groupId>org.gvsig</groupId>
|
|
73 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId>
|
|
71 |
<dependency>
|
|
72 |
<groupId>org.gvsig</groupId>
|
|
73 |
<artifactId>org.gvsig.installer.lib.impl</artifactId>
|
|
74 | 74 |
<scope>test</scope> |
75 |
</dependency>
|
|
76 |
<dependency>
|
|
77 |
<groupId>org.gvsig</groupId>
|
|
78 |
<artifactId>org.gvsig.tools.swing.impl</artifactId>
|
|
75 |
</dependency>
|
|
76 |
<dependency>
|
|
77 |
<groupId>org.gvsig</groupId>
|
|
78 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId>
|
|
79 | 79 |
<scope>test</scope> |
80 |
</dependency>
|
|
80 |
</dependency>
|
|
81 | 81 |
<dependency> |
82 | 82 |
<groupId>org.gvsig</groupId> |
83 |
<artifactId>org.gvsig.tools.swing.impl</artifactId> |
|
84 |
<scope>test</scope> |
|
85 |
</dependency> |
|
86 |
<dependency> |
|
87 |
<groupId>org.gvsig</groupId> |
|
83 | 88 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
84 | 89 |
</dependency> |
90 |
<dependency> |
|
91 |
<groupId>org.gvsig</groupId> |
|
92 |
<artifactId>org.gvsig.installer.lib.api</artifactId> |
|
93 |
</dependency> |
|
85 | 94 |
|
86 | 95 |
<dependency> |
87 | 96 |
<groupId>org.apache.commons</groupId> |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/.classpath | ||
---|---|---|
108 | 108 |
<attribute name="javadoc_location" value="jar:file:/home/jmvivo/.m2/repository/org/gvsig/org.gvsig.i18n/2.0-SNAPSHOT/org.gvsig.i18n-2.0-SNAPSHOT-javadoc.jar!/"/> |
109 | 109 |
</attributes> |
110 | 110 |
</classpathentry> |
111 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.installer.lib.api/1.0.1-SNAPSHOT/org.gvsig.installer.lib.api-1.0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.installer.lib.api/1.0.1-SNAPSHOT/org.gvsig.installer.lib.api-1.0.1-SNAPSHOT-sources.jar"/> |
|
112 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.installer.lib.impl/1.0.1-SNAPSHOT/org.gvsig.installer.lib.impl-1.0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.installer.lib.impl/1.0.1-SNAPSHOT/org.gvsig.installer.lib.impl-1.0.1-SNAPSHOT-sources.jar"/> |
|
113 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.installer.lib.spi/1.0.1-SNAPSHOT/org.gvsig.installer.lib.spi-1.0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.installer.lib.spi/1.0.1-SNAPSHOT/org.gvsig.installer.lib.spi-1.0.1-SNAPSHOT-sources.jar"/> |
|
111 | 114 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.jdk.v1_6/1.0.0-SNAPSHOT/org.gvsig.jdk.v1_6-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.jdk.v1_6/1.0.0-SNAPSHOT/org.gvsig.jdk.v1_6-1.0.0-SNAPSHOT-sources.jar"/> |
112 | 115 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.maven.base.tools/1.0.8-SNAPSHOT/org.gvsig.maven.base.tools-1.0.8-SNAPSHOT.jar"/> |
113 | 116 |
<classpathentry kind="var" path="M2_REPO/org/gvsig/org.gvsig.metadata.lib.basic.api/1.0.0-SNAPSHOT/org.gvsig.metadata.lib.basic.api-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/gvsig/org.gvsig.metadata.lib.basic.api/1.0.0-SNAPSHOT/org.gvsig.metadata.lib.basic.api-1.0.0-SNAPSHOT-sources.jar"/> |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/DefaultThematicMapManager.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.io.File; |
25 | 25 |
import java.io.IOException; |
26 |
import java.text.MessageFormat; |
|
26 | 27 |
import java.util.ArrayList; |
27 | 28 |
import java.util.Collections; |
28 | 29 |
import java.util.List; |
29 | 30 |
|
30 | 31 |
import org.apache.commons.io.FilenameUtils; |
31 | 32 |
import org.apache.commons.lang3.ObjectUtils; |
33 |
import org.apache.commons.lang3.StringUtils; |
|
32 | 34 |
import org.slf4j.Logger; |
33 | 35 |
import org.slf4j.LoggerFactory; |
34 | 36 |
|
37 |
import org.gvsig.educa.thematicmap.ThematicMapException; |
|
35 | 38 |
import org.gvsig.educa.thematicmap.ThematicMapManager; |
36 | 39 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilation; |
37 | 40 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompiler; |
... | ... | |
41 | 44 |
import org.gvsig.educa.thematicmap.impl.map.ThematicMapLoader; |
42 | 45 |
import org.gvsig.educa.thematicmap.impl.util.FileUtils; |
43 | 46 |
import org.gvsig.educa.thematicmap.map.CantLoadContextException; |
47 |
import org.gvsig.educa.thematicmap.map.InvalidInstalledThematicMapException; |
|
44 | 48 |
import org.gvsig.educa.thematicmap.map.InvalidThematicMapFormatException; |
45 | 49 |
import org.gvsig.educa.thematicmap.map.ThematicMap; |
46 | 50 |
import org.gvsig.educa.thematicmap.map.ThematicMapInformation; |
51 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
47 | 52 |
import org.gvsig.tools.ToolsLocator; |
48 | 53 |
|
49 | 54 |
/** |
... | ... | |
62 | 67 |
private static final Logger LOG = LoggerFactory |
63 | 68 |
.getLogger(DefaultThematicMapManager.class); |
64 | 69 |
|
70 |
public static final String BASENAME_FORMAT_STRING = "{0}-{1}-BN{2}"; |
|
71 |
|
|
65 | 72 |
/** |
66 | 73 |
* Manager which manages when deploy/clean maps in |
67 | 74 |
* temporal folder |
... | ... | |
186 | 193 |
* @return |
187 | 194 |
*/ |
188 | 195 |
private List<ThematicMap> getMapsFromFolder(File folder) { |
189 |
File[] files = folder.listFiles(thematicMapFileFilter);
|
|
196 |
File[] files = folder.listFiles(); |
|
190 | 197 |
List<ThematicMap> result = new ArrayList<ThematicMap>(files.length); |
191 | 198 |
ThematicMap map; |
192 | 199 |
for (File file : files) { |
200 |
|
|
201 |
// Only readable folder |
|
202 |
if (!FileUtils.isReadableFolder(file)) { |
|
203 |
continue; |
|
204 |
} |
|
205 |
|
|
193 | 206 |
try { |
194 |
map = getMapFromFile(file);
|
|
195 |
} catch (InvalidThematicMapFormatException ex) {
|
|
196 |
// Ignore this file
|
|
207 |
map = getThematicMapIntalledFolder(file);
|
|
208 |
} catch (ThematicMapException ex) {
|
|
209 |
// Ignore this folder
|
|
197 | 210 |
continue; |
198 | 211 |
} |
199 | 212 |
result.add(map); |
... | ... | |
286 | 299 |
return new DefaultThematicMapCompilation(map); |
287 | 300 |
} |
288 | 301 |
|
302 |
/** |
|
303 |
* Gets a ThematicMap from a installed maps |
|
304 |
* |
|
305 |
* @param folder |
|
306 |
* @return |
|
307 |
* @throws InvalidInstalledThematicMapException |
|
308 |
*/ |
|
309 |
public ThematicMap getThematicMapIntalledFolder(File folder) |
|
310 |
throws ThematicMapException { |
|
311 |
// Only readable folder |
|
312 |
if (!FileUtils.isReadableFolder(folder)) { |
|
313 |
throw new InvalidInstalledThematicMapException(folder, |
|
314 |
"not a readable folder"); |
|
315 |
} |
|
316 |
String code = folder.getName(); |
|
317 |
|
|
318 |
// Load package info |
|
319 |
PackageInfo packageInfo = |
|
320 |
mapLoader.getPackageInfoFromInstalledThematicMap(folder); |
|
321 |
|
|
322 |
if (packageInfo == null) { |
|
323 |
throw new InvalidInstalledThematicMapException(folder, |
|
324 |
"missing package.info file"); |
|
325 |
} |
|
326 |
|
|
327 |
if (!StringUtils.equals(code, packageInfo.getCode())) { |
|
328 |
throw new InvalidInstalledThematicMapException(folder, |
|
329 |
"folder name doesn't match with package.info code"); |
|
330 |
} |
|
331 |
|
|
332 |
if (!StringUtils.equals("ThematicMap", packageInfo.getType())) { |
|
333 |
throw new InvalidInstalledThematicMapException(folder, |
|
334 |
"package.info type is not 'ThematicMap': ".concat(packageInfo |
|
335 |
.getType())); |
|
336 |
} |
|
337 |
|
|
338 |
// Gets the thematic map file |
|
339 |
ThematicMap map; |
|
340 |
String mapFileName = |
|
341 |
getBaseFileNameFromInfo(packageInfo.getCode(), |
|
342 |
packageInfo.getName(), packageInfo.getVersion().getMayor(), |
|
343 |
packageInfo.getVersion().getBuild()).concat( |
|
344 |
thematicMapFileFilter.getFileNameEnding()); |
|
345 |
File mapFile = new File(folder, mapFileName); |
|
346 |
if (!mapFile.exists()) { |
|
347 |
throw new InvalidInstalledThematicMapException(folder, "missing '" |
|
348 |
.concat(mapFileName).concat("' file")); |
|
349 |
} |
|
350 |
map = getMapFromFile(mapFile); |
|
351 |
|
|
352 |
if (map == null) { |
|
353 |
// This must be unreachable code |
|
354 |
throw new IllegalStateException(); |
|
355 |
} |
|
356 |
ThematicMapInformation info = map.getInformation(); |
|
357 |
|
|
358 |
// Compares pkgInfo.code and thmInfo.id |
|
359 |
if (!StringUtils.equals(packageInfo.getCode(), info.getId())) { |
|
360 |
throw new InvalidInstalledThematicMapException(folder, |
|
361 |
"package.info code doesn't match with ThematicMap.id"); |
|
362 |
} |
|
363 |
|
|
364 |
// Compares pkgInfo.version and thmInfo.version |
|
365 |
if (packageInfo.getVersion().getMayor() != info.getVersion()) { |
|
366 |
throw new InvalidInstalledThematicMapException(folder, |
|
367 |
"package.info version doesn't match with ThematicMap.version"); |
|
368 |
} |
|
369 |
|
|
370 |
// Compares pkgInfo.buildNumber and thmInfo.buildNumber |
|
371 |
if (packageInfo.getVersion().getBuild() != info.getBuildNumber()) { |
|
372 |
throw new InvalidInstalledThematicMapException(folder, |
|
373 |
"package.info build doesn't match with ThematicMap.buildNumber"); |
|
374 |
} |
|
375 |
|
|
376 |
return map; |
|
377 |
} |
|
378 |
|
|
379 |
/** {@inheridDoc} */ |
|
380 |
public boolean isAThematicMapIntalledFolder(File folder) { |
|
381 |
if (!FileUtils.isReadableFolder(folder)) { |
|
382 |
return false; |
|
383 |
} |
|
384 |
|
|
385 |
ThematicMap map; |
|
386 |
try { |
|
387 |
map = getThematicMapIntalledFolder(folder); |
|
388 |
} catch (Exception ex) { |
|
389 |
return false; |
|
390 |
} |
|
391 |
|
|
392 |
return map != null; |
|
393 |
|
|
394 |
} |
|
395 |
|
|
396 |
public String getBaseFileNameFromInfo(ThematicMapInformation info) { |
|
397 |
return getBaseFileNameFromInfo(info.getId(), info.getName(), |
|
398 |
info.getVersion(), info.getBuildNumber()); |
|
399 |
} |
|
400 |
|
|
401 |
public String getBaseFileNameFromInfo(String id, String name, int version, |
|
402 |
int buildNumber) { |
|
403 |
return MessageFormat.format(BASENAME_FORMAT_STRING, id, version, |
|
404 |
buildNumber); |
|
405 |
} |
|
289 | 406 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/map/ThematicMapLoader.java | ||
---|---|---|
36 | 36 |
import org.gvsig.educa.thematicmap.impl.util.IOUtils; |
37 | 37 |
import org.gvsig.educa.thematicmap.impl.util.PersistenceUtils; |
38 | 38 |
import org.gvsig.educa.thematicmap.map.CantLoadContextException; |
39 |
import org.gvsig.educa.thematicmap.map.InvalidInstalledThematicMapException; |
|
39 | 40 |
import org.gvsig.educa.thematicmap.map.InvalidThematicMapFormatException; |
40 | 41 |
import org.gvsig.educa.thematicmap.map.ThematicMapInformation; |
41 | 42 |
import org.gvsig.fmap.mapcontext.MapContext; |
43 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
44 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
45 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
46 |
import org.gvsig.installer.lib.api.PackageInfoReader; |
|
42 | 47 |
import org.gvsig.tools.ToolsLocator; |
43 | 48 |
import org.gvsig.tools.persistence.PersistenceManager; |
44 | 49 |
import org.gvsig.tools.persistence.PersistentState; |
... | ... | |
46 | 51 |
|
47 | 52 |
/** |
48 | 53 |
* Utility class which contain methods to load data from a ThematicMap file |
49 |
* |
|
54 |
*
|
|
50 | 55 |
* @author gvSIG Team |
51 | 56 |
* @version $Id$ |
52 |
* |
|
57 |
*
|
|
53 | 58 |
*/ |
54 | 59 |
public class ThematicMapLoader { |
55 | 60 |
|
56 | 61 |
private static final Logger LOG = LoggerFactory |
57 | 62 |
.getLogger(ThematicMapLoader.class); |
58 | 63 |
|
64 |
private final InstallerManager installerManager; |
|
65 |
|
|
66 |
private final PackageInfoReader packageInfoReader; |
|
67 |
|
|
59 | 68 |
/** |
69 |
* |
|
70 |
*/ |
|
71 |
public ThematicMapLoader() { |
|
72 |
installerManager = InstallerLocator.getInstallerManager(); |
|
73 |
packageInfoReader = installerManager.getDefaultPackageInfoReader(); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
60 | 77 |
* Loads the mapContext definition form the deploy folder of a thematic map |
61 |
* |
|
78 |
*
|
|
62 | 79 |
* @param mapFile |
63 | 80 |
* thematic map file name (for problems messages) |
64 | 81 |
* @param deployFolder |
... | ... | |
126 | 143 |
|
127 | 144 |
/** |
128 | 145 |
* Gets information from a thematicMapFile without uncompress it |
129 |
* |
|
146 |
*
|
|
130 | 147 |
* @param thematicMapfile |
131 | 148 |
* @return |
132 | 149 |
* @throws InvalidThematicMapFormatException |
... | ... | |
207 | 224 |
|
208 | 225 |
} |
209 | 226 |
|
227 |
public PackageInfo getPackageInfoFromInstalledThematicMap(File folder) |
|
228 |
throws InvalidInstalledThematicMapException { |
|
229 |
// Check for package.info file |
|
230 |
File packageInfoFile = new File(folder, "package.info"); |
|
231 |
if (!FileUtils.isReadableFile(packageInfoFile)) { |
|
232 |
return null; |
|
233 |
} |
|
234 |
|
|
235 |
PackageInfo packageInfo = installerManager.createPackageInfo(); |
|
236 |
InputStream in = null; |
|
237 |
try { |
|
238 |
in = FileUtils.openInputStream(packageInfoFile); |
|
239 |
packageInfoReader.read(packageInfo, in); |
|
240 |
} catch (Exception ex) { |
|
241 |
throw new InvalidInstalledThematicMapException(folder, ex); |
|
242 |
} finally { |
|
243 |
IOUtils.closeQuietly(in); |
|
244 |
} |
|
245 |
return packageInfo; |
|
246 |
} |
|
210 | 247 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/map/DefaultThematicMapInformation.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
/** |
40 | 40 |
* Default implementation of {@link ThematicMapInformation} |
41 |
* |
|
41 |
*
|
|
42 | 42 |
* @author gvSIG Team |
43 | 43 |
* @version $Id$ |
44 |
* |
|
44 |
*
|
|
45 | 45 |
*/ |
46 | 46 |
public class DefaultThematicMapInformation implements ThematicMapInformation, |
47 | 47 |
Persistent { |
... | ... | |
51 | 51 |
private String id; |
52 | 52 |
private String name; |
53 | 53 |
private String description; |
54 |
private String version;
|
|
54 |
private int version;
|
|
55 | 55 |
private int buildNumber; |
56 | 56 |
private Date creationTimestamp; |
57 | 57 |
private Envelope envelope; |
... | ... | |
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
/** {@inheridDoc} */ |
76 |
public String getVersion() {
|
|
76 |
public int getVersion() {
|
|
77 | 77 |
return version; |
78 | 78 |
} |
79 | 79 |
|
... | ... | |
138 | 138 |
id = state.getString("id"); |
139 | 139 |
name = state.getString("name"); |
140 | 140 |
description = state.getString("description"); |
141 |
version = state.getString("version");
|
|
141 |
version = state.getInt("version");
|
|
142 | 142 |
buildNumber = state.getInt("buildNumber"); |
143 | 143 |
creationTimestamp = state.getDate("creationTimestamp"); |
144 | 144 |
envelope = (Envelope) state.get("envelope"); |
... | ... | |
157 | 157 |
this.description = description; |
158 | 158 |
} |
159 | 159 |
|
160 |
protected void setVersion(String version) {
|
|
160 |
protected void setVersion(int version) {
|
|
161 | 161 |
this.version = version; |
162 | 162 |
} |
163 | 163 |
|
... | ... | |
199 | 199 |
definition.addDynFieldString("id").setMandatory(true); |
200 | 200 |
definition.addDynFieldString("name").setMandatory(true); |
201 | 201 |
definition.addDynFieldString("description").setMandatory(true); |
202 |
definition.addDynFieldString("version").setMandatory(true);
|
|
202 |
definition.addDynFieldInt("version").setMandatory(true);
|
|
203 | 203 |
definition.addDynFieldInt("buildNumber").setMandatory(true); |
204 | 204 |
definition.addDynFieldDate("creationTimestamp").setMandatory(true); |
205 | 205 |
|
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/DefaultThematicMapCompilation.java | ||
---|---|---|
107 | 107 |
if (StringUtils.isEmpty(info.getDescription())) { |
108 | 108 |
addMsgWarning(messages, "Missing Description", source); |
109 | 109 |
} |
110 |
if (StringUtils.isEmpty(info.getVersion())) { |
|
111 |
addMsgWarning(messages, "Missing Version", source); |
|
112 |
isOk = false; |
|
113 |
} |
|
114 | 110 |
// TODO more checks |
115 | 111 |
return isOk; |
116 | 112 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/DefaultThematicMapCompilerStatus.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* Implementation of {@link ThematicMapCompilation} |
33 |
* |
|
33 |
*
|
|
34 | 34 |
* @author gvSIG Team |
35 | 35 |
* @version $Id$ |
36 |
* |
|
36 |
*
|
|
37 | 37 |
*/ |
38 | 38 |
public class DefaultThematicMapCompilerStatus implements |
39 | 39 |
ThematicMapCompilerStatus { |
... | ... | |
48 | 48 |
private String failMessage; |
49 | 49 |
private Throwable exception = null; |
50 | 50 |
private File generatedFile = null; |
51 |
private File generatedInstalledFolder = null; |
|
51 | 52 |
private ThematicMapCompilation resultCompilation; |
52 | 53 |
|
53 | 54 |
/** {@inheridDoc} */ |
... | ... | |
62 | 63 |
|
63 | 64 |
/** |
64 | 65 |
* Set current process percent |
65 |
* |
|
66 |
*
|
|
66 | 67 |
* @param percent |
67 | 68 |
*/ |
68 | 69 |
public void setPercent(int percent) { |
... | ... | |
76 | 77 |
|
77 | 78 |
/** |
78 | 79 |
* Set current step message |
79 |
* |
|
80 |
*
|
|
80 | 81 |
* @param message |
81 | 82 |
*/ |
82 | 83 |
public void setCurrentStepMessage(String message) { |
... | ... | |
90 | 91 |
|
91 | 92 |
/** |
92 | 93 |
* Set current step |
93 |
* |
|
94 |
*
|
|
94 | 95 |
* @param currentStep |
95 | 96 |
*/ |
96 | 97 |
public void setCurrentStep(int currentStep) { |
... | ... | |
104 | 105 |
|
105 | 106 |
/** |
106 | 107 |
* Set total steps |
107 |
* |
|
108 |
*
|
|
108 | 109 |
* @param totalSteps |
109 | 110 |
*/ |
110 | 111 |
public void setTotalSteps(int totalSteps) { |
... | ... | |
118 | 119 |
|
119 | 120 |
/** |
120 | 121 |
* Set the final compilation instance version |
121 |
* |
|
122 |
*
|
|
122 | 123 |
* @param compilation |
123 | 124 |
*/ |
124 | 125 |
public void setResultCompilation(ThematicMapCompilation compilation) { |
... | ... | |
127 | 128 |
|
128 | 129 |
/** |
129 | 130 |
* Set status to {@link Status#preparing} |
130 |
* |
|
131 |
*
|
|
131 | 132 |
*/ |
132 | 133 |
public void setPreparing() { |
133 | 134 |
if (status != null) { |
... | ... | |
157 | 158 |
} |
158 | 159 |
|
159 | 160 |
/** {@inheridDoc} */ |
160 |
public File getGeneratedFile() { |
|
161 |
public File getGeneratedThematicMapFile() {
|
|
161 | 162 |
return generatedFile; |
162 | 163 |
} |
163 | 164 |
|
... | ... | |
167 | 168 |
|
168 | 169 |
/** |
169 | 170 |
* Set status to {@link Status#finished_fail} |
170 |
* |
|
171 |
*
|
|
171 | 172 |
* @param message |
172 | 173 |
*/ |
173 | 174 |
public void setFail(String message) { |
... | ... | |
188 | 189 |
|
189 | 190 |
/** |
190 | 191 |
* Set status to {@link Status#finished_error} |
191 |
* |
|
192 |
*
|
|
192 | 193 |
* @param message |
193 | 194 |
* @param exception |
194 | 195 |
*/ |
... | ... | |
216 | 217 |
|
217 | 218 |
/** |
218 | 219 |
* Set current step name |
220 |
* |
|
219 | 221 |
* @param description |
220 | 222 |
*/ |
221 | 223 |
public void setCurrentStepDescription(String description) { |
... | ... | |
229 | 231 |
|
230 | 232 |
/** |
231 | 233 |
* Set current step i18n key |
234 |
* |
|
232 | 235 |
* @param name |
233 | 236 |
*/ |
234 | 237 |
public void setCurrentStepKey(String key) { |
235 | 238 |
curStepKey = key; |
236 | 239 |
} |
237 | 240 |
|
241 |
public void setGeneratedInstalationThematicMapFolder(File folder) { |
|
242 |
generatedInstalledFolder = folder; |
|
243 |
} |
|
238 | 244 |
|
245 |
/** {@inheridDoc} */ |
|
246 |
public File getGeneratedInstalationThematicMapFolder() { |
|
247 |
return generatedInstalledFolder; |
|
248 |
} |
|
249 |
|
|
239 | 250 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/DefaultThematicMapCompilationInformation.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
/** {@inheridDoc} */ |
87 | 87 |
@Override |
88 |
public void setVersion(String version) {
|
|
88 |
public void setVersion(int version) {
|
|
89 | 89 |
super.setVersion(version); |
90 | 90 |
} |
91 | 91 |
|
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/CleanWorkFolder.java | ||
---|---|---|
39 | 39 |
* <li>{@link ProcessData#WorkFolder}</li> |
40 | 40 |
* </ul> |
41 | 41 |
* </p> |
42 |
* |
|
42 |
*
|
|
43 | 43 |
* @author gvSIG Team |
44 | 44 |
* @version $Id$ |
45 |
* |
|
45 |
*
|
|
46 | 46 |
*/ |
47 | 47 |
public class CleanWorkFolder implements ProcessStep { |
48 | 48 |
|
... | ... | |
61 | 61 |
|
62 | 62 |
/** {@inheridDoc} */ |
63 | 63 |
public String getStepDescriptionKey() { |
64 |
return "Clean_work_folder";
|
|
64 |
return "cleaning_work_folder";
|
|
65 | 65 |
} |
66 | 66 |
|
67 | 67 |
/** {@inheridDoc} */ |
68 | 68 |
public String getStepDescription() { |
69 |
return "Clean work folder"; |
|
69 |
return "Cleaning work folder";
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/GenerateTargetFile.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.io.File; |
25 | 25 |
import java.io.IOException; |
26 |
import java.io.OutputStream; |
|
26 | 27 |
|
27 | 28 |
import org.slf4j.Logger; |
28 | 29 |
import org.slf4j.LoggerFactory; |
... | ... | |
30 | 31 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompiler; |
31 | 32 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerStatus; |
32 | 33 |
import org.gvsig.educa.thematicmap.impl.util.FileUtils; |
34 |
import org.gvsig.educa.thematicmap.impl.util.IOUtils; |
|
35 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
36 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
37 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
38 |
import org.gvsig.installer.lib.api.PackageInfoWriter; |
|
39 |
import org.gvsig.installer.lib.api.Version; |
|
33 | 40 |
|
34 | 41 |
/** |
35 | 42 |
* <p> |
... | ... | |
37 | 44 |
* </p> |
38 | 45 |
* <p> |
39 | 46 |
* This steps packs all contents of work folder into a temporal compressed file. |
40 |
* If all works, moves it to target final file. |
|
47 |
* If all works, creates install folder, its package info and moves the |
|
48 |
* compressed file. |
|
41 | 49 |
* </p> |
42 | 50 |
* <p> |
43 | 51 |
* From {@link ProcessData} Uses: |
... | ... | |
49 | 57 |
* and updates: |
50 | 58 |
* <ul> |
51 | 59 |
* <li>{@link ProcessData#status}. |
52 |
* {@link ThematicMapCompilerStatus#getGeneratedFile()}</li> |
|
60 |
* {@link ThematicMapCompilerStatus#getGeneratedThematicMapFile()}</li> |
|
61 |
* <li>{@link ProcessData#status}. |
|
62 |
* {@link ThematicMapCompilerStatus#getGeneratedInstalationThematicMapFolder()}</li> |
|
53 | 63 |
* </ul> |
54 | 64 |
* </p> |
55 |
* |
|
65 |
*
|
|
56 | 66 |
* @author gvSIG Team |
57 | 67 |
* @version $Id$ |
58 |
* |
|
68 |
*
|
|
59 | 69 |
*/ |
60 | 70 |
public class GenerateTargetFile implements ProcessStep { |
61 | 71 |
|
62 | 72 |
private static final Logger LOG = LoggerFactory |
63 | 73 |
.getLogger(GenerateTargetFile.class); |
64 | 74 |
|
75 |
private final InstallerManager installerManager; |
|
76 |
private final PackageInfoWriter pkgInfoWriter; |
|
77 |
|
|
78 |
/** |
|
79 |
* |
|
80 |
*/ |
|
81 |
public GenerateTargetFile() { |
|
82 |
installerManager = InstallerLocator.getInstallerManager(); |
|
83 |
pkgInfoWriter = installerManager.getDefaultPackageInfoWriter(); |
|
84 |
} |
|
85 |
|
|
65 | 86 |
/** {@inheridDoc} */ |
66 | 87 |
public String getStepDescriptionKey() { |
67 |
return "Generate_target_file";
|
|
88 |
return "generating_target_file";
|
|
68 | 89 |
} |
69 | 90 |
|
70 | 91 |
/** {@inheridDoc} */ |
71 | 92 |
public String getStepDescription() { |
72 |
return "Generate target file";
|
|
93 |
return "Generating target file";
|
|
73 | 94 |
} |
74 | 95 |
|
75 | 96 |
/** {@inheridDoc} */ |
... | ... | |
93 | 114 |
data.status.setError("Problem creating zip file", e); |
94 | 115 |
return; |
95 | 116 |
} |
117 |
|
|
118 |
// Create target folder |
|
119 |
File installFolder = new File(data.targetFolder, data.info.getId()); |
|
120 |
if (!installFolder.exists()) { |
|
121 |
installFolder.mkdirs(); |
|
122 |
} |
|
123 |
|
|
124 |
// create packageInfo |
|
125 |
PackageInfo pkgInfo = installerManager.createPackageInfo(); |
|
126 |
Version version = installerManager.createVersion(); |
|
127 |
|
|
128 |
pkgInfo.setCode(data.info.getId()); |
|
129 |
pkgInfo.setName(data.info.getName()); |
|
130 |
pkgInfo.setDescription(data.info.getDescription()); |
|
131 |
pkgInfo.setType("ThematicMap"); |
|
132 |
version.parse(String.valueOf(data.info.getVersion())); |
|
133 |
version.setBuild(data.info.getBuildNumber()); |
|
134 |
pkgInfo.setVersion(version); |
|
135 |
|
|
136 |
pkgInfo.setGvSIGVersion("2.0"); |
|
137 |
File pkfInfoFile = new File(installFolder, "package.info"); |
|
138 |
|
|
139 |
// write packageInfo |
|
140 |
OutputStream pkgInfoOut = null; |
|
96 | 141 |
try { |
142 |
pkgInfoOut = FileUtils.openOutputStream(pkfInfoFile); |
|
143 |
pkgInfoWriter.write(pkgInfo, pkgInfoOut); |
|
144 |
} catch (Exception ex) { |
|
145 |
data.status.setError("Problem creating package info file", ex); |
|
146 |
return; |
|
147 |
} finally { |
|
148 |
IOUtils.closeQuietly(pkgInfoOut); |
|
149 |
} |
|
150 |
|
|
151 |
try { |
|
97 | 152 |
// Copy file to target file |
98 | 153 |
org.apache.commons.io.FileUtils.copyFile(tmpFile, |
99 | 154 |
data.targetFileName); |
... | ... | |
101 | 156 |
data.status.setError("Problem copying temp file to targetFile", e); |
102 | 157 |
return; |
103 | 158 |
} |
159 |
|
|
104 | 160 |
// delete temporal file |
105 | 161 |
if (!tmpFile.delete()) { |
106 | 162 |
tmpFile.deleteOnExit(); |
107 | 163 |
} |
164 |
|
|
108 | 165 |
// Update status |
109 | 166 |
data.status.setGeneratedFile(data.targetFileName); |
167 |
data.status.setGeneratedInstalationThematicMapFolder(installFolder); |
|
110 | 168 |
} |
111 | 169 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/CreateWorkFolder.java | ||
---|---|---|
42 | 42 |
* <li>{@link ProcessData#workFolder}</li> |
43 | 43 |
* </ul> |
44 | 44 |
* </p> |
45 |
* |
|
45 |
*
|
|
46 | 46 |
* @author gvSIG Team |
47 | 47 |
* @version $Id$ |
48 |
* |
|
48 |
*
|
|
49 | 49 |
*/ |
50 | 50 |
public class CreateWorkFolder implements ProcessStep { |
51 | 51 |
|
... | ... | |
57 | 57 |
|
58 | 58 |
/** {@inheridDoc} */ |
59 | 59 |
public String getStepDescriptionKey() { |
60 |
return "Create_work_folder";
|
|
60 |
return "creating_work_folder";
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
/** {@inheridDoc} */ |
64 | 64 |
public String getStepDescription() { |
65 |
return "Create work folder";
|
|
65 |
return "Creating work folder";
|
|
66 | 66 |
} |
67 | 67 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/GenerateTargetFileName.java | ||
---|---|---|
43 | 43 |
* and Sets: |
44 | 44 |
* <ul> |
45 | 45 |
* <li>{@link ProcessData#targetFileName}</li> |
46 |
* <li>{@link ProcessData#targetInstalledMapFolder}</li> |
|
46 | 47 |
* </ul> |
47 | 48 |
* </p> |
48 |
* |
|
49 |
*
|
|
49 | 50 |
* @author gvSIG Team |
50 | 51 |
* @version $Id$ |
51 |
* |
|
52 |
*
|
|
52 | 53 |
*/ |
53 | 54 |
public class GenerateTargetFileName implements ProcessStep { |
54 | 55 |
|
55 | 56 |
/** {@inheridDoc} */ |
56 | 57 |
public void doProcess(ProcessData data, int stepPercent) { |
58 |
data.targetInstalledMapFolder = |
|
59 |
new File(data.targetFolder, data.info.getId()); |
|
57 | 60 |
data.targetFileName = |
58 |
new File(data.targetFolder, data.baseName.concat(".").concat(
|
|
59 |
data.targetFileExtension)); |
|
61 |
new File(data.targetInstalledMapFolder, data.baseName.concat(".")
|
|
62 |
.concat(data.targetFileExtension));
|
|
60 | 63 |
} |
61 | 64 |
|
62 | 65 |
/** {@inheridDoc} */ |
63 | 66 |
public String getStepDescriptionKey() { |
64 |
return "Generate_target_filename";
|
|
67 |
return "generating_target_filename";
|
|
65 | 68 |
} |
66 | 69 |
|
67 | 70 |
/** {@inheridDoc} */ |
68 | 71 |
public String getStepDescription() { |
69 |
return "Generate target filename";
|
|
72 |
return "Generating target filename";
|
|
70 | 73 |
} |
71 | 74 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/WriteMapInfo.java | ||
---|---|---|
57 | 57 |
* <li>{@link ProcessData#info}</li> |
58 | 58 |
* </ul> |
59 | 59 |
* </p> |
60 |
* |
|
60 |
*
|
|
61 | 61 |
* @author gvSIG Team |
62 | 62 |
* @version $Id$ |
63 |
* |
|
63 |
*
|
|
64 | 64 |
*/ |
65 | 65 |
public class WriteMapInfo implements ProcessStep { |
66 | 66 |
|
67 | 67 |
/** {@inheridDoc} */ |
68 | 68 |
public String getStepDescriptionKey() { |
69 |
return "Write_MapInfo";
|
|
69 |
return "writing_map_information_data";
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
/** {@inheridDoc} */ |
73 | 73 |
public String getStepDescription() { |
74 |
return "Write Map Information data";
|
|
74 |
return "Writing Map Information data";
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
/** {@inheridDoc} */ |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/CopyAllLayersFiles.java | ||
---|---|---|
77 | 77 |
* <li>{@link ProcessData#rootLayersFolder}</li> |
78 | 78 |
* </ul> |
79 | 79 |
* </p> |
80 |
* |
|
80 |
*
|
|
81 | 81 |
* @author gvSIG Team |
82 | 82 |
* @version $Id$ |
83 |
* |
|
83 |
*
|
|
84 | 84 |
*/ |
85 | 85 |
public class CopyAllLayersFiles implements ProcessStep { |
86 | 86 |
|
... | ... | |
100 | 100 |
|
101 | 101 |
/** {@inheridDoc} */ |
102 | 102 |
public String getStepDescriptionKey() { |
103 |
return "Copy_all_layers_files";
|
|
103 |
return "coping_all_layers_files";
|
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
/** {@inheridDoc} */ |
107 | 107 |
public String getStepDescription() { |
108 |
return "Copy all layers files";
|
|
108 |
return "Coping all layers files";
|
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
@SuppressWarnings("unchecked") |
... | ... | |
135 | 135 |
* This creates a new folder (using layer's name) inside |
136 | 136 |
* <code>parentFolde</code> and iterates over children layers. |
137 | 137 |
* </p> |
138 |
* |
|
138 |
*
|
|
139 | 139 |
* @param data |
140 | 140 |
* Process data |
141 | 141 |
* @param layers |
... | ... | |
175 | 175 |
|
176 | 176 |
/** |
177 | 177 |
* Updates process status and notify it to process listener. Utility method. |
178 |
* |
|
178 |
*
|
|
179 | 179 |
* @param data |
180 | 180 |
* @param relativePath |
181 | 181 |
*/ |
... | ... | |
192 | 192 |
* This creates a new folder (using layer's name) inside |
193 | 193 |
* <code>parentFolde</code> and copies all related files. |
194 | 194 |
* </p> |
195 |
* |
|
195 |
*
|
|
196 | 196 |
* @param data |
197 | 197 |
* Process data |
198 | 198 |
* @param layers |
... | ... | |
254 | 254 |
|
255 | 255 |
/** |
256 | 256 |
* Gets file path relative to layer folder |
257 |
* |
|
257 |
*
|
|
258 | 258 |
* @param data |
259 | 259 |
* @param file |
260 | 260 |
* @return |
... | ... | |
276 | 276 |
* <p> |
277 | 277 |
* Avoid problems of duplicate layer name |
278 | 278 |
* </p> |
279 |
* |
|
279 |
*
|
|
280 | 280 |
* @param parentFolder |
281 | 281 |
* @param flayer |
282 | 282 |
* @param namer |
... | ... | |
293 | 293 |
|
294 | 294 |
/** |
295 | 295 |
* Utility class to get a layer name for those layers which hasn't |
296 |
* |
|
296 |
*
|
|
297 | 297 |
* @author gvSIG Team |
298 | 298 |
* @version $Id$ |
299 |
* |
|
299 |
*
|
|
300 | 300 |
*/ |
301 | 301 |
private class LayerNamer { |
302 | 302 |
|
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/GenerateBaseName.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.educa.thematicmap.impl.compilation.process; |
23 | 23 |
|
24 |
import java.text.MessageFormat;
|
|
25 |
|
|
24 |
import org.gvsig.educa.thematicmap.ThematicMapLocator;
|
|
25 |
import org.gvsig.educa.thematicmap.ThematicMapManager; |
|
26 | 26 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompiler; |
27 | 27 |
|
28 | 28 |
/** |
... | ... | |
42 | 42 |
* <li>{@link ProcessData#baseName}</li> |
43 | 43 |
* </ul> |
44 | 44 |
* </p> |
45 |
* |
|
45 |
*
|
|
46 | 46 |
* @author gvSIG Team |
47 | 47 |
* @version $Id$ |
48 |
* |
|
48 |
*
|
|
49 | 49 |
*/ |
50 | 50 |
public class GenerateBaseName implements ProcessStep { |
51 | 51 |
|
52 |
public static final String FORMAT_STRING = "{0}-{1}-BN{2}";
|
|
52 |
private final ThematicMapManager manager;
|
|
53 | 53 |
|
54 |
public GenerateBaseName() { |
|
55 |
manager = ThematicMapLocator.getManager(); |
|
56 |
} |
|
57 |
|
|
54 | 58 |
/** {@inheridDoc} */ |
55 | 59 |
public void doProcess(ProcessData data, int stepPercent) { |
56 |
data.baseName = |
|
57 |
MessageFormat.format(FORMAT_STRING, data.info.getId(), |
|
58 |
data.info.getVersion(), data.info.getBuildNumber()); |
|
60 |
data.baseName = manager.getBaseFileNameFromInfo(data.info); |
|
59 | 61 |
} |
60 | 62 |
|
61 | 63 |
/** {@inheridDoc} */ |
62 | 64 |
public String getStepDescriptionKey() { |
63 |
return "Generate_base_name";
|
|
65 |
return "generating_base_name";
|
|
64 | 66 |
} |
65 | 67 |
|
66 | 68 |
/** {@inheridDoc} */ |
67 | 69 |
public String getStepDescription() { |
68 |
return "Generate a base name for target file";
|
|
70 |
return "Generating a base name for target file";
|
|
69 | 71 |
} |
70 | 72 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/WriteMapContextDefinition.java | ||
---|---|---|
51 | 51 |
* <li>{@link ProcessData#fileMapping}</li> |
52 | 52 |
* </ul> |
53 | 53 |
* </p> |
54 |
* |
|
54 |
*
|
|
55 | 55 |
* @author gvSIG Team |
56 | 56 |
* @version $Id$ |
57 |
* |
|
57 |
*
|
|
58 | 58 |
*/ |
59 | 59 |
public class WriteMapContextDefinition implements ProcessStep { |
60 | 60 |
|
... | ... | |
66 | 66 |
|
67 | 67 |
/** {@inheridDoc} */ |
68 | 68 |
public String getStepDescriptionKey() { |
69 |
return "Write_MapContext_definition";
|
|
69 |
return "writing_mapcontext_definition";
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
/** {@inheridDoc} */ |
73 | 73 |
public String getStepDescription() { |
74 |
return "Write MapContext definition";
|
|
74 |
return "Writing MapContext definition";
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
/** {@inheridDoc} */ |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/ProcessData.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
/** |
37 | 37 |
* Class to store all data about a {@link ThematicMapCompiler} process |
38 |
* |
|
38 |
*
|
|
39 | 39 |
* @author gvSIG Team |
40 | 40 |
* @version $Id$ |
41 |
* |
|
41 |
*
|
|
42 | 42 |
*/ |
43 | 43 |
public class ProcessData { |
44 | 44 |
|
... | ... | |
63 | 63 |
public File targetFolder; |
64 | 64 |
|
65 | 65 |
/** |
66 |
* Final file
|
|
66 |
* Folder installed thematic map
|
|
67 | 67 |
*/ |
68 |
public File targetInstalledMapFolder; |
|
69 |
|
|
70 |
/** |
|
71 |
* Final compress file |
|
72 |
*/ |
|
68 | 73 |
public File targetFileName; |
69 | 74 |
|
70 | 75 |
/** |
... | ... | |
137 | 142 |
* current status |
138 | 143 |
*/ |
139 | 144 |
public void notifyStatus() { |
140 |
if (listener != null){ |
|
145 |
if (listener != null) {
|
|
141 | 146 |
listener.updatedStatus(status); |
142 | 147 |
} |
143 | 148 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/WriteGraphicsLayer.java | ||
---|---|---|
37 | 37 |
* </ul> |
38 | 38 |
* </p> |
39 | 39 |
* TODO |
40 |
* |
|
40 |
*
|
|
41 | 41 |
* @author gvSIG Team |
42 | 42 |
* @version $Id$ |
43 |
* |
|
43 |
*
|
|
44 | 44 |
*/ |
45 | 45 |
public class WriteGraphicsLayer implements ProcessStep { |
46 | 46 |
|
47 | 47 |
/** {@inheridDoc} */ |
48 | 48 |
public String getStepDescriptionKey() { |
49 |
return "Write_Graphics_layer";
|
|
49 |
return "writing_graphics_layer";
|
|
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
/** {@inheridDoc} */ |
53 | 53 |
public String getStepDescription() { |
54 |
return "Write Graphics layer";
|
|
54 |
return "Writing Graphics layer";
|
|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
/** {@inheridDoc} */ |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/PrepareNewMapContext.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
/** {@inheridDoc} */ |
64 | 64 |
public String getStepDescriptionKey() { |
65 |
return "Prepare_New_Map_Context";
|
|
65 |
return "preparing_new_map_context";
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/** {@inheridDoc} */ |
69 | 69 |
public String getStepDescription() { |
70 |
return "Prepare New Map Context";
|
|
70 |
return "Preparing New Map Context";
|
|
71 | 71 |
} |
72 | 72 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/UpdateCompilationInfo.java | ||
---|---|---|
42 | 42 |
* {@link ThematicMapCompilerStatus#getResultCompilation()}</li> |
43 | 43 |
* </ul> |
44 | 44 |
* </p> |
45 |
* |
|
45 |
*
|
|
46 | 46 |
* @author gvSIG Team |
47 | 47 |
* @version $Id$ |
48 |
* |
|
48 |
*
|
|
49 | 49 |
*/ |
50 | 50 |
public class UpdateCompilationInfo implements ProcessStep { |
51 | 51 |
|
... | ... | |
57 | 57 |
|
58 | 58 |
/** {@inheridDoc} */ |
59 | 59 |
public String getStepDescriptionKey() { |
60 |
return "UpdateCompilationInfo";
|
|
60 |
return "updateing_compilation_info";
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
/** {@inheridDoc} */ |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.api/src/main/java/org/gvsig/educa/thematicmap/ThematicMapManager.java | ||
---|---|---|
30 | 30 |
import org.gvsig.educa.thematicmap.map.CantLoadContextException; |
31 | 31 |
import org.gvsig.educa.thematicmap.map.InvalidThematicMapFormatException; |
32 | 32 |
import org.gvsig.educa.thematicmap.map.ThematicMap; |
33 |
import org.gvsig.educa.thematicmap.map.ThematicMapInformation; |
|
33 | 34 |
import org.gvsig.tools.dispose.Disposable; |
34 | 35 |
|
35 | 36 |
/** |
... | ... | |
140 | 141 |
boolean isMap(File file); |
141 | 142 |
|
142 | 143 |
/** |
144 |
* Informs if a folder is a valid <i>Thematic Map</i> installed folder |
|
145 |
* |
|
146 |
* @param file |
|
147 |
* @return |
|
148 |
*/ |
|
149 |
boolean isAThematicMapIntalledFolder(File folder); |
|
150 |
|
|
151 |
/** |
|
143 | 152 |
* Creates a new instance of a {@link ThematicMapCompilation} |
144 | 153 |
* |
145 | 154 |
* @return |
... | ... | |
167 | 176 |
* @return |
168 | 177 |
*/ |
169 | 178 |
ThematicMapCompiler createCompilerInstance(); |
179 |
|
|
180 |
/** |
|
181 |
* Generates the base name for a ThematicMap file using its info data |
|
182 |
* |
|
183 |
* @param info |
|
184 |
* @return |
|
185 |
*/ |
|
186 |
String getBaseFileNameFromInfo(ThematicMapInformation info); |
|
187 |
|
|
188 |
/** |
|
189 |
* Generates the base name for a ThematicMap file |
|
190 |
* |
|
191 |
* @param info |
|
192 |
* @return |
|
193 |
*/ |
|
194 |
String getBaseFileNameFromInfo(String id, String name, int version, |
|
195 |
int buildNumber); |
|
196 |
|
|
170 | 197 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.api/src/main/java/org/gvsig/educa/thematicmap/map/InvalidInstalledThematicMapException.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.educa.thematicmap.map; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import org.gvsig.educa.thematicmap.ThematicMapException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Exception Throws when try to open an installed ThematicMap folder with |
|
30 |
* invalid format (missing package.info file or no match data) |
|
31 |
* |
|
32 |
* @author gvSIG Team |
|
33 |
* @version $Id$ |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class InvalidInstalledThematicMapException extends ThematicMapException { |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
*/ |
|
41 |
private static final long serialVersionUID = 1L; |
|
42 |
|
|
43 |
private static final String MESSAGE = |
|
44 |
"Invalid format of an installed ThematicMap [%(folderPath)]: %(info)"; |
|
45 |
|
|
46 |
private static final String KEY = "_InvalidInstalledThematicMapException"; |
|
47 |
|
|
48 |
/** |
|
49 |
* Invalid format of an installed thematic map folder by unspecified problem |
|
50 |
* |
|
51 |
* @param mapFile |
|
52 |
*/ |
|
53 |
public InvalidInstalledThematicMapException(File mapFolder) { |
|
54 |
this(mapFolder, "unspecified problem"); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Invalid format of a thematic map file |
|
59 |
* |
|
60 |
* @param mapFile |
|
61 |
* @param message |
|
62 |
* problem description |
|
63 |
*/ |
|
64 |
public InvalidInstalledThematicMapException(File mapFolder, String message) { |
|
65 |
super(MESSAGE, KEY, serialVersionUID); |
|
66 |
setValue("info", message); |
|
67 |
setValue("folderPath", mapFolder.getAbsolutePath()); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Invalid format of a thematic map file |
|
72 |
* |
|
73 |
* @param mapFile |
|
74 |
* @param message |
|
75 |
* problem description |
|
76 |
* @param cause |
|
77 |
*/ |
|
78 |
public InvalidInstalledThematicMapException(File mapFolder, String message, |
|
79 |
Throwable cause) { |
|
80 |
super(MESSAGE, cause, KEY, serialVersionUID); |
|
81 |
setValue("info", message); |
|
82 |
setValue("folderPath", mapFolder.getAbsolutePath()); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Invalid format of a thematic map file |
|
87 |
* |
|
88 |
* @param mapFile |
|
89 |
*/ |
|
90 |
public InvalidInstalledThematicMapException(File mapFile, Throwable cause) { |
|
91 |
this(mapFile, "initializing problem", cause); |
|
92 |
} |
|
93 |
|
|
94 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.api/src/main/java/org/gvsig/educa/thematicmap/map/ThematicMapInformation.java | ||
---|---|---|
37 | 37 |
* <li>Author</li> |
38 | 38 |
* <li>License</li> |
39 | 39 |
* </ul> |
40 |
* |
|
40 |
*
|
|
41 | 41 |
* TODO Add more data |
42 |
* |
|
42 |
*
|
|
43 | 43 |
* @author <a href="http://www.disid.com">DiSiD Technologies S.L.</a> |
44 | 44 |
* @version $Rev$ |
45 | 45 |
* @since {version} |
... | ... | |
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* Gets <i>Thematic Map</i> identifier |
53 |
* |
|
53 |
*
|
|
54 | 54 |
* @return |
55 | 55 |
*/ |
56 | 56 |
String getId(); |
57 | 57 |
|
58 | 58 |
/** |
59 | 59 |
* Gets <i>Thematic Map</i> name |
60 |
* |
|
60 |
*
|
|
61 | 61 |
* @return |
62 | 62 |
*/ |
63 | 63 |
String getName(); |
64 | 64 |
|
65 | 65 |
/** |
66 | 66 |
* Gets <i>Thematic Map</i> description |
67 |
* |
|
67 |
*
|
|
68 | 68 |
* @return |
69 | 69 |
*/ |
70 | 70 |
String getDescription(); |
71 | 71 |
|
72 | 72 |
/** |
73 | 73 |
* Gets <i>Thematic Map</i> version |
74 |
* |
|
74 |
*
|
|
75 | 75 |
* @return |
76 | 76 |
*/ |
77 |
String getVersion();
|
|
77 |
int getVersion();
|
|
78 | 78 |
|
79 | 79 |
/** |
80 | 80 |
* Gets <i>Thematic Map</i> build number |
81 |
* |
|
81 |
*
|
|
82 | 82 |
* @return |
83 | 83 |
*/ |
84 | 84 |
int getBuildNumber(); |
85 | 85 |
|
86 | 86 |
/** |
87 | 87 |
* Gets <i>Thematic Map</i> creation timestamp |
88 |
* |
|
88 |
*
|
|
89 | 89 |
* @return |
90 | 90 |
*/ |
91 | 91 |
Date getCreationTimestamp(); |
92 | 92 |
|
93 | 93 |
/** |
94 | 94 |
* Gets full envelope |
95 |
* |
|
95 |
*
|
|
96 | 96 |
* @return |
97 | 97 |
*/ |
98 | 98 |
Envelope getFullEnvelope(); |
99 | 99 |
|
100 | 100 |
/** |
Also available in: Unified diff