/**
   * 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;
  }
 public static boolean isSchemaForSchemaMissingForAnySchema(final IModelRoot root) {
   if (!(root instanceof IWsdlModelRoot)) {
     return false;
   }
   final IWsdlModelRoot wsdlModelRoot = (IWsdlModelRoot) root;
   final IDescription object = wsdlModelRoot.getDescription();
   final List<ISchema> schemas = object.getAllVisibleSchemas();
   for (final ISchema schema : schemas) {
     // do not reload
     if (EmfXsdUtils.isSchemaForSchemaMissing(schema)) {
       return true;
     }
   }
   return false;
 }
  @Override
  protected void validate() {
    final org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description = getDescription();

    final Collection<IDescription> visibleDescriptions = description.getReferencedServices();
    visibleDescriptions.add(description);
    final Set<ISchema> schemas = new HashSet<ISchema>();
    for (final IDescription currentDescription : visibleDescriptions) {
      for (final ISchema currentSchema : currentDescription.getAllVisibleSchemas()) {
        schemas.add(currentSchema);
      }
    }
    final List<IModelObject> validatedEntitites = new ArrayList<IModelObject>(schemas.size() + 1);
    validatedEntitites.addAll(visibleDescriptions);
    validatedEntitites.addAll(schemas);

    validate(validatedEntitites);
  }
  @Test
  public void testOperationFailureOfExecution() throws Exception {
    IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot(WSDL_FILE_PATH, WSDL_FILE);
    IDescription description = wsdlModelRoot.getDescription();
    IXSDModelRoot xsdModelRoot = getXSDModelRoot(XSD_FILE_PATH, XSD_FILE);
    IType type = xsdModelRoot.getSchema().getType(true, "Element1UN");

    IOperation firstOperation =
        description.getAllInterfaces().iterator().next().getAllOperations().iterator().next();
    assertEquals(
        Status.OK_STATUS,
        wsdlModelRoot
            .getEnv()
            .execute(new AddInParameterCommand(wsdlModelRoot, firstOperation, PARAMETER_NAME)));
    IParameter parameter = firstOperation.getInputParameter(PARAMETER_NAME).get(0);
    SetParameterTypeCommand setParameterTypeCommand = new SetParameterTypeCommand(parameter, type);
    IStatus status = wsdlModelRoot.getEnv().execute(setParameterTypeCommand);
    assertEquals(Status.ERROR, status.getSeverity());
  }
  @Override
  protected void addExtraPages(final IStorageEditorInput in) throws PartInitException {
    final IWsdlModelRoot wsdlModelRoot = (IWsdlModelRoot) commonModel;
    final org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description =
        wsdlModelRoot.getDescription();
    final List<ISchema> schemas = description.getContainedSchemas();

    // validation stuff
    validationService =
        new ValidationService(
            commonModel.getEnv().getEditingDomain().getResourceSet(), getModelRoot());
    this.modelAdapter = new ESMModelAdapter(wsdlModelRoot);
    validationService.addModelAdapter(modelAdapter);
    validationService.addModelAdapter(new EsmXsdModelAdapter());
    commonModel.getEnv().addDisposable(validationService);

    final DataTypesEditorPage dtPage;
    final ServiceIntefaceEditorPage sifPage;

    dtPage = new DataTypesEditorPage(this);
    sifPage = new ServiceIntefaceEditorPage(this, dtPage);
    sifPage.setModel(commonModel, isReadOnly, false);
    dtPage.setModel(commonModel, isReadOnly, false);

    addPage(0, sifPage, in);
    addPage(1, dtPage, in);
    // wait for the pages to be initialised and than get the DT
    // controller and give the SI page a reference of it
    sifPage.setDTController(dtPage.getDTController());

    validationService.addValidationListener(createValidationListener(dtPage, sifPage));

    final List<IModelObject> validatedEntitites = new ArrayList<IModelObject>(schemas.size() + 1);
    validatedEntitites.add(description);
    validatedEntitites.addAll(schemas);
  }