Revision 45738

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretable/table/DynFieldFacadeOfAFeatureAttributeDescriptor.java
784 784
        return this;
785 785
    }
786 786

  
787
    @Override
788
    public Object getCoercedDefaultValue() {
789
        return ((DynField_v2)this.field).getCoercedDefaultValue();
790
    }
791

  
787 792
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFetureStore.java
947 947
    public boolean isFeatureModified(Feature feature){
948 948
        return false;
949 949
    }
950

  
951
    @Override
952
    public String getEditingSession() {
953
        return null;
954
    }
950 955
    
951 956
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureAttributeDescriptor.java
720 720
        return this;
721 721
    }
722 722

  
723
    @Override
724
    public Object getCoercedDefaultValue() {
725
        return null;
726
    }
727

  
723 728
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureStore.java
86 86

  
87 87
    public static final String METADATA_DEFINITION_NAME = "FeatureStore";
88 88

  
89
    final static int MODE_UNKNOWN = -1;
90

  
89 91
    /** Indicates that this store is in query mode */
90 92
    final static int MODE_QUERY = 0;
91 93

  
......
1388 1390
    public boolean isFeatureModified(FeatureReference id);
1389 1391

  
1390 1392
    public boolean isFeatureModified(Feature feature);
1393
    
1394
    public String getEditingSession();
1391 1395

  
1396

  
1392 1397
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureStoreNotification.java
46 46

  
47 47
	public static final String BEFORE_STARTEDITING = "before_StartEditing_DataStore";
48 48
	public static final String AFTER_STARTEDITING = "after_StartEditing_DataStore";
49
        public static final String FAILED_STARTEDITING = "failed_StartEditing_DataStore";
49 50

  
51

  
50 52
	public static final String BEFORE_CANCELEDITING = "before_CancelEditing_DataStore";
51 53
	public static final String AFTER_CANCELEDITING = "after_CancelEditing_DataStore";
52 54

  
......
93 95
     */
94 96
    public static final String INDEX_FILLING_ERROR = "Index_Filling_Error";
95 97

  
96
	public Feature getFeature();
98
    public String getEditingSession();
97 99

  
98
	public DataSet getCollectionResult();
100
    public int getEditMode();
101
    
102
    public Feature getFeature();
99 103

  
100
	public boolean loadSucefully();
104
    public DataSet getCollectionResult();
101 105

  
102
	public Exception getExceptionLoading();
106
    public boolean loadSucefully();
103 107

  
104
	public Command getCommand();
108
    public Exception getExceptionLoading();
105 109

  
106
	public EditableFeatureType getFeatureType();
110
    public Command getCommand();
111

  
112
    public EditableFeatureType getFeatureType();
107 113
  
108 114
  public boolean isSelectionCompromised();
109 115

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/Feature.java
38 38
import org.gvsig.tools.evaluator.EvaluatorData;
39 39
import org.gvsig.tools.util.GetItemByKeyWithSizeAndGetKeys;
40 40
import org.gvsig.json.SupportToJson;
41
import org.gvsig.tools.dataTypes.DataType;
41 42

  
42 43
/**
43 44
 * <p>
......
136 137

  
137 138
  public Object getOrDefault(String name, Object defaultValue);
138 139

  
140
  public Object getOrDefault(String name, DataType type, Object defaultValue);
141

  
142
  public Object getOrDefault(String name, int type, Object defaultValue);
143

  
139 144
  public String getStringOrDefault(String name, String defaultValue);
140 145

  
141 146
  public int getIntOrDefault(String name, int defaultValue);
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featureset/FastEditedIterator.java
39 39
 */
40 40
public class FastEditedIterator extends EditedIterator {
41 41

  
42
    DefaultFeature myFeature;
42
    private DefaultFeature myFeature;
43 43

  
44 44
    public FastEditedIterator(DefaultFeatureSet featureSet, long index)
45 45
        throws DataException {
46 46
        super(featureSet, index);
47
        myFeature = new DefaultFeature(fset.store);
48 47
    }
49 48

  
50 49
    @Override
51 50
    protected DefaultFeature createFeature(FeatureProvider data) throws DataException {
51
        if(myFeature == null){
52
            myFeature = new DefaultFeature(fset.store);
53
        }
52 54

  
53 55
        DefaultFeature f = this.featureManager.get(data);
54 56
//        DefaultFeature f = null;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featurereference/FeatureReferencePK.java
161 161
            state.set("pk", pk);
162 162
            state.set("pkNames", pkNames);
163 163
        }
164
        
164
        state.set("isNewFeature", isNewFeature());
165 165
    }
166 166

  
167 167
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featurereference/FeatureReferenceOID.java
114 114
        state.set("oid", oid);
115 115
        state.set("store", (Persistent) storeRef.get());
116 116
        state.set("featureTypeId", featureTypeId);
117
        state.set("isNewFeature", isNewFeature());
117 118
    }
118 119

  
119 120
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featurereference/FeatureReferencePersistenceFactory.java
36 36
                .setMandatory(false)
37 37
                .setPersistent(true);
38 38

  
39
        definition.addDynFieldString("type")
40
                .setPersistent(true);
41

  
39 42
        definition.addDynFieldBoolean("isNewFeature")
40 43
                .setMandatory(true)
41 44
                .setPersistent(true);
......
79 82
            case PK_TYPE:
80 83
                ref = new FeatureReferencePK();
81 84
                break;
82
            default:
83
                throw new IllegalArgumentException("Unsupported feature reference type"+type);
85
            default: //For compatibility with old persistence
86
                Object pk = state.get("pk");
87
                if(pk == null){
88
                    ref = new FeatureReferenceOID();
89
                } else {
90
                    ref = new FeatureReferencePK();
91
                }
84 92
        }
85 93
        ref.loadFromState(state);
86 94
        return ref;
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featurereference/FeatureReferenceUID.java
130 130
        state.set("uid", uid);
131 131
        state.set("store", (Persistent) storeRef.get());
132 132
        state.set("featureTypeId", featureTypeId);
133
        state.set("isNewFeature", isNewFeature());
133 134
    }
134 135

  
135 136
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
35 35
import java.util.Map.Entry;
36 36
import java.util.Objects;
37 37
import java.util.Set;
38
import java.util.UUID;
38 39
import javax.json.JsonObject;
39 40
import org.apache.commons.io.FilenameUtils;
40 41
import org.apache.commons.io.IOUtils;
......
236 237
    
237 238
    private PropertiesSupportHelper propertiesSupportHelper;
238 239
    private DataTransaction transaction;
240
    
241
    private String editingSessionCode;
239 242

  
240 243
    private class StateInformation extends HashMap<Object, Object> {
241 244

  
......
966 969
      return notifyChange(new DefaultFeatureStoreNotification(this, notification));
967 970
    }
968 971
    
972
    public FeatureStoreNotification notifyChange(String notification, String editingSessionCode) {
973
      return notifyChange(new DefaultFeatureStoreNotification(this, notification, editingSessionCode));
974
    }
975
    
976
    public FeatureStoreNotification notifyChange(String notification, String editingSessionCode, int editMode) {
977
      return notifyChange(new DefaultFeatureStoreNotification(this, notification, editingSessionCode, editMode));
978
    }
979
    
969 980
    public FeatureStoreNotification notifyChange(String notification,
981
      String editingSessionCode,
970 982
      Iterator<FeatureReference> deleteds, 
971 983
      Iterator<Feature> inserteds, 
972 984
      Iterator<Feature> updateds, 
973 985
      Iterator<FeatureTypeChanged> featureTypesChanged, 
974 986
      boolean isSelectionCompromised) {
975
        return notifyChange(new DefaultFeatureStoreNotification(this, notification,
987
        return notifyChange(new DefaultFeatureStoreNotification(this, notification, editingSessionCode,
976 988
            deleteds, inserteds, updateds, featureTypesChanged, isSelectionCompromised));
977 989
    }
978 990

  
......
1147 1159

  
1148 1160
    private void exitEditingMode() {
1149 1161
        if (commands != null) {
1150
            commands.clear();
1162
            try {
1163
                commands.clear();
1164
            } catch(Exception ex) {
1165
                LOGGER.trace("Can't clear commands",ex);
1166
            }
1151 1167
            commands = null;
1152 1168
        }
1153 1169

  
1154 1170
        if (featureTypeManager != null) {
1155
            featureTypeManager.dispose();
1171
            DisposeUtils.disposeQuietly(featureTypeManager);
1156 1172
            featureTypeManager = null;
1157 1173

  
1158 1174
        }
......
1166 1182
        mode = MODE_QUERY;
1167 1183
        hasStrongChanges = true; // Lo deja a true por si las moscas
1168 1184
        hasInserts = true;
1185
        
1186
        this.editingSessionCode = null;
1169 1187
    }
1170 1188

  
1171 1189
    @Override
......
1176 1194
    @Override
1177 1195
    synchronized public void edit(int mode) throws DataException {
1178 1196
        LOGGER.debug("Starting editing in mode: {}", mode);
1197
        String newSessionCode = this.createUniqueID();
1179 1198
        try {
1180 1199
            if (this.mode != MODE_QUERY) {
1181 1200
                throw new AlreadyEditingException(this.getName());
......
1191 1210
                if (!this.transforms.isEmpty()) {
1192 1211
                    throw new IllegalStateException(this.getName());
1193 1212
                }
1194
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING).isCanceled() ) {
1213
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, 
1214
                        newSessionCode, mode).isCanceled() ) {
1195 1215
                  return;
1196 1216
                }
1217
                this.editingSessionCode = newSessionCode;
1197 1218
                invalidateIndexes();
1198 1219
                featureManager = new FeatureManager(this);
1199 1220
                featureTypeManager = new FeatureTypeManager(this);
......
1205 1226
                this.mode = MODE_FULLEDIT;
1206 1227
                hasStrongChanges = false;
1207 1228
                hasInserts = false;
1208
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
1229
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, newSessionCode, this.mode);
1209 1230
                break;
1231

  
1210 1232
            case MODE_APPEND:
1211 1233
                if (!this.transforms.isEmpty()) {
1212 1234
                    throw new IllegalStateException(this.getName());
1213 1235
                }
1214
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING).isCanceled() ) {
1236
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, 
1237
                        newSessionCode, mode).isCanceled() ) {
1215 1238
                  return;
1216 1239
                }
1240
                this.editingSessionCode = newSessionCode;
1217 1241
                invalidateIndexes();
1218 1242
                this.provider.beginAppend();
1219 1243
                this.mode = MODE_APPEND;
1220 1244
                hasInserts = false;
1221
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
1245
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, 
1246
                        newSessionCode, this.mode);
1222 1247
                break;
1223 1248
            case MODE_PASS_THROUGH:
1224 1249
                if(!this.provider.supportsPassThroughMode()){
......
1227 1252
                if (!this.transforms.isEmpty()) {
1228 1253
                    throw new IllegalStateException(this.getName());
1229 1254
                }
1230
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING).isCanceled() ) {
1255
                if( notifyChange(FeatureStoreNotification.BEFORE_STARTEDITING, 
1256
                        newSessionCode, mode).isCanceled() ) {
1231 1257
                  return;
1232 1258
                }
1259
                this.editingSessionCode = newSessionCode;
1233 1260
                invalidateIndexes();
1234 1261
                this.mode = MODE_PASS_THROUGH;
1235 1262
                hasInserts = false;
1236
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING);
1263
                notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, 
1264
                        newSessionCode, this.mode);
1237 1265
                break;
1238 1266
                
1239 1267
                
1240 1268
            }
1241 1269
        } catch (Exception e) {
1270
            try {
1271
                if (this.mode != MODE_QUERY) {
1272
                   exitEditingMode();
1273
                }
1274
                notifyChange(FeatureStoreNotification.FAILED_STARTEDITING, 
1275
                        newSessionCode, mode);
1276
            } catch(Throwable th) {
1277
                LOGGER.warn("Can't cleanup after error in start editing.",th);
1278
            }
1242 1279
            throw new StoreEditException(e, this.getName());
1243 1280
        }
1244 1281
    }
......
1305 1342

  
1306 1343
    @Override
1307 1344
    public boolean isEditing() {
1308
        return mode == MODE_FULLEDIT;
1345
        return mode == MODE_FULLEDIT; 
1309 1346
    }
1310 1347

  
1311 1348
    @Override
......
1833 1870
                if( selection!=null ) {
1834 1871
                    selection = null;
1835 1872
                }
1836
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING).isCanceled() ) {
1873
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING,this.editingSessionCode).isCanceled() ) {
1837 1874
                  return;
1838 1875
                }
1839 1876
                saveDALFile();
......
1842 1879
                this.updateComputedFields(computedFields);
1843 1880
                loadDALFile();
1844 1881
                updateIndexes();
1845
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
1882
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING,this.editingSessionCode);
1846 1883
                break;
1847 1884

  
1848 1885
            case MODE_FULLEDIT:
......
1851 1888
                        throw new WriteNotAllowedException(getName());
1852 1889
                    }
1853 1890
                    if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING, 
1891
                            this.editingSessionCode,
1854 1892
                            featureManager.getDeleted(),
1855 1893
                            featureManager.getInsertedFeatures(),
1856 1894
                            featureManager.getUpdatedFeatures(),
......
1879 1917
                    exitEditingMode();
1880 1918
                    loadDALFile();
1881 1919
                    updateIndexes();
1882
                    notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
1920
                    notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING,this.editingSessionCode);
1883 1921
                } else {
1884 1922
                    exitEditingMode();
1885 1923
                }
......
1888 1926
                if( selection!=null ) {
1889 1927
                    selection = null;
1890 1928
                }
1891
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING).isCanceled() ) {
1929
                if( notifyChange(FeatureStoreNotification.BEFORE_FINISHEDITING,this.editingSessionCode).isCanceled() ) {
1892 1930
                  return;
1893 1931
                }
1894 1932
                exitEditingMode();
1895 1933
                updateIndexes();
1896
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING);
1934
                notifyChange(FeatureStoreNotification.AFTER_FINISHEDITING,this.editingSessionCode);
1897 1935
                break;
1898 1936
            }
1899 1937
        } catch (PerformEditingException pee) {
1900
            notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING);
1938
            notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING,this.editingSessionCode);
1901 1939
            throw new WriteException(provider.getSourceId().toString(), pee);
1902 1940
        } catch (Exception e) {
1903
            notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING);
1941
            notifyChange(FeatureStoreNotification.FAILED_FINISHEDITING,this.editingSessionCode);
1904 1942
            throw new FinishEditingException(e);
1905 1943
        }
1906 1944
    }
1945
    
1946
    @Override
1947
    public String getEditingSession() {
1948
        return this.editingSessionCode;
1949
    }
1950
    
1907 1951
    private Map<String,List<FeatureAttributeDescriptor>> getComputedFields() throws DataException {
1908 1952
        Map<String,List<FeatureAttributeDescriptor>> r = new HashMap<>();
1909 1953
        
......
1998 2042
                dalFile.updateStore(this);
1999 2043
            }
2000 2044
        } catch (Throwable ex) {
2001
            if( resource==null) {
2045
            if( resource==null ||  resourcesStorage==null) {
2002 2046
                if( resourcesStorage==null ) {
2003 2047
                    LOGGER.warn("Can't load DAL resource (resname=null, resurl=null, storage=null)", ex);
2004 2048
                } else {
......
3544 3588
        return this.featureManager.getPendingChangesCount();
3545 3589
    }
3546 3590

  
3591
    private ResourcesStorage resourcesStorage;
3592
    
3547 3593
    @Override
3548 3594
    public ResourcesStorage getResourcesStorage() {
3549
        ResourcesStorage resourcesStorage;
3595
        if( this.resourcesStorage!=null )  {
3596
            return this.resourcesStorage;
3597
        }
3598
        ResourcesStorage theResourcesStorage;
3550 3599
        try {
3551
            resourcesStorage = this.provider.getResourcesStorage();
3552
            if( resourcesStorage!=null ) {
3553
                return resourcesStorage;
3600
            theResourcesStorage = this.provider.getResourcesStorage();
3601
            if( theResourcesStorage!=null ) {
3602
                this.resourcesStorage = theResourcesStorage;
3603
                return theResourcesStorage;
3554 3604
            }
3555 3605
        } catch(Throwable th) {
3556 3606
            
......
3560 3610
            if( explorer==null ) {
3561 3611
                return null;
3562 3612
            }
3563
            resourcesStorage = explorer.getResourcesStorage(this);
3613
            theResourcesStorage = explorer.getResourcesStorage(this);
3564 3614
            explorer.dispose();
3565
            return resourcesStorage;
3615
            this.resourcesStorage = theResourcesStorage;
3616
            return theResourcesStorage;
3566 3617
        } catch (Exception ex) {
3567 3618
            LOGGER.trace("Can't create resources storage",ex);
3568 3619
            return null;
......
3709 3760
        }
3710 3761
    }
3711 3762
    
3763
    public String createUniqueID() {
3764
        UUID x = UUID.randomUUID();
3765
        String s = x.toString();
3766
        return s;
3767
    }
3768

  
3712 3769
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java
104 104
public class DefaultFeatureAttributeDescriptor implements
105 105
        FeatureAttributeDescriptor, Persistent, DynField_v2, DynField_LabelAttribute {
106 106

  
107
  protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureAttributeDescriptor.class);
107
    protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureAttributeDescriptor.class);
108 108

  
109
  protected boolean allowNull;
110
  protected DataType dataType;
111
  protected String dataProfile;
112
  protected DateFormat dateFormat;
113
  protected Object defaultValue;
114
  protected int index;
115
  protected int maximumOccurrences;
116
  protected int minimumOccurrences;
117
  protected int size;
118
  protected String name;
119
  protected Class objectClass;
120
  protected int precision;
121
  protected int scale;
122
  protected int roundMode;
123
  protected Evaluator evaluator;
124
  protected boolean primaryKey;
125
  protected boolean readOnly;
126
  protected IProjection SRS;
127
  protected GeometryType geomType;
128
  protected int geometryType;
129
  protected int geometrySubType;
130
  protected Map<String,String> additionalInfo;
131
  protected boolean isAutomatic;
132
  protected boolean isTime = false;
133
  protected Interval interval;
134
  protected FeatureAttributeGetter featureAttributeGetter = null;
135
  protected FeatureAttributeEmulator featureAttributeEmulator = null;
136
  protected boolean indexed = false;
137
  protected boolean isIndexAscending = true;
138
  protected boolean allowIndexDuplicateds = true;
109
    protected boolean allowNull;
110
    protected DataType dataType;
111
    protected String dataProfile;
112
    protected DateFormat dateFormat;
113
    protected Object defaultValue;
114
    protected int index;
115
    protected int maximumOccurrences;
116
    protected int minimumOccurrences;
117
    protected int size;
118
    protected String name;
119
    protected Class objectClass;
120
    protected int precision;
121
    protected int scale;
122
    protected int roundMode;
123
    protected Evaluator evaluator;
124
    protected boolean primaryKey;
125
    protected boolean readOnly;
126
    protected IProjection SRS;
127
    protected GeometryType geomType;
128
    protected int geometryType;
129
    protected int geometrySubType;
130
    protected Map<String, String> additionalInfo;
131
    protected boolean isAutomatic;
132
    protected boolean isTime = false;
133
    protected Interval interval;
134
    protected FeatureAttributeGetter featureAttributeGetter = null;
135
    protected FeatureAttributeEmulator featureAttributeEmulator = null;
136
    protected boolean indexed = false;
137
    protected boolean isIndexAscending = true;
138
    protected boolean allowIndexDuplicateds = true;
139 139

  
140
  protected DynObjectValueItem[] availableValues;
141
  protected DynObjectValueItem[] availableValuesCache; // No persistente
142
  protected Expression availableValuesExpression;
143
  protected boolean avoidCachingAvailableValues;
144
  private Map<Object, String> labelOfValueMap; // No persistente
145
  protected String description;
146
  protected Object minValue;
147
  protected Object maxValue;
148
  protected String label;
149
  protected String shortLabel;
150
  protected int order;
151
  protected boolean hidden;
152
  protected String groupName;
153
  protected Tags tags = new DefaultTags();
154
  private DynMethod availableValuesMethod;
155
  private DynMethod calculateMethod;
156
  private WeakReference typeRef;
157
  protected DefaultForeingKey foreingKey = null;
140
    protected DynObjectValueItem[] availableValues;
141
    protected DynObjectValueItem[] availableValuesCache; // No persistente
142
    protected Expression availableValuesExpression;
143
    protected boolean avoidCachingAvailableValues;
144
    private Map<Object, String> labelOfValueMap; // No persistente
145
    protected String description;
146
    protected Object minValue;
147
    protected Object maxValue;
148
    protected String label;
149
    protected String shortLabel;
150
    protected int order;
151
    protected boolean hidden;
152
    protected String groupName;
153
    protected Tags tags = new DefaultTags();
154
    private DynMethod availableValuesMethod;
155
    private DynMethod calculateMethod;
156
    private WeakReference typeRef;
157
    protected DefaultForeingKey foreingKey = null;
158 158

  
159
  protected CoercionContext coerceContext = null; // not persistent
160
  protected MathContext mathContext = null; // not persistent
159
    protected CoercionContext coerceContext = null; // not persistent
160
    protected MathContext mathContext = null; // not persistent
161 161

  
162
  private int relationType = RELATION_TYPE_NONE;
163
  protected Locale locale;
164
  protected int displaySize;
162
    private int relationType = RELATION_TYPE_NONE;
163
    protected Locale locale;
164
    protected int displaySize;
165 165

  
166
  public DefaultFeatureAttributeDescriptor() {
167
    // Usada en la persistencia
168
    this.precision = DataType.PRECISION_NONE;
169
    this.scale = DataType.SCALE_NONE;
170
    this.roundMode = BigDecimal.ROUND_HALF_UP;
171
  }
166
    public DefaultFeatureAttributeDescriptor() {
167
        // Usada en la persistencia
168
        this.precision = DataType.PRECISION_NONE;
169
        this.scale = DataType.SCALE_NONE;
170
        this.roundMode = BigDecimal.ROUND_HALF_UP;
171
    }
172 172

  
173
  protected DefaultFeatureAttributeDescriptor(FeatureType type) {
174
    this();
173
    protected DefaultFeatureAttributeDescriptor(FeatureType type) {
174
        this();
175 175
//        LOGGER.info(String.format("Created FeatureAttributeDescriptor [%08x].", this.hashCode()));
176
    setFeatureType(type);
177
    this.allowNull = true;
178
    this.dataType = null;
179
    this.dateFormat = null;
180
    this.defaultValue = null;
181
    this.index = -1;
182
    this.maximumOccurrences = 0;
183
    this.minimumOccurrences = 0;
184
    this.size = 0;
185
    this.name = null;
186
    this.objectClass = null;
187
    this.precision = DataType.PRECISION_NONE;
188
    this.scale = DataType.SCALE_NONE;
189
    this.roundMode = BigDecimal.ROUND_HALF_UP;
190
    this.evaluator = null;
191
    this.primaryKey = false;
192
    this.readOnly = false;
193
    this.SRS = null;
194
    this.geometryType = Geometry.TYPES.NULL;
195
    this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
196
    this.additionalInfo = null;
197
    this.isAutomatic = false;
198
    this.hidden = false;
199
    this.relationType = RELATION_TYPE_NONE;
200
    this.locale = null;
201
    this.displaySize = 0;
202
    this.avoidCachingAvailableValues = false;
203
  }
176
        setFeatureType(type);
177
        this.allowNull = true;
178
        this.dataType = null;
179
        this.dateFormat = null;
180
        this.defaultValue = null;
181
        this.index = -1;
182
        this.maximumOccurrences = 0;
183
        this.minimumOccurrences = 0;
184
        this.size = 0;
185
        this.name = null;
186
        this.objectClass = null;
187
        this.precision = DataType.PRECISION_NONE;
188
        this.scale = DataType.SCALE_NONE;
189
        this.roundMode = BigDecimal.ROUND_HALF_UP;
190
        this.evaluator = null;
191
        this.primaryKey = false;
192
        this.readOnly = false;
193
        this.SRS = null;
194
        this.geometryType = Geometry.TYPES.NULL;
195
        this.geometrySubType = Geometry.SUBTYPES.UNKNOWN;
196
        this.additionalInfo = null;
197
        this.isAutomatic = false;
198
        this.hidden = false;
199
        this.relationType = RELATION_TYPE_NONE;
200
        this.locale = null;
201
        this.displaySize = 0;
202
        this.avoidCachingAvailableValues = false;
203
    }
204 204

  
205
  protected DefaultFeatureAttributeDescriptor(
206
          DefaultFeatureAttributeDescriptor other
207
  ) {
208
    this();
209
    copyFrom(other);
205
    protected DefaultFeatureAttributeDescriptor(
206
            DefaultFeatureAttributeDescriptor other
207
    ) {
208
        this();
209
        copyFrom(other);
210 210
//        LOGGER.info(String.format("Created FeatureAttributeDescriptor [%08x] [%s] (copy).", this.hashCode(), this.name));
211
  }
211
    }
212 212

  
213
  @Override
214
  public void copyFrom(DynField other1) {
215
    if (!(other1 instanceof DefaultFeatureAttributeDescriptor)) {
216
      throw new IllegalArgumentException("Can't copy from a non DefaultFeatureAttributeDescriptor");
217
    }
218
    DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) other1;
219
    this.typeRef = other.typeRef;
220
    this.allowNull = other.allowNull;
221
    this.dataType = other.dataType;
222
    this.dateFormat = other.dateFormat;
223
    this.defaultValue = other.defaultValue;
224
    this.index = other.index;
225
    this.maximumOccurrences = other.maximumOccurrences;
226
    this.minimumOccurrences = other.minimumOccurrences;
227
    this.size = other.size;
228
    this.name = other.name;
229
    this.objectClass = other.objectClass;
230
    this.precision = other.precision;
231
    this.scale = other.scale;
232
    this.roundMode = other.roundMode;
233
    this.evaluator = other.evaluator;
234
    this.primaryKey = other.primaryKey;
235
    this.readOnly = other.readOnly;
236
    this.SRS = other.SRS;
237
    this.geometryType = other.geometryType;
238
    this.geometrySubType = other.geometrySubType;
239
    this.geomType = other.geomType;
240
    if (other.additionalInfo != null) {
241
        this.additionalInfo = new HashMap();
242
        for (Entry<String, String> entry : other.additionalInfo.entrySet()) {
243
            this.additionalInfo.put(entry.getKey(), entry.getValue());
213
    @Override
214
    public void copyFrom(DynField other1) {
215
        if (!(other1 instanceof DefaultFeatureAttributeDescriptor)) {
216
            throw new IllegalArgumentException("Can't copy from a non DefaultFeatureAttributeDescriptor");
244 217
        }
245
    } else {
246
      this.additionalInfo = null;
247
    }
248
    this.isAutomatic = other.isAutomatic;
249
    this.isTime = other.isTime;
250
    this.featureAttributeEmulator = other.featureAttributeEmulator;
251
    this.indexed = other.indexed;
252
    this.isIndexAscending = other.isIndexAscending;
253
    this.allowIndexDuplicateds = other.allowIndexDuplicateds;
254
    this.hidden = other.hidden;
255
    this.dataProfile = other.dataProfile;
218
        DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) other1;
219
        this.typeRef = other.typeRef;
220
        this.allowNull = other.allowNull;
221
        this.dataType = other.dataType;
222
        this.dateFormat = other.dateFormat;
223
        this.defaultValue = other.defaultValue;
224
        this.index = other.index;
225
        this.maximumOccurrences = other.maximumOccurrences;
226
        this.minimumOccurrences = other.minimumOccurrences;
227
        this.size = other.size;
228
        this.name = other.name;
229
        this.objectClass = other.objectClass;
230
        this.precision = other.precision;
231
        this.scale = other.scale;
232
        this.roundMode = other.roundMode;
233
        this.evaluator = other.evaluator;
234
        this.primaryKey = other.primaryKey;
235
        this.readOnly = other.readOnly;
236
        this.SRS = other.SRS;
237
        this.geometryType = other.geometryType;
238
        this.geometrySubType = other.geometrySubType;
239
        this.geomType = other.geomType;
240
        if (other.additionalInfo != null) {
241
            this.additionalInfo = new HashMap();
242
            for (Entry<String, String> entry : other.additionalInfo.entrySet()) {
243
                this.additionalInfo.put(entry.getKey(), entry.getValue());
244
            }
245
        } else {
246
            this.additionalInfo = null;
247
        }
248
        this.isAutomatic = other.isAutomatic;
249
        this.isTime = other.isTime;
250
        this.featureAttributeEmulator = other.featureAttributeEmulator;
251
        this.indexed = other.indexed;
252
        this.isIndexAscending = other.isIndexAscending;
253
        this.allowIndexDuplicateds = other.allowIndexDuplicateds;
254
        this.hidden = other.hidden;
255
        this.dataProfile = other.dataProfile;
256 256

  
257
    this.availableValues = other.availableValues;
258
    this.availableValuesExpression = other.availableValuesExpression;
259
    this.description = other.description;
260
    this.minValue = other.minValue;
261
    this.maxValue = other.maxValue;
262
    this.label = other.label;
263
    this.order = other.order;
264
    this.groupName = other.groupName;
265
    if (other.tags == null) {
266
      this.tags = null;
267
    } else {
268
      try {
269
        this.tags = (Tags) other.tags.clone();
270
      } catch (Exception ex) {
271
      }
257
        this.availableValues = other.availableValues;
258
        this.availableValuesExpression = other.availableValuesExpression;
259
        this.description = other.description;
260
        this.minValue = other.minValue;
261
        this.maxValue = other.maxValue;
262
        this.label = other.label;
263
        this.order = other.order;
264
        this.groupName = other.groupName;
265
        if (other.tags == null) {
266
            this.tags = null;
267
        } else {
268
            try {
269
                this.tags = (Tags) other.tags.clone();
270
            } catch (Exception ex) {
271
            }
272
        }
273
        this.foreingKey = null;
274
        if (other.foreingKey != null) {
275
            try {
276
                this.foreingKey = (DefaultForeingKey) other.foreingKey.clone();
277
            } catch (CloneNotSupportedException ex) {
278
            }
279
        }
280
        if (this.foreingKey != null) {
281
            this.foreingKey.setDescriptor(this);
282
        }
283

  
284
        // TODO: ? Habria que clonarlos ?
285
        this.availableValuesMethod = other.availableValuesMethod;
286
        this.calculateMethod = other.calculateMethod;
287
        this.relationType = other.relationType;
288
        this.locale = other.locale;
289
        this.displaySize = other.displaySize;
290
        this.avoidCachingAvailableValues = other.avoidCachingAvailableValues;
272 291
    }
273
    this.foreingKey = null;
274
    if (other.foreingKey != null) {
275
      try {
276
        this.foreingKey = (DefaultForeingKey) other.foreingKey.clone();
277
      } catch (CloneNotSupportedException ex) {
278
      }
279
    }
280
    if (this.foreingKey != null) {
281
      this.foreingKey.setDescriptor(this);
282
    }
283 292

  
284
    // TODO: ? Habria que clonarlos ?
285
    this.availableValuesMethod = other.availableValuesMethod;
286
    this.calculateMethod = other.calculateMethod;
287
    this.relationType = other.relationType;
288
    this.locale = other.locale;
289
    this.displaySize = other.displaySize;
290
    this.avoidCachingAvailableValues = other.avoidCachingAvailableValues;
291
  }
292

  
293
  public void setFeatureType(FeatureType type) {
294
    // Usada en la persistencia
295
    if (type == null) {
296
      this.typeRef = null;
297
    } else {
298
      this.typeRef = new WeakReference(type);
293
    public void setFeatureType(FeatureType type) {
294
        // Usada en la persistencia
295
        if (type == null) {
296
            this.typeRef = null;
297
        } else {
298
            this.typeRef = new WeakReference(type);
299 299
//            LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set FeatureType [%08x], ref [%08x].", this.hashCode(), type.hashCode(), typeRef.hashCode()));
300
        }
300 301
    }
301
  }
302 302

  
303
  @Override
304
  public String getDataTypeName() {
305
    if (this.getDataType() == null) {
306
      return "(unknow)";
303
    @Override
304
    public String getDataTypeName() {
305
        if (this.getDataType() == null) {
306
            return "(unknow)";
307
        }
308
        return this.getDataType().getName();
307 309
    }
308
    return this.getDataType().getName();
309
  }
310 310

  
311
  @Override
312
  public DefaultFeatureAttributeDescriptor getCopy() {
313
    return new DefaultFeatureAttributeDescriptor(this);
314
  }
311
    @Override
312
    public DefaultFeatureAttributeDescriptor getCopy() {
313
        return new DefaultFeatureAttributeDescriptor(this);
314
    }
315 315

  
316
  @Override
317
  public Object clone() throws CloneNotSupportedException {
318
    return new DefaultFeatureAttributeDescriptor(this);
319
  }
316
    @Override
317
    public Object clone() throws CloneNotSupportedException {
318
        return new DefaultFeatureAttributeDescriptor(this);
319
    }
320 320

  
321
  @Override
322
  public boolean allowNull() {
323
    return allowNull;
324
  }
321
    @Override
322
    public boolean allowNull() {
323
        return allowNull;
324
    }
325 325

  
326
  @Override
327
  public Locale getLocale() {
326
    @Override
327
    public Locale getLocale() {
328 328
    if( this.locale == null ) {
329 329
      if( this.dataType.isNumeric() ) {
330
        this.locale = Locale.ENGLISH;
331
      } else {
332
        this.locale = Locale.getDefault();
333
      }
330
                this.locale = Locale.ENGLISH;
331
            } else {
332
                this.locale = Locale.getDefault();
333
            }
334
        }
335
        return this.locale;
334 336
    }
335
    return this.locale;
336
  }
337 337

  
338
  @Override
339
  public DataType getDataType() {
340
    if (featureAttributeGetter != null) {
341
      return featureAttributeGetter.getDataType();
338
    @Override
339
    public DataType getDataType() {
340
        if (featureAttributeGetter != null) {
341
            return featureAttributeGetter.getDataType();
342
        }
343
        return this.dataType;
342 344
    }
343
    return this.dataType;
344
  }
345 345

  
346
  public FeatureAttributeDescriptor setDataType(int type) {
347
    this.dataType = ToolsLocator.getDataTypesManager().get(type);
348
    return this;
349
  }
346
    public FeatureAttributeDescriptor setDataType(int type) {
347
        this.dataType = ToolsLocator.getDataTypesManager().get(type);
348
        return this;
349
    }
350 350

  
351
  @Override
352
  public DateFormat getDateFormat() {
353
    return this.dateFormat;
354
  }
351
    @Override
352
    public DateFormat getDateFormat() {
353
        return this.dateFormat;
354
    }
355 355

  
356
  @Override
357
  public Object getDefaultValue() {
358
    return this.defaultValue;
359
  }
356
    @Override
357
    public Object getDefaultValue() {
358
        return this.defaultValue;
359
    }
360 360

  
361
  @Override
362
  public Object getDefaultValueCoerced() {
363
    try {
364
      Object value = this.defaultValue;
365
      if (value == null) {
366
        return null;
367
      }
368
      if (ExpressionUtils.isDynamicText(value.toString())) {
369
        value = ExpressionUtils.evaluateDynamicText(value.toString());
370
      }
371
      return this.getDataType().coerce(value);
372
    } catch (CoercionException ex) {
373
      return null;
361
    @Override
362
    @Deprecated
363
    public Object getDefaultValueCoerced() {
364
        return getCoercedDefaultValue();
374 365
    }
375
  }
376
  
377
  @Override
378
  public Supplier getDefaultValueSupplier() {
379
      return (Supplier) this::getDefaultValueCoerced;
380
  }
381 366

  
382 367
    @Override
368
    public Object getCoercedDefaultValue() {
369
        try {
370
            Object value = this.defaultValue;
371
            if (value == null) {
372
                return null;
373
            }
374
            if (ExpressionUtils.isDynamicText(value.toString())) {
375
                value = ExpressionUtils.evaluateDynamicText(value.toString());
376
            }
377
            return this.getDataType().coerce(value);
378
        } catch (CoercionException ex) {
379
            return null;
380
        }
381
    }
382

  
383
    @Override
384
    public Supplier getDefaultValueSupplier() {
385
        return (Supplier) this::getDefaultValueCoerced;
386
    }
387

  
388
    @Override
383 389
    public DynField setDefaultValueSupplier(Supplier supplier) {
384 390
        //Do nothing
385 391
        return this;
386 392
    }
393

  
387 394
  
388
  
389 395

  
390
  @Override
391
  public Evaluator getEvaluator() {
392
    return this.evaluator;
393
  }
396
    @Override
397
    public Evaluator getEvaluator() {
398
        return this.evaluator;
399
    }
394 400

  
395
  @Override
396
  public int getGeometryType() {
397
    if (this.dataType.getType() != DataTypes.GEOMETRY) {
398
      return Geometry.TYPES.UNKNOWN;
401
    @Override
402
    public int getGeometryType() {
403
        if (this.dataType.getType() != DataTypes.GEOMETRY) {
404
            return Geometry.TYPES.UNKNOWN;
405
        }
406
        return this.geometryType;
399 407
    }
400
    return this.geometryType;
401
  }
402 408

  
403
  @Override
404
  public int getGeometrySubType() {
405
    if (this.dataType.getType() != DataTypes.GEOMETRY) {
406
      return Geometry.SUBTYPES.UNKNOWN;
409
    @Override
410
    public int getGeometrySubType() {
411
        if (this.dataType.getType() != DataTypes.GEOMETRY) {
412
            return Geometry.SUBTYPES.UNKNOWN;
413
        }
414
        return this.geometrySubType;
407 415
    }
408
    return this.geometrySubType;
409
  }
410 416

  
411
  @Override
412
  public GeometryType getGeomType() {
413
    if (this.dataType.getType() != DataTypes.GEOMETRY) {
414
      return null;
417
    @Override
418
    public GeometryType getGeomType() {
419
        if (this.dataType.getType() != DataTypes.GEOMETRY) {
420
            return null;
421
        }
422
        if (this.geomType == null) {
423
            try {
424
                this.geomType
425
                        = GeometryLocator.getGeometryManager().getGeometryType(
426
                                this.geometryType, this.geometrySubType);
427
            } catch (GeometryException e) {
428
                throw new RuntimeException(
429
                        "Error getting geometry type with type = "
430
                        + this.geometryType + ", subtype = "
431
                        + this.geometrySubType, e);
432
            }
433
        }
434
        return this.geomType;
415 435
    }
416
    if (this.geomType == null) {
417
      try {
418
        this.geomType
419
                = GeometryLocator.getGeometryManager().getGeometryType(
420
                        this.geometryType, this.geometrySubType);
421
      } catch (GeometryException e) {
422
        throw new RuntimeException(
423
                "Error getting geometry type with type = "
424
                + this.geometryType + ", subtype = "
425
                + this.geometrySubType, e);
426
      }
436

  
437
    @Override
438
    public int getIndex() {
439
        return this.index;
427 440
    }
428
    return this.geomType;
429
  }
430 441

  
431
  @Override
432
  public int getIndex() {
433
    return this.index;
434
  }
442
    protected FeatureAttributeDescriptor setIndex(int index) {
443
        this.index = index;
444
        return this;
445
    }
435 446

  
436
  protected FeatureAttributeDescriptor setIndex(int index) {
437
    this.index = index;
438
    return this;
439
  }
447
    @Override
448
    public int getMaximumOccurrences() {
449
        return this.maximumOccurrences;
450
    }
440 451

  
441
  @Override
442
  public int getMaximumOccurrences() {
443
    return this.maximumOccurrences;
444
  }
452
    @Override
453
    public int getMinimumOccurrences() {
454
        return this.minimumOccurrences;
455
    }
445 456

  
446
  @Override
447
  public int getMinimumOccurrences() {
448
    return this.minimumOccurrences;
449
  }
457
    @Override
458
    public String getName() {
459
        return this.name;
460
    }
450 461

  
451
  @Override
452
  public String getName() {
453
    return this.name;
454
  }
455

  
456
  public FeatureAttributeDescriptor setName(String name) {
462
    public FeatureAttributeDescriptor setName(String name) {
457 463
//        LOGGER.info(String.format("FeatureAttributeDescriptor[%08x] set name [%s].", this.hashCode(), name));
458
    this.name = name;
459
    return this;
460
  }
464
        this.name = name;
465
        return this;
466
    }
461 467

  
462
  @Override
463
  public Class getObjectClass() {
464
    if (getDataType().getType() == DataTypes.OBJECT) {
465
      return objectClass;
468
    @Override
469
    public Class getObjectClass() {
470
        if (getDataType().getType() == DataTypes.OBJECT) {
471
            return objectClass;
472
        }
473
        return getDataType().getDefaultClass();
466 474
    }
467
    return getDataType().getDefaultClass();
468
  }
469 475

  
470
  @Override
471
  public int getPrecision() {
472
    return this.precision;
473
  }
476
    @Override
477
    public int getPrecision() {
478
        return this.precision;
479
    }
474 480

  
475
  @Override
476
  public int getScale() {
477
    return this.scale;
478
  }
481
    @Override
482
    public int getScale() {
483
        return this.scale;
484
    }
479 485

  
480
  @Override
481
  public Coercion getCoercion() {
482
    return this.getDataType().getCoercion();
483
  }
486
    @Override
487
    public Coercion getCoercion() {
488
        return this.getDataType().getCoercion();
489
    }
484 490

  
485
  @Override
486
  public MathContext getMathContext() {
487
    if (this.mathContext == null) {
488
      if (this.getDataType().isNumeric()) {
489
        this.mathContext = new MathContext(
490
                this.getPrecision(),
491
                RoundingMode.valueOf(this.getRoundMode())
492
        );
493
      } else {
494
        this.mathContext = MathContext.UNLIMITED;
495
      }
491
    @Override
492
    public MathContext getMathContext() {
493
        if (this.mathContext == null) {
494
            if (this.getDataType().isNumeric()) {
495
                this.mathContext = new MathContext(
496
                        this.getPrecision(),
497
                        RoundingMode.valueOf(this.getRoundMode())
498
                );
499
            } else {
500
                this.mathContext = MathContext.UNLIMITED;
501
            }
502
        }
503
        return this.mathContext;
496 504
    }
497
    return this.mathContext;
498
  }
499 505

  
500
  @Override
501
  public CoercionContext getCoercionContext() {
502
    if (this.coerceContext == null) {
503
      if (this.getDataType().isNumeric()) {
504
        this.coerceContext = DataTypeUtils.coerceContextDecimal(
505
                this.getLocale(),
506
                this.getPrecision(),
507
                this.getScale(),
508
                this.getRoundMode()
509
        );
506
    @Override
507
    public CoercionContext getCoercionContext() {
508
        if (this.coerceContext == null) {
509
            if (this.getDataType().isNumeric()) {
510
                this.coerceContext = DataTypeUtils.coerceContextDecimal(
511
                        this.getLocale(),
512
                        this.getPrecision(),
513
                        this.getScale(),
514
                        this.getRoundMode()
515
                );
510 516
      } else if( this.getType() == DataTypes.GEOMETRY ) {
511
          GeometryCoercionContext context = GeometryLocator.getGeometryManager().createGeometryCoercionContext();
512
          context.setGeometryType(this.getGeomType());
513
          context.setMode(GeometryCoercionContext.MODE_ONERROR_DONTCONVERT);
514
          this.coerceContext = context;
515
      } else {
516
        this.coerceContext = DataTypeUtils.coerceContextLocale(
517
                this.getLocale()
518
        );
519
      }
517
                GeometryCoercionContext context = GeometryLocator.getGeometryManager().createGeometryCoercionContext();
518
                context.setGeometryType(this.getGeomType());
519
                context.setMode(GeometryCoercionContext.MODE_ONERROR_DONTCONVERT);
520
                this.coerceContext = context;
521
            } else {
522
                this.coerceContext = DataTypeUtils.coerceContextLocale(
523
                        this.getLocale()
524
                );
525
            }
526
        }
527
        return this.coerceContext;
520 528
    }
521
    return this.coerceContext;
522
  }
523 529

  
524
  @Override
525
  public int getRoundMode() {
526
    return this.roundMode;
527
  }
528

  
529
  @Override
530
  public IProjection getSRS() {
531
    return this.SRS;
532
  }
533

  
534
  @Override
535
  public Interval getInterval() {
536
    return this.interval;
537
  }
538

  
539
  public IProjection getSRS(WeakReference storeRef) {
540
    if (this.SRS == null) {
541
      FeatureStore store = (FeatureStore) storeRef.get();
542
      this.SRS = (IProjection) store.getDynValue(DataStore.METADATA_CRS);
530
    @Override
531
    public int getRoundMode() {
532
        return this.roundMode;
543 533
    }
544
    return this.SRS;
545
  }
546 534

  
547
  @Override
548
  public int getSize() {
549
    return this.size;
550
  }
551

  
552
  @Override
553
  public boolean isPrimaryKey() {
554
    return this.primaryKey;
555
  }
556

  
557
  @Override
558
  public boolean isReadOnly() {
559
    if (this.readOnly) {
560
      return true;
535
    @Override
536
    public IProjection getSRS() {
537
        return this.SRS;
561 538
    }
562
    return this.isComputed();
563
  }
564 539

  
565
  @Override
566
  public String getAdditionalInfo(String infoName) {
567
    if (this.additionalInfo == null) {
568
      return null;
540
    @Override
541
    public Interval getInterval() {
542
        return this.interval;
569 543
    }
570
    return this.additionalInfo.get(infoName);
571
  }
572 544

  
573
  @Override
574
  public boolean isAutomatic() {
575
    return this.isAutomatic;
576
  }
577

  
578
  @Override
579
  public boolean equals(Object obj) {
580
    if (this == obj) {
581
      return true;
545
    public IProjection getSRS(WeakReference storeRef) {
546
        if (this.SRS == null) {
547
            FeatureStore store = (FeatureStore) storeRef.get();
548
            this.SRS = (IProjection) store.getDynValue(DataStore.METADATA_CRS);
549
        }
550
        return this.SRS;
582 551
    }
583
    if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
584
      return false;
585
    }
586
    DefaultFeatureAttributeDescriptor other
587
            = (DefaultFeatureAttributeDescriptor) obj;
588 552

  
589
    if (this.allowNull != other.allowNull) {
590
      return false;
553
    @Override
554
    public int getSize() {
555
        return this.size;
591 556
    }
592 557

  
593
    if (this.index != other.index) {
594
      return false;
558
    @Override
559
    public boolean isPrimaryKey() {
560
        return this.primaryKey;
595 561
    }
596 562

  
597
    if (!Objects.equals(this.name, other.name)) {
598
      return false;
563
    @Override
564
    public boolean isReadOnly() {
565
        if (this.readOnly) {
566
            return true;
567
        }
568
        return this.isComputed();
599 569
    }
600 570

  
601
    if (this.getDataType() != other.getDataType()) {
602
      return false;
571
    @Override
572
    public String getAdditionalInfo(String infoName) {
573
        if (this.additionalInfo == null) {
574
            return null;
575
        }
576
        return this.additionalInfo.get(infoName);
603 577
    }
604 578

  
605
    if (this.size != other.size) {
606
      return false;
579
    @Override
580
    public boolean isAutomatic() {
581
        return this.isAutomatic;
607 582
    }
608 583

  
609
    if (!Objects.equals(this.defaultValue, other.defaultValue)) {
610
      return false;
611
    }
584
    @Override
585
    public boolean equals(Object obj) {
586
        if (this == obj) {
587
            return true;
588
        }
589
        if (!(obj instanceof DefaultFeatureAttributeDescriptor)) {
590
            return false;
591
        }
592
        DefaultFeatureAttributeDescriptor other
593
                = (DefaultFeatureAttributeDescriptor) obj;
612 594

  
613
    if (this.primaryKey != other.primaryKey) {
614
      return false;
615
    }
595
        if (this.allowNull != other.allowNull) {
596
            return false;
597
        }
616 598

  
617
    if (this.isAutomatic != other.isAutomatic) {
618
      return false;
619
    }
599
        if (this.index != other.index) {
600
            return false;
601
        }
620 602

  
621
    if (this.readOnly != other.readOnly) {
622
      return false;
623
    }
603
        if (!Objects.equals(this.name, other.name)) {
604
            return false;
605
        }
624 606

  
625
    if (this.precision != other.precision) {
626
      return false;
627
    }
607
        if (this.getDataType() != other.getDataType()) {
608
            return false;
609
        }
628 610

  
629
    if (this.maximumOccurrences != other.maximumOccurrences) {
630
      return false;
631
    }
611
        if (this.size != other.size) {
612
            return false;
613
        }
632 614

  
633
    if (this.minimumOccurrences != other.minimumOccurrences) {
634
      return false;
635
    }
615
        if (!Objects.equals(this.defaultValue, other.defaultValue)) {
616
            return false;
617
        }
636 618

  
637
    if (this.geometryType != other.geometryType) {
638
      return false;
639
    }
619
        if (this.primaryKey != other.primaryKey) {
620
            return false;
621
        }
640 622

  
641
    if (this.geometrySubType != other.geometrySubType) {
642
      return false;
643
    }
623
        if (this.isAutomatic != other.isAutomatic) {
624
            return false;
625
        }
644 626

  
645
    if (!Objects.equals(this.evaluator, other.evaluator)) {
646
      return false;
647
    }
627
        if (this.readOnly != other.readOnly) {
628
            return false;
629
        }
648 630

  
649
    if (!Objects.equals(this.featureAttributeEmulator, other.featureAttributeEmulator)) {
650
      return false;
651
    }
631
        if (this.precision != other.precision) {
632
            return false;
633
        }
652 634

  
653
    if (!Objects.equals(this.SRS, other.SRS)) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff