Example #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 */
    }
  }
Example #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;
 }
Example #3
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);
 }