Search in sources :

Example 1 with ConfigOpacDoctype

use of de.unigoettingen.sub.search.opac.ConfigOpacDoctype in project goobi-workflow by intranda.

the class ProzesskopieForm method createNewFileformat.

/* =============================================================== */
private void createNewFileformat() throws TypeNotAllowedForParentException, TypeNotAllowedAsChildException {
    Prefs myPrefs = this.prozessKopie.getRegelsatz().getPreferences();
    try {
        DigitalDocument dd = new DigitalDocument();
        Fileformat ff = new XStream(myPrefs);
        ff.setDigitalDocument(dd);
        /* BoundBook hinzufügen */
        DocStructType dst = myPrefs.getDocStrctTypeByName("BoundBook");
        DocStruct dsBoundBook = dd.createDocStruct(dst);
        dd.setPhysicalDocStruct(dsBoundBook);
        ConfigOpacDoctype configOpacDoctype = co.getDoctypeByName(this.docType);
        /* Monographie */
        if (!configOpacDoctype.isPeriodical() && !configOpacDoctype.isMultiVolume()) {
            DocStructType dsty = myPrefs.getDocStrctTypeByName(configOpacDoctype.getRulesetType());
            DocStruct ds = dd.createDocStruct(dsty);
            dd.setLogicalDocStruct(ds);
            this.myRdf = ff;
        } else /* periodica */
        if (configOpacDoctype.isPeriodical() || configOpacDoctype.isMultiVolume()) {
            DocStructType anchor = myPrefs.getDocStrctTypeByName(configOpacDoctype.getRulesetType());
            DocStruct ds = dd.createDocStruct(anchor);
            dd.setLogicalDocStruct(ds);
            DocStructType dstyvolume = myPrefs.getDocStrctTypeByName(configOpacDoctype.getRulesetChildType());
            DocStruct dsvolume = dd.createDocStruct(dstyvolume);
            ds.addChild(dsvolume);
            this.myRdf = ff;
        }
    // } catch (TypeNotAllowedForParentException e) {
    // log.error(e);
    // } catch (TypeNotAllowedAsChildException e) {
    // log.error(e);
    } catch (PreferencesException e) {
        log.error(e);
    }
}
Also used : XStream(ugh.fileformats.mets.XStream) DocStructType(ugh.dl.DocStructType) Fileformat(ugh.dl.Fileformat) Prefs(ugh.dl.Prefs) DigitalDocument(ugh.dl.DigitalDocument) PreferencesException(ugh.exceptions.PreferencesException) DocStruct(ugh.dl.DocStruct) ConfigOpacDoctype(de.unigoettingen.sub.search.opac.ConfigOpacDoctype)

Example 2 with ConfigOpacDoctype

use of de.unigoettingen.sub.search.opac.ConfigOpacDoctype in project kitodo-production by kitodo.

the class NewspaperProcessesGenerator method initializeTitleGenerator.

/**
 * Initializes the title generator.
 *
 * @param configProject
 *            the config project
 * @param allowedMetadata
 *            allowed Metadata views
 * @return the initialized title generator
 */
private static TitleGenerator initializeTitleGenerator(ConfigProject configProject, Workpiece workpiece, Collection<MetadataViewInterface> allowedMetadata) throws DoctypeMissingException {
    LogicalDivision logicalStructure = workpiece.getLogicalStructure();
    Map<String, Map<String, String>> metadata = new HashMap<>(4);
    Map<String, String> topstruct = getMetadataEntries(logicalStructure.getMetadata());
    metadata.put("topstruct", topstruct);
    List<LogicalDivision> children = logicalStructure.getChildren();
    metadata.put("firstchild", children.isEmpty() ? Collections.emptyMap() : getMetadataEntries(children.get(0).getMetadata()));
    metadata.put("physSequence", getMetadataEntries(workpiece.getPhysicalStructure().getMetadata()));
    String docType = null;
    for (ConfigOpacDoctype configOpacDoctype : ConfigOpac.getAllDoctypes()) {
        if (configOpacDoctype.getRulesetType().equals(logicalStructure.getType())) {
            docType = configOpacDoctype.getTitle();
            break;
        }
    }
    List<AdditionalField> projectAdditionalFields = configProject.getAdditionalFields();
    ProcessFieldedMetadata table = new ProcessFieldedMetadata();
    for (AdditionalField additionalField : projectAdditionalFields) {
        if (isDocTypeAndNotIsNotDoctype(additionalField, docType)) {
            String value = metadata.getOrDefault(additionalField.getDocStruct(), Collections.emptyMap()).get(additionalField.getMetadata());
            List<MetadataViewInterface> filteredViews = allowedMetadata.stream().filter(v -> v.getId().equals(additionalField.getMetadata())).collect(Collectors.toList());
            if (!filteredViews.isEmpty()) {
                MetadataEntry metadataEntry = new MetadataEntry();
                metadataEntry.setValue(value);
                if (filteredViews.get(0).isComplex()) {
                    table.createMetadataGroupPanel((ComplexMetadataViewInterface) filteredViews.get(0), Collections.singletonList(metadataEntry));
                } else {
                    table.createMetadataEntryEdit((SimpleMetadataViewInterface) filteredViews.get(0), Collections.singletonList(metadataEntry));
                }
            }
        }
    }
    return new TitleGenerator(topstruct.getOrDefault("TSL_ATS", ""), table.getRows());
}
Also used : RulesetManagementInterface(org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface) LanguageRange(java.util.Locale.LanguageRange) MetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface) Metadata(org.kitodo.api.Metadata) Process(org.kitodo.data.database.beans.Process) AdditionalField(org.kitodo.production.process.field.AdditionalField) Map(java.util.Map) MetsService(org.kitodo.production.services.dataformat.MetsService) URI(java.net.URI) DataException(org.kitodo.data.exceptions.DataException) FileService(org.kitodo.production.services.file.FileService) DAOException(org.kitodo.data.database.exceptions.DAOException) ConfigProject(org.kitodo.config.ConfigProject) MetadataEditor(org.kitodo.production.metadata.MetadataEditor) ProcessFieldedMetadata(org.kitodo.production.forms.createprocess.ProcessFieldedMetadata) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) MetadataViewWithValuesInterface(org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewWithValuesInterface) ConfigOpac(de.unigoettingen.sub.search.opac.ConfigOpac) Objects(java.util.Objects) List(java.util.List) Logger(org.apache.logging.log4j.Logger) LocalDate(java.time.LocalDate) Optional(java.util.Optional) ConfigOpacDoctype(de.unigoettingen.sub.search.opac.ConfigOpacDoctype) FunctionalMetadata(org.kitodo.api.dataeditor.rulesetmanagement.FunctionalMetadata) HashMap(java.util.HashMap) Helper(org.kitodo.production.helper.Helper) ProcessService(org.kitodo.production.services.data.ProcessService) ConfigurationException(javax.naming.ConfigurationException) DoctypeMissingException(org.kitodo.exceptions.DoctypeMissingException) SimpleMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface) LinkedMetsResource(org.kitodo.api.dataformat.mets.LinkedMetsResource) ArrayList(java.util.ArrayList) CommandException(org.kitodo.exceptions.CommandException) RulesetService(org.kitodo.production.services.data.RulesetService) IndividualIssue(org.kitodo.production.model.bibliography.course.IndividualIssue) ServiceManager(org.kitodo.production.services.ServiceManager) MonthDay(java.time.MonthDay) StructuralElementViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface) Workpiece(org.kitodo.api.dataformat.Workpiece) IOException(java.io.IOException) TimeUnit(java.util.concurrent.TimeUnit) ProcessGenerationException(org.kitodo.exceptions.ProcessGenerationException) DateTimeFormatter(java.time.format.DateTimeFormatter) ComplexMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.ComplexMetadataViewInterface) DatesSimpleMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.DatesSimpleMetadataViewInterface) MetadataEntry(org.kitodo.api.MetadataEntry) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) LogicalDivision(org.kitodo.api.dataformat.LogicalDivision) Course(org.kitodo.production.model.bibliography.course.Course) HashMap(java.util.HashMap) LogicalDivision(org.kitodo.api.dataformat.LogicalDivision) ConfigOpacDoctype(de.unigoettingen.sub.search.opac.ConfigOpacDoctype) AdditionalField(org.kitodo.production.process.field.AdditionalField) MetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface) SimpleMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface) ComplexMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.ComplexMetadataViewInterface) DatesSimpleMetadataViewInterface(org.kitodo.api.dataeditor.rulesetmanagement.DatesSimpleMetadataViewInterface) MetadataEntry(org.kitodo.api.MetadataEntry) Map(java.util.Map) HashMap(java.util.HashMap) ProcessFieldedMetadata(org.kitodo.production.forms.createprocess.ProcessFieldedMetadata)

Aggregations

ConfigOpacDoctype (de.unigoettingen.sub.search.opac.ConfigOpacDoctype)2 ConfigOpac (de.unigoettingen.sub.search.opac.ConfigOpac)1 IOException (java.io.IOException)1 URI (java.net.URI)1 LocalDate (java.time.LocalDate)1 MonthDay (java.time.MonthDay)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 LanguageRange (java.util.Locale.LanguageRange)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 ConfigurationException (javax.naming.ConfigurationException)1 LogManager (org.apache.logging.log4j.LogManager)1