Ejemplo n.º 1
0
 public boolean validateProfile(MetadataProfile profile) {
   List<String> statementNames = new ArrayList<String>();
   if (profile.getStatements() == null) {
     BeanHelper.error(sessionBean.getLabel("profile_empty"));
     return false;
   }
   int i = 0;
   for (Statement s : profile.getStatements()) {
     for (LocalizedString ls : s.getLabels()) {
       if (ls.getLang() == null) {
         BeanHelper.error(sessionBean.getMessage("error_profile_label_no_lang"));
         return false;
       }
     }
     if (s.getType() == null) {
       BeanHelper.error(sessionBean.getMessage("error_profile_select_metadata_type"));
       return false;
     } else if (s.getId() == null || !s.getId().isAbsolute()) {
       BeanHelper.error(s.getId() + " " + sessionBean.getMessage("error_profile_name_not_valid"));
       return false;
     } else if (statementNames.contains(s.getId())) {
       BeanHelper.error(sessionBean.getMessage("error_profile_name_not_unique"));
       return false;
     } else if (s.getLabels().isEmpty()
         || "".equals(((List<LocalizedString>) s.getLabels()).get(0).toString())) {
       BeanHelper.error(sessionBean.getMessage("error_profile_name_required"));
       return false;
     } else {
       statementNames.add(s.getId().toString());
     }
     s.setPos(i);
     i++;
   }
   return true;
 }
Ejemplo n.º 2
0
 public String changeTemplate() throws Exception {
   profile.getStatements().clear();
   MetadataProfile tp = ObjectLoader.loadProfile(URI.create(this.template), sessionBean.getUser());
   if (!tp.getStatements().isEmpty()) {
     profile.setStatements(tp.getStatements());
   } else {
     profile.getStatements().add(ImejiFactory.newStatement());
   }
   for (Statement s : profile.getStatements()) {
     s.setId(
         URI.create(
             s.getId().toString().replace(tp.getId().toString(), profile.getId().toString())));
   }
   collectionSession.setProfile(profile);
   initBeanObjects(profile);
   return getNavigationString();
 }