http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/ResourceFilter.java ---------------------------------------------------------------------- diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/ResourceFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/ResourceFilter.java deleted file mode 100644 index eacadcf..0000000 --- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/ResourceFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.marmotta.commons.sesame.filter.resource; - -import org.apache.marmotta.commons.sesame.filter.SesameFilter; -import org.openrdf.model.Resource; - -/** - * A common interface for enhancement filters on resources. Specifies a single method, "accept", which should - * return false in case the filter does not accept the resource passed as argument. - * <p/> - * Note that enhancement filters should only implement methods that are not expensive to compute, since they will be - * evaluated when the transaction commits and before adding a resource to the enhancement queue. - * <p/> - * Author: Sebastian Schaffert - */ -public interface ResourceFilter extends SesameFilter<Resource> { - -}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriPrefixFilter.java ---------------------------------------------------------------------- diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriPrefixFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriPrefixFilter.java deleted file mode 100644 index fb54a8d..0000000 --- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriPrefixFilter.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.marmotta.commons.sesame.filter.resource; - -import org.openrdf.model.Resource; -import org.openrdf.model.URI; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * A filter only accepting resources starting with a given prefix. - * <p/> - * Author: Sebastian Schaffert - */ -public class UriPrefixFilter implements ResourceFilter { - - - private Set<String> prefixes; - - public UriPrefixFilter(String... prefixes) { - this(new HashSet<String>(Arrays.asList(prefixes))); - } - - public UriPrefixFilter(Set<String> prefixes) { - this.prefixes = prefixes; - } - - public Set<String> getPrefixes() { - return prefixes; - } - - /** - * Return false in case the filter does not accept the resource passed as argument, true otherwise. - * - * - * @param resource - * @return - */ - @Override - public boolean accept(Resource resource) { - if(! (resource instanceof URI)) { - return false; - } - - URI uri = (URI) resource; - - for(String prefix : prefixes) { - if(uri.stringValue().startsWith(prefix)) { - return true; - } - } - - - return false; - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java ---------------------------------------------------------------------- diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java deleted file mode 100644 index c965916..0000000 --- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.marmotta.commons.sesame.filter.resource; - -import org.openrdf.model.Resource; -import org.openrdf.model.URI; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.regex.Pattern; - -/** - * A filter only accepting URI resources where the URI matches one of the configured patterns. - * <p/> - * Author: Sebastian Schaffert - */ -public class UriRegexFilter implements ResourceFilter { - - private Set<Pattern> patterns; - - - public UriRegexFilter(Collection<String> regexps) { - patterns = new HashSet<Pattern>(); - - for(String s : regexps) { - Pattern p = Pattern.compile(s); - patterns.add(p); - } - - } - - /** - * Return false in case the filter does not accept the resource passed as argument, true otherwise. - * - * - * @param resource - * @return - */ - @Override - public boolean accept(Resource resource) { - if(! (resource instanceof URI)) { - return false; - } - - URI uri = (URI) resource; - - for(Pattern p : patterns) { - if(p.matcher(uri.stringValue()).matches()) { - return true; - } - } - - - return false; - } -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java ---------------------------------------------------------------------- diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java deleted file mode 100644 index 3969e73..0000000 --- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.marmotta.commons.sesame.filter.statement; - -import org.apache.marmotta.commons.sesame.filter.SesameFilter; -import org.openrdf.model.Statement; - -/** - * Add file description here! - * <p/> - * Author: Sebastian Schaffert ([email protected]) - */ -public interface StatementFilter extends SesameFilter<Statement> { -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/pom.xml ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/pom.xml b/commons/sesame-tools-facading/pom.xml deleted file mode 100644 index e877efa..0000000 --- a/commons/sesame-tools-facading/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.marmotta</groupId> - <artifactId>marmotta-parent</artifactId> - <version>3.2.0-SNAPSHOT</version> - <relativePath>../../parent</relativePath> - </parent> - - <artifactId>sesame-tools-facading</artifactId> - <name>Sesame Tools: Facading</name> - <description> - Allows using annotated Java interfaces (facades) to access an underlying - Sesame repository, similar to JPA. - </description> - - <dependencies> - <dependency> - <groupId>org.apache.marmotta</groupId> - <artifactId>marmotta-commons</artifactId> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-model</artifactId> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-repository-api</artifactId> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-query</artifactId> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-queryparser-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-queryparser-sparql</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-queryalgebra-model</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-queryalgebra-evaluation</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-sail-memory</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-repository-sail</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-rio-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-rio-rdfxml</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.marmotta</groupId> - <artifactId>kiwi-triplestore</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/FacadingFactory.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/FacadingFactory.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/FacadingFactory.java deleted file mode 100644 index 772a398..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/FacadingFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading; - -import org.apache.marmotta.commons.sesame.facading.api.Facading; -import org.apache.marmotta.commons.sesame.facading.impl.FacadingImpl; -import org.openrdf.repository.RepositoryConnection; - -/** - * A factory to simplify the creation of facading services. - * <p/> - * Author: Sebastian Schaffert - */ -public class FacadingFactory { - - /** - * Create a facading for an existing repository connection. - * - * @param connection the repository connection to use for facading - * @return a new facading service wrapping the given connection - */ - public static Facading createFacading(RepositoryConnection connection) { - return new FacadingImpl(connection); - } - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDF.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDF.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDF.java deleted file mode 100644 index 33b7b2a..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDF.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * This annotation indicates that a certain field should be - * persisted to the KiWi triple store using the property URI - * passed as annotation parameter.<br> - * The TripleStore class checks for <b>RDF</b> annotations - * during persist and load. <br> - * Classes using this annotation must currently implement the - * {@link org.apache.marmotta.platform.core.model.rdf.KiWiEntity} interface, so that the - * KnowledgeSpace has access to the resource associated with the - * entity.<br> - * This is a runtime annotation and it is applicable on fields - * and on getter methods.<br> - * - * @author Sebastian Schaffert - * @see org.apache.marmotta.platform.core.model.rdf.KiWiEntity - */ - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.FIELD, ElementType.METHOD}) -public @interface RDF { - - /** - * Return the URI of the RDF predicate to use for the field - * or method. - * - * @returns URI of the RDF predicate to use for the field or - * method. - */ - String[] value(); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFContext.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFContext.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFContext.java deleted file mode 100644 index 15c5d76..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFContext.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation indicates that a certain interface should be - * persisted to the KiWi triple store using the context uri and type - * for the default context for all implementations of this class.<br> - * - * @author Stefan Robert - */ -@Retention(RetentionPolicy.RUNTIME) -@Target( { ElementType.TYPE } ) -public @interface RDFContext { - - String value(); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFFilter.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFFilter.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFFilter.java deleted file mode 100644 index 95542b8..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Specifies a filter for facades that selects the content items that may be facaded based on the - * type of the content item. Only of a content item satisfies all types specified here is it accepted in - * a result set. - * - * @author Sebastian Schaffert - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target( { ElementType.TYPE } ) -public @interface RDFFilter { - /** - * The URI of the RDF type to use for the class - * @return - */ - String[] value(); - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFInverse.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFInverse.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFInverse.java deleted file mode 100644 index 25e7fc5..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFInverse.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation indicates that a certain KiWi facade field should be mapped - * inversely to a property in the triple store. It is the inverse of the - * <code>@RDF</code> annotation, e.g. when using - * <code>@RDFInverse("rdfs:subClassOf")</code>, the annotated method returns the - * subclasses, while the annotation <code>@RDF("rdfs:subClassOf")</code> would - * return the superclasses. Note that <code>@RDFInverse</code> only works on - * ObjectProperties; for all other properties it behaves exactly like - * <code>@RDF</code> - * <p> - * The KiWiEntityManager and TripleStore check for the presence of this - * annotation on methods and dynamically maps them to queries on the triple - * store, using the resource of the annotated interface or class (which must - * implement KiWiEntity to provide a getResource() method) as object. - * <p> - * This is a runtime annotation and it is applicable on getter methods.<br> - * <p> - * TODO: currently, only KiWiFacades are supported; also, it is currently not - * possible to provide {@link @RDF} and {@link @RDFInverse} on the same method - * at the same time. - * - * @author Sebastian Schaffert - */ - -@Retention(RetentionPolicy.RUNTIME) -@Target( {ElementType.METHOD}) -public @interface RDFInverse { - - /** - * Return the URI of the RDF predicate to use for the field - * or method. - * - * @returns URI of the RDF predicate to use for the field or - * method. - */ - String[] value(); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFPropertyBuilder.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFPropertyBuilder.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFPropertyBuilder.java deleted file mode 100644 index 47688a3..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFPropertyBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.apache.marmotta.commons.sesame.facading.api.FacadingPredicateBuilder; - -/** - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface RDFPropertyBuilder { - - Class<? extends FacadingPredicateBuilder> value(); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFType.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFType.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFType.java deleted file mode 100644 index 215f3a1..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/annotations/RDFType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * This annotation specifies the RDF-type of an object-class - * - * @author Stephanie Stroka - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target( { ElementType.TYPE } ) -public @interface RDFType { - /** - * The URI of the RDF type to use for the class - * @return - */ - String[] value(); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/Facading.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/Facading.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/Facading.java deleted file mode 100644 index dc9334b..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/Facading.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.api; - -import org.apache.marmotta.commons.sesame.facading.model.Facade; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; - -import java.util.Collection; - -/** - * Offers methods for loading and proxying KiWiFacades. A KiWi Facade is an interface that defines a Java - * object with convenient Java methods around a KiWiResource and makes it possible to use RDF properties like - * Java Bean properties from inside Java. - * <p/> - * The facading service is used by many other services, e.g. ContentItemService and TaggingService, to provide - * access on a higher level than raw RDF resources. - * - * - * <p/> - * User: sschaffe - */ -public interface Facading { - - /** - * Create an instance of C that facades the resource given as argument using the @RDF annotations provided - * to the getter or setter methods of Cto map to properties of the resource in the triple store. - * - * - * @param r the resource to facade - * @param type the facade type as a class - * @return - */ - public <C extends Facade> C createFacade(Resource r, Class<C> type); - - /** - * Create an instance of C that facades the resource given as argument using the @RDF annotations provided - * to the getter or setter methods of Cto map to properties of the resource in the triple store. - * Additionally, it puts the facade into the given context. - * This is useful if the @RDFContext annotation for Facades is not applicable. - * E.g. if the context is dynamically generated. - * - * - * @param r the resource to facade - * @param type the facade type as a class - * @param context the context into which the facade should be put - * @return - */ - public <C extends Facade> C createFacade(Resource r, Class<C> type, URI context); - - /** - * Create a collection of instances of C that facade the resources given in the collection passed as argument. - * The facade uses the @RDF annotations provided to the getter or setter methods of C. The returned collection - * is of the same kind as the passed collection. - * - * - * @param list the collection containing the resources to facade - * @param type the facade type as a class - * @return - */ - public <C extends Facade> Collection<C> createFacade(Collection<? extends Resource> list, Class<C> type); - - /** - * Create an instance of C that facades the resource identified by the uri given as argument, using the @RDF - * annotations provided to the getter or setter methods of C to map to properties of the resource in the triple - * store. - * - * @param uri the uri of the resource to facade - * @param type the facade type as a class - * @param <C> the facade type as a generic parameter - * @return - */ - public <C extends Facade> C createFacade(String uri, Class<C> type); - - /** - * Check whether the resource fits into the facade. - * - * - * @param r the resource to check - * @param type the facade to check for - * @param context limit all checks to this context - * @return <code>true</code> if the resource <code>r</code> fulfills all {@link org.apache.marmotta.commons.sesame.facading.annotations.RDFType} and - * {@link org.apache.marmotta.commons.sesame.facading.annotations.RDFFilter} requirements of <code>type</code> - */ - public <C extends Facade> boolean isFacadeable(Resource r, Class<C> type, URI context); - - /** - * Check whether the resource fits into the facade. - * - * - * @param r the resource to check - * @param type the facade to check for - * @return <code>true</code> if the resource <code>r</code> fulfills all {@link org.apache.marmotta.commons.sesame.facading.annotations.RDFType} and - * {@link org.apache.marmotta.commons.sesame.facading.annotations.RDFFilter} requirements of <code>type</code> - */ - public <C extends Facade> boolean isFacadeable(Resource r, Class<C> type); - - /** - * Create a collection of instances of C that facade the resources given in the collection passed as argument. - * The facade uses the {@link org.apache.marmotta.commons.sesame.facading.annotations.RDF} annotations provided to the getter or setter methods of C. The returned collection - * is of the same kind as the passed collection. - * - * - * @param list the collection containing the resources to facade - * @param type the facade type as a class - * @return - */ - <C extends Facade> Collection<C> createFacade(Collection<? extends Resource> list, Class<C> type, URI context); -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/FacadingPredicateBuilder.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/FacadingPredicateBuilder.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/FacadingPredicateBuilder.java deleted file mode 100644 index bf29a4a..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/api/FacadingPredicateBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.api; - - -import java.lang.reflect.Method; - -import org.apache.marmotta.commons.sesame.facading.impl.FacadingPredicate; -import org.apache.marmotta.commons.sesame.facading.model.Facade; - -/** - * Dynamically create the RDF-property uri for facading. - * <p> - * <strong>NOTE: All implementations MUST provide either a public no-arg Constructor or a public - * static no-arg <code>getInstance()</code>-method!</strong> - * <p> - * - */ -public interface FacadingPredicateBuilder { - - public FacadingPredicate getFacadingPredicate(String fieldName, Class<? extends Facade> facade, Method method); - -} http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingImpl.java ---------------------------------------------------------------------- diff --git a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingImpl.java b/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingImpl.java deleted file mode 100644 index 8cfba98..0000000 --- a/commons/sesame-tools-facading/src/main/java/org/apache/marmotta/commons/sesame/facading/impl/FacadingImpl.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.marmotta.commons.sesame.facading.impl; - -import java.lang.reflect.Proxy; -import java.util.Collection; -import java.util.LinkedList; - -import org.apache.marmotta.commons.sesame.facading.annotations.RDF; -import org.apache.marmotta.commons.sesame.facading.annotations.RDFContext; -import org.apache.marmotta.commons.sesame.facading.annotations.RDFFilter; -import org.apache.marmotta.commons.sesame.facading.annotations.RDFType; -import org.apache.marmotta.commons.sesame.facading.api.Facading; -import org.apache.marmotta.commons.sesame.facading.model.Facade; -import org.apache.marmotta.commons.sesame.facading.util.FacadeUtils; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.RepositoryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Offers methods for loading and proxying Facades. A {@link Facade} is an interface that defines a - * Java object with convenient Java methods around a {@link Resource} and makes it possible to use RDF - * properties like Java Bean properties from inside Java. - * <p/> - * The facading service is to provide access on a higher level than raw RDF resources. - * <p/> - * @author Sebastian Schaffert <[email protected]> - * @author Jakob Frank <[email protected]> - */ -public class FacadingImpl implements Facading { - - private static final URI RDF_TYPE = org.openrdf.model.vocabulary.RDF.TYPE; - - - private static Logger log = LoggerFactory.getLogger(FacadingImpl.class); - - - private final RepositoryConnection connection; - - - public FacadingImpl(RepositoryConnection connection) { - this.connection = connection; - } - - /** - * Create an instance of {@code C} that facades the resource given as argument using the {@link RDF} annotations provided - * to the getter or setter methods of {@code C} to map to properties of the resource in the triple store. - * - * - * @param r the resource to facade - * @param type the facade type as a class - * @return a facading proxy of type {@code C} - */ - @Override - public <C extends Facade> C createFacade(Resource r, Class<C> type) { - // support @RDFContext annotation in facade - URI context = null; - if(FacadeUtils.isFacadeAnnotationPresent(type, RDFContext.class)) { - String s_context = FacadeUtils.getFacadeAnnotation(type,RDFContext.class).value(); - context = connection.getValueFactory().createURI(s_context); - log.debug("applying context {} for facade {} of {}", context, type.getSimpleName(), r); - } - return createFacade(r, type, context); - } - - /** - * Create an instance of {@code C} that facades the resource given as argument using the {@link RDF} annotations provided - * to the getter or setter methods of {@code C} to map to properties of the resource in the triple store. - * Additionally, it puts the facade into the given context, a present {@link RDFContext} annotation is ignored. - * This is useful if the {@link RDFContext} annotation for Facades is not applicable, - * e.g. if the context is dynamically generated. - * - * @param r the resource to facade - * @param type the facade type as a class - * @param context the context of the facade - * @return a facading proxy of type {@code C} - */ - @Override - public <C extends Facade> C createFacade(Resource r, Class<C> type, URI context) { - if(r == null) { - log.trace("null facade for null resouce"); - return null; - } else - // if the interface is a Facade, we execute the query and then - // create an invocation handler for each result to create proxy objects - if(type.isInterface() && FacadeUtils.isFacade(type)) { - try { - // support @RDFType annotation in facade - if(FacadeUtils.isFacadeAnnotationPresent(type, RDFType.class)) { - if (!connection.isOpen()) { throw new IllegalStateException("the connection is already closed, cannot access triple-store."); } - if (!connection.isActive()) { throw new IllegalStateException("no active transaction, cannot access triple-store."); } - - String[] a_type = FacadeUtils.getFacadeAnnotation(type, RDFType.class).value(); - for(String s_type : a_type) { - final URI r_type = connection.getValueFactory().createURI(s_type); - connection.add(r, RDF_TYPE, r_type, context); - log.trace("added type {} to {} because of RDFType-Annotation", r_type, r); - if(!connection.hasStatement(r, RDF_TYPE, r_type,true,context)) { - log.error("error adding type for facade!"); - } - } - } - - FacadingInvocationHandler handler = new FacadingInvocationHandler(r, context, type, this, connection); - if (log.isDebugEnabled()) { - if (context != null) { - log.debug("New Facading: {} delegating to {} (@{})", type.getSimpleName(), r, context); - } else { - log.debug("New Facading: {} delegating to {}", type.getSimpleName(), r); - } - } - return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler)); - } catch (RepositoryException e) { - log.error("error while accessing triple store", e); - return null; - } - } else { - throw new IllegalArgumentException("interface passed as parameter is not a Facade (" + type.getCanonicalName() + ")"); - } - } - - /** - * Create a collection of instances of C that facade the resources given in the collection passed as argument. - * The facade uses the {@link RDF} annotations provided to the getter or setter methods of C. The returned collection - * is of the same kind as the passed collection. - * - * - * @param list the collection containing the resources to facade - * @param type the facade type as a class - * @return - */ - @Override - public <C extends Facade> Collection<C> createFacade(Collection<? extends Resource> list, Class<C> type) { - URI context = null; - if(FacadeUtils.isFacadeAnnotationPresent(type, RDFContext.class)) { - String s_context = FacadeUtils.getFacadeAnnotation(type,RDFContext.class).value(); - context = connection.getValueFactory().createURI(s_context); - log.debug("applying context {} for facade {} of {}", context, type.getSimpleName(), list); - } - return createFacade(list, type, context); - } - - /** - * Create a collection of instances of C that facade the resources given in the collection passed as argument. - * The facade uses the {@link RDF} annotations provided to the getter or setter methods of C. The returned collection - * is of the same kind as the passed collection. - * - * - * @param list the collection containing the resources to facade - * @param type the facade type as a class - * @return - */ - @Override - public <C extends Facade> Collection<C> createFacade(Collection<? extends Resource> list, Class<C> type, URI context) { - log.trace("createFacadeList: creating {} facade over {} content items",type.getName(),list.size()); - LinkedList<C> result = new LinkedList<C>(); - if(type.isAnnotationPresent(RDFFilter.class)) { - try { - if (!connection.isOpen()) { throw new IllegalStateException("the connection is already closed, cannot access triple-store."); } - if (!connection.isActive()) { throw new IllegalStateException("no active transaction, cannot access triple-store."); } - - // if the RDFType annotation is present, filter out content items that are of the wrong type - LinkedList<URI> acceptable_types = new LinkedList<URI>(); - if(FacadeUtils.isFacadeAnnotationPresent(type,RDFFilter.class)) { - String[] a_type = FacadeUtils.getFacadeAnnotation(type,RDFFilter.class).value(); - for(String s_type : a_type) { - URI r_type = connection.getValueFactory().createURI(s_type); - acceptable_types.add(r_type); - } - } - - // add facades for all content items to the result list - for(Resource item : list) { - boolean accept = acceptable_types.size() == 0; // true for empty filter - for(URI rdf_type : acceptable_types) { - if(connection.hasStatement(item, RDF_TYPE, rdf_type, true)) { - accept = true; - log.trace("accepting resource {} because type matches ({})",item.toString(),rdf_type.stringValue()); - break; - } - } - if(accept) { - result.add(createFacade(item,type,context)); - } - } - log.debug("createFacadeList: filtered {} content items because they did not match the necessary criteria",list.size()-result.size()); - } catch (RepositoryException ex) { - log.error("error while accessing RDF repository",ex); - } - } else { - // add facades for all content items to the result list - for(Resource item : list) { - result.add(createFacade(item,type,context)); - } - } - return result; - } - - - /** - * Create an instance of C that facades the resource identified by the uri given as argument, using the {@link RDF} - * annotations provided to the getter or setter methods of C to map to properties of the resource in the triple - * store. - * - * @param uri the uri of the resource to facade - * @param type the facade type as a class - * @param <C> the facade type as a generic parameter - * @return - */ - @Override - public <C extends Facade> C createFacade(String uri, Class<C> type) { - return createFacade(connection.getValueFactory().createURI(uri), type); - } - - /** - * Check whether the resource fits into the facade. - * - * - * @param r the resource to check - * @param type the facade to check for - * @return <code>true</code> if the resource <code>r</code> fulfills all {@link RDFType} and - * {@link RDFFilter} requirements of <code>type</code> - */ - @Override - public <C extends Facade> boolean isFacadeable(Resource r, Class<C> type) { - return isFacadeable(r, type, null); - } - - /** - * Check whether the resource fits into the facade. - * - * - * @param r the resource to check - * @param type the facade to check for - * @param context limit all checks to this context - * @return <code>true</code> if the resource <code>r</code> fulfills all {@link RDFType} and - * {@link RDFFilter} requirements of <code>type</code> - */ - @Override - public <C extends Facade> boolean isFacadeable(Resource r, Class<C> type, URI context) { - if (FacadeUtils.isFacadeAnnotationPresent(type, RDFType.class)) { - try { - if (!connection.isOpen()) { throw new IllegalStateException("the connection is already closed, cannot access triple store."); } - if (!connection.isActive()) { throw new IllegalStateException("no active transaction, cannot access triple-store."); } - - String[] rdfTypes = FacadeUtils.getFacadeAnnotation(type, RDFType.class).value(); - boolean facadeable = true; - for (String s_type : rdfTypes) { - if(context != null) { - facadeable &= connection.hasStatement(r, RDF_TYPE, connection.getValueFactory().createURI(s_type), true, context); - } else { - facadeable &= connection.hasStatement(r, RDF_TYPE, connection.getValueFactory().createURI(s_type), true); - } - } - // also check for @RDFFilter - if (FacadeUtils.isFacadeAnnotationPresent(type, RDFFilter.class)) { - String[] filterTypes = FacadeUtils.getFacadeAnnotation(type, RDFFilter.class).value(); - for (String s_type : filterTypes) { - if(context != null) { - facadeable &= connection.hasStatement(r, RDF_TYPE, connection.getValueFactory().createURI(s_type), true, context); - } else { - facadeable &= connection.hasStatement(r, RDF_TYPE, connection.getValueFactory().createURI(s_type), true); - } - } - } - return facadeable; - } catch(RepositoryException ex) { - log.error("error while accessing RDF repository",ex); - } - } - return false; - } -}
