branch feature/7017 updated (8d4ddaf -> ef9329a)
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 8d4ddaf refactor save action for seine new ef9329a refactor save action for longline 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 ef9329a1edb7cd0ea5b50a8a9e83292dc45865a0 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Apr 27 17:15:40 2015 +0200 refactor save action for longline Summary of changes: .../data/longline/ActivityLonglineService.java | 2 +- .../data/longline/ActivityLonglineServiceImpl.java | 29 ++++-- .../services/data/longline/SetLonglineService.java | 8 ++ .../data/longline/SetLonglineServiceImpl.java | 114 +++++++++++++++++++++ .../data/longline/TripLonglineService.java | 2 +- .../data/longline/TripLonglineServiceImpl.java | 56 +++++----- .../impl/longline/SetLonglineUIHandler.java | 45 +------- .../impl/longline/ActivityLonglineUIHandler.java | 4 +- .../open/impl/longline/TripLonglineUIHandler.java | 4 +- 9 files changed, 174 insertions(+), 90 deletions(-) -- 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 ef9329a1edb7cd0ea5b50a8a9e83292dc45865a0 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Apr 27 17:15:40 2015 +0200 refactor save action for longline --- .../data/longline/ActivityLonglineService.java | 2 +- .../data/longline/ActivityLonglineServiceImpl.java | 29 ++++-- .../services/data/longline/SetLonglineService.java | 8 ++ .../data/longline/SetLonglineServiceImpl.java | 114 +++++++++++++++++++++ .../data/longline/TripLonglineService.java | 2 +- .../data/longline/TripLonglineServiceImpl.java | 56 +++++----- .../impl/longline/SetLonglineUIHandler.java | 45 +------- .../impl/longline/ActivityLonglineUIHandler.java | 4 +- .../open/impl/longline/TripLonglineUIHandler.java | 4 +- 9 files changed, 174 insertions(+), 90 deletions(-) diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineService.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineService.java index ed6fbfa..cebe40e 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineService.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineService.java @@ -27,7 +27,7 @@ public interface ActivityLonglineService extends ObserveService { ActivityLongline preCreate(String tripLonglineId); @Commit - ActivityLongline save(String tripLonglineId, ActivityLongline toSave); + String save(String tripLonglineId, ActivityLongline toSave); @Commit void delete(String tripLonglineId, String activityLonglineId); diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineServiceImpl.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineServiceImpl.java index d25a0e2..14a8e39 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineServiceImpl.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/ActivityLonglineServiceImpl.java @@ -101,23 +101,32 @@ public class ActivityLonglineServiceImpl extends AbstractObserveService implemen } @Override - public ActivityLongline save(String tripLonglineId, ActivityLongline toSave) { + public String save(String tripLonglineId, ActivityLongline toSave) { - ActivityLongline saved; + String activityLonglineId = doSave(tripLonglineId, toSave, new SaveAction<TripLongline, ActivityLongline>(TripLongline.class, ActivityLongline.class) { - if (toSave.getTopiaId() == null) { + @Override + public ActivityLongline onCreate(TripLongline parent, ActivityLongline toCreate) { - // create - saved = create(tripLonglineId, toSave); + ActivityLongline created = getDao().create(); + getBinderForEdit().copy(toCreate, created); - } else { + parent.addActivityLongline(created); + return created; + } - // update - saved = update(toSave); + @Override + public ActivityLongline onUpdate(TripLongline parent, ActivityLongline toUpdate, ActivityLongline updated) { - } + getBinderForEdit().copyExcluding(toUpdate, updated, + ActivityLongline.PROPERTY_ENCOUNTER, + ActivityLongline.PROPERTY_SENSOR_USED); + + return updated; + } + }); - return saved; + return activityLonglineId; } diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineService.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineService.java index 6e28f73..38f574b 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineService.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineService.java @@ -2,7 +2,9 @@ package fr.ird.observe.services.data.longline; import fr.ird.observe.entities.longline.Section; import fr.ird.observe.entities.longline.SetLongline; +import fr.ird.observe.services.NoTransaction; import fr.ird.observe.services.ObserveService; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; import java.util.List; @@ -18,4 +20,10 @@ public interface SetLonglineService extends ObserveService { List<Section> getSections(String setLonglineId); + String save(String activityId, SetLongline bean); + + @NoTransaction + TopiaEntityBinder<SetLongline> getBinderForEdit(); + + } diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineServiceImpl.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineServiceImpl.java index c02e1bb..e432560 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineServiceImpl.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/SetLonglineServiceImpl.java @@ -1,13 +1,19 @@ package fr.ird.observe.services.data.longline; +import fr.ird.observe.BinderService; +import fr.ird.observe.entities.longline.ActivityLongline; import fr.ird.observe.entities.longline.Basket; import fr.ird.observe.entities.longline.Branchline; import fr.ird.observe.entities.longline.Section; import fr.ird.observe.entities.longline.SetLongline; import fr.ird.observe.entities.longline.SetLonglineDAO; +import fr.ird.observe.entities.seine.TripSeine; import fr.ird.observe.services.AbstractObserveService; import org.nuiton.decorator.Decorator; import org.nuiton.topia.persistence.TopiaDAO; +import org.nuiton.topia.persistence.util.TopiaEntityBinder; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; import java.util.List; @@ -64,6 +70,114 @@ public class SetLonglineServiceImpl extends AbstractObserveService implements Se } + @Override + public String save(String activityLonglineId, SetLongline toSave) { + String setLonglineId = doSave(activityLonglineId, toSave, new SaveAction<ActivityLongline, SetLongline>(ActivityLongline.class, SetLongline.class) { + + @Override + public SetLongline onCreate(ActivityLongline parent, SetLongline toCreate) { + + SetLongline created = getDao().create(); + getBinderForEdit().copy(toCreate, created); + + parent.setSetLongline(created); + + return created; + } + + @Override + public SetLongline onUpdate(ActivityLongline parent, SetLongline toUpdate, SetLongline updated) { + + getBinderForEdit().copyExcluding(toUpdate, updated, + SetLongline.PROPERTY_BAITS_COMPOSITION, + SetLongline.PROPERTY_FLOATLINES_COMPOSITION, + SetLongline.PROPERTY_HOOKS_COMPOSITION, + SetLongline.PROPERTY_BRANCHLINES_COMPOSITION, + SetLongline.PROPERTY_SECTION, + SetLongline.PROPERTY_CATCH_LONGLINE, + SetLongline.PROPERTY_MITIGATION_TYPE, + SetLongline.PROPERTY_TDR); + return updated; + + } + }); + + return setLonglineId; + } + + @Override + public TopiaEntityBinder<SetLongline> getBinderForEdit() { + TopiaEntityBinder<SetLongline> r = loadBinder("-forEdit", SetLongline.class, new CreateBinder<SetLongline>() { + + @Override + public BinderModelBuilder<SetLongline, SetLongline> createBinderBuilder(BinderService binderService, String name) { + + BinderModelBuilder<SetLongline, SetLongline> builder = binderService.newBinderBuilder( + SetLongline.class, + SetLongline.PROPERTY_COMMENT, + + // setting tab + SetLongline.PROPERTY_HOME_ID, + SetLongline.PROPERTY_NUMBER, + + SetLongline.PROPERTY_SETTING_START_TIME_STAMP, + SetLongline.PROPERTY_SETTING_START_QUADRANT, + SetLongline.PROPERTY_SETTING_START_LATITUDE, + SetLongline.PROPERTY_SETTING_START_LONGITUDE, + + SetLongline.PROPERTY_SETTING_END_TIME_STAMP, + SetLongline.PROPERTY_SETTING_END_QUADRANT, + SetLongline.PROPERTY_SETTING_END_LATITUDE, + SetLongline.PROPERTY_SETTING_END_LONGITUDE, + + // setting caracteristics tab + SetLongline.PROPERTY_SETTING_SHAPE, + SetLongline.PROPERTY_LINE_TYPE, + SetLongline.PROPERTY_LIGHTSTICKS_TYPE, + SetLongline.PROPERTY_LIGHTSTICKS_COLOR, + SetLongline.PROPERTY_SETTING_VESSEL_SPEED, + SetLongline.PROPERTY_MAX_DEPTH_TARGETED, + SetLongline.PROPERTY_SHOOTER_USED, + SetLongline.PROPERTY_SHOOTER_SPEED, + SetLongline.PROPERTY_WEIGHTED_SWIVEL, + SetLongline.PROPERTY_SWIVEL_WEIGHT, + SetLongline.PROPERTY_WEIGHTED_SNAP, + SetLongline.PROPERTY_SNAP_WEIGHT, + SetLongline.PROPERTY_MONITORED, + SetLongline.PROPERTY_TIME_BETWEEN_HOOKS, + SetLongline.PROPERTY_BASKETS_PER_SECTION_COUNT, + SetLongline.PROPERTY_BRANCHLINES_PER_BASKET_COUNT, + SetLongline.PROPERTY_LIGHTSTICKS_PER_BASKET_COUNT, + SetLongline.PROPERTY_TOTAL_SECTIONS_COUNT, + SetLongline.PROPERTY_TOTAL_BASKETS_COUNT, + SetLongline.PROPERTY_TOTAL_HOOKS_COUNT, + + // hauling tab + SetLongline.PROPERTY_HAULING_DIRECTION_SAME_AS_SETTING, + + SetLongline.PROPERTY_HAULING_START_QUADRANT, + SetLongline.PROPERTY_HAULING_START_LATITUDE, + SetLongline.PROPERTY_HAULING_START_LONGITUDE, + SetLongline.PROPERTY_HAULING_START_TIME_STAMP, + + SetLongline.PROPERTY_HAULING_END_QUADRANT, + SetLongline.PROPERTY_HAULING_END_LATITUDE, + SetLongline.PROPERTY_HAULING_END_LONGITUDE, + SetLongline.PROPERTY_HAULING_END_TIME_STAMP, + + SetLongline.PROPERTY_HAULING_BREAKS); + + // on ajoute la recopie de l'association route + builder.addCollectionStrategy(Binder.CollectionStrategy.duplicate, TripSeine.PROPERTY_ROUTE); + + return builder; + } + + }); + + return r; + } + protected SetLonglineDAO getDao() { return (SetLonglineDAO) getDao(SetLongline.class); } diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineService.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineService.java index b39e076..587414d 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineService.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineService.java @@ -29,7 +29,7 @@ public interface TripLonglineService extends ObserveService { TripLongline preCreate(String programId); @Commit - TripLongline save(TripLongline toSave); + String save(TripLongline toSave); @Commit void delete(String tripLonglineId); diff --git a/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineServiceImpl.java b/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineServiceImpl.java index 7a93264..98c20d2 100644 --- a/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineServiceImpl.java +++ b/observe-services/src/main/java/fr/ird/observe/services/data/longline/TripLonglineServiceImpl.java @@ -96,29 +96,36 @@ public class TripLonglineServiceImpl extends AbstractObserveService implements T } @Override - public TripLongline save(TripLongline toSave) { + public String save(TripLongline toSave) { - Date startDate = DateUtil.getDay(toSave.getStartDate()); - toSave.setStartDate(startDate); + String tripLonglineId = doSave(null, toSave, new SaveAction<Program, TripLongline>(Program.class, TripLongline.class) { - // mise a jour de la date de fin - toSave.updateDateFin(); - - TripLongline saved; - - if (toSave.getTopiaId() == null) { + @Override + public void beforeSave(String parentId, TripLongline toSave) { + super.beforeSave(parentId, toSave); + Date startDate = DateUtil.getDay(toSave.getStartDate()); + toSave.setStartDate(startDate); - // create - saved = create(toSave); + // mise a jour de la date de fin + toSave.updateDateFin(); - } else { + } - // update - saved = update(toSave); + @Override + public TripLongline onCreate(Program parent, TripLongline toCreate) { + TripLongline created = getDao().create(); + getBinderForEdit().copy(toCreate, created); + return created; + } - } + @Override + public TripLongline onUpdate(Program parentBean, TripLongline toUpdate, TripLongline updated) { + getBinderForEdit().copyExcluding(toUpdate, updated, TripLongline.PROPERTY_ACTIVITY_LONGLINE); + return updated; + } + }); - return saved; + return tripLonglineId; } @@ -177,23 +184,6 @@ public class TripLonglineServiceImpl extends AbstractObserveService implements T } - protected TripLongline create(TripLongline toCreate) { - - TripLonglineDAO dao = getDao(); - TripLongline created = dao.create(toCreate); - return created; - - } - - protected TripLongline update(TripLongline toUpdate) { - - TripLonglineDAO dao = getDao(); - TripLongline updated = dao.findByTopiaId(toUpdate.getTopiaId()); - getBinderForEdit().copyExcluding(toUpdate, updated, TripLongline.PROPERTY_ACTIVITY_LONGLINE); - return updated; - - } - protected TripLonglineDAO getDao() { return (TripLonglineDAO) getDao(TripLongline.class); } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java index 54f8c65..11414a1 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java @@ -30,6 +30,7 @@ import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.db.util.TopiaExecutor2; import fr.ird.observe.entities.longline.ActivityLongline; import fr.ird.observe.entities.longline.SetLongline; +import fr.ird.observe.services.data.longline.SetLonglineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -374,48 +375,10 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLongline> { String activityId = getSelectedParentId(); - if (bean.getTopiaId() == null) { - - dataService.create(dataSource, activityId, bean, binder, getCreateExecutor()); - - } else { - - dataService.update(dataSource, null, bean, getUpdateExecutor()); - - } - + SetLonglineService service = getService(SetLonglineService.class); + String savedId = service.save(activityId, bean); + bean.setTopiaId(savedId); return true; - - } - - @Override - protected SetLongline onCreate(TopiaContext tx, Object parent, SetLongline editBean) throws TopiaException { - - ActivityLongline parentBean = (ActivityLongline) parent; - SetLongline beanToSave = ObserveDAOHelper.getSetLonglineDAO(tx).create(); - editBean.setTopiaId(beanToSave.getTopiaId()); - parentBean.setSetLongline(beanToSave); - return beanToSave; - - } - - @Override - protected SetLongline onUpdate(TopiaContext tx, - Object parentBean, - SetLongline beanToSave) throws TopiaException { - - getLoadBinder().copyExcluding(getBean(), - beanToSave, - SetLongline.PROPERTY_BAITS_COMPOSITION, - SetLongline.PROPERTY_FLOATLINES_COMPOSITION, - SetLongline.PROPERTY_HOOKS_COMPOSITION, - SetLongline.PROPERTY_BRANCHLINES_COMPOSITION, - SetLongline.PROPERTY_SECTION, - SetLongline.PROPERTY_CATCH_LONGLINE, - SetLongline.PROPERTY_MITIGATION_TYPE, - SetLongline.PROPERTY_TDR); - return beanToSave; - } @Override diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java index 7938b31..ef7ce2c 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java @@ -206,8 +206,8 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity bean.setOpen(true); ActivityLonglineService service = getService(ActivityLonglineService.class); - ActivityLongline saved = service.save(tripId, bean); - bean.setTopiaId(saved.getTopiaId()); + String savedId = service.save(tripId, bean); + bean.setTopiaId(savedId); obtainChildPosition(bean); diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java index 83985f0..0bbc283 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java @@ -229,8 +229,8 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline bean.setOpen(true); TripLonglineService service = getService(TripLonglineService.class); - TripLongline saved = service.save(bean); - bean.setTopiaId(saved.getTopiaId()); + String savedId = service.save(bean); + bean.setTopiaId(savedId); // recuperation de la position de la maree dans le program obtainChildPosition(bean); -- 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