示例#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;
 }
示例#2
0
 public void addStatement() {
   if (statements.isEmpty()) {
     statements.add(new StatementWrapper(ImejiFactory.newStatement(), profile.getId()));
   } else {
     statements.add(
         getStatementPosition() + 1,
         new StatementWrapper(ImejiFactory.newStatement(), profile.getId()));
   }
 }
示例#3
0
 public void templateListener(ValueChangeEvent event) throws Exception {
   if (event != null && event.getNewValue() != event.getOldValue()) {
     this.template = event.getNewValue().toString();
     MetadataProfile tp = ObjectCachedLoader.loadProfile(URI.create(this.template));
     profile.getStatements().clear();
     profile.setStatements(tp.getStatements());
     collectionSession.setProfile(profile);
     initBeanObjects(profile);
   }
 }
示例#4
0
 public void loadtemplates() {
   profilesMenu = new ArrayList<SelectItem>();
   profilesMenu.add(new SelectItem(null, sessionBean.getLabel("profile_select_template")));
   try {
     for (MetadataProfile mdp : pc.search()) {
       if (mdp.getId().toString() != profile.getId().toString()) {
         profilesMenu.add(new SelectItem(mdp.getId().toString(), mdp.getTitle()));
       }
     }
   } catch (Exception e) {
     BeanHelper.error(sessionBean.getMessage("error_profile_template_load"));
   }
 }
示例#5
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();
 }
示例#6
0
 public void initBeanObjects(MetadataProfile mdp) {
   statements.clear();
   for (Statement st : mdp.getStatements()) {
     statements.add(new StatementWrapper(st, mdp.getId()));
   }
 }
示例#7
0
 public void reset() {
   profile.getStatements().clear();
   statements.clear();
   collectionSession.setProfile(profile);
 }
示例#8
0
 public String getEncodedId() throws UnsupportedEncodingException {
   if (profile != null && profile.getId() != null) {
     return URLEncoder.encode(profile.getId().toString(), "UTF-8");
   } else return "";
 }