Skip to content
Snippets Groups Projects
Commit b80b560c authored by Florian Hölzl's avatar Florian Hölzl
Browse files

refactored constraint checker service to use service base implementation

parent f85bd607
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<extension-point id="modelPrototypeProvider" name="Model Prototype Provider" schema="schema/modelPrototypeProvider.exsd"/> <extension-point id="modelPrototypeProvider" name="Model Prototype Provider" schema="schema/modelPrototypeProvider.exsd"/>
<extension-point id="modelElementCompositor" name="Model Element Compositor" schema="schema/modelElementCompositor.exsd"/> <extension-point id="modelElementCompositor" name="Model Element Compositor" schema="schema/modelElementCompositor.exsd"/>
<extension-point id="modelStorageProvider" name="Model Storage Provider" schema="schema/modelStorageProvider.exsd"/> <extension-point id="modelStorageProvider" name="Model Storage Provider" schema="schema/modelStorageProvider.exsd"/>
<extension-point id="modelConstraintChecker" name="Model Constraint Checker" schema="schema/modelConstraintChecker.exsd"/> <extension-point id="modelElementConstraintChecker" name="Model Element Constraint Checker" schema="schema/modelElementConstraintChecker.exsd"/>
<extension-point id="eclipseResourceStorageLocationProvider" name="Eclipse Resource Storage Location Provider" schema="schema/eclipseResourceStorageLocationProvider.exsd"/> <extension-point id="eclipseResourceStorageLocationProvider" name="Eclipse Resource Storage Location Provider" schema="schema/eclipseResourceStorageLocationProvider.exsd"/>
<extension-point id="modelConnectionCompositor" name="Model Connection Compositor" schema="schema/modelConnectionCompositor.exsd"/> <extension-point id="modelConnectionCompositor" name="Model Connection Compositor" schema="schema/modelConnectionCompositor.exsd"/>
<extension <extension
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<schema targetNamespace="org.fortiss.tooling.kernel" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.fortiss.tooling.kernel" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appinfo> <appinfo>
<meta.schema plugin="org.fortiss.tooling.kernel" id="modelConstraintChecker" name="Model Constraint Checker"/> <meta.schema plugin="org.fortiss.tooling.kernel" id="modelElementConstraintChecker" name="Model Element Constraint Checker"/>
</appinfo> </appinfo>
<documentation> <documentation>
Registers a constraint checker for model elements. Registers a constraint checker for model elements.
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</complexType> </complexType>
</element> </element>
<element name="modelConstraintChecker" type="string"> <element name="modelElementConstraintChecker" type="string">
</element> </element>
<annotation> <annotation>
......
...@@ -38,8 +38,8 @@ public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C> ...@@ -38,8 +38,8 @@ public interface IConstraintChecker<C extends EObject> extends IEObjectAware<C>
* Determines whether the constraint checker is applicable to the given * Determines whether the constraint checker is applicable to the given
* model element. * model element.
*/ */
boolean isApplicable(C modelElement); boolean isApplicable(EObject modelElement);
/** Applies the constraint checker to the given model element. */ /** Applies the constraint checker to the given model element. */
IConstraintViolation apply(C modelElement); IConstraintViolation<EObject> apply(EObject modelElement);
} }
...@@ -17,6 +17,8 @@ $Id$ ...@@ -17,6 +17,8 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.interfaces; package org.fortiss.tooling.kernel.interfaces;
import org.eclipse.emf.ecore.EObject;
/** /**
* This interface describes a constraint violation produced by some constraint * This interface describes a constraint violation produced by some constraint
* checker. A constraint violation has a severity of type {@link ESeverity}, an * checker. A constraint violation has a severity of type {@link ESeverity}, an
...@@ -28,7 +30,10 @@ package org.fortiss.tooling.kernel.interfaces; ...@@ -28,7 +30,10 @@ package org.fortiss.tooling.kernel.interfaces;
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0506883B3019B9D1DC5AC6C0AB2F35FB * @ConQAT.Rating YELLOW Hash: 0506883B3019B9D1DC5AC6C0AB2F35FB
*/ */
public interface IConstraintViolation { public interface IConstraintViolation<T extends EObject> {
/** Returns the source of the constraint violation. */
T getSource();
/** Returns the severity of the constraint violation. */ /** Returns the severity of the constraint violation. */
ESeverity getSeverity(); ESeverity getSeverity();
......
...@@ -17,9 +17,11 @@ $Id$ ...@@ -17,9 +17,11 @@ $Id$
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal; package org.fortiss.tooling.kernel.internal;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.interfaces.IConstraintChecker; import org.fortiss.tooling.kernel.interfaces.IConstraintChecker;
import org.fortiss.tooling.kernel.interfaces.IConstraintViolation; import org.fortiss.tooling.kernel.interfaces.IConstraintViolation;
import org.fortiss.tooling.kernel.services.IConstraintService; import org.fortiss.tooling.kernel.services.IConstraintService;
...@@ -32,21 +34,57 @@ import org.fortiss.tooling.kernel.services.IConstraintService; ...@@ -32,21 +34,57 @@ import org.fortiss.tooling.kernel.services.IConstraintService;
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating RED Hash: 9E0D8411A1525AA3989DED2C0DC7A033 * @ConQAT.Rating RED Hash: 9E0D8411A1525AA3989DED2C0DC7A033
*/ */
public class ConstraintService implements IConstraintService { public class ConstraintService extends
EObjectAwareServiceBase<IConstraintChecker<? extends EObject>>
implements IConstraintService {
/** The compositor extension point ID. */
private static final String EXTENSION_POINT_NAME = "org.fortiss.tooling.kernel.modelElementConstraintChecker";
/** The compositor configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "modelElementConstraintChecker";
/** The compositor class attribute name. */
private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "checker";
/** {@inheritDoc} */ /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override @Override
public List<IConstraintViolation> performAllConstraintChecks( public List<IConstraintViolation<? extends EObject>> performAllConstraintChecks(
EObject modelElement) { EObject modelElement) {
// TODO List<IConstraintViolation<? extends EObject>> result = new LinkedList<IConstraintViolation<? extends EObject>>();
return null; for (IConstraintChecker<? extends EObject> checker : getRegisteredHandlers(modelElement
.getClass())) {
if (checker.isApplicable(modelElement)) {
result.add(checker.apply(modelElement));
}
}
return result;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override @Override
public List<IConstraintChecker> getAllConstraintCheckers( public List<IConstraintChecker<? extends EObject>> getAllConstraintCheckers(
EObject modelElement) { EObject modelElement) {
// TODO return getRegisteredHandlers(modelElement.getClass());
return null; }
/** {@inheritDoc} */
@Override
protected String getExtensionPointName() {
return EXTENSION_POINT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getConfigurationElementName() {
return CONFIGURATION_ELEMENT_NAME;
}
/** {@inheritDoc} */
@Override
protected String getHandlerClassAttribute() {
return HANDLER_CLASS_ATTRIBUTE_NAME;
} }
} }
...@@ -42,11 +42,13 @@ public interface IConstraintService { ...@@ -42,11 +42,13 @@ public interface IConstraintService {
* Performs all constraint checks on the given model element and returns the * Performs all constraint checks on the given model element and returns the
* check results. * check results.
*/ */
List<IConstraintViolation> performAllConstraintChecks(EObject modelElement); <T extends EObject> List<IConstraintViolation<T>> performAllConstraintChecks(
T modelElement);
/** /**
* Returns the list of registered constraint checkers for the given model * Returns the list of registered constraint checkers for the given model
* element. * element.
*/ */
List<IConstraintChecker> getAllConstraintCheckers(EObject modelElement); <T extends EObject> List<IConstraintChecker<T>> getAllConstraintCheckers(
T modelElement);
} }
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