net.anotheria.anosite.gen.asfeature.data.ModuleASFeature Maven / Gradle / Ivy
/**
********************************************************************************
*** ModuleASFeature.java ***
*** generated by AnoSiteGenerator (ASG), Version: 2.6.3 ***
*** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net ***
*** All Rights Reserved. ***
********************************************************************************
*** Don't edit this code, if you aren't sure ***
*** that you do exactly know what you are doing! ***
*** It's better to invest time in the generator, as into the generated code. ***
********************************************************************************
*/
package net.anotheria.anosite.gen.asfeature.data;
import net.anotheria.anodoc.data.Module;
import net.anotheria.anodoc.data.DocumentList;
import net.anotheria.anodoc.data.IDHolder;
import net.anotheria.anodoc.data.NoSuchDocumentListException;
import java.util.List;
public class ModuleASFeature extends Module{
public static final String MODULE_ID = "asfeature";
public static final String LIST_FEATURE = "list_feature";
public static final String ID_HOLDER_FEATURE = IDHolder.DOC_ID_HOLDER_PRE+"feature";
public ModuleASFeature(){
super(MODULE_ID);
}
@SuppressWarnings("unchecked")
private DocumentList _getFeatures(){
try{
return getList(LIST_FEATURE);
}catch(NoSuchDocumentListException e){
return new DocumentList(LIST_FEATURE);
}
}
private void _updateFeatures(DocumentList list){
putList(list);
}
public List getFeatures(){
return _getFeatures().getList();
}
public FeatureDocument getFeature(String id){
return _getFeatures().getDocumentById(id);
}
public void updateFeature(FeatureDocument feature){
DocumentList features = _getFeatures();
features.removeDocumentById(feature.getId());
feature.setLastUpdateNow();
feature.setCallContextAuthor();
features.addDocument(feature);
_updateFeatures(features);
}
public void deleteFeature(String id){
DocumentList entries = _getFeatures();
entries.removeDocumentById(id);
_updateFeatures(entries);
}
public FeatureDocument createFeature(FeatureDocument feature ){
IDHolder idh = _getIdHolder(ID_HOLDER_FEATURE);
int id = idh.getNextIdInt();
feature.renameTo(""+id);
putDocument(idh);
DocumentList entries = _getFeatures();
feature.setLastUpdateNow();
feature.setCallContextAuthor();
entries.addDocument(feature);
_updateFeatures(entries);
return feature;
}
public FeatureDocument importFeature(FeatureDocument feature ){
IDHolder idh = _getIdHolder(ID_HOLDER_FEATURE);
idh.adjustTill(feature.getId());
putDocument(idh);
DocumentList entries = _getFeatures();
feature.setLastUpdateNow();
feature.setCallContextAuthor();
entries.addDocument(feature);
_updateFeatures(entries);
return feature;
}
}