public boolean isOutConcept(Term concept) {
   if (concept instanceof IRI) return isOutConcept(factory.createConcept((IRI) concept));
   if (concept instanceof UnnumberedAnonymousID)
     return isOutConcept(factory.createConcept((UnnumberedAnonymousID) concept));
   // FIXME?
   return false;
 }
 public boolean isOut(Term instance) {
   if (instance instanceof IRI) return isOut(factory.createInstance((IRI) instance));
   if (instance instanceof UnnumberedAnonymousID)
     return isOut(factory.createInstance((UnnumberedAnonymousID) instance));
   // FIXME?
   return false;
 }
 private void initializeState(StateSignature signature) {
   if (signature.listOntologies() == null || signature.listOntologies().isEmpty())
     throw new IllegalArgumentException("Signature doesn't have an ontology.");
   state =
       factory.createOntology(
           factory.createIRI(
               "http://www.wsmx.org/choreography/state_id-"
                   + stateCounter
                   + "_at-"
                   + System.currentTimeMillis()));
   logger.fatal("Initializing state " + state.getIdentifier());
   // TODO the default namespace of the ontology is selected somewhat arbitrarily
   state.setDefaultNamespace(signature.listOntologies().iterator().next().getDefaultNamespace());
   for (Ontology o : signature.listOntologies()) {
     logger.debug("Transadding from " + o.getIdentifier());
     for (Namespace ns :
         (Collection<Namespace>) signature.listOntologies().iterator().next().listNamespaces()) {
       logger.debug("Transadding namespace " + ns.getPrefix());
       state.addNamespace(ns);
     }
   }
   for (Mode mode : signature) {
     try {
       Concept concept = mode.getConcept();
       Concept copy = copy(concept);
       state.addConcept(copy);
     } catch (SynchronisationException e) {
       try {
         logger.warn("Failed to initialize state with " + mode.getConcept().getIdentifier(), e);
       } catch (Throwable t) {
         logger.warn("Failed to initialize state.", e);
       }
     } catch (InvalidModelException e) {
       try {
         logger.warn("Failed to initialize state with " + mode.getConcept().getIdentifier(), e);
       } catch (Throwable t) {
         logger.warn("Failed to initialize state.", e);
       }
     }
   }
 }
 /* (non-Javadoc)
  * @see ie.deri.wsmx.asm.State#add(org.omwg.logicalexpression.MembershipMolecule)
  */
 public void add(MembershipMolecule fact) {
   logger.info("Adding membership molecule " + fact);
   // TODO write this more elegant once factory convenience creators are fixed
   Set<MembershipMolecule> mms = new HashSet<MembershipMolecule>();
   mms.add(fact);
   facts.add(cFactory.facts.createMoleculeFact(mms, new HashSet<AttributeValueMolecule>()));
   Axiom axiom =
       factory.createAxiom(
           factory.createIRI(
               "http://www.wsmx.org/choreography/state/membership" + membershipCounter++));
   axiom.addDefinition(fact);
   try {
     logger.debug("Adding MM axiom: " + fact);
     state.addAxiom(axiom);
   } catch (SynchronisationException e) {
     logger.warn("Failed to add membership molecule to state.", e);
   } catch (InvalidModelException e) {
     logger.warn("Failed to add membership molecule to state.", e);
   }
   for (StateModificationListener listener : listeners) {
     listener.addedMembership(this, fact);
   }
 }
 /* (non-Javadoc)
  * @see ie.deri.wsmx.asm.State#add(org.omwg.logicalexpression.AttributeValueMolecule)
  */
 public void add(AttributeValueMolecule fact) {
   facts.add(
       cFactory.facts.createMoleculeFact(
           new HashSet<MembershipMolecule>(),
           new HashSet<AttributeValueMolecule>(
               Arrays.asList(new AttributeValueMolecule[] {fact}))));
   Axiom axiom =
       factory.createAxiom(
           factory.createIRI(
               "http://www.wsmx.org/choreography/state/attribute" + attributeCounter++));
   axiom.addDefinition(fact);
   try {
     logger.debug("Adding AVM axiom: " + fact);
     axioms.put(fact, axiom);
     state.addAxiom(axiom);
   } catch (SynchronisationException e) {
     logger.warn("Failed to add attribute value to state.", e);
   } catch (InvalidModelException e) {
     logger.warn("Failed to add attribute value to state.", e);
   }
   for (StateModificationListener listener : listeners) {
     listener.addedAttribute(this, fact);
   }
 }
 public void initializeWithControlState() {
   Concept controlState =
       factory.createConcept(factory.createIRI(OASM_NAMESPACE + "controlState"));
   Instance controlStateInstance =
       factory.createInstance(factory.createIRI(OASM_NAMESPACE + "cs"));
   try {
     controlStateInstance.addConcept(controlState);
     state.addInstance(controlStateInstance);
     AttributeValueMolecule avm =
         leFactory.createAttributeValue(
             factory.createIRI(OASM_NAMESPACE + "cs"),
             factory.createIRI(OASM_NAMESPACE + "value"),
             factory.createIRI(OASM_NAMESPACE + "initial"));
     add(avm);
   } catch (SynchronisationException e) {
     logger.warn("Failure during insertion of control state.", e);
   } catch (InvalidModelException e) {
     logger.warn("Failure during insertion of control state.", e);
   }
 }