コード例 #1
0
 @Test
 public void convertShouldReturnSuppliedId() {
   ProjectIdWriteConverter converter = new ProjectIdWriteConverter();
   String suppliedId = UUID.randomUUID().toString();
   ProjectId projectId = ProjectId.get(suppliedId);
   String convertedId = converter.convert(projectId);
   assertEquals(suppliedId, convertedId);
 }
コード例 #2
0
 @Override
 public ProjectDetails getProjectDetails(ProjectId projectId) throws UnknownProjectException {
   ProjectInstance pi = metaproject.getProject(projectId.getId());
   if (pi == null) {
     throw new UnknownProjectException(projectId);
   }
   return createProjectDetailsFromProjectInstance(pi);
 }
コード例 #3
0
 public String getDisplayName(ProjectId projectId) {
   ProjectInstance pi = getProjectInstance(projectId);
   Slot displayNameSlot = pi.getProtegeInstance().getKnowledgeBase().getSlot("displayName");
   if (displayNameSlot == null) {
     return projectId.getId();
   } else {
     return pi.getProtegeInstance().getDirectOwnSlotValue(displayNameSlot).toString();
   }
 }
コード例 #4
0
 /**
  * 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);
 }
コード例 #5
0
 public List<ProjectDetails> getListableReadableProjects(UserId userId) {
   Policy policy = metaproject.getPolicy();
   User user = policy.getUserByName(userId.getUserName());
   List<ProjectDetails> result = new ArrayList<ProjectDetails>();
   for (ProjectInstance projectInstance : metaproject.getProjects()) {
     final String name = projectInstance.getName();
     if (name != null && ProjectId.isWelFormedProjectId(name)) {
       final ProjectId projectId = ProjectId.get(name);
       if (isAuthorisedToReadAndList(policy, user, projectInstance)) {
         OWLAPIProjectDocumentStore ds =
             OWLAPIProjectDocumentStore.getProjectDocumentStore(projectId);
         if (ds.exists()) {
           final ProjectDetails projectDetails =
               createProjectDetailsFromProjectInstance(projectInstance);
           result.add(projectDetails);
         }
       }
     }
   }
   return result;
 }
コード例 #6
0
  private void setInitialSelection() {
    final String ontologyName = com.google.gwt.user.client.Window.Location.getParameter("ontology");
    if (ontologyName == null || !projectId.getId().equals(ontologyName)) {
      return;
    }

    final String tabNameToSelect = com.google.gwt.user.client.Window.Location.getParameter("tab");
    if (tabNameToSelect == null) {
      return;
    }

    selectTabWithName(tabNameToSelect);
  }
コード例 #7
0
 private ProjectInstance getProjectInstance(ProjectId projectId) throws UnknownProjectException {
   try {
     READ_LOCK.lock();
     MetaProject metaProject = getMetaProject();
     ProjectInstance pi = metaProject.getProject(projectId.getId());
     if (pi == null) {
       throw new UnknownProjectException(projectId);
     }
     return pi;
   } finally {
     READ_LOCK.unlock();
   }
 }
コード例 #8
0
 /**
  * Detemines if the signed in user is the owner of the specified project
  *
  * @param projectId The project id
  * @return <code>true</code> if the project exists AND there is a user signed in AND the signed in
  *     user is the owner of the project, otherwise <code>false</code>.
  */
 protected boolean isSignedInUserProjectOwner(ProjectId projectId) {
   UserId userId = getUserInSession();
   if (userId.isGuest()) {
     return false;
   }
   MetaProjectManager mpm = getMetaProjectManager();
   MetaProject metaProject = mpm.getMetaProject();
   ProjectInstance project = metaProject.getProject(projectId.getId());
   if (project == null) {
     return false;
   }
   User owner = project.getOwner();
   return owner != null && userId.getUserName().equals(owner.getName());
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 public synchronized Set<ProjectId> getProjects() {
   try {
     READ_LOCK.lock();
     MetaProject metaProject = getMetaProject();
     Set<ProjectInstance> projectInstances = metaProject.getProjects();
     Set<ProjectId> result = new HashSet<ProjectId>(projectInstances.size());
     for (ProjectInstance pi : projectInstances) {
       String projectName = pi.getName();
       result.add(ProjectId.get(projectName));
     }
     return result;
   } finally {
     READ_LOCK.unlock();
   }
 }
コード例 #11
0
 /**
  * Computes the hashCode as the sum of {@link #getProjectId()#hashCode()} and {@link
  * #getSubject()#hashCode()}.
  *
  * @return The hashcode based on the result of {@link #getProjectId()} and {@link #getSubject()}.
  */
 @Override
 public int hashCode() {
   return "HasSubjectAndProjectBase".hashCode() + projectId.hashCode() + subject.hashCode();
 }
コード例 #12
0
 @Override
 public int hashCode() {
   return "EditorContext".hashCode() + projectId.hashCode() + selectedEntityData.hashCode();
 }