Esempio n. 1
0
  protected void fillRequirements(RequirementSource requirementSource) throws Exception {
    requirementSource.clearContent();
    Collection<MappingElement> mapping = requirementSource.getMappings();
    ResourceSet resourceSet = new ResourceSetImpl();

    String repositoryUri = requirementSource.getRepositoryUri();

    Resource resource =
        resourceSet.getResource(URI.createPlatformResourceURI(repositoryUri, true), true);
    OCLEvaluator evaluator =
        ZigguratOCLPlugin.compileOCL(
            resourceSet, URI.createPlatformResourceURI(bean.getOclUri(), true));

    TreeIterator<EObject> contents = resource.getAllContents();
    Collection<IRequirementType> requirementTypes = bean.getDataPackage().getRequirementTypes();
    while (contents.hasNext()) {
      EObject eObject = contents.next();
      for (IRequirementType reqType : requirementTypes) {
        if (OCLUtilities.isDataType(evaluator, eObject, reqType)) {
          AbstractElement requirement = createRequirement(evaluator, mapping, eObject, reqType);
          dataManager.addElementsToSource(requirementSource, requirement);
        }
      }
    }
  }
Esempio n. 2
0
 protected AbstractElement createRequirement(
     OCLEvaluator evaluator,
     Collection<MappingElement> mappings,
     EObject eObject,
     IRequirementType reqType)
     throws Exception {
   Requirement requirement = reqType.createInstance();
   for (IAttribute attribute : Iterables.filter(reqType.getAttributes(), IAttribute.class)) {
     Object value = OCLUtilities.getAttributeValue(evaluator, eObject, attribute);
     if (value != null) {
       dataManager.addAttribute(requirement, attribute, value);
     }
   }
   return requirement;
 }