Index: DALFile.java
===================================================================
--- DALFile.java	(revision 44093)
+++ DALFile.java	(revision 44094)
@@ -16,6 +16,8 @@
 import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
 import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.timesupport.RelativeInterval;
+import org.gvsig.timesupport.TimeSupportLocator;
 import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.dynobject.DynStruct;
 import org.gvsig.tools.persistence.PersistenceManager;
@@ -24,10 +26,11 @@
 import org.gvsig.tools.persistence.exception.PersistenceException;
 
 
+@SuppressWarnings("UseSpecificCatch")
 public class DALFile implements Persistent {
 
     private static final String DALFILE_PERSISTENCE_DEFINITION_NAME = "DALFile";
-    private static final String CALCULATEDATTRIBUTE_PERSISTENCE_DEFINITION_NAME = "DALFileCalculatedAttribute";
+    private static final String ATTRIBUTE_PERSISTENCE_DEFINITION_NAME = "DALFileAttribute";
     
     public static DALFile getDALFile() {
         DALFile f = new DALFile();
@@ -50,16 +53,16 @@
                 null, 
                 null
             );
-            definition.addDynFieldList("calculatedAttributes")
-                .setClassOfItems(CalculatedAttribute.class)
+            definition.addDynFieldList("attributes")
+                .setClassOfItems(Attribute.class)
                 .setMandatory(true)
                 .setPersistent(true);
         }
-        if (manager.getDefinition(CALCULATEDATTRIBUTE_PERSISTENCE_DEFINITION_NAME) == null) {
+        if (manager.getDefinition(ATTRIBUTE_PERSISTENCE_DEFINITION_NAME) == null) {
             DynStruct definition = manager.addDefinition(
-                CalculatedAttribute.class,
-                CALCULATEDATTRIBUTE_PERSISTENCE_DEFINITION_NAME, 
-                CALCULATEDATTRIBUTE_PERSISTENCE_DEFINITION_NAME + " Persistent definition", 
+                Attribute.class,
+                ATTRIBUTE_PERSISTENCE_DEFINITION_NAME, 
+                ATTRIBUTE_PERSISTENCE_DEFINITION_NAME + " Persistent definition", 
                 null, 
                 null
             );
@@ -80,30 +83,53 @@
     }
 
     
-    public static class CalculatedAttribute implements Persistent {
+    public static class Attribute implements Persistent {
 
         private String name;
         private int type;
         private FeatureAttributeEmulator emulator;
         private int featureTypeIndex;
+        private RelativeInterval interval;
         
-        public CalculatedAttribute() {
+        public Attribute() {
             
         }
 
-        private CalculatedAttribute(int featureTypeIndex, FeatureAttributeDescriptor attrdesc) {
+        private Attribute(int featureTypeIndex, FeatureAttributeDescriptor attrdesc) {
             this.featureTypeIndex = featureTypeIndex;
             this.name = attrdesc.getName();
             this.type = attrdesc.getType();
             this.emulator = attrdesc.getFeatureAttributeEmulator();
+            if( attrdesc.getInterval().isRelative() ) {
+                this.interval = (RelativeInterval) attrdesc.getInterval();
+            } else {
+                this.interval = null;
+            }
         }
 
+        public boolean needPersist() {
+            if( emulator!= null && emulator instanceof Persistent ) {
+                return true;
+            }
+            if( this.interval!=null ) {
+                return true;
+            }
+            return false;
+        }
+        
         @Override
         public void saveToState(PersistentState state) throws PersistenceException {
             state.set("name", name);
             state.set("type", type);
             state.set("featureTypeIndex", featureTypeIndex);
             state.set("emulator", emulator);
+            if( this.interval!=null ) {
+                state.set("intervalStart", interval.getStart().toMillis());
+                state.set("intervalEnd", interval.getEnd().toMillis());
+            } else {
+                state.setNull("intervalStart");
+                state.setNull("intervalEnd");
+            }
         }
 
         @Override
@@ -112,19 +138,32 @@
             this.type = state.getInt("type");
             this.featureTypeIndex = state.getInt("featureTypeIndex");
             this.emulator = (FeatureAttributeEmulator) state.get("emulator");
+            if( state.get("intervalStart")!=null ) {
+                this.interval = TimeSupportLocator.getManager().createRelativeInterval(
+                        state.getLong("intervalStart"), 
+                        state.getLong("intervalEnd")
+                );
+            }
         }
+
+        private void fetch(DefaultFeatureAttributeDescriptor attrdesc) {
+            attrdesc.setDataType(this.type);
+            attrdesc.setName(this.name);
+            attrdesc.setFeatureAttributeEmulator(this.emulator);
+            attrdesc.setInterval(this.interval);
+        }
         
         
     }
     
-    private final List<CalculatedAttribute> calculatedAttributes;
+    private final List<Attribute> attributes;
     
     public DALFile() {
-        this.calculatedAttributes = new ArrayList<>();
+        this.attributes = new ArrayList<>();
     }
 
     public boolean isEmpty() {
-        if( CollectionUtils.isEmpty(this.calculatedAttributes) ) {
+        if( CollectionUtils.isEmpty(this.attributes) ) {
             return true;
         }
         return false;
@@ -144,15 +183,14 @@
         }
     }
 
-    @SuppressWarnings("UseSpecificCatch")
     public void read(File f) {
         FileInputStream in = null;
         try {
             PersistenceManager manager = ToolsLocator.getPersistenceManager();
             in = new FileInputStream(f);
             DALFile x = (DALFile) manager.getObject(in);
-            this.calculatedAttributes.clear();
-            this.calculatedAttributes.addAll(x.calculatedAttributes);
+            this.attributes.clear();
+            this.attributes.addAll(x.attributes);
         } catch(Exception ex) {
             throw new RuntimeException("Can't read DAL file.",ex);
         } finally {
@@ -161,16 +199,15 @@
     }
 
     public void setStore(FeatureStore store) throws DataException {
-        this.calculatedAttributes.clear();
+        this.attributes.clear();
         
         List<FeatureType> types = store.getFeatureTypes();
         for( int n=0; n<types.size(); n++ ) {
             FeatureType type = types.get(n);
                 for (FeatureAttributeDescriptor attrdesc : type) {
-                    FeatureAttributeEmulator emulator = attrdesc.getFeatureAttributeEmulator();
-                    if( emulator!= null && emulator instanceof Persistent ) {
-                        CalculatedAttribute calculatedAttribute = new CalculatedAttribute(n,attrdesc);
-                        this.calculatedAttributes.add(calculatedAttribute);
+                    Attribute attribute = new Attribute(n,attrdesc);
+                    if( attribute.needPersist() ) {
+                        this.attributes.add(attribute);
                     }
             }
         }
@@ -180,13 +217,16 @@
         List<FeatureType> types = store.getFeatureTypes();
         Set<DefaultFeatureType> needFixTypes = new HashSet<>();
         
-        for (CalculatedAttribute calculatedAttribute : calculatedAttributes) {
-            DefaultFeatureType ft = (DefaultFeatureType) types.get(calculatedAttribute.featureTypeIndex);
-            DefaultFeatureAttributeDescriptor attrdesc = new DefaultFeatureAttributeDescriptor(ft);
-            attrdesc.setDataType(calculatedAttribute.type);
-            attrdesc.setName(calculatedAttribute.name);
-            attrdesc.setFeatureAttributeEmulator(calculatedAttribute.emulator);
-            ft.add(attrdesc);
+        for (Attribute attribute : this.attributes) {
+            DefaultFeatureType ft = (DefaultFeatureType) types.get(attribute.featureTypeIndex);
+            DefaultFeatureAttributeDescriptor attrdesc = (DefaultFeatureAttributeDescriptor) ft.get(attribute.name);
+            if( ft.get(attribute.name)==null ) {
+                attrdesc = new DefaultFeatureAttributeDescriptor(ft);
+                attribute.fetch(attrdesc);
+                ft.add(attrdesc);
+            } else {
+                attribute.fetch(attrdesc);
+            }
             needFixTypes.add(ft);
         }
         for (DefaultFeatureType type : needFixTypes) {
@@ -196,16 +236,16 @@
 
     @Override
     public void saveToState(PersistentState state) throws PersistenceException {
-        state.set("calculatedAttributes", calculatedAttributes);
+        state.set("attributes", attributes);
     }
 
     @Override
     public void loadFromState(PersistentState state) throws PersistenceException {
-        this.calculatedAttributes.clear();
-        Iterator<CalculatedAttribute> it = state.getIterator("calculatedAttributes");
+        this.attributes.clear();
+        Iterator<Attribute> it = state.getIterator("attributes");
         while( it.hasNext() ) {
-            CalculatedAttribute calculatedAttribute = it.next();
-            this.calculatedAttributes.add(calculatedAttribute);
+            Attribute attribute = it.next();
+            this.attributes.add(attribute);
         }
     }
 
