Search in sources :

Example 31 with EReference

use of org.eclipse.emf.ecore.EReference in project BIMserver by opensourceBIM.

the class Step0029 method migrate.

@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
    EClass oAuthAuthorizationCodeClass = schema.getEClass("store", "OAuthAuthorizationCode");
    EClass userClass = schema.getEClass("store", "User");
    EReference codeToUser = schema.createEReference(oAuthAuthorizationCodeClass, "user", userClass);
    EReference codes = (EReference) userClass.getEStructuralFeature("oAuthIssuedAuthorizationCodes");
    codeToUser.setEOpposite(codes);
    codes.setEOpposite(codeToUser);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EReference(org.eclipse.emf.ecore.EReference)

Example 32 with EReference

use of org.eclipse.emf.ecore.EReference in project BIMserver by opensourceBIM.

the class Step0030 method migrate.

@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
    EClass geometryInfo = schema.getEClass("geometry", "GeometryInfo");
    EClass vector3f = schema.getEClass("geometry", "Vector3f");
    EReference geometryInfoMinBounds = schema.createEReference(geometryInfo, "minBoundsUntranslated", vector3f, Multiplicity.SINGLE);
    geometryInfoMinBounds.getEAnnotations().add(createDbEmbedReferenceAnnotation());
    geometryInfoMinBounds.getEAnnotations().add(createEmbedsReferenceAnnotation());
    geometryInfoMinBounds.getEAnnotations().add(createHiddenAnnotation());
    EReference geometryInfoMaxBounds = schema.createEReference(geometryInfo, "maxBoundsUntranslated", vector3f, Multiplicity.SINGLE);
    geometryInfoMaxBounds.getEAnnotations().add(createDbEmbedReferenceAnnotation());
    geometryInfoMaxBounds.getEAnnotations().add(createEmbedsReferenceAnnotation());
    geometryInfoMaxBounds.getEAnnotations().add(createHiddenAnnotation());
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EReference(org.eclipse.emf.ecore.EReference)

Example 33 with EReference

use of org.eclipse.emf.ecore.EReference in project BIMserver by opensourceBIM.

the class DatabaseReadingStackFrame method processPossibleInclude.

protected void processPossibleInclude(HashMapVirtualObject object, CanInclude previousInclude, Include include) throws QueryException, BimserverDatabaseException {
    if (include.hasTypes()) {
        for (TypeDef filterClass : include.getTypes()) {
            if (!filterClass.geteClass().isSuperTypeOf(object.eClass())) {
                // TODO too many times queries are spending time here
                return;
            }
        }
    }
    if (include.hasDirectFields()) {
        for (EReference eReference : include.getFieldsDirect()) {
            Object ref = object.get(eReference.getName());
            if (ref != null) {
                if (ref instanceof List) {
                    for (Long r : (List<Long>) ref) {
                        HashMapVirtualObject byOid = getByOid(r, true);
                        object.addDirectListReference(eReference, byOid);
                        processPossibleIncludes(byOid, byOid.eClass(), include);
                    }
                } else {
                    HashMapVirtualObject byOid = getByOid((Long) ref, true);
                    object.setDirectReference(eReference, byOid);
                    processPossibleIncludes(byOid, byOid.eClass(), include);
                }
            }
        }
    }
    if (include.hasFields()) {
        for (EStructuralFeature eStructuralFeature : include.getFields()) {
            // TODO do we really have to iterate through the EAtrributes as well? You should not use fields for attributes anyways, so there should be none ...
            object.addUseForSerialization(eStructuralFeature);
        }
    }
    getQueryObjectProvider().push(new QueryIncludeStackFrame(getQueryObjectProvider(), getReusable(), previousInclude, include, object, queryPart));
}
Also used : TypeDef(org.bimserver.database.queries.om.Include.TypeDef) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) List(java.util.List) EReference(org.eclipse.emf.ecore.EReference)

Example 34 with EReference

use of org.eclipse.emf.ecore.EReference in project xtext-eclipse by eclipse.

the class AbstractPortableURIsTest method doTestResource.

protected void doTestResource(String platformPath, String... packageNames) {
    Resource resource = resourceSet.getResource(URI.createPlatformPluginURI(platformPath, false), true);
    assertNotNull(resource);
    assertEquals(1, resource.getContents().size());
    EObject obj = resource.getContents().get(0);
    if (obj instanceof EPackage) {
        assertEquals(packageNames[0], ((EPackage) obj).getName());
    } else if (obj instanceof GenModel) {
        GenModel model = (GenModel) obj;
        List<GenPackage> packages = Lists.newArrayList(model.getGenPackages());
        assertEquals(packageNames.length, packages.size());
        ListExtensions.sortInplaceBy(packages, new Functions.Function1<GenPackage, String>() {

            @Override
            public String apply(GenPackage p) {
                return p.getEcorePackage().getName();
            }
        });
        List<String> packageNamesList = Arrays.asList(packageNames);
        Collections.sort(packageNamesList);
        for (int i = 0; i < packageNamesList.size(); i++) {
            assertEquals(packageNamesList.get(i), packages.get(i).getEcorePackage().getName());
        }
        IStatus status = model.validate();
        assertTrue(printLeafs(status), status.isOK());
        EObject orig = EcoreUtil.copy(obj);
        ((GenModel) obj).reconcile();
        if (!EcoreUtil.equals(orig, obj)) {
            Predicate<EStructuralFeature> ignoreContainer = new Predicate<EStructuralFeature>() {

                @Override
                public boolean apply(EStructuralFeature f) {
                    if (f instanceof EReference) {
                        EReference casted = (EReference) f;
                        return !casted.isContainment();
                    }
                    return false;
                }
            };
            String origAsString = EmfFormatter.objToStr(orig, ignoreContainer);
            String newAsString = EmfFormatter.objToStr(obj, ignoreContainer);
            throw new ComparisonFailure("Reconcile changed model", origAsString, newAsString);
        }
    } else {
        fail("Unexpected root element type: " + obj.eClass().getName());
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) GenPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage) EPackage(org.eclipse.emf.ecore.EPackage) Predicate(com.google.common.base.Predicate) ComparisonFailure(org.junit.ComparisonFailure) EObject(org.eclipse.emf.ecore.EObject) GenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel) List(java.util.List) EReference(org.eclipse.emf.ecore.EReference)

Example 35 with EReference

use of org.eclipse.emf.ecore.EReference in project xtext-eclipse by eclipse.

the class XtextProposalProvider method completeAction_Feature.

@Override
public void completeAction_Feature(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    Action action = EcoreUtil2.getContainerOfType(model, Action.class);
    if (action != null && action.getType() != null) {
        EClassifier classifier = action.getType().getClassifier();
        if (classifier instanceof EClass) {
            List<EReference> containments = ((EClass) classifier).getEAllContainments();
            Function<IEObjectDescription, ICompletionProposal> factory = getProposalFactory(grammarAccess.getValidIDRule().getName(), context);
            completeStructuralFeatures(context, factory, acceptor, containments);
        }
    }
    super.completeAction_Feature(model, assignment, context, acceptor);
}
Also used : Action(org.eclipse.xtext.Action) EClass(org.eclipse.emf.ecore.EClass) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) EClassifier(org.eclipse.emf.ecore.EClassifier) EReference(org.eclipse.emf.ecore.EReference) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

EReference (org.eclipse.emf.ecore.EReference)229 EObject (org.eclipse.emf.ecore.EObject)118 EClass (org.eclipse.emf.ecore.EClass)58 List (java.util.List)52 ArrayList (java.util.ArrayList)48 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)37 Test (org.junit.Test)31 EAttribute (org.eclipse.emf.ecore.EAttribute)29 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)28 EClassifier (org.eclipse.emf.ecore.EClassifier)21 Resource (org.eclipse.emf.ecore.resource.Resource)21 IdEObject (org.bimserver.emf.IdEObject)18 EList (org.eclipse.emf.common.util.EList)17 IScope (org.eclipse.xtext.scoping.IScope)15 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)14 InternalEObject (org.eclipse.emf.ecore.InternalEObject)14 URI (org.eclipse.emf.common.util.URI)13 EPackage (org.eclipse.emf.ecore.EPackage)12 AbstractEList (org.eclipse.emf.common.util.AbstractEList)10 CrossReference (org.eclipse.xtext.CrossReference)10