/**
* This file is part of d:swarm graph extension.
*
* d:swarm graph extension is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* d:swarm graph extension is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with d:swarm graph extension. If not, see <http://www.gnu.org/licenses/>.
*/
package org.dswarm.graph.batch;
import java.util.Map;
import java.util.Optional;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.dswarm.graph.DMPGraphException;
import org.dswarm.graph.hash.HashUtils;
import org.dswarm.graph.model.GraphStatics;
/**
* @author tgaengler
*/
public class SimpleNeo4jProcessor extends BatchNeo4jProcessor {
private static final Logger LOG = LoggerFactory.getLogger(SimpleNeo4jProcessor.class);
public SimpleNeo4jProcessor(final BatchInserter inserter) throws DMPGraphException {
super(inserter);
}
@Override
public void addObjectToResourceWDataModelIndex(final long nodeId, final String URI, final Optional<String> optionalDataModelURI) {
if (optionalDataModelURI.isPresent()) {
addToResourcesWDataModelIndex(URI + optionalDataModelURI.get(), nodeId);
}
}
@Override
public void handleObjectDataModel(final Map<String, Object> objectNodeProperties, final Optional<String> optionalDataModelURI) {
if (optionalDataModelURI.isPresent()) {
objectNodeProperties.put(GraphStatics.DATA_MODEL_PROPERTY, optionalDataModelURI.get());
}
}
@Override
public void handleSubjectDataModel(final Map<String, Object> subjectNodeProperties, final String URI,
final Optional<String> optionalDataModelURI) {
if (optionalDataModelURI.isPresent()) {
subjectNodeProperties.put(GraphStatics.DATA_MODEL_PROPERTY, optionalDataModelURI.get());
}
}
@Override
public Optional<Long> getResourceNodeHits(final String resourceURI) {
return getNodeIdFromResourcesIndex(resourceURI);
}
@Override
public long generateResourceHash(final String resourceURI, final Optional<String> dataModelURI) {
final String hashString = resourceURI;
return HashUtils.generateHash(hashString);
}
@Override
protected String putSaltToStatementHash(final String hash) {
return hash;
}
}