[New] When retrieving new templates, then the type and ID is set auto

This commit is contained in:
Robert von Burg 2016-09-21 15:47:18 +02:00
parent f8165208b1
commit e3ea9fa159
3 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import li.strolch.agent.api.ElementMap;
import li.strolch.agent.api.StrolchAgent;
import li.strolch.agent.api.StrolchRealm;
import li.strolch.exception.StrolchException;
import li.strolch.model.StrolchRootElement;
@ -96,6 +97,8 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
@SuppressWarnings("unchecked")
T clone = (T) t.getClone();
clone.setId(StrolchAgent.getUniqueId());
clone.setType(type);
return clone;
}

View File

@ -22,6 +22,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import li.strolch.agent.api.ElementMap;
import li.strolch.agent.api.StrolchAgent;
import li.strolch.agent.api.StrolchRealm;
import li.strolch.exception.StrolchException;
import li.strolch.model.StrolchRootElement;
@ -92,6 +93,8 @@ public abstract class TransactionalElementMap<T extends StrolchRootElement> impl
@SuppressWarnings("unchecked")
T clone = (T) t.getClone();
clone.setId(StrolchAgent.getUniqueId());
clone.setType(type);
return clone;
}

View File

@ -25,6 +25,14 @@ import li.strolch.model.visitor.StrolchRootElementVisitor;
*/
public interface StrolchRootElement extends StrolchElement, PolicyContainer, ParameterBagContainer {
/**
* Set the type of this {@link StrolchRootElement}. Not that this method should only be called for new elements, not
* if this element has already been persisted!
*
* @param type
*/
public void setType(String type);
/**
* Returns true if this {@link StrolchRootElement} has a version set
*