Commit 17ac8554 authored by Martti Käärik's avatar Martti Käärik
Browse files

OCL constraint files for TDL metamodels and validator registrations (disabled)

parent 68abae27
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.emf.ecore;visibility:=reexport,
 org.eclipse.emf.ecore.xmi;visibility:=reexport,
 org.eclipse.ocl.pivot;visibility:=reexport,
 org.eclipse.ocl.xtext.essentialocl
 org.eclipse.ocl.xtext.essentialocl,
 org.eclipse.ocl.xtext.completeocl
Eclipse-LazyStart: true
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.etsi.mts.tdl.Activator
+29 −0
Original line number Diff line number Diff line
import 'http://www.etsi.org/spec/TDL/1.4.1'
import 'http://www.etsi.org/spec/TDL/1.3.1/configurations'

package extendedconfigurations

context ComponentMerge
  -- No self-merging
  inv NoSelfMerge ('A \'ComponentInstance\' shall not be merged with itself, i.e. the source and target \'ComponentInstance\'s specified by means of the \'ComponentReference\'s shall be different. ' + self.toString()):
        not (self.component.component = self.target.component and
               self.component.configuration = self.target.configuration)
  

  -- Conforming 'ComponentType's
  inv ComponentMergeType ('The \'ComponentInstance\' specified by means of the target \'ComponentReference\'s shall have a \'ComponentType\' which conforms to the \'ComponentType\' of the source \'ComponentReference\'. ' + self.toString()):
        self.target.component.type.conformsTo(self.component.component.type)
  



context ComponentAlias
  -- Mandatory name
  inv AliasMandatoryName ('The \'name\' property of the \'ComponentAlias\' shall be set and it shall not be an empty String.' + self.toString()):
        not self.name.oclIsUndefined() and self.name.size() > 0
  




endpackage
+1152 −0

File added.

Preview size limit exceeded, changes collapsed.

+134 −0
Original line number Diff line number Diff line
import 'http://www.etsi.org/spec/TDL/1.4.1'
import 'http://www.etsi.org/spec/TDL/1.3.1/structured'

package structuredobjectives

context PICSReference
  -- Combining Multiple 'PICSReference's 
  inv MultiplePICS ('A \'Comment\' with body containing an \'and\' or \'or\' shall be attached to the \'PICSReference\' as a Boolean operand if there are two or more \'PICSReference\'s and it is not the first \'PICSReference\'.' + self.toString()):
    self.getTestObjective().picsReference->size() < 2 
      or self.getTestObjective().picsReference->forAll(p | 
        self.getTestObjective().picsReference->at(0) = p
        or (not p.comment->isEmpty()
            and (p.comment->first()._'body' = 'and'
                or p.comment->first()._'body' = 'or')))
  



context RepeatedEventSequence
  -- Either 'repetitions', or 'interval' or neither shall be specified
  inv RepetitionOrInterval ('At most one of the optional properties \'repetitions\' or \'interval\' shall be defined.' + self.toString()):
        self.repetitions.oclIsUndefined() or self.interval.oclIsUndefined()
  

  -- The 'repetitions' 'Value' shall be countable and positive
  inv RepetitionCount ('The expression assigned to the \'repetitions\' property shall evaluate to a positive and countable \'Value\'.' + self.toString()):
        true --This constraint cannot be expressed in OCL
  

  -- The 'interval' 'Value' shall be countable and positive
  inv RepetitionInterval ('The expression assigned to the \'repetitions\' property shall evaluate to a positive and countable \'Value\'' + self.toString()):
        true --This constraint cannot be expressed in OCL
  



--context EventOccurrence
--  -- Combining Multiple 'EventOccurrence's
--  inv MultipleEventOccurrences ('A \'Comment\' with body containing an \'and\' or \'or\' shall be attached to the \'EventOccurrence\' as an operand if there are two or more \'EventOccurrence\'s and it is not the first \'EventOccurrence\'.' + self.toString()):
--    self.container().oclIsTypeOf(EventSpecificationTemplate)
--      or self.container().events->size() < 2 
--      or self.container().events->forAll(o | 
--      self.container().events->at(0) = o
--      or (not o.comment->isEmpty()
--      and (o.comment->first()._'body' = 'and'
--      or o.comment->first()._'body' = 'or')))
  



context EntityReference
  -- An 'Entity' or a 'ComponentInstance' shall be referenced.
  inv EntityOrComponentInstance ('There shall be a reference to an \'Entity\' or a \'ComponentInstance\' but not both.' + self.toString()):
    (not self.entity.oclIsUndefined() and self.component.oclIsUndefined())
      or (self.entity.oclIsUndefined() and not self.component.oclIsUndefined())
  



context Content
  -- No nested 'Content's if 'Value' is provided 
  inv ContentOrValue ('Either nested \'Content\'s or \'Value\' may be specified within \'Content\', but not both.' + self.toString()):
        self.content->isEmpty() or self.value.oclIsUndefined()
  



context LiteralValueReference
  -- Referenced 'LiteralValue' visibility
  inv VisibleValue ('Only \'LiteralValue\'s defined within previous \'EventOccurrence\'s of the containing \'StructuredTestObjective\' may be referenced.' + self.toString()):
    self.getTestObjective().contains(self.content) 
      and self.getTestObjective().indexOf(self.content) < self.getTestObjective().indexOf(self)
  



context ContentReference
  -- Referenced 'Content' visibility
  inv VisibleContent ('Only \'Content\' defined within previous \'EventOccurrence\'s of the containing \'StructuredTestObjective\' may be referenced.' + self.toString()):
    self.getTestObjective().contains(self.content) 
      and self.getTestObjective().indexOf(self.content) < self.getTestObjective().indexOf(self)
  



context DataReference
  -- 'DataUse' restrictions within 'DataReference'
  inv DataReferenceContents ('Only \'StaticDataUse\' may be used directly or indirectly in \'ParameterBinding\'s of the \'StaticDataUse\' within a \'DataReference\'.' + self.toString()):
    self.content.oclIsTypeOf(StaticDataUse)
          and self.content.argument->forAll(a | a.dataUse.oclIsKindOf(StaticDataUse))
          and self.content.argument->closure(a | 
          a.dataUse.argument)->forAll(a|a.dataUse.oclIsKindOf(StaticDataUse))
  

  -- No 'reduction' within 'DataReference'
  inv DataReferenceReduction ('The \'reduction\' property of \'StaticDataUse\' inherited from \'DataUse\' shall not be used within a \'DataReference\'.' + self.toString()):
    self.content.reduction->isEmpty()
  



context EventTemplateOccurrence
  -- 'EntityReference' of referenced 'EventSpecificationTemplate'
  inv EntityTemplateOccurrenceConsistency ('If \'EntityBinding\'s are provided, the \'Entity\'s or \'ComponentInstance\'s referenced in the \'templateEntity\' properties shall also be referenced by one of the \'EntityReferences\' in the \'EventOccurrenceSpecification\' of the \'EventSpecificationTemplate\' referenced in the \'EventTemplateOccurrence\'.' + self.toString()):
        self.entityBinding->forAll(b | 
              (not b.templateEntity.entity.oclIsUndefined() 
           and (b.templateEntity.entity = 
                    self.eventTemplate.eventSpecification.entityReference.entity))
           or (not b.templateEntity.component.oclIsUndefined() 
           and (b.templateEntity.component = 
                    self.eventTemplate.eventSpecification.entityReference.component)
           or self.eventTemplate.eventSpecification.oppositeEntityReference->exists(e | 
                  (not b.templateEntity.entity.oclIsUndefined() 
               and (e.entity = b.templateEntity.entity))
               or (not b.templateEntity.component.oclIsUndefined() 
               and (e.component = b.templateEntity.component)))))
  



context VariantBinding
  -- Referenced 'Value' of 'VariantBinding'
  inv VariantBindingValues ('If the \'value\' property references a \'LiteralValue\' or \'Content\' element, the referenced element shall be contained in the \'StructuredTestObjective\' containing the \'VariantBinding\'.' + self.toString()):
        self.value.oclIsTypeOf(LiteralValueReference) implies
          self.value.oclAsType(LiteralValueReference).content.getTestObjective() = self.getTestObjective()
          and 
          self.value.oclIsKindOf(ContentReference) implies
          self.value.oclAsType(ContentReference).content.getTestObjective() = self.getTestObjective()
  




endpackage
+49 −0
Original line number Diff line number Diff line
package org.etsi.mts.tdl;

import java.net.URISyntaxException;
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.ocl.xtext.completeocl.validation.CompleteOCLEObjectValidator;
import org.etsi.mts.tdl.extendedconfigurations.ExtendedConfigurationsPackage;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

	@Override
	public void start(BundleContext context) throws Exception {

		// TODO disabled for now
//		registerValidator("model/tdl-structured-constraints.ocl", StructuredObjectivesPackage.eINSTANCE, context);
//		registerValidator("model/tdl-configurations-constraints.ocl", ExtendedConfigurationsPackage.eINSTANCE, context);
//		registerValidator("model/tdl-constraints.ocl", tdlPackage.eINSTANCE, context);

	}

	void registerValidator(String path, EPackage ePakcage, BundleContext context) {

		Path oclPath = new Path(path);
		URL oclURL = FileLocator.find(context.getBundle(), oclPath);

		URI oclURI;
		try {
			oclURI = URI.createURI(oclURL.toURI().toString());
			CompleteOCLEObjectValidator validator = new CompleteOCLEObjectValidator(ePakcage, oclURI);
			EValidator.Registry.INSTANCE.put(tdlPackage.eINSTANCE, validator);
		} catch (URISyntaxException e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		EValidator.Registry.INSTANCE.remove(tdlPackage.eINSTANCE);
	}

}