Search in sources :

Example 1 with ReferenceContext

use of org.osate.ge.businessobjecthandling.ReferenceContext in project osate2 by osate.

the class DefaultReferenceService method getRelativeReference.

@Override
public RelativeBusinessObjectReference getRelativeReference(final Object bo) {
    Objects.requireNonNull(bo, "bo must not be null");
    final BusinessObjectHandler boh = bohProvider.getApplicableBusinessObjectHandler(bo);
    if (boh == null) {
        return null;
    }
    try {
        return Objects.requireNonNull(boh.getRelativeReference(new ReferenceContext(bo, this)), () -> "Business object handlers must not return a null relative reference. Null reference returned by '" + boh.getClass().getCanonicalName() + "'");
    } catch (RuntimeException ex) {
        StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error retrieving relative reference for " + bo.getClass().getCanonicalName() + ".", ex), StatusManager.LOG | StatusManager.SHOW);
        return null;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ReferenceContext(org.osate.ge.businessobjecthandling.ReferenceContext) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler)

Example 2 with ReferenceContext

use of org.osate.ge.businessobjecthandling.ReferenceContext in project osate2 by osate.

the class DefaultReferenceService method getCanonicalReference.

@Override
public CanonicalBusinessObjectReference getCanonicalReference(final Object bo) {
    Objects.requireNonNull(bo, "bo must not be null");
    final BusinessObjectHandler boh = bohProvider.getApplicableBusinessObjectHandler(bo);
    if (boh == null) {
        return null;
    }
    try {
        return boh.getCanonicalReference(new ReferenceContext(bo, this));
    } catch (RuntimeException ex) {
        StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error retrieving canonical reference for " + bo.getClass().getCanonicalName() + ".", ex), StatusManager.LOG | StatusManager.SHOW);
        return null;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ReferenceContext(org.osate.ge.businessobjecthandling.ReferenceContext) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 BusinessObjectHandler (org.osate.ge.businessobjecthandling.BusinessObjectHandler)2 ReferenceContext (org.osate.ge.businessobjecthandling.ReferenceContext)2