use of org.obeonetwork.dsl.requirement.Repository in project InformationSystem by ObeoNetwork.
the class BusinessProjectImporter method cacheRequirementReferences.
private Map<String, List<EObject>> cacheRequirementReferences() {
Map<String, List<EObject>> requirementReferencedObjectsCache = new HashMap<String, List<EObject>>();
// Collect target project semantic roots impacted by the import
Collection<EObject> impactedTargetSemanticRoots = getAllImpactedTargetSemanticRoots();
// Collect target project requirement repositories impacted by the import
Collection<Repository> impactedRepositories = EcoreUtil.getObjectsByType(impactedTargetSemanticRoots, RequirementPackage.Literals.REPOSITORY);
// Cache the reference for each referenced objects in the impacted requirements
for (Repository impactedRepository : impactedRepositories) {
List<Requirement> localRequirements = ImporterUtil.getAllContentsOfType(impactedRepository, Requirement.class);
for (Requirement localRequirement : localRequirements) {
for (EObject referencedObject : localRequirement.getReferencedObject()) {
if (!impactedTargetSemanticRoots.contains(EcoreUtil.getRootContainer(referencedObject))) {
lazyPut(requirementReferencedObjectsCache, localRequirement.getId(), referencedObject);
}
}
}
}
return requirementReferencedObjectsCache;
}
use of org.obeonetwork.dsl.requirement.Repository in project InformationSystem by ObeoNetwork.
the class RequirementModelWizard method createInitialModel.
/**
* Create a new model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected EObject createInitialModel(String repositoryName) {
Repository rootObject = requirementFactory.createRepository();
rootObject.setName(repositoryName);
return rootObject;
}
use of org.obeonetwork.dsl.requirement.Repository in project InformationSystem by ObeoNetwork.
the class ValidateRequirementsHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event);
if (editor instanceof RequirementEditor) {
shell = HandlerUtil.getActiveShell(event);
RequirementEditor ed = (RequirementEditor) editor;
resourceSet = ed.getEditingDomain().getResourceSet();
} else if (editorInput instanceof SessionEditorInput) {
shell = HandlerUtil.getActiveShell(event);
resourceSet = ((SessionEditorInput) editorInput).getSession().getTransactionalEditingDomain().getResourceSet();
} else {
return null;
}
Collection<EObject> objects = new ArrayList<EObject>();
for (Resource resource : resourceSet.getResources()) {
for (EObject eObject : resource.getContents()) {
if (eObject instanceof Repository || eObject instanceof Category || eObject instanceof Requirement) {
objects.add(eObject);
}
}
}
executeValidation(objects);
return null;
}
use of org.obeonetwork.dsl.requirement.Repository in project InformationSystem by ObeoNetwork.
the class RequiremelntServicesTest method testService.
@Test
public void testService() {
Repository repo = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
Category cat = (Category) EcoreUtil.create(RequirementPackage.Literals.CATEGORY);
repo.getMainCategories().add(cat);
Requirement req1 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
Requirement req2 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
Requirement req3 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
cat.getRequirements().add(req1);
cat.getRequirements().add(req2);
cat.getRequirements().add(req3);
Repository repo2 = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
ResourceSet rs = new ResourceSetImpl();
Resource resource = new XMLResourceImpl();
rs.getResources().add(resource);
resource.getContents().add(repo);
resource.getContents().add(repo2);
req1.getReferencedObject().add(repo2);
req2.getReferencedObject().add(repo2);
req3.getReferencedObject().add(repo2);
List<Requirement> reqs = new RequirementServices().relatedRequirements(repo2);
assertTrue(reqs.contains(req1));
assertTrue(reqs.contains(req2));
assertTrue(reqs.contains(req3));
}
use of org.obeonetwork.dsl.requirement.Repository in project InformationSystem by ObeoNetwork.
the class LinkRequirementsDialog method determineObjectsToCheck.
/**
* Initially, we want to check:
* <ul>
* <li>the {@link Requirement Requirements} linked to the selected model
* element.</li>
* <li>the {@link Category Categories and sub-Categories} containing
* selected {@link Requirement Requirements}.</li>
* <li>the {@link Repository Repositories} containing selected
* {@link Requirement Requirements}.</li>
* <li>the {@link Resource Resources} containing selected {@link Requirement
* Requirements}.</li>
* </ul>
*
* @param linkedRequirements
* the {@link Requirement Requirements} linked to the selected
* model element.
* @return the objects in the {@link CheckboxTreeViewer} which must be
* checked initially.
*/
private static Set<Object> determineObjectsToCheck(Set<Requirement> linkedRequirements) {
Set<Object> objectsToCheck = new HashSet<Object>();
for (Requirement linkedRequirement : linkedRequirements) {
// The linked Requirement.
objectsToCheck.add(linkedRequirement);
// The Categories and all its super-Categories.
Category category = linkedRequirement.getCategory();
objectsToCheck.add(category);
while (category.getParentCategory() != null) {
category = category.getParentCategory();
objectsToCheck.add(category);
}
// The Repository
Repository repository = category.getRepository();
objectsToCheck.add(repository);
// The Resource
Resource resource = repository.eResource();
objectsToCheck.add(resource);
}
return objectsToCheck;
}
Aggregations