Package org.openiaml.model.inference

Examples of org.openiaml.model.inference.InferenceException


    try {
      monitor.beginTask("Refreshing " + getTitle() + " mappings", 100);
     
      EObject obj = part.resolveSemanticElement();
      if (!getExpectedEObjectClass().isAssignableFrom(obj.getClass())) {
        throw new InferenceException("Resolved EObject from EditPart was not of expected type " + getExpectedEObjectClass().getSimpleName() + ": was " + obj.getClass().getSimpleName());
      }
     
      // select the actual target
      final EObject target = selectRootElement(obj);
     
View Full Code Here


        try {
          super.create(model, logRuleSource, monitor, new InferenceQueueLog());
          // reload
          model = reloader.reload();
        } catch (NumberFormatException e1) {
          throw new InferenceException(e1);
        } catch (IOException e1) {
          throw new InferenceException(e1);
        } catch (ModelLoadException e1) {
          throw new InferenceException(e1);
        }
       
        int MAX_TIMES = 10;
        List<Long> timedList = new ArrayList<Long>();
        // now execute it 5 times, to get the times
        for (int iteration = 0; iteration < MAX_TIMES; iteration++) {
          System.out.println("iteration " + (iteration + 1) + "...");
          long startTime = System.currentTimeMillis();
          super.create(model, logRuleSource, monitor);
          long diff = System.currentTimeMillis() - startTime;
          timedList.add(diff);
          // reload
          try {
            model = reloader.reload();
          } catch (ModelLoadException e) {
            throw new InferenceException(e);
          }
        }
        long diff = timedList.get(0);
       
        // this execution is to get the actual final result
        super.create(model, logRuleSource, monitor);

        // investigate final model properties
        List<Object> finalProperties = getModelPropertiesInvestigator(false).investigate(model);
        List<Object> finalPropertiesNoGen = getModelPropertiesInvestigator(true).investigate(model);
        List<Object> finalDiff = getIncreaseAbsolute(finalPropertiesNoGen, finalProperties);
        List<Object> finalDiffPct = getIncreasePercent(finalPropertiesNoGen, finalProperties);

        // how many are in the final model?
        int finalCount = 0;
        {
          Iterator<EObject> it = model.eAllContents();
          while (it.hasNext()) {
            it.next();
            finalCount++;
          }
        }
       
        // write this out to a log file
        try {
          File f = new File("inference-properties.csv");
          if (!f.exists()) {
            // write down a list of all the property names
            write(f, "mode", getModelPropertiesInvestigator(false).getModelProperties());
          }
          write(f, "initial", initialProperties);
          write(f, "initial-no-gen", initialPropertiesNoGen);
          write(f, "initial-diff", initialDiff);
          write(f, "initial-diff-%", initialDiffPct);
          write(f, "final", finalProperties);
          write(f, "final-no-gen", finalPropertiesNoGen);
          write(f, "final-diff", finalDiff);
          write(f, "final-diff-%", finalDiffPct);
          write(f, "time", timedList);
          System.out.println(initial + " -> " + finalCount + "(" + diff + " ms)");
         
        } catch (IOException e) {
          throw new InferenceException(e);
        }
       
      }

      /**
 
View Full Code Here

             
            }
           
            return root;
          } catch (ModelLoadException e) {
            throw new InferenceException(e);
          }
        }
      };
     
      InternetApplication root = (InternetApplication) reloader.reload();
View Full Code Here

  public EObject createElement(final EObject container, EClass elementType,
      EStructuralFeature containerFeature) throws InferenceException {
    try {
      if (container == null)
        // return null;
        throw new InferenceException("Cannot create an element in a null container");

      IElementType et = getDiagramEditType(elementType);

      // GMF 2.2: XXXCreateCommands no longer extend CreateElementCommand, so
      // we must get the newly created element from the CreateElementRequest instead
      CreateElementRequest request = new CreateElementRequest(getEditingDomain(), container, et );
      EditElementCommand cc = getDiagramCreateNodeCommand(request, elementType );
      if (cc == null) {
        // we can't do anything because the diagram editor won't allow us to create it currently
        //return null;
        throw new InferenceException("Cannot create an element " + elementType + " in the editing domain " + getEditingDomain());
      }
      doExecute(cc);

      //EObject createdElement = cc.getNewElement();
      EObject createdElement = request.getNewElement();

      return createdElement;
    } catch (ExecutionException e) {
      throw new InferenceException(e);
    }
  }
View Full Code Here

      EStructuralFeature sourceFeature, EStructuralFeature targetFeature)
      throws InferenceException {
    try {
      if (container == null || source == null || target == null)
        //return null;
        throw new InferenceException("Cannot create a relationship in a null container, source or target");

      // GMF 2.2: XXXCreateCommands no longer extend CreateElementCommand, so
      // we must get the newly created element from the CreateElementRequest instead
      CreateRelationshipRequest request = new CreateRelationshipRequest(getEditingDomain(), container, source, target, getDiagramEditType(elementType) );
      EditElementCommand cc = getDiagramCreateRelationshipCommand(request, elementType, source, target );
      if (cc == null) {
        // we can't do anything because the diagram editor won't allow us to create it currently
        //return null;
        throw new InferenceException("Cannot create a relationship " + elementType + " in the editing domain " + getEditingDomain());
      }
      doExecute(cc);

      //EObject createdElement = cc.getNewElement();
      EObject createdElement = request.getNewElement();

      return createdElement;
    } catch (ExecutionException e) {
      throw new InferenceException(e);
    }
  }
View Full Code Here

  public void setValue(EObject element, EStructuralFeature reference,
      Object value) throws InferenceException {
    try {
      if (element == null)
        //return;
        throw new InferenceException("Cannot set a value on a null element");

      SetValueCommand sv = new SetValueCommand(new SetRequest(getEditingDomain(), element, reference, value));
      if (sv == null) {
        // we can't do anything because the diagram editor won't allow us to create it currently
        //return;
        throw new InferenceException("Cannot set a value " + reference + " on the element " + element);
      }
      doExecute(sv);
    } catch (ExecutionException e) {
      throw new InferenceException(e);
    }
  }
View Full Code Here

  public void addReference(EObject element, EStructuralFeature reference,
      Object value) throws InferenceException {
    try {
      if (element == null)
        //return;
        throw new InferenceException("Cannot set a value on a null element");

      AddReferenceCommand sv = new AddReferenceCommand(new SetRequest(getEditingDomain(), element, reference, value));
      if (sv == null) {
        // we can't do anything because the diagram editor won't allow us to create it currently
        //return;
        throw new InferenceException("Cannot set a value " + reference + " on the element " + element);
      }
      doExecute(sv);
    } catch (ExecutionException e) {
      throw new InferenceException(e);
    }
  }
View Full Code Here

  public void deleteElement(EObject object, EObject container,
      EStructuralFeature containerFeature)
      throws InferenceException {

    // TODO implement
    throw new InferenceException("Cannot yet delete from GmfInferenceHandler");
  }
View Full Code Here

        @Override
        public EObject reload() throws InferenceException {
          try {
            return loader.loadDirectly(loadClass, logRuleSource);
          } catch (Exception e) {
            throw new InferenceException(e);
          }
        }
       
      });
View Full Code Here

          @Override
          public EObject reload() throws InferenceException {
            try {
              return loader.loadModelDirectly(filename);
            } catch (ModelLoadException e) {
              throw new InferenceException(e);
            }
          }
     
    });
  }
View Full Code Here

TOP

Related Classes of org.openiaml.model.inference.InferenceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.