use of ugh.dl.MetadataGroupType in project goobi-workflow by intranda.
the class Metadaten method getMetadataGroupTypes.
public SelectItem[] getMetadataGroupTypes() {
/*
* -------------------------------- zuerst mal die addierbaren Metadatentypen ermitteln --------------------------------
*/
List<MetadataGroupType> types = this.myDocStruct.getAddableMetadataGroupTypes();
if (types == null) {
return new SelectItem[0];
}
/*
* -------------------------------- die Metadatentypen sortieren --------------------------------
*/
HelperComparator c = new HelperComparator();
c.setSortierart("MetadatenGroupTypes");
Collections.sort(types, c);
/*
* -------------------------------- nun ein Array mit der richtigen Größe anlegen --------------------------------
*/
int zaehler = types.size();
SelectItem[] myTypen = new SelectItem[zaehler];
/*
* -------------------------------- und anschliessend alle Elemente in das Array packen --------------------------------
*/
zaehler = 0;
for (MetadataGroupType mdt : types) {
myTypen[zaehler] = new SelectItem(mdt.getName(), this.metahelper.getMetadataGroupTypeLanguage(mdt));
zaehler++;
}
/*
* -------------------------------- alle Typen, die einen Unterstrich haben nochmal rausschmeissen --------------------------------
*/
SelectItem[] myTypenOhneUnterstrich = new SelectItem[zaehler];
for (int i = 0; i < zaehler; i++) {
myTypenOhneUnterstrich[i] = myTypen[i];
}
return myTypenOhneUnterstrich;
}
use of ugh.dl.MetadataGroupType in project goobi-workflow by intranda.
the class Metadaten method getAddableMetadataGroupTypes.
public List<SelectItem> getAddableMetadataGroupTypes() {
List<SelectItem> myList = new ArrayList<>();
List<MetadataGroupType> types = null;
if (currentGroup != null) {
List<String> groupNames = currentGroup.getMetadataGroup().getAddableMetadataGroupTypes();
if (groupNames != null) {
types = new ArrayList<>();
for (String groupName : groupNames) {
MetadataGroupType mgt = myPrefs.getMetadataGroupTypeByName(groupName);
types.add(mgt);
}
}
} else {
types = this.myDocStruct.getAddableMetadataGroupTypes();
}
if (types == null) {
return myList;
}
/*
* -------------------------------- die Metadatentypen sortieren --------------------------------
*/
HelperComparator c = new HelperComparator();
c.setSortierart("MetadatenGroupTypes");
Collections.sort(types, c);
for (MetadataGroupType mdt : types) {
myList.add(new SelectItem(mdt.getName(), this.metahelper.getMetadataGroupTypeLanguage(mdt)));
try {
MetadataGroup md = new MetadataGroup(mdt);
MetadataGroupImpl mdum = new MetadataGroupImpl(myPrefs, myProzess, md, this, metahelper.getMetadataGroupTypeLanguage(mdt), null, 0);
this.tempMetadataGroups.add(mdum);
// TODO initialize all fields
} catch (MetadataTypeNotAllowedException e) {
log.error("Fehler beim sortieren der Metadaten: " + e.getMessage());
}
}
return myList;
}
use of ugh.dl.MetadataGroupType in project goobi-workflow by intranda.
the class HelperComparator method compareMetadataGroupTypes.
private int compareMetadataGroupTypes(Object o1, Object o2) {
MetadataGroupType s1 = (MetadataGroupType) o1;
MetadataGroupType s2 = (MetadataGroupType) o2;
String name1 = s1.getLanguage(Helper.getMetadataLanguage());
String name2 = s2.getLanguage(Helper.getMetadataLanguage());
if (name1 == null) {
name1 = "";
}
if (name2 == null) {
name2 = "";
}
return name1.compareToIgnoreCase(name2);
}
use of ugh.dl.MetadataGroupType in project goobi-workflow by intranda.
the class MetadatumImpl method linkProcess.
public void linkProcess(RestProcess rp) {
Project p = this.getBean().getMyProzess().getProjekt();
XMLConfiguration xmlConf = ConfigPlugins.getPluginConfig("ProcessPlugin");
if (xmlConf == null) {
return;
}
HierarchicalConfiguration use = getConfigForProject(p, xmlConf);
Map<String, List<RestMetadata>> addMetadata = new HashMap<>();
List<HierarchicalConfiguration> mappings = use.configurationsAt("mapping");
for (HierarchicalConfiguration mapping : mappings) {
String from = mapping.getString("[@from]");
String to = mapping.getString("[@to]");
List<RestMetadata> fromMeta = rp.getMetadata().get(from);
if (fromMeta != null) {
addMetadata.put(to, fromMeta);
}
}
Prefs prefs = this.getBean().getMyPrefs();
DocStruct ds = this.getBean().getMyDocStruct();
for (String name : addMetadata.keySet()) {
try {
for (RestMetadata rmd : addMetadata.get(name)) {
if (!rmd.anyValue()) {
continue;
}
if (name.contains("/")) {
String[] split = name.split("/");
String group = split[0];
String metaName = split[1];
MetadataGroupType mgt = prefs.getMetadataGroupTypeByName(group);
MetadataGroup addGroup = null;
addGroup = new MetadataGroup(mgt);
List<Metadata> metaList = addGroup.getMetadataByType(metaName);
Metadata md;
if (metaList.isEmpty()) {
md = new Metadata(prefs.getMetadataTypeByName(metaName));
addGroup.addMetadata(md);
} else {
md = metaList.get(0);
}
if (rmd.getValue() != null) {
md.setValue(rmd.getValue());
}
if (rmd.getAuthorityID() != null) {
md.setAuthorityID(rmd.getAuthorityID());
}
if (rmd.getAuthorityURI() != null) {
md.setAuthorityURI(rmd.getAuthorityURI());
}
if (rmd.getAuthorityValue() != null) {
md.setAuthorityValue(rmd.getAuthorityValue());
}
ds.addMetadataGroup(addGroup);
} else {
Metadata md = new Metadata(prefs.getMetadataTypeByName(name));
if (rmd.getValue() != null) {
md.setValue(rmd.getValue());
}
if (rmd.getAuthorityID() != null) {
md.setAuthorityID(rmd.getAuthorityID());
}
if (rmd.getAuthorityURI() != null) {
md.setAuthorityURI(rmd.getAuthorityURI());
}
if (rmd.getAuthorityValue() != null) {
md.setAuthorityValue(rmd.getAuthorityValue());
}
ds.addMetadata(md);
}
}
} catch (MetadataTypeNotAllowedException e) {
Helper.setFehlerMeldung("Metadata " + name + " not allowed in preferences.", e);
}
}
this.getBean().reloadMetadataList();
}
use of ugh.dl.MetadataGroupType in project goobi-workflow by intranda.
the class MetadatenHelper method getMetadataGroupsInclDefaultDisplay.
/**
* vom übergebenen DocStruct alle Metadaten ermitteln und um die fehlenden DefaultDisplay-Metadaten ergänzen
* ================================================================
*/
public List<MetadataGroup> getMetadataGroupsInclDefaultDisplay(DocStruct inStruct, String inLanguage, Process inProzess) {
List<MetadataGroupType> displayMetadataTypes = inStruct.getDefaultDisplayMetadataGroupTypes();
/* sofern Default-Metadaten vorhanden sind, diese ggf. ergänzen */
if (displayMetadataTypes != null) {
for (MetadataGroupType mdt : displayMetadataTypes) {
// - add it
if (!(inStruct.getAllMetadataGroupsByType(mdt) != null && inStruct.getAllMetadataGroupsByType(mdt).size() != 0)) {
try {
MetadataGroup md = new MetadataGroup(mdt);
// add this new metadata
inStruct.addMetadataGroup(md);
// element
} catch (DocStructHasNoTypeException e) {
continue;
} catch (MetadataTypeNotAllowedException e) {
continue;
}
}
}
}
/*
* wenn keine Sortierung nach Regelsatz erfolgen soll, hier alphabetisch sortieren
*/
List<MetadataGroup> answer = inStruct.getAllMetadataGroups();
if (answer != null && !inProzess.getRegelsatz().isOrderMetadataByRuleset()) {
// order metadata within each group
for (MetadataGroup mg : answer) {
Collections.sort(mg.getMetadataList(), new MetadataComparator(inLanguage));
Collections.sort(mg.getPersonList(), new MetadataComparator(inLanguage));
Collections.sort(mg.getCorporateList(), new MetadataComparator(inLanguage));
}
}
return answer;
}
Aggregations