Java Code Examples for org.eclipse.emf.ecore.EClass#getEAllReferences()

The following examples show how to use org.eclipse.emf.ecore.EClass#getEAllReferences() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageMetaData.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initOppositeInfo() {
	for (EClassifier eClassifier : ePackage.getEClassifiers()) {
		if (eClassifier instanceof EClass) {
			EClass eClass = (EClass)eClassifier;
			boolean hasOpposites = false;
			boolean hasManyOpposites = false;
			for (EReference eReference : eClass.getEAllReferences()) {
				if (eReference.getEOpposite() != null) {
					hasOpposites = true;
					if (eReference.isMany()) {
						hasManyOpposites = true;
					}
				}
			}
			oppositeInfos.put(eClass, new OppositeInfo(hasOpposites, hasManyOpposites));
		}
	}
}
 
Example 2
Source File: GenerateGeometryLibrary.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void process(EClass eClass, EReference eReferencedFrom) {
		if (definesNode.has(eClass.getName())) {
			return;
		}
//		if (eReferencedFrom != null) {
//			System.out.println(eReferencedFrom.getEContainingClass().getName() + "." + eReferencedFrom.getName() + " -> " + eClass.getName());
//		}
		ObjectNode defineNode = OBJECT_MAPPER.createObjectNode();
		definesNode.set(eClass.getName(), defineNode);
		
		// TODO no type node required, subclasses always used
		ObjectNode typeNode = OBJECT_MAPPER.createObjectNode();
		typeNode.put("name", eClass.getName());
		typeNode.put("includeAllSubTypes", true);
		defineNode.set("type", typeNode);
		
		ArrayNode fieldsNode = OBJECT_MAPPER.createArrayNode();
		defineNode.set("fields", fieldsNode);
		
		ArrayNode includesNode = OBJECT_MAPPER.createArrayNode();
		defineNode.set("includes", includesNode);
		for (EReference eReference : eClass.getEAllReferences()) {
			if (!packageMetaData.isInverse(eReference) || isException(eReference)) {
				EClass eType = (EClass) eReference.getEType();
				if (eType.getEPackage() == ePackage) {
					for (EClass eClass2 : packageMetaData.getAllSubClassesIncludingSelf(eType)) {
						if (eClass2.getEAnnotation("wrapped") == null) {
							process(eClass2);
							includesNode.add(eClass2.getName());
						}
					}
					fieldsNode.add(eReference.getName());
				}
			}
		}
	}
 
Example 3
Source File: PackageMetaData.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public Set<EReference> getAllInverseReferences(EClass eClass) {
	// TODO cache
	Set<EReference> result = new HashSet<>();
	for (EReference eReference : eClass.getEAllReferences()) {
		if (isInverse(eReference)) {
			result.add(eReference);
		}
	}
	return result;
}
 
Example 4
Source File: PackageMetaData.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public Set<EReference> getAllHasInverseReferences(EClass eClass) {
	// TODO cache
	Set<EReference> result = new HashSet<>();
	for (EReference eReference : eClass.getEAllReferences()) {
		if (hasInverse(eReference)) {
			result.add(eReference);
		}
	}
	return result;
}
 
Example 5
Source File: PackageMetaData.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean hasInverses(EClass eClass) {
	for (EReference eReference : eClass.getEAllReferences()) {
		if (hasInverse(eReference)) {
			return true;
		}
	}
	return false;
}
 
Example 6
Source File: StructureAnalyzer.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private int printClassifier(String name, EClassifier classifier, ArrayList<EClassifier> referrers, int indention) {
	out2.println(StringUtils.fill("", indention, "\t") + name + ": " + classifier.getName());
	if (count > limit) {
		return -1;
	}
	count++;
	if (classifier instanceof EClass) {
		EClass eClass = (EClass)classifier;
		int references = 0;
		for (EReference reference : eClass.getEAllReferences()) {
			String name2 = reference.getName();
			if (name2.equals("ProvidesBoundaries") || name2.equals("ContainedInStructure") || 
					name2.equals("FillsVoids") || name2.equals("IsDecomposedBy") || name2.equals("Decomposes") ||
					name2.equals("RelatedObjects") || name2.equals("IsDefinedBy") || name2.equals("ReferencedBy") ||
					name2.equals("HasAssociations") || name2.equals("HasAssignments") || name2.equals("ReferencedByPlacements") || 
					name2.equals("ConnectedTo") || name2.equals("HasCoverings") || name2.equals("HasProjections") || 
					name2.equals("HasStructuralMember") || name2.equals("ReferencedInStructures") || name2.equals("VoidsElements") ||
					name2.equals("ConnectedFrom")) {
			} else {
				boolean go = true;
				for (EClassifier referrer : referrers) {
					if (referrer == reference.getEType()) {
						go = false;
					}
				}
				if (go) {
					if (((EClass)reference.getEType()).getEStructuralFeature("wrappedValue") == null) {
						references++;
						ArrayList<EClassifier> newList = (ArrayList<EClassifier>)referrers.clone();
						newList.add(classifier);
						int newReferences = printClassifier(name2, reference.getEType(), newList, indention+1);
						if (newReferences != -1) {
							references += newReferences;
						} else {
							return -1;
						}
					}
				}
			}
		}
		return references;
	}
	return 0;
}