Search in sources :

Example 1 with Requirement

use of org.obeonetwork.dsl.requirement.Requirement 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;
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 2 with Requirement

use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.

the class RequirementItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public String getText(Object object) {
    Requirement req = (Requirement) object;
    String id = req.getId();
    String name = req.getName();
    String label = null;
    if (!isEmptyString(id) && !isEmptyString(name)) {
        label = id + " - " + name;
    } else if (isEmptyString(id) && !isEmptyString(name)) {
        label = name;
    } else if (!isEmptyString(id) && isEmptyString(name)) {
        label = id;
    }
    return label == null || label.length() == 0 ? getString("_UI_Requirement_type") + " undefined" : label;
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement)

Example 3 with Requirement

use of org.obeonetwork.dsl.requirement.Requirement 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;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementEditor(org.obeonetwork.dsl.requirement.presentation.RequirementEditor) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Example 4 with Requirement

use of org.obeonetwork.dsl.requirement.Requirement 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));
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementServices(org.obeonetwork.requirement.m2doc.services.RequirementServices) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Test(org.junit.Test)

Example 5 with Requirement

use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.

the class LinkRequirementsCheckStateListener method checkStateChanged.

/**
 * {@inheritDoc}
 * <ul>
 * <li>When a {@link Requirement} is:
 * <ul>
 * <li>Checked:
 * <ul>
 * <li>Check and gray all its containers in the tree.</li>
 * </ul>
 * </li>
 * <li>Unchecked:
 * <ul>
 * <li>Uncheck and ungray all its containers in the tree which have no more
 * children which are checked in the tree.</li>
 * </ul>
 * </li>
 * </ul>
 * </li>
 * <li>When a {@link Category}, {@link Repository} or {@link Resource} is:
 * <ul>
 * <li>Checked:
 * <ul>
 * <li>Check all its children in the tree.</li>
 * <li>Gray all its children which are also containers in the tree.</li>
 * <li>Check all its parents in the tree.</li>
 * </ul>
 * </li>
 * <li>Unchecked:
 * <ul>
 * <li>Uncheck all its children in the tree.</li>
 * <li>Ungray all its childre which are also containers in the tree.</li>
 * <li>Uncheck and ungray all its containers in the tree which have no more
 * children which are checked in the tree.</li>
 * </ul>
 * </li>
 * </ul>
 * </li>
 * </ul>
 */
public void checkStateChanged(CheckStateChangedEvent event) {
    CheckboxTreeViewer checkboxTreeViewer = (CheckboxTreeViewer) event.getSource();
    Object changedElement = event.getElement();
    boolean newCheckedState = event.getChecked();
    if (changedElement instanceof Requirement) {
        updateViewerForLeafChange(checkboxTreeViewer, (Requirement) changedElement, newCheckedState);
    } else if (isOfContainerType(changedElement)) {
        updateViewerForContainerChange(checkboxTreeViewer, changedElement, newCheckedState);
    }
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Requirement(org.obeonetwork.dsl.requirement.Requirement)

Aggregations

Requirement (org.obeonetwork.dsl.requirement.Requirement)20 EObject (org.eclipse.emf.ecore.EObject)11 ArrayList (java.util.ArrayList)7 Category (org.obeonetwork.dsl.requirement.Category)6 Resource (org.eclipse.emf.ecore.resource.Resource)5 Repository (org.obeonetwork.dsl.requirement.Repository)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)2 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)2 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 IStatus (org.eclipse.core.runtime.IStatus)1