Java Code Examples for org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getInverseReferences()

The following examples show how to use org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getInverseReferences() . 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: PhysicalModelInitializer.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Remove the physical foreign key from the Physical Model and also remove pending references (ex in BusinessRelationship)
 *
 */
public void removePhysicalForeignKey(PhysicalModel physicalModel, PhysicalForeignKey physicalForeignKey) {
	physicalModel.getForeignKeys().remove(physicalForeignKey);

	// remove inverse references (if any)
	// ModelSingleton modelSingleton = ModelSingleton.getInstance();
	ECrossReferenceAdapter adapter = getCrossReferenceAdapter();
	Collection<Setting> settings = adapter.getInverseReferences(physicalForeignKey, true);
	for (Setting setting : settings) {
		EObject eobject = setting.getEObject();
		if (eobject instanceof BusinessRelationship) {
			BusinessRelationship businessRelationship = (BusinessRelationship) eobject;
			if (businessRelationship.getPhysicalForeignKey().equals(physicalForeignKey)) {
				// remove reference
				businessRelationship.setPhysicalForeignKey(null);
			}
		}
	}
}
 
Example 2
Source File: ECrossReferenceAdapterCrossReferenceProvider.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Collection<Setting> getInverseReferences(EObject self) {
    final Collection<Setting> res;

    final ECrossReferenceAdapter crossReferenceAdapter = getAdapter(self);
    if (crossReferenceAdapter != null) {
        res = crossReferenceAdapter.getInverseReferences(self);
    } else {
        throw new IllegalStateException("No ECrossReferenceAdapter found for :" + self);
    }

    return res;
}