/**
  * Adds a new project to the metaproject. This sets up the name of the project and the description
  * of the project in the metaproject. (Location is not set/used by this implementation - not all
  * implementations use pprj files anymore).
  *
  * @param newProjectSettings The info about the new project
  */
 private void addProjectToMetaProject(ProjectId projectId, NewProjectSettings newProjectSettings) {
   MetaProject mp = getMetaProject();
   ProjectInstance pi = mp.createProject(projectId.getId());
   pi.setDescription(newProjectSettings.getProjectDescription());
   final Instance protegeInstance = pi.getProtegeInstance();
   final KnowledgeBase kb = protegeInstance.getKnowledgeBase();
   final Slot displayNameSlot = kb.getSlot("displayName");
   protegeInstance.setOwnSlotValue(displayNameSlot, newProjectSettings.getDisplayName());
   User user = mp.getUser(newProjectSettings.getProjectOwner().getUserName());
   pi.setOwner(user);
   OWLAPIMetaProjectStore.getStore().saveMetaProject(this);
 }
 public void setInTrash(ProjectId projectId, boolean b) {
   try {
     WRITE_LOCK.lock();
     ProjectInstance pi = getProjectInstance(projectId);
     Instance instance = pi.getProtegeInstance();
     KnowledgeBase knowledgeBase = instance.getKnowledgeBase();
     Slot inTrashSlot = knowledgeBase.getSlot(IN_TRASH_SLOT_NAME);
     if (inTrashSlot != null) {
       instance.setOwnSlotValue(inTrashSlot, b);
     }
     save();
   } finally {
     WRITE_LOCK.unlock();
   }
 }
Esempio n. 3
0
 public void addForwardReferences() {
   KnowledgeBase kb = this.getKnowledgeBase();
   Collection transitions = getOwnSlotValues(kb.getSlot("transitions"));
   Slot fromSlot = kb.getSlot(":FROM");
   Slot toSlot = kb.getSlot(":TO");
   Instance from = null;
   Instance to = null;
   Slot branches = kb.getSlot("branches");
   Slot followed_by = kb.getSlot("followed_by");
   Slot label = kb.getSlot("label");
   for (Iterator transition = transitions.iterator(); transition.hasNext(); ) {
     Instance inst = (Instance) transition.next();
     from = (Instance) inst.getOwnSlotValue(fromSlot);
     if (from != null) {
       to = (Instance) inst.getOwnSlotValue(toSlot);
       if (to != null) {
         try {
           if (from.hasOwnSlot(branches)) {
             /*logger.debug("addForwardReferences: "+ from.getOwnSlotValue(label)+
             " has branches"); */
             if ((from.getOwnSlotValues(branches) == null)
                 || (!from.getOwnSlotValues(branches).contains(to)))
               from.addOwnSlotValue(branches, to);
           } else if (from.hasOwnSlot(followed_by)) {
             /*logger.debug("addForwardReferences: "+ from.getOwnSlotValue(label)+
             " has followed by");*/
             if (!(to.equals(from.getOwnSlotValue(followed_by))))
               from.setOwnSlotValue(followed_by, to);
           } else
             logger.error(
                 "addForwardReferences: "
                     + from.getOwnSlotValue(label)
                     + "has no followed_by or branches slot");
         } catch (Exception e) {
           logger.error(
               "Exception adding "
                   + to.getOwnSlotValue(label)
                   + " to "
                   + from.getOwnSlotValue(label));
         }
       }
     }
   }
 }
Esempio n. 4
0
  public void removeForwardReferences() {
    KnowledgeBase kb = this.getKnowledgeBase();
    Slot branches = kb.getSlot("branches");
    Slot followed_by = kb.getSlot("followed_by");
    // logger.debug("Slot "+branches.getName());
    // logger.debug("Slot "+followed_by.getName());
    Slot label = kb.getSlot("label");
    Collection steps = getOwnSlotValues(kb.getSlot("steps"));
    for (Iterator iterater = steps.iterator(); iterater.hasNext(); ) {
      Instance step = (Instance) iterater.next();
      // logger.debug("removeForwardReferences: node ="+step.getOwnSlotValue(label));
      /*for (Iterator slots=step.getOwnSlots().iterator(); slots.hasNext();){
      	logger.debug("has slot "+((Slot)slots.next()).getName());
      }*/
      try {
        if (step.hasOwnSlot(branches)) {
          /*logger.debug("removeForwardReferences: "+ step.getOwnSlotValue(label)+
          " has branches"); */
          step.setOwnSlotValues(branches, new ArrayList());
        } else if (step.hasOwnSlot(followed_by)) {
          /* logger.debug("removeForwardReferences: "+ step.getOwnSlotValue(label)+
          " has followed_by value "+step.getOwnSlotValue(followed_by));*/
          step.setOwnSlotValue(followed_by, null);
        } else
          logger.error(
              "removeForwardReferences: "
                  + step.getOwnSlotValue(label)
                  + "has no followed_by or branches slot");
      } catch (Exception e) {

        logger.error(
            "Exception making " + step.getOwnSlotValue(label) + " null, Message: " + e.getMessage(),
            e);
      }
    }
  }