Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Neumann2016-01-15 07:23:00 -0500
committerHans Neumann2016-01-15 07:23:00 -0500
commit11121018472946e324625b09b655846daae76c66 (patch)
tree3505d0d40f383d92ae0b72d1a0005f286beae56c
parent61a73e4f1f641c83d883dafbc13a709f20b437e8 (diff)
downloadorg.eclipse.openk-platform.openk-repo-11121018472946e324625b09b655846daae76c66.tar.gz
org.eclipse.openk-platform.openk-repo-11121018472946e324625b09b655846daae76c66.tar.xz
org.eclipse.openk-platform.openk-repo-11121018472946e324625b09b655846daae76c66.zip
Bugfix
Signed-off-by: Hans Neumann <hans.neumann@btc-ag.com>
-rwxr-xr-xopenk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/adapter/rest/controller/ActivityRestController.java6
-rwxr-xr-xopenk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/AbstractReductionAdviceService.java4
-rwxr-xr-xopenk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ActivityJpaService.java23
-rwxr-xr-xopenk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ReductionAdviceUpdateService.java33
-rwxr-xr-xopenk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/SynchronousMachineOrderService.java8
5 files changed, 42 insertions, 32 deletions
diff --git a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/adapter/rest/controller/ActivityRestController.java b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/adapter/rest/controller/ActivityRestController.java
index a91073d0..4645ec95 100755
--- a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/adapter/rest/controller/ActivityRestController.java
+++ b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/adapter/rest/controller/ActivityRestController.java
@@ -182,6 +182,7 @@ public class ActivityRestController extends AbstractRestController {
modifyDateFinischedForAction(activityJpaProxy.getParentActivityJpaId().toString(),
activityJpaProxy.getUserSettingsJpa().getDateFinished());
}
+ activityJpaService.handleManualReductions(activityJpaProxy);
return activityJpaService.saveActivityWithParent(activityJpaProxy);
//return activityJpaService.updateActivityJpaSetConfirmation(activityJpaProxy);
}
@@ -214,8 +215,9 @@ public class ActivityRestController extends AbstractRestController {
activityJpaProxy.setDateConfirmed(now());
activityJpaProxy.setUpdatedBy(getUserScreenName());
activityJpaProxy.setDateUpdated(now());
- activityJpaService.prepareJpaMapping(activityJpaProxy);
- activityJpaService.removeSynchronousMachineAndSubstationNotReduced(activityJpaProxy);
+ activityJpaService.handleManualReductions(activityJpaProxy);
+ //activityJpaService.prepareJpaMapping(activityJpaProxy);
+ //activityJpaService.removeSynchronousMachineAndSubstationNotReduced(activityJpaProxy);
final ActivityJpa childActivityJpa = activityJpa.getChildrenActivityJpaList().get(0);
if (null != childActivityJpa.getSubGeographicalRegionJpaList()) {
diff --git a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/AbstractReductionAdviceService.java b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/AbstractReductionAdviceService.java
index 2fe50016..90e77333 100755
--- a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/AbstractReductionAdviceService.java
+++ b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/AbstractReductionAdviceService.java
@@ -112,7 +112,7 @@ public abstract class AbstractReductionAdviceService extends AbstractService {
getSynchronousMachineListWithSubGeographicalRegionList(activityJpa);
// list of Substation/Transformer Stations
- } else if (activityJpa.getSubstationJpaList() != null && activityJpa.getSubstationJpaList().size() >= 0) {
+ } else if (activityJpa.getSubstationJpaList() != null && activityJpa.getSubstationJpaList().size() > 0) {
getSynchronousMachineListWithSubstationList(activityJpa);
@@ -124,7 +124,7 @@ public abstract class AbstractReductionAdviceService extends AbstractService {
}
}
- private void getSynchronousMachineListWithSubGeographicalRegionList(final ActivityJpa activityJpa) {
+ public void getSynchronousMachineListWithSubGeographicalRegionList(final ActivityJpa activityJpa) {
for (final SubGeographicalRegionJpa subGeographicalRegionJpa : activityJpa.getSubGeographicalRegionJpaList()) {
diff --git a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ActivityJpaService.java b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ActivityJpaService.java
index b533f7f3..b9efecbd 100755
--- a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ActivityJpaService.java
+++ b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ActivityJpaService.java
@@ -44,11 +44,30 @@ public class ActivityJpaService {
@Autowired
private SynchronousMachineJpaService synchronousMachineJpaService;
- public ActivityJpa saveActivityWithParent(final ActivityJpa activityJpa) {
+ @Autowired
+ private ReductionAdviceUpdateService reductionAdviceUpdateService;
+
+ public void handleManualReductions(final ActivityJpa activityJpa) {
+ reductionAdviceUpdateService.updateActivityChangedReductionList(activityJpa);
- prepareJpaMapping(activityJpa);
//activityJpa.setReductionAdviceNotFulfilled(sumOfReduction.compareTo(valueToBeReduced) == -1);
removeSynchronousMachineAndSubstationNotReduced(activityJpa);
+ prepareJpaMapping(activityJpa);
+
+ // TODO: Find out why referenced sync machines could not be persisted and if its necessary
+ for (final SubGeographicalRegionJpa subGeographicalRegionJpa : activityJpa.getSubGeographicalRegionJpaList()) {
+
+ for (final SubstationJpa substationJpa : subGeographicalRegionJpa.getSubstationJpaList()) {
+
+ for (final SynchronousMachineJpa synchronousMachineJpa : substationJpa.getSynchronousMachineJpaList()) {
+ synchronousMachineJpa.setReferencedSynchronousMachineJpa(null);
+ }
+ }
+ }
+ }
+
+ public ActivityJpa saveActivityWithParent(final ActivityJpa activityJpa) {
+
if (activityJpa.getParentActivityJpaId() == null) {
diff --git a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ReductionAdviceUpdateService.java b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ReductionAdviceUpdateService.java
index a941800a..847a6bd6 100755
--- a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ReductionAdviceUpdateService.java
+++ b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/ReductionAdviceUpdateService.java
@@ -12,10 +12,8 @@
*/
package org.eclipse.openk.eisman.service;
-import org.apache.commons.collections.CollectionUtils;
import org.eclipse.openk.eisman.model.jpa.core.SubGeographicalRegionJpa;
import org.eclipse.openk.eisman.model.jpa.core.SubstationJpa;
-import org.eclipse.openk.eisman.model.jpa.meas.AnalogJpa;
import org.eclipse.openk.eisman.model.jpa.process.ActivityJpa;
import org.eclipse.openk.eisman.model.jpa.wires.SynchronousMachineJpa;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +44,9 @@ public class ReductionAdviceUpdateService {
@Autowired
private SubstationJpaService substationJpaService;
+ @Autowired
+ private ReductionAdviceService reductionAdviceService;
+
public ActivityJpa updateActivity(final ActivityJpa activityJpa) {
updateActivityChangedReductionList(activityJpa);
@@ -61,31 +62,24 @@ public class ReductionAdviceUpdateService {
}
}
- private void updateActivityChangedReductionList(final ActivityJpa activityJpa) {
-
- final ActivityJpa activityJpaPersisted = activityJpaFindService.findActivity(activityJpa.getId());
- activityJpa.setSubGeographicalRegionJpaList(activityJpaPersisted.getSubGeographicalRegionJpaList());
+ public void updateActivityChangedReductionList(final ActivityJpa activityJpa) {
final List<SynchronousMachineJpa> synchronousMachineJpaListToBeAdded = new ArrayList<>();
final List<SynchronousMachineJpa> synchronousMachineJpaListJunction = new ArrayList<>();
-
for (final SynchronousMachineJpa synchronousMachineJpaToBeReduced : activityJpa.getSynchronousMachineJpaReducedList()) {
boolean exists = false;
for (final SynchronousMachineJpa synchronousMachineJpaPersisted :
- activityJpaService.getSynchronousMachineListOfActivity(activityJpaPersisted)) {
+ activityJpaService.getSynchronousMachineListOfActivity(activityJpa)) {
if (synchronousMachineJpaService.isSame(synchronousMachineJpaPersisted, synchronousMachineJpaToBeReduced)) {
exists = true;
synchronousMachineJpaListJunction.add(synchronousMachineJpaPersisted);
-
- if (synchronousMachineJpaPersisted.getReductionAdvice()
- .compareTo(synchronousMachineJpaToBeReduced.getReductionAdvice()) == 0) {
-
- synchronousMachineJpaPersisted.setReductionAdvice(synchronousMachineJpaToBeReduced.getReductionAdvice());
- }
+ synchronousMachineJpaPersisted.setReductionAdvice(synchronousMachineJpaToBeReduced.getReductionAdvice());
+ synchronousMachineJpaPersisted.setActivePowerJpaToBeReduced(synchronousMachineJpaToBeReduced
+ .getActivePowerJpaToBeReduced());
}
}
@@ -95,11 +89,6 @@ public class ReductionAdviceUpdateService {
}
}
- final List<SynchronousMachineJpa> synchronousMachineJpaListToBeDeleted =
- (List) CollectionUtils.disjunction(
- activityJpaService.getSynchronousMachineListOfActivity(activityJpaPersisted),
- synchronousMachineJpaListJunction);
-
for (final SynchronousMachineJpa synchronousMachineJpaToBeAdded : synchronousMachineJpaListToBeAdded) {
final SubGeographicalRegionJpa subGeographicalRegionJpaToBeAdded =
@@ -158,10 +147,10 @@ public class ReductionAdviceUpdateService {
}
}
- delete(activityJpa, synchronousMachineJpaListToBeDeleted);
+ //delete(activityJpa, synchronousMachineJpaListToBeDeleted);
}
- private void delete(final ActivityJpa activityJpa,
+/* private void delete(final ActivityJpa activityJpa,
final List<SynchronousMachineJpa> synchronousMachineJpaListToBeDeleted) {
for (final SynchronousMachineJpa synchronousMachineJpa : synchronousMachineJpaListToBeDeleted) {
@@ -215,6 +204,6 @@ public class ReductionAdviceUpdateService {
}
}
}
- }
+ }*/
}
diff --git a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/SynchronousMachineOrderService.java b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/SynchronousMachineOrderService.java
index d79a4b7c..68f03303 100755
--- a/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/SynchronousMachineOrderService.java
+++ b/openk-platform/openk-eisman-portlet/src/main/java/org/eclipse/openk/eisman/service/SynchronousMachineOrderService.java
@@ -43,10 +43,10 @@ public class SynchronousMachineOrderService {
return Double.compare(
sm1.getDiscriminatorCoefficient() == null ? 0 : sm1.getDiscriminatorCoefficient()
+ sm1.getFeedInPriority()
- + sm1.getFeedInRandomNumber(),
+ + (sm1.getFeedInRandomNumber() == null ? 0 : sm1.getFeedInRandomNumber()),
sm2.getDiscriminatorCoefficient() == null ? 0 : sm2.getDiscriminatorCoefficient()
+ sm2.getFeedInPriority()
- + sm2.getFeedInRandomNumber());
+ + (sm2.getFeedInRandomNumber() == null ? 0 : sm2.getFeedInRandomNumber()));
}
};
@@ -54,8 +54,8 @@ public class SynchronousMachineOrderService {
@Override
public int compare(final SynchronousMachineJpa sm1, final SynchronousMachineJpa sm2) {
return Double.compare(
- sm1.getFeedInPriority() + sm1.getFeedInRandomNumber(),
- sm2.getFeedInPriority() + sm2.getFeedInRandomNumber());
+ sm1.getFeedInPriority() + (sm1.getFeedInRandomNumber() == null ? 0 : sm1.getFeedInRandomNumber()),
+ sm2.getFeedInPriority() + (sm2.getFeedInRandomNumber() == null ? 0 : sm2.getFeedInRandomNumber()));
}
};

Back to the top