/** * Checks modelObject.getModelRoot() referred definitions, do match of modelObject's Definition * * @param modelObject which is supposed to be from referred definition. * @return referred Description, or null */ public static IDescription getReferredDescription(IModelObject modelObject) { if (modelObject instanceof IFault) { final Collection<IParameter> parameters = ((IFault) modelObject).getParameters(); modelObject = parameters.isEmpty() ? null : parameters.iterator().next(); } if (modelObject == null || !(modelObject.getModelRoot() instanceof IWsdlModelRoot)) { return null; } final IWsdlModelRoot wsdlModelRoot = (IWsdlModelRoot) modelObject.getModelRoot(); final IDescription description = wsdlModelRoot.getDescription(); // get referred Definition EObject referredDefinition = modelObject.getComponent(); while (referredDefinition != null && !(referredDefinition instanceof Definition)) { referredDefinition = referredDefinition.eContainer(); } if (referredDefinition != null) { for (final IDescription referredDescription : description.getReferencedServices()) { if (referredDefinition.equals(referredDescription.getComponent())) { return referredDescription; } } } return null; }
/** * Checks modelObject.getModelRoot() referred schemas, do match modelObject's XSDSchema * * @param modelObject which is supposed to be from referred schema. * @return referred ISchema, or null */ public static ISchema getReferredSchema(final IModelObject modelObject) { if (modelObject == null || !(modelObject.getModelRoot() instanceof IXSDModelRoot)) { return null; } final IXSDModelRoot xsdModelRoot = (IXSDModelRoot) modelObject.getModelRoot(); final ISchema schema = xsdModelRoot.getSchema(); // get referred XSDSchema EObject referredXSDSchema = modelObject.getComponent(); while (referredXSDSchema != null && !(referredXSDSchema instanceof XSDSchema)) { referredXSDSchema = referredXSDSchema.eContainer(); } if (referredXSDSchema != null) { for (final ISchema referredSchema : schema.getAllReferredSchemas()) { if (referredXSDSchema.equals(referredSchema.getComponent())) { return referredSchema; } } } return null; }