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));
}
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);
}
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());
}
}
Aggregations