Search in sources :

Example 6 with DomainClass

use of org.obeonetwork.graal.DomainClass in project InformationSystem by ObeoNetwork.

the class DomainClassServicesTest method testAnnotationPresentMultipleTimes.

@Test
public void testAnnotationPresentMultipleTimes() {
    System system = loadRoot("AnnotationPresentMultipleTimes.graal", System.class);
    DomainClass domainClass = query(() -> {
        return (DomainClass) system.getOwnedNamespaces().get(0).getTypes().get(0);
    });
    assertEquals("physical size 1", getPhysicalSize(domainClass));
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Example 7 with DomainClass

use of org.obeonetwork.graal.DomainClass in project InformationSystem by ObeoNetwork.

the class DomainClassServicesTest method testAnnotationWithEmptyMetadataContainer.

@Test
public void testAnnotationWithEmptyMetadataContainer() {
    System system = loadRoot("AnnotationWithEmptyMetadataContainer.graal", System.class);
    DomainClass domainClass = query(() -> {
        return (DomainClass) system.getOwnedNamespaces().get(0).getTypes().get(0);
    });
    assertEquals("", getPhysicalSize(domainClass));
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Example 8 with DomainClass

use of org.obeonetwork.graal.DomainClass in project InformationSystem by ObeoNetwork.

the class DomainClassServicesTest method testAnnotationPresent.

@Test
public void testAnnotationPresent() {
    System system = loadRoot("AnnotationPresent.graal", System.class);
    DomainClass domainClass = query(() -> {
        return (DomainClass) system.getOwnedNamespaces().get(0).getTypes().get(0);
    });
    assertEquals("physical size", getPhysicalSize(domainClass));
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Example 9 with DomainClass

use of org.obeonetwork.graal.DomainClass in project InformationSystem by ObeoNetwork.

the class UseCaseServices method allDomainClasses.

/**
 * Collect all domain classes referenced by a use case
 * @param uc
 * @return
 */
public List<DomainClass> allDomainClasses(UseCase uc) {
    Set<DomainClass> classes = new HashSet<DomainClass>();
    // Add domain classes directly references
    classes.addAll(uc.getDomainClasses());
    // Search for domain classes in referenced namespaces
    for (Namespace ns : uc.getNamespaces()) {
        collectClasses(ns, classes);
    }
    // This reference exists for compatibility with old metamodel version (before DomainClass)
    for (StructuredType type : uc.getTypes()) {
        if (type instanceof DomainClass) {
            classes.add((DomainClass) type);
        }
    }
    // Convert set to list
    List<DomainClass> result = new ArrayList<>(classes);
    // and sort by fully qualified names
    Collections.sort(result, new Comparator<DomainClass>() {

        @Override
        public int compare(DomainClass arg0, DomainClass arg1) {
            // Use a primary collator to ignore accents and case
            Collator collator = Collator.getInstance();
            collator.setStrength(Collator.PRIMARY);
            return collator.compare(fullQualifiedName(arg0), fullQualifiedName(arg1));
        }
    });
    return result;
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) ArrayList(java.util.ArrayList) Namespace(org.obeonetwork.dsl.environment.Namespace) HashSet(java.util.HashSet) StructuredType(org.obeonetwork.dsl.environment.StructuredType) Collator(java.text.Collator)

Aggregations

DomainClass (org.obeonetwork.graal.DomainClass)9 Test (org.junit.Test)5 System (org.obeonetwork.graal.System)5 Collator (java.text.Collator)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 EObjectFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter)1 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 Namespace (org.obeonetwork.dsl.environment.Namespace)1 StructuredType (org.obeonetwork.dsl.environment.StructuredType)1 UseCaseServices (org.obeonetwork.dsl.graal.m2doc.services.UseCaseServices)1 DomainClassPropertiesEditionPart (org.obeonetwork.graal.parts.DomainClassPropertiesEditionPart)1 PersistencePropertiesEditionPart (org.obeonetwork.graal.parts.PersistencePropertiesEditionPart)1