org.metafacture.linkeddata.OreAggregationAdder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metafacture-linkeddata Show documentation
Show all versions of metafacture-linkeddata Show documentation
Modules for working with linked data formats
The newest version!
/*
* Copyright 2013, 2014 Deutsche Nationalbibliothek
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.metafacture.linkeddata;
import org.metafacture.commons.ResourceUtil;
import org.metafacture.commons.types.ListMap;
import org.metafacture.framework.FluxCommand;
import org.metafacture.framework.MetafactureException;
import org.metafacture.framework.StreamReceiver;
import org.metafacture.framework.annotations.Description;
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
import org.metafacture.framework.helpers.DefaultStreamPipe;
import java.io.IOException;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.regex.Pattern;
/**
* Adds ore:Aggregation to an Europeana Data Model stream. The aggregation id is
* set by emitting literal('aggregation_id', id).
*
* @author Markus Michael Geipel
*
*/
@Description("adds ore:Aggregation to an Europeana Data Model stream. The aggregation id is set by emitting literal('aggregation_id', id)")
@In(StreamReceiver.class)
@Out(StreamReceiver.class)
@FluxCommand("add-oreaggregation")
public final class OreAggregationAdder extends DefaultStreamPipe {
private static final String RDF_ABOUT = "~rdf:about";
private static final ListMap AGGREGATED_ENTITIES = new ListMap();
private static final String ORE_AGGREGATION_PROPERTIES = "ore-aggregation.properties";
private static final String ORE_AGGREGATION = "ore:Aggregation";
private static final String AGGREGATION_ID = "aggregation_id";
private static final String RDF_REFERENCE = "~rdf:resource";
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s*,\\s*");
private final Deque entityStack = new LinkedList();
private final ListMap aggregation = new ListMap();
private String aggregationId;
static {
final Properties properties;
try {
properties = ResourceUtil.loadProperties(ORE_AGGREGATION_PROPERTIES);
}
catch (final IOException e) {
throw new MetafactureException("Failed to load properties", e);
}
for (final Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy