use of ugh.dl.MetadataGroup 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.MetadataGroup in project goobi-workflow by intranda.
the class Metadaten method saveGroup.
public String saveGroup() {
try {
MetadataGroup md = new MetadataGroup(this.myPrefs.getMetadataGroupTypeByName(this.tempGroupType));
for (MetadatumImpl mdi : selectedGroup.getMetadataList()) {
if (StringUtils.isNotBlank(mdi.getMd().getValue())) {
Metadata metadata = new Metadata(mdi.getMd().getType());
metadata.setValue(mdi.getMd().getValue());
md.addMetadata(metadata);
}
}
for (MetaPerson mp : selectedGroup.getPersonList()) {
Person p = new Person(mp.getP().getType());
p.setFirstname(mp.getP().getFirstname());
p.setLastname(mp.getP().getLastname());
p.setAutorityFile(mp.getP().getAuthorityID(), mp.getP().getAuthorityURI(), mp.getP().getAuthorityValue());
md.addPerson(p);
}
for (MetaCorporate mc : selectedGroup.getCorporateList()) {
Corporate corporate = new Corporate(mc.getCorporate().getType());
corporate.setMainName(mc.getCorporate().getMainName());
corporate.setSubNames(mc.getCorporate().getSubNames());
corporate.setPartName(mc.getCorporate().getPartName());
md.addCorporate(currentCorporate);
}
if (currentGroup != null) {
currentGroup.getMetadataGroup().addMetadataGroup(md);
} else {
this.myDocStruct.addMetadataGroup(md);
}
} catch (MetadataTypeNotAllowedException e) {
log.error("Error while adding metadata (MetadataTypeNotAllowedException): " + e.getMessage());
}
this.modeAddGroup = false;
for (MetadatumImpl mdi : selectedGroup.getMetadataList()) {
mdi.setValue("");
}
for (MetaPerson mp : selectedGroup.getPersonList()) {
mp.setVorname("");
mp.setNachname("");
}
for (MetaCorporate mc : selectedGroup.getCorporateList()) {
mc.setMainName("");
mc.getSubNames().clear();
mc.addSubName();
mc.setPartName("");
}
MetadatenalsBeanSpeichern(this.myDocStruct);
if (!SperrungAktualisieren()) {
return "metseditor_timeout";
}
MetadatenalsTree3Einlesen1(this.tree3, this.currentTopstruct, false);
return "";
}
use of ugh.dl.MetadataGroup in project goobi-workflow by intranda.
the class Metadaten method AddMetadaFromOpacPpn.
/**
* eine PPN aus dem Opac abfragen und dessen Metadaten dem aktuellen Strukturelement zuweisen
* ================================================================
*/
public String AddMetadaFromOpacPpn() {
StringTokenizer tokenizer = new StringTokenizer(this.additionalOpacPpns, "\n");
while (tokenizer.hasMoreTokens()) {
String tok = tokenizer.nextToken();
try {
ConfigOpacCatalogue coc = ConfigOpac.getInstance().getCatalogueByName(getOpacKatalog());
IOpacPlugin iopac = (IOpacPlugin) PluginLoader.getPluginByTitle(PluginType.Opac, coc.getOpacType());
Fileformat addrdf = iopac.search(this.opacSuchfeld, tok, coc, this.myPrefs);
if (addrdf != null) {
// remove empty default elements
List<Metadata> metadataList = this.myDocStruct.getAllMetadata();
if (metadataList != null) {
List<Metadata> metadataListClone = new ArrayList<>(metadataList);
for (Metadata md : metadataListClone) {
if (md.getValue() == null || md.getValue().isEmpty()) {
this.myDocStruct.removeMetadata(md, true);
}
}
}
List<Person> personList = myDocStruct.getAllPersons();
if (personList != null) {
List<Person> personListClone = new ArrayList<>(personList);
for (Person p : personListClone) {
if (p.getFirstname().isEmpty() && p.getLastname().isEmpty()) {
myDocStruct.removePerson(p);
}
}
}
/* die Liste aller erlaubten Metadatenelemente erstellen */
List<String> erlaubte = new ArrayList<>();
for (MetadataType mt : this.myDocStruct.getAddableMetadataTypes(false)) {
erlaubte.add(mt.getName());
}
/*
* wenn der Metadatentyp in der Liste der erlaubten Typen, dann hinzufügen
*/
for (Metadata m : addrdf.getDigitalDocument().getLogicalDocStruct().getAllMetadata()) {
if (erlaubte.contains(m.getType().getName())) {
this.myDocStruct.addMetadata(m);
}
}
for (Person m : addrdf.getDigitalDocument().getLogicalDocStruct().getAllPersons()) {
if (erlaubte.contains(m.getType().getName())) {
this.myDocStruct.addPerson(m);
}
}
for (MetadataGroup m : addrdf.getDigitalDocument().getLogicalDocStruct().getAllMetadataGroups()) {
if (myDocStruct.getAddableMetadataGroupTypes().contains(m.getType())) {
myDocStruct.addMetadataGroup(m);
}
}
MetadatenalsTree3Einlesen1(this.tree3, this.currentTopstruct, false);
} else {
Helper.setMeldung(null, "Opac abgefragt: ", "kein Ergebnis");
}
} catch (Exception e) {
log.error("Error while importing from catalogue: " + e.getMessage());
}
}
MetadatenalsBeanSpeichern(this.myDocStruct);
this.modusAnsicht = "Metadaten";
return "";
}
use of ugh.dl.MetadataGroup in project goobi-workflow by intranda.
the class MetadataGroupImplTest method testGetMyPrefs.
@Test
public void testGetMyPrefs() throws MetadataTypeNotAllowedException {
MetadataGroup md = new MetadataGroup(prefs.getMetadataGroupTypeByName("junitgrp"));
MetadataGroupImpl fixture = new MetadataGroupImpl(prefs, process, md, null, "", "", 0);
assertEquals(prefs, fixture.getMyPrefs());
}
use of ugh.dl.MetadataGroup in project goobi-workflow by intranda.
the class MetadataGroupImplTest method testMetadataGroup.
@Test
public void testMetadataGroup() throws MetadataTypeNotAllowedException {
MetadataGroup md = new MetadataGroup(prefs.getMetadataGroupTypeByName("junitgrp"));
MetadataGroupImpl fixture = new MetadataGroupImpl(prefs, process, md, null, "", "", 0);
fixture.setMetadataGroup(md);
assertEquals(md, fixture.getMetadataGroup());
}
Aggregations