Revision 23774
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/CloseException.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.exceptions; |
2 | 2 |
|
3 |
/** |
|
4 |
* FIXME |
|
5 |
* |
|
6 |
*/ |
|
3 | 7 |
|
8 |
public class CloseException extends DataException { |
|
4 | 9 |
|
5 |
public class CloseException extends ReadException { |
|
6 |
|
|
7 |
public CloseException(String name,Throwable exception) { |
|
8 |
super("Close Error",name,exception); |
|
9 |
init(); |
|
10 |
} |
|
11 |
|
|
12 |
public CloseException(String description,String name,Throwable exception) { |
|
13 |
super(description,name,exception); |
|
14 |
init(); |
|
15 |
} |
|
16 |
|
|
17 |
public CloseException(String description,String name) { |
|
18 |
super(description,name); |
|
19 |
init(); |
|
20 |
} |
|
21 |
|
|
22 | 10 |
/** |
23 | 11 |
* |
24 | 12 |
*/ |
25 |
protected void init() { |
|
26 |
super.init(); |
|
27 |
messageKey = "error_close"; |
|
28 |
formatString = "Can?t close %(name): %(description) "; |
|
13 |
private static final long serialVersionUID = 9186224366705822305L; |
|
14 |
private final static String MESSAGE_FORMAT = "Exception closing '%(store)s'."; |
|
15 |
private final static String MESSAGE_KEY = "_CloseException"; |
|
16 |
|
|
17 |
public CloseException(String store, Throwable cause) { |
|
18 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
19 |
setValue("store", store); |
|
29 | 20 |
} |
21 |
|
|
30 | 22 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/PrepareResourceException.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
private static final long serialVersionUID = 2198478752691400900L; |
11 | 11 |
private final static String MESSAGE_FORMAT = "Exception preparing '%(resource)s'."; |
12 |
private final static String MESSAGE_KEY = "_AlreadyEditingException";
|
|
12 |
private final static String MESSAGE_KEY = "_PrepareResourceException";
|
|
13 | 13 |
private Resource resource; |
14 | 14 |
|
15 | 15 |
public PrepareResourceException(Resource resource, Throwable cause) { |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/UnreferenceResourceException.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.exceptions; |
|
2 |
|
|
3 |
public class UnreferenceResourceException extends DataException { |
|
4 |
/** |
|
5 |
* |
|
6 |
*/ |
|
7 |
private static final long serialVersionUID = 4433967723311453510L; |
|
8 |
private final static String MESSAGE_FORMAT = "Exception unreferencing resource '%(resource)s'."; |
|
9 |
private final static String MESSAGE_KEY = "_UnreferenceResourceException"; |
|
10 |
|
|
11 |
public UnreferenceResourceException(String resource) { |
|
12 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
|
13 |
setValue("resource", resource); |
|
14 |
} |
|
15 |
|
|
16 |
|
|
17 |
} |
|
0 | 18 |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/CopyException.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.exceptions; |
|
2 |
|
|
3 |
public class CopyException extends DataException { |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
*/ |
|
8 |
private static final long serialVersionUID = 6998431565823817880L; |
|
9 |
private final static String MESSAGE_FORMAT = "Exception in copy '%(name)s'."; |
|
10 |
private final static String MESSAGE_KEY = "_CopyException"; |
|
11 |
|
|
12 |
public CopyException(String name, Throwable cause) { |
|
13 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
14 |
setValue("name", name); |
|
15 |
} |
|
16 |
|
|
17 |
} |
|
0 | 18 |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/WriteException.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.exceptions; |
2 | 2 |
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
3 |
/** |
|
4 |
* FIXME |
|
5 |
* |
|
6 |
* |
|
7 |
*/ |
|
5 | 8 |
|
6 |
import org.gvsig.tools.exception.BaseException; |
|
7 |
|
|
8 | 9 |
public class WriteException extends DataException { |
9 | 10 |
|
11 |
/** |
|
12 |
* |
|
13 |
*/ |
|
14 |
private static final long serialVersionUID = 3656543768356545436L; |
|
15 |
private final static String MESSAGE_FORMAT = "Exception writing '%(store)s'."; |
|
16 |
private final static String MESSAGE_KEY = "_WriteException"; |
|
10 | 17 |
|
11 |
private String name = null; |
|
12 |
|
|
13 |
public WriteException(String description, String name) { |
|
14 |
super(description); |
|
15 |
this.name = name; |
|
16 |
init(); |
|
18 |
public WriteException(String store, Throwable cause) { |
|
19 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
20 |
setValue("store", store); |
|
17 | 21 |
} |
18 | 22 |
|
19 |
public WriteException(String description, String name,Throwable exception) { |
|
20 |
super(description); |
|
21 |
this.name = name; |
|
22 |
init(); |
|
23 |
initCause(exception); |
|
24 |
} |
|
25 |
|
|
26 |
public WriteException(String name,Throwable exception) { |
|
27 |
super("Error writing"); |
|
28 |
this.name = name; |
|
29 |
init(); |
|
30 |
initCause(exception); |
|
31 |
} |
|
32 |
|
|
33 |
protected void init() { |
|
34 |
super.init(); |
|
35 |
messageKey = "error_write"; |
|
36 |
formatString = "Can?t write %(name): %(description) "; |
|
37 |
} |
|
38 |
|
|
39 |
protected Map values() { |
|
40 |
Map params = super.values(); |
|
41 |
params.put("name",this.name); |
|
42 |
return params; |
|
43 |
} |
|
44 |
|
|
45 | 23 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/ReadException.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.exceptions; |
2 | 2 |
|
3 |
import java.util.Map; |
|
4 | 3 |
|
4 |
/** |
|
5 |
* FIXME |
|
6 |
* |
|
7 |
* |
|
8 |
*/ |
|
5 | 9 |
|
6 | 10 |
public class ReadException extends DataException { |
7 | 11 |
|
12 |
/** |
|
13 |
* |
|
14 |
*/ |
|
15 |
private static final long serialVersionUID = -8512708060535066804L; |
|
16 |
private final static String MESSAGE_FORMAT = "Exception reading '%(store)s'."; |
|
17 |
private final static String MESSAGE_KEY = "_ReadException"; |
|
8 | 18 |
|
9 |
private String name = "{unknow}"; |
|
10 |
|
|
11 |
public ReadException(String description, String name) { |
|
12 |
super(description); |
|
13 |
this.name = name; |
|
14 |
init(); |
|
19 |
public ReadException(String store, Throwable cause) { |
|
20 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
21 |
setValue("store", store); |
|
15 | 22 |
} |
16 | 23 |
|
17 |
public ReadException(String description, String name,Throwable exception) { |
|
18 |
super(description); |
|
19 |
this.name = name; |
|
20 |
init(); |
|
21 |
initCause(exception); |
|
22 |
} |
|
23 |
|
|
24 |
public ReadException(String name,Throwable exception) { |
|
25 |
super("Error reading"); |
|
26 |
this.name = name; |
|
27 |
init(); |
|
28 |
initCause(exception); |
|
29 |
} |
|
30 |
|
|
31 |
protected void init() { |
|
32 |
super.init(); |
|
33 |
messageKey = "error_read"; |
|
34 |
formatString = "Can?t read %(name): %(description) "; |
|
35 |
} |
|
36 |
|
|
37 |
protected Map values() { |
|
38 |
Map params = super.values(); |
|
39 |
params.put("name",this.name); |
|
40 |
return params; |
|
41 |
} |
|
42 |
|
|
43 | 24 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/NotResgisteredStore.java | ||
---|---|---|
1 |
package org.gvsig.fmap.data.exceptions; |
|
2 |
|
|
3 |
public class NotResgisteredStore extends DataException { |
|
4 |
/** |
|
5 |
* |
|
6 |
*/ |
|
7 |
private static final long serialVersionUID = 4873697202452898968L; |
|
8 |
private final static String MESSAGE_FORMAT = "'%(storeName)s not registered'."; |
|
9 |
private final static String MESSAGE_KEY = "_NotResgisteredStore"; |
|
10 |
|
|
11 |
public NotResgisteredStore(String storeName) { |
|
12 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
|
13 |
setValue("storeName", storeName); |
|
14 |
} |
|
15 |
} |
|
0 | 16 |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/ResourceConsumerNotFoundException.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
private static final long serialVersionUID = -3762206616316749438L; |
11 | 11 |
private final static String MESSAGE_FORMAT = "Consumer '%(consumer)s' not found for resource '%(resource)s'."; |
12 |
private final static String MESSAGE_KEY = "_AlreadyEditingException";
|
|
12 |
private final static String MESSAGE_KEY = "_ResourceConsumerNotFoundException";
|
|
13 | 13 |
private Resource resouce; |
14 | 14 |
private Object consumer; |
15 | 15 |
|
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/InitializeException.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.exceptions; |
2 | 2 |
|
3 | 3 |
|
4 |
/** |
|
5 |
* FIXME |
|
6 |
* |
|
7 |
* |
|
8 |
*/ |
|
9 |
public class InitializeException extends DataException { |
|
4 | 10 |
|
5 |
public class InitializeException extends ReadException { |
|
6 |
|
|
7 |
public InitializeException(String name,Throwable exception) { |
|
8 |
super("Intialize Error",name,exception); |
|
9 |
init(); |
|
10 |
} |
|
11 |
|
|
12 |
public InitializeException(String description,String name,Throwable exception) { |
|
13 |
super(description,name,exception); |
|
14 |
init(); |
|
15 |
} |
|
16 |
|
|
17 |
public InitializeException(String description,String name) { |
|
18 |
super(description,name); |
|
19 |
init(); |
|
20 |
} |
|
21 | 11 |
/** |
22 | 12 |
* |
23 | 13 |
*/ |
24 |
protected void init() { |
|
25 |
super.init(); |
|
26 |
messageKey = "error_initialize"; |
|
27 |
formatString = "Can?t initialize %(name): %(description) "; |
|
14 |
private static final long serialVersionUID = -3054877505579218816L; |
|
15 |
private final static String MESSAGE_FORMAT = "Exception intializing '%(store)s'."; |
|
16 |
private final static String MESSAGE_KEY = "_InitializeException"; |
|
17 |
|
|
18 |
public InitializeException(String store, Throwable cause) { |
|
19 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
20 |
setValue("store", store); |
|
28 | 21 |
} |
29 | 22 |
|
23 |
public InitializeException(Throwable cause) { |
|
24 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
25 |
setValue("store", "{unknow}"); |
|
26 |
} |
|
27 |
|
|
30 | 28 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/OpenException.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data.exceptions; |
2 | 2 |
|
3 |
|
|
4 |
|
|
5 |
public class OpenException extends InitializeException { |
|
6 |
public OpenException(String name,Throwable exception) { |
|
7 |
super("Open Error",name,exception); |
|
8 |
init(); |
|
9 |
} |
|
10 |
|
|
11 |
public OpenException(String description,String name,Throwable exception) { |
|
12 |
super(description,name,exception); |
|
13 |
init(); |
|
14 |
} |
|
15 |
|
|
16 |
public OpenException(String description,String name) { |
|
17 |
super(description,name); |
|
18 |
init(); |
|
19 |
} |
|
3 |
/** |
|
4 |
* FIXME |
|
5 |
* |
|
6 |
* |
|
7 |
*/ |
|
8 |
public class OpenException extends DataException { |
|
20 | 9 |
/** |
21 | 10 |
* |
22 | 11 |
*/ |
23 |
protected void init() { |
|
24 |
super.init(); |
|
25 |
messageKey = "error_open"; |
|
26 |
formatString = "Can?t open %(name): %(description) "; |
|
12 |
private static final long serialVersionUID = -8318431541669401823L; |
|
13 |
private final static String MESSAGE_FORMAT = "Exception opening '%(store)s'."; |
|
14 |
private final static String MESSAGE_KEY = "_OpenException"; |
|
15 |
|
|
16 |
public OpenException(String store, Throwable cause) { |
|
17 |
super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID); |
|
18 |
setValue("store", store); |
|
27 | 19 |
} |
28 | 20 |
|
29 |
|
|
30 | 21 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/exceptions/ResourceChangedException.java | ||
---|---|---|
30 | 30 |
*/ |
31 | 31 |
package org.gvsig.fmap.data.exceptions; |
32 | 32 |
|
33 |
import org.gvsig.fmap.data.Resource; |
|
33 | 34 |
|
35 |
|
|
36 |
|
|
34 | 37 |
/** |
35 |
* @author jmvivo
|
|
38 |
* FIXME
|
|
36 | 39 |
* |
40 |
* |
|
37 | 41 |
*/ |
38 |
public class ResourceChangedException extends OpenException { |
|
39 |
public ResourceChangedException(String name) { |
|
40 |
super("Resource has been changed",name); |
|
41 |
init(); |
|
42 |
} |
|
42 |
|
|
43 |
public class ResourceChangedException extends DataException { |
|
44 |
|
|
43 | 45 |
/** |
44 | 46 |
* |
45 | 47 |
*/ |
46 |
protected void init() { |
|
47 |
super.init(); |
|
48 |
messageKey = "error_resource_Changed"; |
|
49 |
formatString = "Can?t open %(name): %(description) "; |
|
48 |
private static final long serialVersionUID = -2048575104684692260L; |
|
49 |
private final static String MESSAGE_FORMAT = "Resource '%(resource)s' changed."; |
|
50 |
private final static String MESSAGE_KEY = "_ResourceChangedException"; |
|
51 |
private Resource resource; |
|
52 |
|
|
53 |
public ResourceChangedException(Resource resource) { |
|
54 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
|
55 |
this.resource = resource; |
|
56 |
setValue("resource", resource.getKey()); |
|
50 | 57 |
} |
51 | 58 |
|
59 |
public Resource getResouce() { |
|
60 |
return resource; |
|
61 |
} |
|
52 | 62 |
} |
53 | 63 |
|
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data; |
2 | 2 |
|
3 | 3 |
import org.gvsig.fmap.data.exceptions.InitializeException; |
4 |
import org.gvsig.fmap.data.exceptions.NotResgisteredStore; |
|
4 | 5 |
import org.gvsig.tools.evaluator.Evaluator; |
5 | 6 |
import org.gvsig.tools.operations.Operation; |
6 | 7 |
|
... | ... | |
40 | 41 |
* name |
41 | 42 |
* @throws InitializeException |
42 | 43 |
* TODO |
44 |
* @throws NotResgisteredStore |
|
43 | 45 |
**/ |
44 | 46 |
public DataStoreParameters createDataStoreParameters(String name) |
45 |
throws InitializeException; |
|
47 |
throws InitializeException, NotResgisteredStore;
|
|
46 | 48 |
|
47 | 49 |
public DataStoreParameters createDataStoreParameters( |
48 |
XMLEntity xmlEntity) throws InitializeException; |
|
50 |
XMLEntity xmlEntity) |
|
51 |
throws InitializeException, NotResgisteredStore; |
|
49 | 52 |
|
50 | 53 |
/** |
51 | 54 |
* Levanta la instancia del datasource, |
... | ... | |
59 | 62 |
* |
60 | 63 |
* @params DataStoreParameters parameters |
61 | 64 |
* @throws InitializeException |
65 |
* @throws NotResgisteredStore |
|
62 | 66 |
**/ |
63 | 67 |
public DataStore createDataStore(DataStoreParameters parameters) |
64 |
throws InitializeException; |
|
68 |
throws InitializeException, NotResgisteredStore;
|
|
65 | 69 |
|
66 | 70 |
public DataStore createDataStore(XMLEntity xmlEntity) |
67 |
throws InitializeException; |
|
71 |
throws InitializeException, NotResgisteredStore;
|
|
68 | 72 |
|
69 | 73 |
/** |
70 | 74 |
* Collection of generic properties of a DataStore type which can access |
... | ... | |
102 | 106 |
* name |
103 | 107 |
* @throws InitializeException |
104 | 108 |
* TODO |
109 |
* @throws NotResgisteredStore |
|
105 | 110 |
**/ |
106 | 111 |
|
107 | 112 |
public DataExplorerParameters createDataExplorerParameters( |
108 |
String name) throws InitializeException; |
|
113 |
String name) |
|
114 |
throws InitializeException, NotResgisteredStore; |
|
109 | 115 |
|
110 | 116 |
/** |
111 | 117 |
* |
... | ... | |
113 | 119 |
* parameters |
114 | 120 |
* @return DataExplorer |
115 | 121 |
* @throws InitializeException |
122 |
* @throws NotResgisteredStore |
|
116 | 123 |
*/ |
117 | 124 |
|
118 | 125 |
public DataExplorerParameters createDataExplorerParameters( |
119 |
XMLEntity xmlEntity) throws InitializeException; |
|
126 |
XMLEntity xmlEntity) throws InitializeException, |
|
127 |
NotResgisteredStore; |
|
120 | 128 |
|
121 | 129 |
public DataExplorer createDataExplorer( |
122 |
DataExplorerParameters parameters) throws InitializeException; |
|
130 |
DataExplorerParameters parameters) |
|
131 |
throws InitializeException, NotResgisteredStore; |
|
123 | 132 |
|
124 | 133 |
/** |
125 |
* |
|
134 |
*
|
|
126 | 135 |
* @param String |
127 | 136 |
* name |
128 | 137 |
* @return RegisterInfo |
138 |
* @throws NotResgisteredStore |
|
129 | 139 |
*/ |
130 | 140 |
|
131 | 141 |
public DataExplorer createDataExplorer(XMLEntity xmlEntity) |
132 |
throws InitializeException; |
|
142 |
throws InitializeException, NotResgisteredStore;
|
|
133 | 143 |
|
134 | 144 |
/** |
135 | 145 |
* |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataStoreParameters.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.data; |
29 | 29 |
|
30 |
import org.gvsig.fmap.data.exceptions.CopyException; |
|
30 | 31 |
import org.gvsig.fmap.data.exceptions.InitializeException; |
31 | 32 |
import org.gvsig.fmap.data.spi.AbstractDataParameters; |
32 | 33 |
|
... | ... | |
51 | 52 |
return xmlEntity; |
52 | 53 |
} |
53 | 54 |
|
54 |
public DataParameters getCopy() throws InitializeException { |
|
55 |
DataStoreParameters params = DALLocator.getDataManager() |
|
56 |
.createDataStoreParameters(this.getDataStoreName()); |
|
55 |
public DataParameters getCopy() throws CopyException { |
|
56 |
DataStoreParameters params; |
|
57 |
try { |
|
58 |
params = DALLocator.getDataManager().createDataStoreParameters( |
|
59 |
this.getDataStoreName()); |
|
60 |
} catch (Exception e) { |
|
61 |
throw new CopyException(this.toString(), e); |
|
62 |
} |
|
57 | 63 |
params.putAll(this); |
58 | 64 |
return params; |
59 | 65 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/spi/AbstractResource.java | ||
---|---|---|
45 | 45 |
import org.gvsig.fmap.data.exceptions.PrepareResourceException; |
46 | 46 |
import org.gvsig.fmap.data.exceptions.ResourceChangedException; |
47 | 47 |
import org.gvsig.fmap.data.exceptions.ResourceConsumerNotFoundException; |
48 |
import org.gvsig.fmap.data.exceptions.UnreferenceResourceException; |
|
48 | 49 |
import org.gvsig.fmap.data.impl.DefaultResourceNotification; |
49 | 50 |
import org.gvsig.tools.observer.DefaultObservable; |
50 | 51 |
import org.gvsig.tools.observer.Observable; |
... | ... | |
209 | 210 |
*/ |
210 | 211 |
public void unref(Object consumer) throws DataException { |
211 | 212 |
if (this.references.size() < 1) { |
212 |
throw new DataException("unref in refs < 1");
|
|
213 |
throw new UnreferenceResourceException(this.getKey());
|
|
213 | 214 |
} |
214 | 215 |
this.updateLastTimeUsed(); |
215 | 216 |
|
... | ... | |
289 | 290 |
this.updateLastTimeUsed(); |
290 | 291 |
} |
291 | 292 |
|
292 |
protected synchronized void checkOpen() throws OpenException{ |
|
293 |
protected synchronized void checkOpen() throws OpenException, |
|
294 |
ResourceChangedException { |
|
293 | 295 |
this.updateLastTimeUsed(); |
294 | 296 |
if (!this.isOpen()){ |
295 | 297 |
this.open(); |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorerParameters.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.data; |
29 | 29 |
|
30 |
import org.gvsig.fmap.data.exceptions.CopyException; |
|
30 | 31 |
import org.gvsig.fmap.data.exceptions.InitializeException; |
32 |
import org.gvsig.fmap.data.exceptions.NotResgisteredStore; |
|
31 | 33 |
import org.gvsig.fmap.data.spi.AbstractDataParameters; |
32 | 34 |
|
33 | 35 |
import com.iver.utiles.XMLEntity; |
... | ... | |
50 | 52 |
} |
51 | 53 |
|
52 | 54 |
public DataParameters getCopy() |
53 |
throws InitializeException { |
|
54 |
DataExplorerParameters params = DALLocator.getDataManager() |
|
55 |
.createDataExplorerParameters(this.getDataExplorerName()); |
|
55 |
throws CopyException { |
|
56 |
DataExplorerParameters params; |
|
57 |
try { |
|
58 |
params = DALLocator.getDataManager().createDataExplorerParameters( |
|
59 |
this.getDataExplorerName()); |
|
60 |
} catch (Exception e) { |
|
61 |
throw new CopyException(this.toString(), e); |
|
62 |
} |
|
56 | 63 |
params.putAll(this); |
57 | 64 |
return params; |
58 | 65 |
} |
59 | 66 |
|
60 |
public DataStoreParameters newStoreParameters() throws InitializeException { |
|
67 |
public DataStoreParameters newStoreParameters() throws InitializeException, |
|
68 |
NotResgisteredStore { |
|
61 | 69 |
DataManager manager = DALLocator.getDataManager(); |
62 |
DataStoreParameters param = null; |
|
63 |
try { |
|
64 |
param = manager |
|
70 |
DataStoreParameters param = manager |
|
65 | 71 |
.createDataStoreParameters(getDataStoreName()); |
66 |
} catch (InitializeException e) { |
|
67 |
// TODO Auto-generated catch block |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 | 72 |
param.putAllDefaultValues(this); |
71 | 73 |
return param; |
72 | 74 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/impl/DefaultDataManager.java | ||
---|---|---|
15 | 15 |
import org.gvsig.fmap.data.DataStoreProvider; |
16 | 16 |
import org.gvsig.fmap.data.ResourceManager; |
17 | 17 |
import org.gvsig.fmap.data.exceptions.InitializeException; |
18 |
import org.gvsig.fmap.data.exceptions.NotResgisteredStore; |
|
18 | 19 |
import org.gvsig.tools.evaluator.Evaluator; |
19 | 20 |
import org.gvsig.tools.operations.Operation; |
20 | 21 |
import org.gvsig.tools.operations.OperationContext; |
... | ... | |
72 | 73 |
* en la instancia y la devuelve. |
73 | 74 |
* |
74 | 75 |
* @throws InitializeException |
76 |
* @throws NotResgisteredStore |
|
75 | 77 |
**/ |
76 |
public DataStoreParameters createDataStoreParameters(String name) throws InitializeException{ |
|
78 |
public DataStoreParameters createDataStoreParameters(String name) |
|
79 |
throws InitializeException, NotResgisteredStore { |
|
77 | 80 |
|
78 | 81 |
RegisterInfo registerInfo = this.getRegisterByName(name); |
79 | 82 |
if (registerInfo == null){ |
80 |
throw new InitializeException("Not registered in manager",name);
|
|
83 |
throw new NotResgisteredStore(name);
|
|
81 | 84 |
} else if (registerInfo.type != RegisterInfo.TYPE_STORE) { |
82 |
throw new InitializeException("Not register as Store", name);
|
|
85 |
throw new NotResgisteredStore(name);
|
|
83 | 86 |
} |
84 | 87 |
|
85 | 88 |
try { |
... | ... | |
97 | 100 |
* @see org.gvsig.fmap.data.DataManager#createDataStoreParameters(com.iver.utiles.XMLEntity) |
98 | 101 |
*/ |
99 | 102 |
public DataStoreParameters createDataStoreParameters(XMLEntity xmlEntity) |
100 |
throws InitializeException { |
|
103 |
throws InitializeException, NotResgisteredStore {
|
|
101 | 104 |
String name; |
102 | 105 |
try { |
103 | 106 |
name = xmlEntity.getStringProperty("dataStoreName"); |
104 | 107 |
} catch (NotExistInXMLEntity e) { |
105 |
throw new InitializeException("dataStoreName property not set", |
|
106 |
"DataManager"); |
|
108 |
throw new InitializeException(e); |
|
107 | 109 |
} |
108 | 110 |
|
109 | 111 |
DataStoreParameters params = this.createDataStoreParameters(name); |
... | ... | |
114 | 116 |
} |
115 | 117 |
|
116 | 118 |
/** |
117 |
* Levanta la instancia del datasource, |
|
118 |
* levanta una instancia del driver que precisa el datasource
|
|
119 |
* y por ultimo invoca al metodo init del datasource.
|
|
119 |
* Levanta la instancia del datasource, levanta una instancia del driver que
|
|
120 |
* precisa el datasource y por ultimo invoca al metodo init del datasource.
|
|
121 |
* |
|
120 | 122 |
* @throws InitializeException |
123 |
* @throws NotResgisteredStore |
|
121 | 124 |
**/ |
122 | 125 |
/* (non-Javadoc) |
123 | 126 |
* @see org.gvsig.fmap.data.DataManager#createDataStore(org.gvsig.fmap.data.impl.DataStoreParameters) |
124 | 127 |
*/ |
125 |
public DataStore createDataStore(DataStoreParameters parameters) throws InitializeException { |
|
128 |
public DataStore createDataStore(DataStoreParameters parameters) |
|
129 |
throws InitializeException, NotResgisteredStore { |
|
126 | 130 |
String name = parameters.getDataStoreName(); |
127 | 131 |
|
128 | 132 |
RegisterInfo registerInfo = this.getRegisterByName(name); |
129 | 133 |
if (registerInfo == null){ |
130 |
throw new InitializeException("Not registered in manager",name);
|
|
134 |
throw new NotResgisteredStore(name);
|
|
131 | 135 |
} |
132 | 136 |
|
133 | 137 |
try { |
... | ... | |
145 | 149 |
* @see org.gvsig.fmap.data.DataManager#createDataStore(com.iver.utiles.XMLEntity) |
146 | 150 |
*/ |
147 | 151 |
public DataStore createDataStore(XMLEntity xmlEntity) |
148 |
throws InitializeException { |
|
149 |
String name; |
|
152 |
throws InitializeException, NotResgisteredStore {
|
|
153 |
String name = null;
|
|
150 | 154 |
try { |
151 | 155 |
name = xmlEntity.getStringProperty("dataStoreName"); |
152 | 156 |
} catch (NotExistInXMLEntity e) { |
153 |
throw new InitializeException("dataStoreName property not set", |
|
154 |
"DataManager"); |
|
157 |
throw new InitializeException(e); |
|
155 | 158 |
} |
156 | 159 |
|
157 | 160 |
RegisterInfo registerInfo = this.getRegisterByName(name); |
158 | 161 |
if (registerInfo == null) { |
159 |
throw new InitializeException("Not registered in manager", name);
|
|
162 |
throw new NotResgisteredStore(name);
|
|
160 | 163 |
} |
161 | 164 |
|
162 | 165 |
try { |
... | ... | |
215 | 218 |
} |
216 | 219 |
|
217 | 220 |
/** |
218 |
* Levanta una instancia de los parametros solicitados |
|
219 |
* inicializa el nombre en la instancia |
|
220 |
* y la devuelve. |
|
221 |
* @throws InitializeException TODO |
|
221 |
* Levanta una instancia de los parametros solicitados inicializa el nombre |
|
222 |
* en la instancia y la devuelve. |
|
223 |
* |
|
224 |
* @throws InitializeException |
|
225 |
* TODO |
|
226 |
* @throws NotResgisteredStore |
|
222 | 227 |
**/ |
223 | 228 |
|
224 |
public DataExplorerParameters createDataExplorerParameters(String name) throws InitializeException { |
|
229 |
public DataExplorerParameters createDataExplorerParameters(String name) |
|
230 |
throws InitializeException, NotResgisteredStore { |
|
225 | 231 |
RegisterInfo registerInfo = this.getRegisterByName(name); |
226 | 232 |
if (registerInfo == null){ |
227 |
throw new InitializeException("Not registered in manager",name);
|
|
233 |
throw new NotResgisteredStore(name);
|
|
228 | 234 |
} else if (registerInfo.type != RegisterInfo.TYPE_EXPLORER) { |
229 |
throw new InitializeException("Not register as Explorer", name);
|
|
235 |
throw new NotResgisteredStore(name);
|
|
230 | 236 |
} |
231 | 237 |
|
232 | 238 |
try { |
... | ... | |
246 | 252 |
*/ |
247 | 253 |
|
248 | 254 |
public DataExplorerParameters createDataExplorerParameters( |
249 |
XMLEntity xmlEntity) throws InitializeException { |
|
255 |
XMLEntity xmlEntity) throws InitializeException, |
|
256 |
NotResgisteredStore { |
|
250 | 257 |
String name = null; |
251 | 258 |
try { |
252 | 259 |
name = xmlEntity.getStringProperty("dataExplorerName"); |
253 | 260 |
} catch (NotExistInXMLEntity e) { |
254 |
throw new InitializeException("dataExplorerName property not set", |
|
255 |
"DataManager"); |
|
261 |
throw new InitializeException(e); |
|
256 | 262 |
} |
257 | 263 |
DataExplorerParameters params = this.createDataExplorerParameters(name); |
258 | 264 |
|
... | ... | |
264 | 270 |
/* (non-Javadoc) |
265 | 271 |
* @see org.gvsig.fmap.data.DataManager#createDataExplorer(org.gvsig.fmap.data.impl.DataExplorerParameters) |
266 | 272 |
*/ |
267 |
public DataExplorer createDataExplorer(DataExplorerParameters parameters) throws InitializeException { |
|
273 |
public DataExplorer createDataExplorer(DataExplorerParameters parameters) |
|
274 |
throws InitializeException, NotResgisteredStore { |
|
268 | 275 |
RegisterInfo registerInfo = this.getRegisterByName(parameters.getDataExplorerName()); |
269 | 276 |
if (registerInfo == null){ |
270 |
throw new InitializeException("Not registered in manager",parameters.getDataExplorerName());
|
|
277 |
throw new NotResgisteredStore(parameters.getDataExplorerName());
|
|
271 | 278 |
} |
272 | 279 |
try { |
273 | 280 |
DataExplorer dataSource= (DataExplorer)registerInfo.clazz.newInstance(); |
... | ... | |
286 | 293 |
|
287 | 294 |
|
288 | 295 |
public DataExplorer createDataExplorer(XMLEntity xmlEntity) |
289 |
throws InitializeException { |
|
296 |
throws InitializeException, NotResgisteredStore {
|
|
290 | 297 |
|
291 | 298 |
String name; |
292 | 299 |
try { |
293 | 300 |
name = xmlEntity.getStringProperty("dataExplorerName"); |
294 | 301 |
} catch (NotExistInXMLEntity e) { |
295 |
throw new InitializeException("dataExplorerName property not set", |
|
296 |
"DataManager"); |
|
302 |
throw new InitializeException(e); |
|
297 | 303 |
} |
298 | 304 |
|
299 | 305 |
RegisterInfo registerInfo = this.getRegisterByName(name); |
300 | 306 |
if (registerInfo == null) { |
301 |
throw new InitializeException("Not registered in manager", |
|
302 |
name); |
|
307 |
throw new NotResgisteredStore(name); |
|
303 | 308 |
} |
304 | 309 |
try { |
305 | 310 |
DataExplorer dataSource = (DataExplorer) registerInfo.clazz |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/index/IndexRegistry.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
/* |
24 | 24 |
* AUTHORS (In addition to CIT): |
25 | 25 |
* 2008 {{Company}} {{Task}} |
26 | 26 |
*/ |
27 |
|
|
27 |
|
|
28 | 28 |
package org.gvsig.fmap.data.index; |
29 | 29 |
|
30 | 30 |
import java.util.HashMap; |
31 | 31 |
import java.util.Iterator; |
32 | 32 |
import java.util.Map; |
33 | 33 |
|
34 |
import org.gvsig.fmap.data.exceptions.DataException; |
|
34 | 35 |
import org.gvsig.fmap.data.feature.FeatureStore; |
35 | 36 |
import org.gvsig.fmap.data.feature.FeatureType; |
36 | 37 |
|
... | ... | |
42 | 43 |
*/ |
43 | 44 |
public class IndexRegistry { |
44 | 45 |
|
45 |
private Map featureTypes = new HashMap();
|
|
46 |
private Map featureTypes = new HashMap(); |
|
46 | 47 |
|
47 | 48 |
/** |
48 | 49 |
* Creates an empty IndexRegistry for the given FeatureStore |
49 |
* @param store FeatureStore to whom this IndexRegistry belongs |
|
50 |
* |
|
51 |
* @param store |
|
52 |
* FeatureStore to whom this IndexRegistry belongs |
|
53 |
* @throws DataException |
|
50 | 54 |
*/ |
51 |
public IndexRegistry(FeatureStore store) { |
|
55 |
public IndexRegistry(FeatureStore store) throws DataException {
|
|
52 | 56 |
Iterator it = store.getFeatureTypes().iterator(); |
53 | 57 |
while (it.hasNext()) { |
54 | 58 |
FeatureType type = (FeatureType) it.next(); |
... | ... | |
70 | 74 |
} |
71 | 75 |
return null; |
72 | 76 |
} |
73 |
|
|
77 |
|
|
74 | 78 |
/** |
75 | 79 |
* Adds an index to the registry, given its FeatureType and column name |
76 | 80 |
* @param fType |
77 | 81 |
* @param colName |
78 | 82 |
* @param index |
79 | 83 |
*/ |
80 |
public void addIndex(FeatureType fType, String colName, Index index) {
|
|
81 |
Map indexes = (Map) featureTypes.get(fType);
|
|
84 |
public void addIndex(FeatureType fType, String colName, Index index) { |
|
85 |
Map indexes = (Map) featureTypes.get(fType); |
|
82 | 86 |
if (indexes == null) { |
83 | 87 |
// A new feature type has been added to the FeatureStore since this IndexStore was created |
84 | 88 |
indexes = new HashMap(); |
... | ... | |
86 | 90 |
} |
87 | 91 |
indexes.put(colName, index); |
88 | 92 |
} |
89 |
|
|
93 |
|
|
90 | 94 |
/** |
91 | 95 |
* Returns true if this registry contains an index for the given FeatureType and column name, otherwise |
92 | 96 |
* it returns false. |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/index/AbstractIndex.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
/* |
24 | 24 |
* AUTHORS (In addition to CIT): |
25 | 25 |
* 2008 {{Company}} {{Task}} |
26 | 26 |
*/ |
27 |
|
|
28 | 27 |
|
28 |
|
|
29 | 29 |
package org.gvsig.fmap.data.index; |
30 | 30 |
|
31 | 31 |
import java.util.Iterator; |
32 | 32 |
import java.util.List; |
33 | 33 |
|
34 |
import org.gvsig.fmap.data.exceptions.ReadException;
|
|
34 |
import org.gvsig.fmap.data.exceptions.DataException;
|
|
35 | 35 |
import org.gvsig.fmap.data.feature.Feature; |
36 | 36 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
37 | 37 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
... | ... | |
40 | 40 |
|
41 | 41 |
|
42 | 42 |
public abstract class AbstractIndex implements Index { |
43 |
|
|
43 |
|
|
44 | 44 |
private final IndexParameters params; |
45 | 45 |
|
46 | 46 |
public AbstractIndex(IndexParameters params) throws IndexException { |
47 |
if (params == null) throw new IllegalArgumentException("params cannot be null."); |
|
47 |
if (params == null) { |
|
48 |
throw new IllegalArgumentException("params cannot be null."); |
|
49 |
} |
|
48 | 50 |
this.params = params; |
49 | 51 |
} |
50 |
|
|
52 |
|
|
51 | 53 |
public final FeatureAttributeDescriptor getFeatureAttributeDescriptor() { |
52 | 54 |
return params.getFeatureAttributeDescriptor(); |
53 | 55 |
} |
... | ... | |
59 | 61 |
public final FeatureType getFeatureType() { |
60 | 62 |
return params.getFeatureType(); |
61 | 63 |
} |
62 |
|
|
64 |
|
|
63 | 65 |
public final String getName() { |
64 | 66 |
return params.getName(); |
65 | 67 |
} |
66 |
|
|
68 |
|
|
67 | 69 |
public final boolean isOverwrite() { |
68 | 70 |
return params.isOverwrite(); |
69 | 71 |
} |
70 |
|
|
72 |
|
|
71 | 73 |
/** |
72 | 74 |
* Fills this index with all the data in its FeatureStore |
73 | 75 |
*/ |
74 | 76 |
public final void fill() throws IndexException { |
75 | 77 |
try { |
76 | 78 |
insert(getFeatureStore().getFeatureCollection()); |
77 |
} catch (ReadException e) {
|
|
79 |
} catch (DataException e) {
|
|
78 | 80 |
throw new IndexException(e); |
79 | 81 |
} |
80 | 82 |
} |
81 |
|
|
83 |
|
|
82 | 84 |
public final void insert(FeatureCollection data) { |
83 | 85 |
Iterator it = data.iterator(); |
84 | 86 |
while (it.hasNext()) { |
85 | 87 |
Feature feat = (Feature) it.next(); |
86 | 88 |
insert(feat); |
87 |
}
|
|
89 |
} |
|
88 | 90 |
} |
89 |
|
|
91 |
|
|
90 | 92 |
public void insert(Feature feat) { |
91 | 93 |
try { |
92 | 94 |
insert(feat.get(getFeatureAttributeDescriptor().getName()), feat.getID()); |
Also available in: Unified diff