branch feature/7017 updated (d8e7ac2 -> 8ef6168)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7017 in repository observe. See http://git.codelutin.com/observe.git from d8e7ac2 refactor save action for table entities (in schoolEstimate) new 8ef6168 refactor save action for table entities (in ObjectSchoolEstimate) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 8ef616819f0affe78b79a82281b70205669064f5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Apr 29 11:09:26 2015 +0200 refactor save action for table entities (in ObjectSchoolEstimate) Summary of changes: .../data/seine/ObjectSchoolEstimateService.java | 3 + .../seine/ObjectSchoolEstimateServiceImpl.java | 137 +++++++++++++++++++++ .../services/data/seine/SchoolEstimateService.java | 3 + .../data/seine/SchoolEstimateServiceImpl.java | 1 + .../impl/seine/ObjectSchoolEstimateUIHandler.java | 15 +++ 5 files changed, 159 insertions(+) create mode 100644 observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateServiceImpl.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7017 in repository observe. See http://git.codelutin.com/observe.git commit 8ef616819f0affe78b79a82281b70205669064f5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Apr 29 11:09:26 2015 +0200 refactor save action for table entities (in ObjectSchoolEstimate) --- .../data/seine/ObjectSchoolEstimateService.java | 3 + .../seine/ObjectSchoolEstimateServiceImpl.java | 137 +++++++++++++++++++++ .../services/data/seine/SchoolEstimateService.java | 3 + .../data/seine/SchoolEstimateServiceImpl.java | 1 + .../impl/seine/ObjectSchoolEstimateUIHandler.java | 15 +++ 5 files changed, 159 insertions(+) diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateService.java b/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateService.java index afc6127..a1e079d 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateService.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateService.java @@ -5,6 +5,7 @@ import fr.ird.observe.entities.seine.ObjectSchoolEstimate; import fr.ird.observe.services.Commit; import fr.ird.observe.services.NoTransaction; import fr.ird.observe.services.ObserveService; +import org.nuiton.topia.persistence.util.EntityListUpdator; import org.nuiton.topia.persistence.util.TopiaEntityBinder; /** @@ -31,4 +32,6 @@ public interface ObjectSchoolEstimateService extends ObserveService { @NoTransaction void copyForEdit(ObjectSchoolEstimate source, ObjectSchoolEstimate target); + + EntityListUpdator<FloatingObject, ObjectSchoolEstimate> getListUpdator(); } diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateServiceImpl.java b/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateServiceImpl.java new file mode 100644 index 0000000..34b8409 --- /dev/null +++ b/observe-services/src/main/java/fr/ird/observe/services/data/seine/ObjectSchoolEstimateServiceImpl.java @@ -0,0 +1,137 @@ +package fr.ird.observe.services.data.seine; + +import fr.ird.observe.BinderService; +import fr.ird.observe.entities.seine.FloatingObject; +import fr.ird.observe.entities.seine.ObjectSchoolEstimate; +import fr.ird.observe.services.AbstractObserveService; +import org.nuiton.topia.persistence.TopiaDAO; +import org.nuiton.topia.persistence.util.EntityListUpdator; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; +import org.nuiton.util.beans.BinderModelBuilder; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ObjectSchoolEstimateServiceImpl extends AbstractObserveService implements ObjectSchoolEstimateService { + + @Override + public FloatingObject loadForEdit(String floatingObjectId) { + + FloatingObject parentToLoad = findByTopiaId(FloatingObject.class, floatingObjectId); + + FloatingObject parentLoaded = getDao(FloatingObject.class).newInstance(); + + copyForEdit(parentToLoad, parentLoaded); + + if (!parentToLoad.isObjectSchoolEstimateEmpty()) { + + TopiaDAO<ObjectSchoolEstimate> childDao = getDao(ObjectSchoolEstimate.class); + + List<ObjectSchoolEstimate> childs = new ArrayList<ObjectSchoolEstimate>(); + + for (ObjectSchoolEstimate sourceChild : parentToLoad.getObjectSchoolEstimate()) { + + ObjectSchoolEstimate targetChild = childDao.newInstance(); + copyForEdit(sourceChild, targetChild); + childs.add(targetChild); + + } + + parentLoaded.setObjectSchoolEstimate(childs); + + } + + return parentLoaded; + } + + @Override + public void save(FloatingObject floatingObject) { + doSaveList(floatingObject, new SaveCollectionAction<FloatingObject, ObjectSchoolEstimate>(FloatingObject.class, ObjectSchoolEstimate.class, getListUpdator()) { + + @Override + public FloatingObject onUpdateParent(FloatingObject parentToSave, FloatingObject parentSaved) { + getBinderForFloatingObjectEdit().copyExcluding(parentToSave, parentSaved, FloatingObject.PROPERTY_OBJECT_SCHOOL_ESTIMATE); + getDao(FloatingObject.class).update(parentSaved); + return parentSaved; + } + + @Override + public ObjectSchoolEstimate onCreateChild(ObjectSchoolEstimate childToSave) { + ObjectSchoolEstimate childSaved = getDao(ObjectSchoolEstimate.class).newInstance(); + getBinderForObjectSchoolEstimateEdit().copy(childToSave, childSaved); + getDao(ObjectSchoolEstimate.class).create(childSaved); + return childSaved; + } + + @Override + public ObjectSchoolEstimate onUpdateChild(ObjectSchoolEstimate childToSave, ObjectSchoolEstimate childSaved) { + getBinderForObjectSchoolEstimateEdit().copy(childToSave, childSaved); + getDao(ObjectSchoolEstimate.class).update(childSaved); + return childSaved; + } + }); + } + + @Override + public TopiaEntityBinder<FloatingObject> getBinderForFloatingObjectEdit() { + TopiaEntityBinder<FloatingObject> binder = loadBinder("-forObjectSchoolEstimateEdit", FloatingObject.class, new CreateBinder<FloatingObject>() { + + @Override + public BinderModelBuilder<FloatingObject, FloatingObject> createBinderBuilder(BinderService binderService, String name) { + + BinderModelBuilder<FloatingObject, FloatingObject> builder = binderService.newBinderBuilder( + FloatingObject.class, + FloatingObject.PROPERTY_OBJECT_SCHOOL_ESTIMATE, + FloatingObject.PROPERTY_COMMENT); + + return builder; + + } + + }); + + return binder; + } + + @Override + public void copyForEdit(FloatingObject source, FloatingObject target) { + getBinderForFloatingObjectEdit().load(source, target, true); + } + + @Override + public TopiaEntityBinder<ObjectSchoolEstimate> getBinderForObjectSchoolEstimateEdit() { + TopiaEntityBinder<ObjectSchoolEstimate> binder = loadBinder("-forEdit", ObjectSchoolEstimate.class, new CreateBinder<ObjectSchoolEstimate>() { + + @Override + public BinderModelBuilder<ObjectSchoolEstimate, ObjectSchoolEstimate> createBinderBuilder(BinderService binderService, String name) { + + BinderModelBuilder<ObjectSchoolEstimate, ObjectSchoolEstimate> builder = binderService.newBinderBuilder( + ObjectSchoolEstimate.class, + ObjectSchoolEstimate.PROPERTY_SPECIES, + ObjectSchoolEstimate.PROPERTY_TOTAL_WEIGHT); + + return builder; + + } + + }); + + return binder; + } + + @Override + public void copyForEdit(ObjectSchoolEstimate source, ObjectSchoolEstimate target) { + getBinderForObjectSchoolEstimateEdit().load(source, target, true); + } + + @Override + public EntityListUpdator<FloatingObject, ObjectSchoolEstimate> getListUpdator() { + return EntityListUpdator.newEntityListUpdator( + FloatingObject.class, + ObjectSchoolEstimate.class, + FloatingObject.PROPERTY_OBJECT_SCHOOL_ESTIMATE); + } +} diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateService.java b/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateService.java index 2b4f831..9be981c 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateService.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateService.java @@ -5,6 +5,7 @@ import fr.ird.observe.entities.seine.SetSeine; import fr.ird.observe.services.Commit; import fr.ird.observe.services.NoTransaction; import fr.ird.observe.services.ObserveService; +import org.nuiton.topia.persistence.util.EntityListUpdator; import org.nuiton.topia.persistence.util.TopiaEntityBinder; /** @@ -32,4 +33,6 @@ public interface SchoolEstimateService extends ObserveService { @NoTransaction void copyForEdit(SchoolEstimate source, SchoolEstimate target); + EntityListUpdator<SetSeine, SchoolEstimate> getListUpdator(); + } diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateServiceImpl.java b/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateServiceImpl.java index a7b0afa..9509a8d 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateServiceImpl.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/seine/SchoolEstimateServiceImpl.java @@ -148,6 +148,7 @@ public class SchoolEstimateServiceImpl extends AbstractObserveService implements } + @Override public EntityListUpdator<SetSeine, SchoolEstimate> getListUpdator() { return EntityListUpdator.newEntityListUpdator( SetSeine.class, diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java index 542486d..853fb15 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java @@ -111,4 +111,19 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin super.initUI(); } + + @Override + protected void doPersist(FloatingObject editBean) { + getService(ObjectSchoolEstimateService.class).save(editBean); + } + + + //TODO Supprimer saveUI et mettre saveUI2 a la place + @Override + public final void saveUI(boolean refresh) { + saveUI2(refresh); + } + + + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm