Examples of ObjectEntity


Examples of unbbayes.prs.mebn.entity.ObjectEntity

    if (continuousResidentNode.getMFrag() == null || continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork() == null) {
      throw new IllegalArgumentException(continuousResidentNode + " is inconsistent: it is not associated with any MTheory");
    }
   
    // extract the "Number" entity from the continuousResidentNode. The possible values of continuous resident nodes are assumed to be individuals of entity "Number"
    ObjectEntity numberType = null;
    try {
      numberType = (ObjectEntity) continuousResidentNode.getPossibleValueByName(continuousResidentNode.NUMBER_ENTITY_NAME).getState();
    } catch (Exception e) {
      // could not extract from continuousResidentNode. Try from the MTheory of continuousResidentNode
      try {
        Debug.println(getClass(), "Could not extract " + continuousResidentNode.NUMBER_ENTITY_NAME + " type from " + continuousResidentNode + ": " + e.getMessage(),e);
        Debug.println(getClass(), "Extracting the " + continuousResidentNode.NUMBER_ENTITY_NAME + " type from " + continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork());
        numberType = continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork().getObjectEntityContainer().getObjectEntityByName(continuousResidentNode.NUMBER_ENTITY_NAME);
      } catch (Exception e2) {
        // "Number" was not neither a type of continuousResidentNode nor a type in the MTheory of continuousResidentNode.
        throw new IllegalArgumentException("The type of " + continuousResidentNode +" is not a " + continuousResidentNode.NUMBER_ENTITY_NAME +", and also could not extract the type from its MTheory.", e2);
      }
    }
   
    if (numberType == null) {
      // let's assure we never have numberType == null
      throw new IllegalArgumentException("The type of " + continuousResidentNode +" is not a " + continuousResidentNode.NUMBER_ENTITY_NAME +", and also could not extract the type from its MTheory.");
    }
   
    // check whether the value is already recorded as a possible value of numberType. If so, reuse it
    ObjectEntityInstance state = numberType.getInstanceByName(String.valueOf(value));
    if (state == null) {
      // this is a new value. Insert it
      try {
        state = numberType.addInstance(String.valueOf(value));
        continuousResidentNode.getMFrag().getMultiEntityBayesianNetwork().getObjectEntityContainer().addEntityInstance(state);
      } catch (TypeException e) {
        throw new IllegalArgumentException("Cannnot use " + value + " as a possible value of " + continuousResidentNode,e);
      } catch (EntityInstanceAlreadyExistsException e) {
        e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.