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