Search in sources :

Example 1 with Person

use of ugh.dl.Person in project goobi-workflow by intranda.

the class Metadaten method TransliterierenPerson.

public String TransliterierenPerson() {
    Person md = this.curPerson.getP();
    /*
         * -------------------------------- wenn es ein russischer Autor ist, dessen Transliterierungen anlegen --------------------------------
         */
    if (md.getRole().equals("Author")) {
        Transliteration trans = new Transliteration();
        try {
            MetadataType mdtDin = this.myPrefs.getMetadataTypeByName("AuthorTransliteratedDIN");
            MetadataType mdtIso = this.myPrefs.getMetadataTypeByName("AuthorTransliteratedISO");
            Person mdDin = new Person(mdtDin);
            Person mdIso = new Person(mdtIso);
            mdDin.setFirstname(trans.transliterate_din(md.getFirstname()));
            mdDin.setLastname(trans.transliterate_din(md.getLastname()));
            mdIso.setFirstname(trans.transliterate_iso(md.getFirstname()));
            mdIso.setLastname(trans.transliterate_iso(md.getLastname()));
            mdDin.setRole("AuthorTransliteratedDIN");
            mdIso.setRole("AuthorTransliteratedISO");
            this.myDocStruct.addPerson(mdDin);
            this.myDocStruct.addPerson(mdIso);
        } catch (MetadataTypeNotAllowedException e) {
            log.error("Fehler beim Hinzufügen der Transliterationen (MetadataTypeNotAllowedException): " + e.getMessage());
        }
    }
    MetadatenalsBeanSpeichern(this.myDocStruct);
    /* zum Schluss die Sperrung aktualisieren */
    if (!SperrungAktualisieren()) {
        return "metseditor_timeout";
    }
    return "";
}
Also used : Transliteration(de.sub.goobi.helper.Transliteration) MetadataTypeNotAllowedException(ugh.exceptions.MetadataTypeNotAllowedException) MetadataType(ugh.dl.MetadataType) Person(ugh.dl.Person)

Example 2 with Person

use of ugh.dl.Person 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 "";
}
Also used : MetadataTypeNotAllowedException(ugh.exceptions.MetadataTypeNotAllowedException) Corporate(ugh.dl.Corporate) MetadataGroup(ugh.dl.MetadataGroup) Metadata(ugh.dl.Metadata) Person(ugh.dl.Person)

Example 3 with Person

use of ugh.dl.Person 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 "";
}
Also used : IOpacPlugin(org.goobi.production.plugin.interfaces.IOpacPlugin) Metadata(ugh.dl.Metadata) ArrayList(java.util.ArrayList) MetadataType(ugh.dl.MetadataType) MetadataGroup(ugh.dl.MetadataGroup) Fileformat(ugh.dl.Fileformat) TypeNotAllowedAsChildException(ugh.exceptions.TypeNotAllowedAsChildException) JDOMException(org.jdom2.JDOMException) DAOException(de.sub.goobi.helper.exceptions.DAOException) SwapException(de.sub.goobi.helper.exceptions.SwapException) PreferencesException(ugh.exceptions.PreferencesException) WriteException(ugh.exceptions.WriteException) TypeNotAllowedForParentException(ugh.exceptions.TypeNotAllowedForParentException) IncompletePersonObjectException(ugh.exceptions.IncompletePersonObjectException) IOException(java.io.IOException) MetadataTypeNotAllowedException(ugh.exceptions.MetadataTypeNotAllowedException) ReadException(ugh.exceptions.ReadException) InvalidImagesException(de.sub.goobi.helper.exceptions.InvalidImagesException) DocStructHasNoTypeException(ugh.exceptions.DocStructHasNoTypeException) StringTokenizer(java.util.StringTokenizer) ConfigOpacCatalogue(de.unigoettingen.sub.search.opac.ConfigOpacCatalogue) Person(ugh.dl.Person)

Example 4 with Person

use of ugh.dl.Person in project goobi-workflow by intranda.

the class MetaPersonTest method testIdentifier.

@Test
public void testIdentifier() throws MetadataTypeNotAllowedException {
    Person p = new Person(prefs.getMetadataTypeByName(METADATA_TYPE));
    MetaPerson mp = new MetaPerson(p, 0, prefs, docstruct, process, null);
    assertNotNull(mp);
    assertEquals(0, mp.getIdentifier());
    mp.setIdentifier(1);
    assertNotEquals(0, mp.getIdentifier());
}
Also used : Person(ugh.dl.Person) AbstractTest(de.sub.goobi.AbstractTest) Test(org.junit.Test)

Example 5 with Person

use of ugh.dl.Person in project goobi-workflow by intranda.

the class MetaPersonTest method testAdditionalNameParts.

@Test
public void testAdditionalNameParts() throws MetadataTypeNotAllowedException {
    Person p = new Person(prefs.getMetadataTypeByName(METADATA_TYPE));
    MetaPerson mp = new MetaPerson(p, 0, prefs, docstruct, process, null);
    assertNotNull(mp);
    List<NamePart> fixture = mp.getAdditionalNameParts();
    assertNull(fixture);
    mp.addNamePart();
    fixture = mp.getAdditionalNameParts();
    assertEquals(1, mp.getAdditionalNameParts().size());
    mp.setAdditionalNameParts(fixture);
    assertEquals(1, mp.getAdditionalNameParts().size());
}
Also used : NamePart(ugh.dl.NamePart) Person(ugh.dl.Person) AbstractTest(de.sub.goobi.AbstractTest) Test(org.junit.Test)

Aggregations

Person (ugh.dl.Person)34 AbstractTest (de.sub.goobi.AbstractTest)15 Test (org.junit.Test)15 Metadata (ugh.dl.Metadata)14 MetadataTypeNotAllowedException (ugh.exceptions.MetadataTypeNotAllowedException)10 Corporate (ugh.dl.Corporate)9 MetadataGroup (ugh.dl.MetadataGroup)9 MetadataType (ugh.dl.MetadataType)9 DocStruct (ugh.dl.DocStruct)7 NamePart (ugh.dl.NamePart)5 DocStructHasNoTypeException (ugh.exceptions.DocStructHasNoTypeException)5 ArrayList (java.util.ArrayList)4 IncompletePersonObjectException (ugh.exceptions.IncompletePersonObjectException)4 DocStructType (ugh.dl.DocStructType)3 UghHelperException (de.sub.goobi.helper.exceptions.UghHelperException)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 MetadataGroupType (ugh.dl.MetadataGroupType)2 PreferencesException (ugh.exceptions.PreferencesException)2 TypeNotAllowedAsChildException (ugh.exceptions.TypeNotAllowedAsChildException)2