private static ProjectDetails createProjectDetailsFromProjectInstance( ProjectInstance projectInstance) { final ProjectId projectId = ProjectId.get(projectInstance.getName()); final String description = projectInstance.getDescription(); final User projectOwner = projectInstance.getOwner(); final UserId ownerId = projectOwner != null ? UserId.getUserId(projectOwner.getName()) : UserId.getGuest(); final boolean inTrash = isInTrash(projectInstance); final Slot displayNameSlot = projectInstance.getProtegeInstance().getKnowledgeBase().getSlot("displayName"); final String displayName = (String) projectInstance.getProtegeInstance().getOwnSlotValue(displayNameSlot); return new ProjectDetails(projectId, displayName, description, ownerId, inTrash); }
private static boolean isInTrash(ProjectInstance projectInstance) { Instance protegeInstance = projectInstance.getProtegeInstance(); KnowledgeBase kb = protegeInstance.getKnowledgeBase(); Slot inTrashSlot = getInTrashSlot(kb); Object ownSlotValue = protegeInstance.getOwnSlotValue(inTrashSlot); return ownSlotValue != null && ownSlotValue.equals(Boolean.TRUE); }
/** * 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); }