Ejemplo n.º 1
0
  /**
   * If a metadata is deleted in profile, or the type is changed, the metadata should be removed in
   * image
   *
   * @throws Exception
   */
  public void removeDeadMetadata() throws Exception {
    boolean update = false;
    Collection<ImageMetadata> mds = new ArrayList<ImageMetadata>();
    try {
      for (ImageMetadata md : image.getMetadataSet().getMetadata()) {
        boolean isStatement = false;

        for (Statement st : profile.getStatements()) {
          if (st.getName().equals(md.getNamespace())) {
            isStatement = true;
            if (!st.getType().equals(md.getType().getURI())) {
              isStatement = false;
            }
          }
        }

        if (isStatement) mds.add(md);
        else update = true;
      }

      if (update) {
        ImageController imageController = new ImageController(sessionBean.getUser());
        image.getMetadataSet().setMetadata(mds);
        List<Image> l = new ArrayList<Image>();
        l.add(image);
        imageController.update(l);
      }
    } catch (Exception e) {
      /* this user has not the priviliges to update the image */
    }
  }
Ejemplo n.º 2
0
 public List<SelectItem> getStatementMenu() {
   List<SelectItem> statementMenu = new ArrayList<SelectItem>();
   if (profile == null) {
     loadProfile();
   }
   for (Statement s : profile.getStatements()) {
     statementMenu.add(new SelectItem(s.getName(), s.getLabels().iterator().next().toString()));
   }
   return statementMenu;
 }
Ejemplo n.º 3
0
 public String getDescription() {
   for (Statement s : getProfile().getStatements()) {
     if (s.isDescription()) {
       for (ImageMetadata md : this.getImage().getMetadataSet().getMetadata()) {
         if (md.getNamespace().equals(s.getName())) {
           return md.getSearchValue();
         }
       }
     }
   }
   return image.getFilename();
 }
Ejemplo n.º 4
0
 private void sortMetadataAccordingtoProfile() {
   Collection<ImageMetadata> mdSorted = new ArrayList<ImageMetadata>();
   if (profile != null) {
     for (Statement st : profile.getStatements()) {
       for (ImageMetadata md : image.getMetadataSet().getMetadata()) {
         if (st.getName().equals(md.getNamespace())) {
           mdSorted.add(md);
         }
       }
     }
   }
   image.getMetadataSet().setMetadata(mdSorted);
 }