Skip to content
Snippets Groups Projects
Commit e5bf38b5 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

adapts the service to the new metamodel

refs 2726
parent e308c5d6
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,6 @@ import static java.util.Collections.emptyList;
import static org.eclipse.emf.ecore.xmi.XMLResource.OPTION_PROCESS_DANGLING_HREF;
import static org.eclipse.emf.ecore.xmi.XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.disableNotificationsOf;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.enableNotificationsOf;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
import java.io.ByteArrayOutputStream;
......@@ -20,6 +18,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
......@@ -34,9 +33,7 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.items.ConstraintVerificationServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.model.constraints.ConstrainedWithChecksum;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.ConstraintsFactory;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.service.IConstraintService;
......@@ -49,7 +46,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CF334BB211CE8640BB9A3B90F5D94532
* @ConQAT.Rating YELLOW Hash: 1FC7269BEBCFB91D0029CCD01E2F5741
*/
public final class ConstraintService implements IIntrospectiveKernelService, IConstraintService {
......@@ -169,9 +166,11 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
/** {@inheritDoc} */
@Override
public boolean isUpToDate(ConstraintInstance ci) {
for(ConstrainedWithChecksum cwc : ci.getConstrainedsWithChecksum()) {
BigInteger computeCheckSum = computeCheckSum(cwc.getConstrained(), ci);
if(computeCheckSum == null || !computeCheckSum.equals(cwc.getChecksum())) {
for(IConstrained c : ci.getConstraineds()) {
BigInteger computeCheckSum = computeCheckSum(c, ci);
EMap<String, BigInteger> checksumMap = c.getChecksumsPerConstraintName();
BigInteger storedChecksum = checksumMap.get(ci.getConstraintName());
if(computeCheckSum == null || !computeCheckSum.equals(storedChecksum)) {
return false;
}
}
......@@ -180,18 +179,9 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
/** Updates all the checksums of <code>ci</code>. */
private void updateChecksums(ConstraintInstance ci) {
List<ConstrainedWithChecksum> newCwcs = new ArrayList<ConstrainedWithChecksum>();
for(ConstrainedWithChecksum cwc : ci.getConstrainedsWithChecksum()) {
ConstrainedWithChecksum newCwc =
ConstraintsFactory.eINSTANCE.createConstrainedWithChecksum();
newCwc.setConstrained(cwc.getConstrained());
newCwc.setChecksum(computeCheckSum(cwc.getConstrained(), ci));
newCwcs.add(newCwc);
for(IConstrained c : ci.getConstraineds()) {
c.getChecksumsPerConstraintName().put(ci.getConstraintName(), computeCheckSum(c, ci));
}
disableNotificationsOf(ci);
ci.getConstrainedsWithChecksum().clear();
ci.getConstrainedsWithChecksum().addAll(newCwcs);
enableNotificationsOf(ci);
}
/**
......@@ -257,12 +247,13 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
}
/**
* @return The object to be used to compute the checksum.
* Generally, all statuses and checksums are removed. Each constraint can also provide
* specific adaptations.
* Returns the object to be used to compute the checksum.
* Generally, all statuses and checksums are removed. Each constraint can also provide
* specific adaptations.
*/
protected EObject getChecksumRelevantEObject(IConstrained constrained, ConstraintInstance ci) {
IConstrained res = copy(constrained);
res.getChecksumsPerConstraintName().clear();
IConstraint verifier = getConstraint(ci);
if(verifier != null) {
verifier.preprocessBeforeChecksum(res);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment