Revision 43610 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

View differences:

DefaultFeatureStore.java
61 61
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
62 62
import org.gvsig.fmap.dal.exception.WriteException;
63 63
import org.gvsig.fmap.dal.feature.EditableFeature;
64
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
64 65
import org.gvsig.fmap.dal.feature.EditableFeatureType;
65 66
import org.gvsig.fmap.dal.feature.Feature;
66 67
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
......
2531 2532
    }
2532 2533

  
2533 2534
    public void setTimeSupport(FeatureStoreTimeSupport timeSupport) {
2534
        FeatureAttributeDescriptor attr;
2535
        DefaultFeatureType ft;
2536
        try {
2537
            ft = (DefaultFeatureType) this.getDefaultFeatureType();
2538
        } catch (DataException ex) {
2539
            throw new RuntimeException("Can't add time support, can't get the default feature type.", ex);
2535
        if( this.isEditing() ) {
2536
            throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"' while store is editing.");
2540 2537
        }
2541
        attr = ft.getAttributeDescriptor(timeSupport.getAttributeName());
2542
        if( attr != null ) {
2543
            throw new RuntimeException("Can't add time support, attribute '"+timeSupport.getAttributeName()+"'already exists.");
2538
        if( !this.transforms.isEmpty() ) {
2539
            throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"' if has transforms.");
2544 2540
        }
2545
        attr = ft.getAttributeDescriptor(timeSupport.getRequiredFieldNames()[0]);
2546
        if( attr != null ) {
2541
        FeatureType ft = this.defaultFeatureType;
2542
        FeatureAttributeDescriptor attr = ft.getAttributeDescriptor(timeSupport.getRequiredFieldNames()[0]);
2543
        if( attr == null ) {
2547 2544
            throw new RuntimeException("Can't add time support over attribute '"+timeSupport.getAttributeName()+"', this attribute don't exists.");
2548 2545
        }
2549
        DefaultEditableFeatureAttributeDescriptor attr2 = new DefaultEditableFeatureAttributeDescriptor();
2550
        attr2.setDataType(timeSupport.getDataType());
2551
        attr2.setIsTime(true);
2552
        attr2.setFeatureAttributeEmulator(timeSupport);
2553
        ft.add(attr2);
2554

  
2546
        EditableFeatureType eft = ft.getEditable();
2547
        attr = eft.getAttributeDescriptor(timeSupport.getAttributeName());
2548
        if( attr != null ) {
2549
            if( !(attr.getFeatureAttributeEmulator() instanceof FeatureStoreTimeSupport) ) {
2550
                throw new RuntimeException("Can't add time support, attribute '"+timeSupport.getAttributeName()+"'already exists.");
2551
            }
2552
            eft.remove(attr.getName());
2553
        }
2554
        EditableFeatureAttributeDescriptor attrTime = eft.add(
2555
            timeSupport.getAttributeName(), 
2556
            timeSupport.getDataType()
2557
        );
2558
        attrTime.setIsTime(true);
2559
        attrTime.setFeatureAttributeEmulator(timeSupport);
2560
        eft.setDefaultTimeAttributeName(timeSupport.getAttributeName());
2561
        this.defaultFeatureType = eft.getNotEditableCopy();
2562
        
2555 2563
        this.timeSupport = timeSupport;
2556 2564
    }
2557 2565

  

Also available in: Unified diff