Search in sources :

Example 1 with XMLResourceImpl

use of org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl 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 2 with XMLResourceImpl

use of org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl in project xtext-core by eclipse.

the class DefaultResourceDescriptionTest method setUp.

@Before
public void setUp() throws Exception {
    resource = new XMLResourceImpl();
    resource.setURI(URI.createURI("foo:/test"));
    nameProvider = new IQualifiedNameProvider.AbstractImpl() {

        @Override
        public QualifiedName getFullyQualifiedName(EObject obj) {
            if (obj instanceof ENamedElement)
                return QualifiedName.create(((ENamedElement) obj).getName());
            return null;
        }
    };
    strategy = new DefaultResourceDescriptionStrategy();
    strategy.setQualifiedNameProvider(nameProvider);
    description = new DefaultResourceDescription(resource, strategy);
    EcoreFactory f = EcoreFactory.eINSTANCE;
    pack = f.createEPackage();
    pack.setName("MyPackage");
    eClass = f.createEClass();
    eClass.setName("MyEClass");
    dtype = f.createEDataType();
    dtype.setName("MyDatatype");
    pack.getEClassifiers().add(eClass);
    pack.getEClassifiers().add(dtype);
    resource.getContents().add(pack);
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) EObject(org.eclipse.emf.ecore.EObject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) ENamedElement(org.eclipse.emf.ecore.ENamedElement) EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) Before(org.junit.Before)

Example 3 with XMLResourceImpl

use of org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl in project tdq-studio-se by Talend.

the class ResourceUtils method setUUID.

public static void setUUID(EObject parent, EObject eobject) {
    if (eobject.eResource() == null) {
        XMLResource xmlResource = parent != null && parent.eResource() != null ? (XMLResource) parent.eResource() : new XMLResourceImpl();
        xmlResource.getContents().add(eobject);
    }
    Resource res = eobject.eResource();
    if (res instanceof XMLResource) {
        ((XMLResource) res).setID(eobject, EcoreUtil.generateUUID());
    }
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Aggregations

XMLResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 ENamedElement (org.eclipse.emf.ecore.ENamedElement)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreFactory (org.eclipse.emf.ecore.EcoreFactory)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Category (org.obeonetwork.dsl.requirement.Category)1 Repository (org.obeonetwork.dsl.requirement.Repository)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1 RequirementServices (org.obeonetwork.requirement.m2doc.services.RequirementServices)1