001/** 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.kernel.impl.rdf.impl; 017 018import static com.hp.hpl.jena.graph.Triple.create; 019import static com.hp.hpl.jena.vocabulary.RDF.type; 020import static org.fcrepo.kernel.FedoraJcrTypes.FEDORA_CONTAINER; 021import static org.fcrepo.kernel.RdfLexicon.BASIC_CONTAINER; 022import static org.fcrepo.kernel.RdfLexicon.CONTAINER; 023import static org.fcrepo.kernel.RdfLexicon.RDF_SOURCE; 024 025import org.fcrepo.kernel.identifiers.IdentifierConverter; 026import org.fcrepo.kernel.models.Container; 027import org.fcrepo.kernel.models.FedoraResource; 028 029import com.hp.hpl.jena.graph.Triple; 030import com.hp.hpl.jena.rdf.model.Resource; 031 032/** 033 * @author cabeer 034 * @since 9/16/14 035 */ 036public class LdpRdfContext extends NodeRdfContext { 037 038 039 /** 040 * Default constructor. 041 * 042 * @param resource the resource 043 * @param idTranslator the id translator 044 */ 045 public LdpRdfContext(final FedoraResource resource, 046 final IdentifierConverter<Resource, FedoraResource> idTranslator) { 047 super(resource, idTranslator); 048 049 concat(typeContext()); 050 051 if (resource instanceof Container) { 052 concat(containerContext()); 053 054 if (!resource.hasType(FEDORA_CONTAINER)) { 055 concat(defaultContainerContext()); 056 } 057 } 058 059 } 060 061 private Triple typeContext() { 062 return create(subject(), type.asNode(), RDF_SOURCE.asNode()); 063 } 064 065 private Triple containerContext() { 066 return create(subject(), type.asNode(), CONTAINER.asNode()); 067 } 068 069 private Triple defaultContainerContext() { 070 return create(subject(), type.asNode(), BASIC_CONTAINER.asNode()); 071 } 072}