diff --git a/.gitignore b/.gitignore index fd1fbcf..74caed0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,11 @@ .DS_Store -core/lib -jena/lib -sesame/lib build -dist out -settings/ivy-cache -settings/repo *.iml +*.iws +*.ipr .idea target + +gradle.properties +.gradle diff --git a/ACKNOWLEDGEMENTS.txt b/ACKNOWLEDGEMENTS.txt index 901e92d..2b425dc 100644 --- a/ACKNOWLEDGEMENTS.txt +++ b/ACKNOWLEDGEMENTS.txt @@ -7,9 +7,10 @@ Manuel Blechschmidt Ultan O'Carroll Laurent Bihanic Nicolas Delsaux -Adri‡n Quintana +Adrian Quintana Davide Sottara Laurent Bihanic +Fernando Hernandez Others who preferred not to be named: you know who you are. diff --git a/CHANGES.txt b/CHANGES.txt index bb82db6..8eacb31 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,8 +3,10 @@ Change Log Empire 0.9 (TBD) ======================= + * ADDED: Gradle build out + * ADDED: Open sourced Stardog bindings * FIXED: Resolved perm-gen leak (issue #86) - * MODIFIED: Upgraded to Sesame 2.7.12, Guava 17, CP Utils 3.1.1 & CP OpenRDF Utils 2.0.4 + * MODIFIED: Upgraded to Sesame 2.7.14, Guava 18, CP Utils 4.0 & CP OpenRDF Utils 3.0 Empire 0.8 (2013-09-30) ======================= diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ee8ddfa --- /dev/null +++ b/build.gradle @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2009-2010 Clark & Parsia, LLC. + * + * 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. + */ + + if (!project.hasProperty('stardogRepo')) { + throw new InvalidUserDataException("Url to Stardog repository is not defined." + + " Set up the property 'stardogRepo' in gradle.properties.") +} + +apply plugin: 'java' +apply plugin: 'idea' + +task wrapper(type: Wrapper) { + gradleVersion = '2.0' + distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" +} + +ext { + stardogVersion = "3.0" + projectVersion = "0.9.0" + projectDescription = "JPA implementation for RDF" + projectUrl = "https://github.com/mhgrove/Empire" +} + +allprojects { + group = "com.clarkparsia.empire" + version = projectVersion + sourceCompatibility = '1.6' + targetCompatibility = '1.6' + + repositories { + mavenCentral() + maven { + url stardogRepo + // todo: remove this once we go live + credentials { + username artifactoryUsername + password artifactoryPassword + } + } + } + + +} + +subprojects { + apply plugin: "java" + apply plugin: "maven" + + dependencies { + compile 'org.slf4j:slf4j-api:1.7.7' + compile 'org.slf4j:slf4j-jdk14:1.7.7' + + testCompile 'junit:junit:4.8.2' + } + + configurations { + // ignore + compile.dependencies.all { dep -> + if (dep instanceof ExternalModuleDependency + && (dep.group == 'org.openrdf.sesame' || dep.group == 'com.complexible.common')) { + dep.exclude group: "junit" + } + } + } + + sourceSets { + main { + java { + srcDir 'main/src' + } + resources { + srcDir 'main/resources' + } + } + test { + java { + srcDir 'test/src' + } + resources { + srcDir 'test/resources' + } + } + } + + // create a 'tests' conf for importing test classes from other sub-projects + task testJar(type: Jar, dependsOn: testClasses) { + classifier = 'tests' + from sourceSets.test.output + } + + artifacts { + testRuntime testJar // include the tests of other subprojects + } + + if (project.hasProperty('publishUrl') + && project.hasProperty('artifactoryUser') + && project.hasProperty('artifactoryPassword')) { + + // this task is just so artifactory picks up the pom changes + task('uploadMvn', type: Upload) { + configuration = configurations.archives + repositories { + mavenDeployer { + repository(url: publishUrl) + pom.project { + name = archivesBaseName + packaging = 'jar' + description projectDescription + url projectUrl + } + + //mess with the generated pom to remove test dependencies from published artifacts + pom.withXml { XmlProvider xmlProvider -> + def xml = xmlProvider.asString() + def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes)) + + pomXml.dependencies.dependency.each { dep -> + if (dep.scope.text() != 'compile') { + def parent = dep.parent() + parent.remove(dep) + } + } + + def newXml = new StringWriter() + def printer = new XmlNodePrinter(new PrintWriter(newXml)) + printer.preserveWhitespace = true + printer.print(pomXml) + xml.setLength(0) + xml.append(newXml.toString()) + } + + } + } + } + } +} + +evaluationDependsOnChildren() + +subprojects { + task javadocs(type: Javadoc) { + source sourceSets.main.allJava + classpath = configurations.compile + destinationDir = file("${rootProject.buildDir}/javadocs/${project.name}") + configure(options) { + windowTitle "${project.archivesBaseName}-${project.version} API" + docTitle "${project.archivesBaseName}-${project.version}" + bottom "Copyright © 2010-2015 Complexible. All Rights Reserved." + links "http://docs.oracle.com/javase/6/docs/api/", + "http://docs.guava-libraries.googlecode.com/git-history/v17.0/javadoc/" + } + } +} + + diff --git a/build.xml b/build.xml deleted file mode 100644 index 7103f30..0000000 --- a/build.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Complexible: Empire - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..4afa9e2 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + // make sure to have the $JAVA_HOME env variable declared in your system + compile files("${System.properties['java.home']}/../lib/tools.jar") + + compile "org.javassist:javassist:3.17.1-GA" + compile "org.ow2.spec.ee:ow2-jpa-1.0-spec:1.0.12" + + compile "com.complexible.common:cp-common-utils:4.0" + + compile "com.complexible.common:cp-openrdf-utils:3.0" + + compile "commons-dbcp:commons-dbcp:1.3" + + compile ("com.google.guava:guava:18.0") { + exclude group: "com.google.code.findbugs" + } + + compile ("org.openrdf.sesame:sesame-runtime:2.7.14") { + exclude group: "org.slf4j" + } + compile ("org.openrdf.sesame:sesame-queryrender:2.7.14") { + exclude group: "org.slf4j" + } + compile ("org.openrdf.sesame:sesame-queryparser-serql:2.7.14") { + exclude group: "org.slf4j" + } + + // Guice and related + compile "com.google.inject:guice:3.0" + compile "com.google.inject.extensions:guice-multibindings:3.0" + compile "com.google.inject.extensions:guice-assistedinject:3.0" + compile "com.google.inject.extensions:guice-throwingproviders:3.0" + compile "aopalliance:aopalliance:1.0" +} + +test { + workingDir = projectDir +// debug = true // for attaching the IDE to the gradle cli + + // set JVM arguments for the test JVM(s) + jvmArgs '-XX:MaxPermSize=256m', '-enableassertions' + include"**/TestEmpireCore.class" +} \ No newline at end of file diff --git a/core/main/src/META-INF/services/javax.persistence.spi.PersistenceProvider b/core/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider similarity index 100% rename from core/main/src/META-INF/services/javax.persistence.spi.PersistenceProvider rename to core/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider diff --git a/core/main/src/log4j.properties b/core/main/resources/log4j.properties similarity index 100% rename from core/main/src/log4j.properties rename to core/main/resources/log4j.properties diff --git a/core/main/src/com/clarkparsia/empire/codegen/BeanGenerator.java b/core/main/src/com/clarkparsia/empire/codegen/BeanGenerator.java index 4257cea..1611a19 100644 --- a/core/main/src/com/clarkparsia/empire/codegen/BeanGenerator.java +++ b/core/main/src/com/clarkparsia/empire/codegen/BeanGenerator.java @@ -15,6 +15,7 @@ package com.clarkparsia.empire.codegen; +import com.clarkparsia.empire.util.Repositories2; import com.complexible.common.collect.Iterables2; import com.complexible.common.collect.Iterators2; import com.complexible.common.openrdf.model.Statements; @@ -438,7 +439,7 @@ private static String className(Resource theClass) { public static void generateSourceFiles(String thePackageName, URL theOntology, RDFFormat theFormat, File theDirToSave) throws Exception { NAMES_TO_COUNT.clear(); - Repository aRepository = Repositories.createInMemoryRepo(); + Repository aRepository = Repositories2.createInMemoryRepo(); Repositories.add(aRepository, theOntology.openStream(), theFormat); diff --git a/core/main/src/com/clarkparsia/empire/util/Repositories2.java b/core/main/src/com/clarkparsia/empire/util/Repositories2.java new file mode 100644 index 0000000..f5f49f8 --- /dev/null +++ b/core/main/src/com/clarkparsia/empire/util/Repositories2.java @@ -0,0 +1,37 @@ +package com.clarkparsia.empire.util; + +import org.openrdf.repository.Repository; +import org.openrdf.repository.RepositoryException; +import org.openrdf.repository.sail.SailRepository; +import org.openrdf.sail.memory.MemoryStore; + +/** + * @author Fernando Hernandez + * @since 0.8.7 + * @version 0.8.7 + */ +public class Repositories2 { + + private Repositories2() { + throw new AssertionError(); + } + + /** + * Create a simple in-memory {@link Repository} which is already initialized + * + * @return an in memory Repository + */ + public static Repository createInMemoryRepo() { + try { + Repository aRepo = new SailRepository(new MemoryStore()); + + aRepo.initialize(); + + return aRepo; + } + catch (RepositoryException e) { + // impossible? + throw new AssertionError(e); + } + } +} diff --git a/core/main/src/com/complexible/common/web/Header.java b/core/main/src/com/complexible/common/web/Header.java new file mode 100644 index 0000000..98cb956 --- /dev/null +++ b/core/main/src/com/complexible/common/web/Header.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2005-2011 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import com.complexible.common.util.Tuple; + +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.Collections; + +/** + *

Represents an HTTP header, either from a request or a response.

+ * + * @author Michael Grove + * @see Request + * @see Response + * @since 1.0 + * @version 2.0 + */ +@Deprecated +public final class Header { + + /** + * The name of the header. {@link HttpHeaders} is an enumeration of common header names. + */ + private String mName; + + /** + * The list of values for the header + */ + private Map mValues = new HashMap(); + + /** + * The list of raw values for the header (i.e., before parsing/splitting) + */ + private List mRawValues = new LinkedList(); + + /** + * Create a new HTTP header + * @param theName the name of the header attribute + * @param theValue the singleton value of the header + */ + public Header(final String theName, String theValue) { + mName = theName; + addValue(theValue); + } + + /** + * Create a new HTTP header + * @param theName the name of the header attribute + * @param theValues the values of the HTTP header + */ + public Header(final String theName, final List theValues) { + mName = theName; + + for (String aValue : theValues) { + addValue(aValue); + } + } + + /** + * Create a new HTTP header + * @param theName the name of the header attribute + * @param theValues the values of the HTTP header + */ + public Header(final String theName, final Map theValues) { + mName = theName; + mValues = theValues; + + // at this point there is no information about "raw" values + // (need to "recreate" the "raw" version) + mRawValues.add(mapToValue(theValues)); + } + + /** + * Add a key-value pair to this header + * @param theName the name of the header element + * @param theValue the value of the element + * @return this Header object + */ + public Header addValue(String theName, String theValue) { + addValues(Collections.singletonMap(theName, theValue)); + + return this; + } + + /** + * Add a value to the header + * @param theValue the value to add + */ + void addValue(String theValue) { + if (theValue == null) { + return; + } + + if (theValue.indexOf(";") != -1) { + for (String aKeyValuePair : Splitter.on(";").trimResults().omitEmptyStrings().split(theValue)) { + Tuple aTuple = split(aKeyValuePair); + mValues.put(aTuple.get(0), (aTuple.length() < 2 ? null : aTuple.get(1))); + } + } + else if (theValue.indexOf("=") != -1) { + Tuple aTuple = split(theValue); + mValues.put(aTuple.get(0), (aTuple.length() < 2 ? null : aTuple.get(1))); + } + else { + mValues.put(null, theValue); + } + + mRawValues.add(theValue); + } + + /** + * Add all the values to the header + * @param theValues the values to add + */ + void addValues(Map theValues) { + mValues.putAll(theValues); + + // at this point there is no information about "raw" values + // (need to "recreate" the "raw" version) + mRawValues.add(mapToValue(theValues)); + } + + /** + * The name of the HTTP header. Common HTTP header names can be found in {@link HttpHeaders} + * @return the header name + */ + public String getName() { + return mName; + } + + /** + * Returns the values of the HTTP header + * @return the header values + */ + public Map getValues() { + return mValues; + } + + /** + * Return the raw values of the HTTP header (i.e., before any processing/splitting has + * occurred). + * + * @return the list of raw header values (one for each header occurrence) + */ + public Collection getRawValues() { + return mRawValues; + } + + /** + * Return the value of the header element + * @param theKey the name of the header element, or null to get the value of the header + * @return the value, or null if one is not specified + */ + public String getValue(String theKey) { + return getValues().get(theKey); + } + + /** + * Splits the key-value string on the = sign. + * @param theKeyValue the key/value string + * @return a 2-tuple of strings with the key and value. + */ + private Tuple split(String theKeyValue) { + List aStrings = Lists.newArrayList(Splitter + .on("=") + .trimResults() + .omitEmptyStrings() + .split(theKeyValue)); + + return new Tuple((Object[])aStrings.toArray(new String[aStrings.size()])); + } + + /** + * Return the value(s) of the header as a semi-colon separated string. For example, if your values are "foo", "bar" + * and "baz" this will return the string "foo; bar; baz" + * @return the string encoded reprsentation of the header values suitable for insertion into a HTTP request + */ + public String getHeaderValue() { + return mapToValue(getValues()); + } + + /** + * Converts a map of key-value pairs to a semi-colon separated string. For example, if your values are "foo", "bar" + * and "baz" this will return the string "foo; bar; baz" + * @param theValues a map to be converted + * @return the string encoded reprsentation of the header values suitable for insertion into a HTTP request + */ + private static String mapToValue(Map theValues) { + StringBuffer aBuffer = new StringBuffer(); + + boolean aFirst = true; + for (Map.Entry aEntry : theValues.entrySet()) { + + if (!aFirst) { + aBuffer.append("; "); + } + + aFirst = false; + + if (aEntry.getKey() != null) { + aBuffer.append(aEntry.getKey()).append("="); + } + + aBuffer.append(aEntry.getValue()); + } + + return aBuffer.toString(); + } + + /** + * Return a raw header value (i.e., before any processing/splitting). If the header was mentioned + * multiple times, this method returns all the header values concatenated together and separated by a comma + * (RFC 2616, Section 4.2 Message Headers: "It MUST be possible to combine the multiple header fields into one + * (..) without changing the semantics of the message, by appending each subsequent field-value to the first, + * each separated by a comma"). + * + * @return a single string that contain the raw header values concatenated together, separated by a comma + */ + public String getRawHeaderValue() { + StringBuffer aBuffer = new StringBuffer(); + + boolean aFirst = true; + for (String aRawValue : getRawValues()) { + if (!aFirst) { + aBuffer.append(", "); + } + + aFirst = false; + + aBuffer.append(aRawValue); + } + + return aBuffer.toString(); + } + + /** + * @inheritDoc + */ + @Override + public String toString() { + return getName() + " [" + getHeaderValue() + "]"; + } +} diff --git a/core/main/src/com/complexible/common/web/HttpHeaders.java b/core/main/src/com/complexible/common/web/HttpHeaders.java new file mode 100644 index 0000000..fe5167d --- /dev/null +++ b/core/main/src/com/complexible/common/web/HttpHeaders.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +/** + *

Enumeration of common http headers.

+ * + * @author Michael Grove + * @since 1.1 + */ +@Deprecated +public enum HttpHeaders { + + Accept("Accept"), + Authentication("Authentication"), + ContentDisposition("Content-Disposition"), + ContentLength("Content-Length"), + ContentType("Content-Type"), + TransferEncoding("Transfer-Encoding"); + + /** + * The name of the HTTP header + */ + private String mName; + + /** + * Create a new HTTP header key + * @param theName the name of the header + */ + HttpHeaders(final String theName) { + mName = theName; + } + + /** + * Return the name of the header + * @return the header name + */ + public String getName() { + return mName; + } +} diff --git a/core/main/src/com/complexible/common/web/HttpResource.java b/core/main/src/com/complexible/common/web/HttpResource.java new file mode 100644 index 0000000..b39cacb --- /dev/null +++ b/core/main/src/com/complexible/common/web/HttpResource.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import java.io.IOException; +import java.net.URL; + +/** + *

+ * + * @author Michael Grove + * @since 1.0 + */ +@Deprecated +public interface HttpResource { + public HttpResource resource(String theName); + + public Response get() throws IOException; + public Response delete() throws IOException; + + public Request initGet(); + public Request initPost(); + public Request initPut(); + public Request initDelete(); + + public Request initRequest(Method theMethod); + + public URL url(); +} diff --git a/core/main/src/com/complexible/common/web/HttpResourceImpl.java b/core/main/src/com/complexible/common/web/HttpResourceImpl.java new file mode 100644 index 0000000..222e232 --- /dev/null +++ b/core/main/src/com/complexible/common/web/HttpResourceImpl.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +/** + *

Simple implementation of the {@link HttpResource} interface.

+ * + * @author Michael Grove + * @since 1.0 + */ +@Deprecated +public class HttpResourceImpl implements HttpResource { + private URL mURL; + + public HttpResourceImpl(final URL theBaseURL) { + mURL = theBaseURL; + // TODO: does this need to be an interface? seems like overkill. + } + + /** + * @inheritDoc + */ + public HttpResource resource(final String theName) { + try { + return new HttpResourceImpl(new URL(mURL.toString() + (mURL.toString().endsWith("/") ? "" : "/") + theName));// + (theName.endsWith("/") ? "" : "/"))); + } + catch (MalformedURLException e) { + throw new IllegalArgumentException(e); + } + } + + /** + * @inheritDoc + */ + public Response delete() throws IOException { + return initDelete().execute(); + } + + /** + * @inheritDoc + */ + public Response get() throws IOException { + return initGet().execute(); + } + + /** + * @inheritDoc + */ + public Request initGet() { + return new Request(Method.GET, mURL); + } + + /** + * @inheritDoc + */ + public Request initPost() { + return new Request(Method.POST, mURL); + } + + /** + * @inheritDoc + */ + public Request initPut() { + return new Request(Method.PUT, mURL); + } + + /** + * @inheritDoc + */ + public Request initDelete() { + return new Request(Method.DELETE, mURL); + } + + /** + * @inheritDoc + */ + public Request initRequest(Method theMethod) { + return new Request(theMethod, mURL); + } + + /** + * @inheritDoc + */ + public URL url() { + return mURL; + } +} diff --git a/core/main/src/com/complexible/common/web/Method.java b/core/main/src/com/complexible/common/web/Method.java new file mode 100644 index 0000000..13739fb --- /dev/null +++ b/core/main/src/com/complexible/common/web/Method.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +/** + *

Enumeration of HTTP methods.

+ * + * @author Michael Grove + * @since 1.0 + */ +@Deprecated +public enum Method { + PUT, GET, POST, DELETE, HEAD +} diff --git a/core/main/src/com/complexible/common/web/MimeTypes.java b/core/main/src/com/complexible/common/web/MimeTypes.java new file mode 100644 index 0000000..d9a116f --- /dev/null +++ b/core/main/src/com/complexible/common/web/MimeTypes.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +/** + *

Enumeration of common mime-types.

+ * + * @author Michael Grove + */ +@Deprecated +public enum MimeTypes { + FormUrlEncoded("application/x-www-form-urlencoded"), + TextPlain("text/plain"); + + /** + * The mime-type string + */ + private String mType; + + /** + * Create the new MimeType + * @param theType the mime type + */ + MimeTypes(final String theType) { + mType = theType; + } + + /** + * Return the mime-type + * @return the mime-type string + */ + public String getMimeType() { + return mType; + } +} diff --git a/core/main/src/com/complexible/common/web/Parameter.java b/core/main/src/com/complexible/common/web/Parameter.java new file mode 100644 index 0000000..f890167 --- /dev/null +++ b/core/main/src/com/complexible/common/web/Parameter.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +/** + *

A representation of a parameter, simply a key-value pair.

+ * + * @author Michael Grove + * @since 1.0 + */ +@Deprecated +public class Parameter { + /** + * The parameter name + */ + private final String mName; + + /** + * The parameter value + */ + private final String mValue; + + /** + * Create a new Parameter + * @param theName the name of the parameter + * @param theValue the value of the parameter + */ + public Parameter(final String theName, final String theValue) { + mName = theName; + mValue = theValue; + } + + /** + * Return the name of the parameter + * @return the name + */ + public String getName() { + return mName; + } + + /** + * Return the value of the parameter + * @return the value + */ + public String getValue() { + return mValue; + } + + /** + * @inheritDoc + */ + @Override + public String toString() { + return getName() + " = " + getValue(); + } + + /** + * @inheritDoc + */ + @Override + public int hashCode() { + return getName().hashCode() + getValue().hashCode(); + } + + /** + * @inheritDoc + */ + @Override + public boolean equals(Object theObject) { + return theObject instanceof Parameter + && ((Parameter)theObject).getName().equals(getName()) + && ((Parameter)theObject).getValue().equals(getValue()); + } +} diff --git a/core/main/src/com/complexible/common/web/ParameterList.java b/core/main/src/com/complexible/common/web/ParameterList.java new file mode 100644 index 0000000..ba9f7b2 --- /dev/null +++ b/core/main/src/com/complexible/common/web/ParameterList.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import com.complexible.common.base.Strings2; + +import java.util.ArrayList; + +/** + *

A list of {@link Parameter} objects.

+ * + * @author Michael Grove + * @since 1.0 + * @version 2.0 + */ +@Deprecated +public class ParameterList extends ArrayList { + + /** + * Adds a new parameter to the list + * @param theName the name of the parameter + * @param theValue the value of the parameter + * @return the list itself + */ + public ParameterList add(String theName, String theValue) { + add(new Parameter(theName, theValue)); + return this; + } + + /** + * Create a string representation of the list of parameters + * @param theEncode true if the values of the parameters should be URL encoded, false otherwise + * @return the params as a string + */ + private String str(boolean theEncode) { + + // guesstimate the size needed to serialize to a string + int size = 0; + for (int i = 0; i < size(); i++) { + Parameter aParam = get(i); + size += aParam.getName().length() + aParam.getValue().length() + 16 /* padding for url encoding of value */; + } + + StringBuilder aBuffer = new StringBuilder(size); + + boolean aFirst = true; + for (Parameter aParam : this) { + + if (!aFirst) { + aBuffer.append('&'); + } + + aBuffer.append(aParam.getName()); + aBuffer.append('='); + aBuffer.append(theEncode + ? Strings2.urlEncode(aParam.getValue()) + : aParam.getValue()); + + aFirst = false; + } + + return aBuffer.toString(); + } + + /** + * Return the Parameters in the list in URL (encoded) form. They will be & delimited and the values of each parameter + * will be encoded. If you have two parameters a:b and c:"d d", the result is a=b&c=d+d + * @return the URL encoded parameter list in key-value pairs + */ + public String getURLEncoded() { + return str(true /* encode */); + } + + + /** + * Functionally similar to {@link #getURLEncoded} but the values of the parameters are not URL encoded. + * @inheritDoc + */ + @Override + public String toString() { + return str(false /* don't encode */); + } +} diff --git a/core/main/src/com/complexible/common/web/Request.java b/core/main/src/com/complexible/common/web/Request.java new file mode 100644 index 0000000..9980716 --- /dev/null +++ b/core/main/src/com/complexible/common/web/Request.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import com.google.common.io.ByteStreams; +import com.google.common.io.Closeables; +import com.google.common.base.Charsets; + +import java.net.URL; +import java.net.MalformedURLException; +import java.net.URLConnection; +import java.net.HttpURLConnection; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.OutputStream; + +import java.util.HashMap; +import java.util.Map; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Arrays; + +/** + *

+ * + * @author Michael Grove + * @since 1.0 + * @version 2.0 + */ +@Deprecated +public class Request { + private URL mURL; + private Method mMethod; + private ParameterList mParameters = new ParameterList(); + private InputStream mBody; + private Map mHeaders = new HashMap(); + + private int mTimeout = -1; + private boolean mFollowRedirects; + + public Request(String theURL) throws MalformedURLException { + this(Method.GET, new URL(theURL)); + } + + public Request(URL theURL) { + this(Method.GET, theURL); + } + + public Request(Method theMethod, URL theURL) { + mMethod = theMethod; + mURL = theURL; + } + + public static Request formPost(URL theURL, ParameterList theParams) { + Request aRequest = new Request(Method.POST, theURL); + aRequest.addHeader(new Header(HttpHeaders.ContentType.getName(), MimeTypes.FormUrlEncoded.getMimeType())); + aRequest.setBody(theParams.toString()); + + return aRequest; + } + + /** + * Return the current timeout value + * @return the timeout value in milliseconds or -1 for no timeout + */ + public int getTimeout() { + return mTimeout; + } + + /** + * Set the timeout associated associated with this request + * @param theTimeout the timeout in milliseconds, or -1 for no timeout + * @return this request + */ + public Request setTimeout(final int theTimeout) { + mTimeout = theTimeout; + + return this; + } + + /** + * Return whether or not this request will follow redirects + * @return true to follow redirects, false otherwise + */ + public boolean isFollowRedirects() { + return mFollowRedirects; + } + + /** + * Set whether or not this request will follow redirects + * @param theFollowRedirects true to follow redirects, false otherwise + * @return this request + */ + public Request setFollowRedirects(final boolean theFollowRedirects) { + mFollowRedirects = theFollowRedirects; + + return this; + } + + /** + * Add a parameter to this web request + * @param theKey the parameter key + * @param theValue the parameter value + * @return this request + */ + public Request addParameter(String theKey, String theValue) { + return addParameter(new Parameter(theKey, theValue)); + } + + /** + * Adds a parameter to this web request + * @param theParameter the parameter to add + * @return this request + */ + public Request addParameter(Parameter theParameter) { + mParameters.add(theParameter); + + return this; + } + + /** + * Sets the list of parameters for this web request + * @param theParameters the list of parameters + * @return this request + */ + public Request setParameters(final ParameterList theParameters) { + mParameters = theParameters; + + return this; + } + + /** + * Add a header to this request + * @param theHeader the header to add + * @return this request + */ + public Request addHeader(Header theHeader) { + if (mHeaders.containsKey(theHeader.getName())) { + theHeader.addValues(mHeaders.get(theHeader.getName()).getValues()); + } + + mHeaders.put(theHeader.getName(), theHeader); + + return this; + } + + public Request addHeader(String theName, String... theValue) { + addHeader(new Header(theName, Arrays.asList(theValue))); + + return this; + } + + public Request setBody(String theString) { + mBody = new ByteArrayInputStream(theString.getBytes(Charsets.UTF_8)); + + return this; + } + + public Request setBody(final InputStream theBody) { + mBody = theBody; + + return this; + } + + public URL getURL() { + return mURL; + } + + public Method getMethod() { + return mMethod; + } + + public ParameterList getParameters() { + return mParameters; + } + + public InputStream getBody() { + return mBody; + } + + public Collection
getHeaders() { + return Collections.unmodifiableCollection(mHeaders.values()); + } + + private URL getURLWithParams() throws IOException { + if (!getParameters().isEmpty()) { + try { + return new URL(getURL().toString() + "?" + getParameters().getURLEncoded()); + } + catch (MalformedURLException e) { + throw new IOException(e.getMessage()); + } + } + else { + return getURL(); + } + } + + public Header getHeader(String theName) { + return mHeaders.get(theName); + } + + public Response execute() throws IOException { + + // TODO: use-caches?, if-modified-since, HTTPS security twiddling, HTTP Authentication, chunking, user interactions? + InputStream aResponseStream = null; + InputStream aInput = null; + HttpURLConnection aConn = null; + + try { + URLConnection aTempConn = getURLWithParams().openConnection(); + + if (!(aTempConn instanceof HttpURLConnection)) { + throw new IllegalArgumentException("Only HTTP or HTTPS are supported"); + } + + aConn = (HttpURLConnection) aTempConn; + + aConn.setDoInput(true); + + if (getTimeout() != -1) { + aConn.setConnectTimeout(getTimeout()); + aConn.setReadTimeout(getTimeout()); + } + + aConn.setInstanceFollowRedirects(isFollowRedirects()); + aConn.setRequestMethod(getMethod().name()); + + for (Header aHeader : getHeaders()) { + aConn.setRequestProperty(aHeader.getName(), aHeader.getHeaderValue()); + } + + aConn.setInstanceFollowRedirects(isFollowRedirects()); + aConn.setRequestMethod(getMethod().name()); + + aInput = getBody(); + + if (aInput == null && getMethod() == Method.POST) { + aInput = new ByteArrayInputStream(new byte[0]); + } + + if (aInput != null && (getMethod() != Method.DELETE)) { + aConn.setDoOutput(true); + OutputStream aOut = aConn.getOutputStream(); + + ByteStreams.copy(aInput, aOut); + + if (aOut != null) { + aOut.flush(); + aOut.close(); + } + + aInput.close(); + } + + aConn.connect(); + + Collection
aResponseHeaders = new HashSet
(); + + Map> aHeaderMap = aConn.getHeaderFields(); + + for (Map.Entry> aEntry : aHeaderMap.entrySet()) { + aResponseHeaders.add(new Header(aEntry.getKey(), aEntry.getValue())); + } + + return new Response(aConn, aResponseHeaders); + } + finally { + Closeables.closeQuietly(aInput); + } + } +} diff --git a/core/main/src/com/complexible/common/web/Response.java b/core/main/src/com/complexible/common/web/Response.java new file mode 100644 index 0000000..de991e0 --- /dev/null +++ b/core/main/src/com/complexible/common/web/Response.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2005-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.common.web; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; + +import java.net.HttpURLConnection; + +import java.util.Map; +import java.util.Collection; +import java.util.HashMap; +import java.util.zip.GZIPInputStream; + +/** + *

A response to an HTTP invocation. Responses must be closed when they are no longer used to close the + * connection to the server and release the content stream.

+ * + * @author Michael Grove + * @since 1.0 + * @version 1.1 + */ +@Deprecated +public class Response implements Closeable { + + private InputStream mContent = null; + private InputStream mErrorStream = null; + + private final Map mHeaders; + private String mMessage; + private final HttpURLConnection mConnection; + private int mResponseCode; + + public Response(final HttpURLConnection theConn, final Collection
theHeaders) { + + mHeaders = new HashMap(); + + for (Header aHeader : theHeaders) { + mHeaders.put(aHeader.getName(), aHeader); + } + + mConnection = theConn; + + try { + mContent = theConn.getInputStream(); + + // if this is GZIP encoded, then wrap the input stream + String contentEncoding = theConn.getContentEncoding(); + if ("gzip".equals(contentEncoding)) { + mContent = new GZIPInputStream(mContent); + } + } + catch (IOException e) { + // there was an error in the connection, so probably the error stream will be populated, this is safe to ignore + } + + try { + mErrorStream = theConn.getErrorStream(); + } + catch (Exception e) { + // there was an error in the connection, probably just no error stream. + } + + try { + mMessage = theConn.getResponseMessage(); + } + catch (IOException e) { + // ugh? + } + + try { + mResponseCode = theConn.getResponseCode(); + } + catch (IOException e) { + // ugh? + mResponseCode = -1; + } + } + + /** + * Return the error stream from the connection + * @return the error stream + */ + public InputStream getErrorStream() { + return mErrorStream; + } + + /** + * Return the response message from the server + * @return the message + */ + public String getMessage() { + return mMessage; + } + + /** + * Return all headers returned by the server + * @return the headers + */ + public Collection
getHeaders() { + return mHeaders.values(); + } + + /** + * Get the header with the specified name + * @param theName the header name + * @return the value of the header, or null if the header is not present + */ + public Header getHeader(String theName) { + return mHeaders.get(theName); + } + + /** + * Return the response code + * @return the response code + */ + public int getResponseCode() { + return mResponseCode; + } + + /** + * Return the response content from the server + * @return the response content + */ + public InputStream getContent() { + return mContent; + } + + /** + * Return whether or not this has an error result + * @return true if there is an error result, false otherwise + */ + public boolean hasErrorCode() { + // TODO: right? + return (getResponseCode() >= 400) || (getResponseCode() < 0); + } + + /** + * Close this response + * @throws IOException if there is an error while closing + */ + public void close() throws IOException { + if (mContent != null) { + mContent.close(); + } + + if (mErrorStream != null) { + mErrorStream.close(); + } + + mConnection.disconnect(); + } +} diff --git a/core/test/src/com/clarkparsia/empire/TestEmpireCore.java b/core/test/src/com/clarkparsia/empire/TestEmpireCore.java index 215a7dc..70233dd 100644 --- a/core/test/src/com/clarkparsia/empire/TestEmpireCore.java +++ b/core/test/src/com/clarkparsia/empire/TestEmpireCore.java @@ -15,8 +15,6 @@ package com.clarkparsia.empire; -import java.io.File; - import com.clarkparsia.empire.codegen.CodegenTests; import com.clarkparsia.empire.lazyload.TestLazyCollectionLoad; diff --git a/core/test/src/com/clarkparsia/empire/api/MutableTestDataSourceFactory.java b/core/test/src/com/clarkparsia/empire/api/MutableTestDataSourceFactory.java index 59c4529..8f9a2e2 100644 --- a/core/test/src/com/clarkparsia/empire/api/MutableTestDataSourceFactory.java +++ b/core/test/src/com/clarkparsia/empire/api/MutableTestDataSourceFactory.java @@ -20,6 +20,7 @@ import com.clarkparsia.empire.ds.DataSourceException; import com.clarkparsia.empire.ds.Alias; +import com.clarkparsia.empire.util.Repositories2; import com.complexible.common.openrdf.repository.Repositories; import com.google.common.base.Splitter; import org.openrdf.repository.Repository; @@ -51,7 +52,7 @@ public DataSource create(final Map theMap) throws DataSourceExce return mSourceCache.get(theMap.get("files")); } - Repository aRepo = Repositories.createInMemoryRepo(); + Repository aRepo = Repositories2.createInMemoryRepo(); if (theMap.containsKey("files")) { for (String aFile : Splitter.on(",").omitEmptyStrings().trimResults().split(theMap.get("files").toString())) { diff --git a/core/test/src/com/clarkparsia/empire/api/TestDataSource.java b/core/test/src/com/clarkparsia/empire/api/TestDataSource.java index 1775993..8dcc904 100644 --- a/core/test/src/com/clarkparsia/empire/api/TestDataSource.java +++ b/core/test/src/com/clarkparsia/empire/api/TestDataSource.java @@ -16,6 +16,7 @@ package com.clarkparsia.empire.api; import com.clarkparsia.empire.ds.impl.AbstractResultSet; +import com.clarkparsia.empire.util.Repositories2; import com.complexible.common.openrdf.model.Graphs; import com.complexible.common.openrdf.repository.Repositories; import com.complexible.common.openrdf.util.AdunaIterations; @@ -58,7 +59,7 @@ public TestDataSource(final Repository theRepository) { } public TestDataSource(Graph theGraph) { - mRepo = Repositories.createInMemoryRepo(); + mRepo = Repositories2.createInMemoryRepo(); try { Repositories.add(mRepo, theGraph); diff --git a/examples/build.gradle b/examples/build.gradle new file mode 100644 index 0000000..b4e2f62 --- /dev/null +++ b/examples/build.gradle @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + compile project(":core") + compile project(":sesame") +} diff --git a/examples/src/com/clarkparsia/empire/examples/Book.java b/examples/main/src/com/clarkparsia/empire/examples/Book.java similarity index 100% rename from examples/src/com/clarkparsia/empire/examples/Book.java rename to examples/main/src/com/clarkparsia/empire/examples/Book.java diff --git a/examples/src/com/clarkparsia/empire/examples/Main.java b/examples/main/src/com/clarkparsia/empire/examples/Main.java similarity index 100% rename from examples/src/com/clarkparsia/empire/examples/Main.java rename to examples/main/src/com/clarkparsia/empire/examples/Main.java diff --git a/examples/src/com/clarkparsia/empire/examples/Manifestation.java b/examples/main/src/com/clarkparsia/empire/examples/Manifestation.java similarity index 100% rename from examples/src/com/clarkparsia/empire/examples/Manifestation.java rename to examples/main/src/com/clarkparsia/empire/examples/Manifestation.java diff --git a/gradle.properties.example b/gradle.properties.example new file mode 100644 index 0000000..f3b1658 --- /dev/null +++ b/gradle.properties.example @@ -0,0 +1,4 @@ +stardogRepo=url/to/repo +stardogHome=path/to/$STARDOG_HOME +artifactoryUsername=user +artifactoryPassword=secret diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..b761216 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e716024 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Feb 23 15:14:32 EST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/ivy.build.xml b/ivy.build.xml deleted file mode 100644 index aec707b..0000000 --- a/ivy.build.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - Empire IVY Tasks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jena/build.gradle b/jena/build.gradle new file mode 100644 index 0000000..05f5083 --- /dev/null +++ b/jena/build.gradle @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + compile project(":core") + compile project(path: ":core", configuration: "testRuntime") + + compile "org.apache.jena:jena-arq:2.10.0" + compile "org.apache.jena:jena-core:2.10.0" + compile "org.apache.jena:jena-tdb:0.10.1" +} diff --git a/jena/build.xml b/jena/build.xml deleted file mode 100644 index 31c55aa..0000000 --- a/jena/build.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Empire: Jena - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jena/ivy.xml b/jena/ivy.xml deleted file mode 100644 index 6b81267..0000000 --- a/jena/ivy.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Empire: JPA for the Semantic Web. Jena bindings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jena/pom.template b/jena/pom.template deleted file mode 100644 index 35f73a9..0000000 --- a/jena/pom.template +++ /dev/null @@ -1,66 +0,0 @@ -${ivy.pom.license} -${ivy.pom.header} - - - - com.clarkparsia.empire - Empire-parent - 0.8.6 - - - 4.0.0 - ${ivy.pom.groupId} - ${ivy.pom.artifactId} - ${ivy.pom.packaging} - ${ivy.pom.version} - ${ivy.pom.name} - ${ivy.pom.description} - ${ivy.pom.url} - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - main/src - - - - - add-test-source - generate-test-sources - - add-test-source - - - - test/src - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - 1.6 - 1.6 - - - - - diff --git a/jena/pom.xml b/jena/pom.xml deleted file mode 100644 index e5e908f..0000000 --- a/jena/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - com.clarkparsia.empire - Empire-parent - 0.8.4 - - - 4.0.0 - com.clarkparsia.empire - jena - jar - 0.8.4 - http://www.clarkparsia.com - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - main/src - - - - - add-test-source - generate-test-sources - - add-test-source - - - - test/src - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - 1.6 - 1.6 - - - - - - - com.clarkparsia.empire - empire - 0.8.4 - tests - test - - - com.clarkparsia.empire - empire - 0.8.4 - compile - - - junit - junit - 4.8.2 - test - - - org.apache.jena - jena-core - 2.10.0 - compile - - - org.slf4j - * - - - - - org.apache.jena - jena-tdb - 0.10.1 - compile - - - org.slf4j - * - - - - - org.apache.jena - jena-arq - 2.10.0 - compile - - - org.slf4j - * - - - - - diff --git a/jena/test/src/com/clarkparsia/empire/jena/JenaEntityManagerTestSuite.java b/jena/test/src/com/clarkparsia/empire/jena/JenaEntityManagerTestSuite.java index 8de4128..4d9a2f1 100644 --- a/jena/test/src/com/clarkparsia/empire/jena/JenaEntityManagerTestSuite.java +++ b/jena/test/src/com/clarkparsia/empire/jena/JenaEntityManagerTestSuite.java @@ -15,8 +15,6 @@ package com.clarkparsia.empire.jena; -import java.io.File; - import com.clarkparsia.empire.ds.DataSourceFactory; import com.clarkparsia.empire.EntityManagerTestSuite; import com.clarkparsia.empire.util.TestUtil; diff --git a/master.build.xml b/master.build.xml deleted file mode 100644 index 47877ba..0000000 --- a/master.build.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Empire Master build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiling ${src} to ${build.main} ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiling ${test} to ${build.test} ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #Generated by Empire build -#${build.date} -version=${ivy.pom.version} -groupId=${ivy.organisation} -artifactId=${ivy.module} - - - - - - - - - - - - - - - - - - - - - #Generated by Empire build -#${build.date} -version=${ivy.pom.version} -groupId=${ivy.organisation} -artifactId=${ivy.module} - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 9f25ecf..0000000 --- a/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - 4.0.0 - - Empire-parent - com.clarkparsia.empire - 0.8.4 - pom - - Parent pom for Empire - Groups common configuration and dependencies for all the empire artifacts - - - core - jena - reflections - sesame - examples - sdb - - - - - 1.6 - - 1.7.5 - - 2.7.10 - - - - - - com.sun - tools - ${java.version} - system - ${java.home}/../lib/tools.jar - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - ${java.version} - ${java.version} - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 1.5 - - - output jar for non maven use - package - - shade - - - true - onejar - - - * - - - com.sun:tools - - - - - - - - - - \ No newline at end of file diff --git a/project.properties b/project.properties deleted file mode 100644 index 34356ac..0000000 --- a/project.properties +++ /dev/null @@ -1,8 +0,0 @@ -project.name = empire -project.version = 0.8.6 - -core.version = 0.8.6 -sesame.version = 0.8.6 -jena.version = 0.8.6 - -dist = dist diff --git a/reflections/build.gradle b/reflections/build.gradle new file mode 100644 index 0000000..5c7024d --- /dev/null +++ b/reflections/build.gradle @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + compile project(":core") + + compile "org.reflections:reflections:0.9.8" +} diff --git a/reflections/lib/dom4j-1.6.jar b/reflections/lib/dom4j-1.6.jar deleted file mode 100755 index e19f4ce..0000000 Binary files a/reflections/lib/dom4j-1.6.jar and /dev/null differ diff --git a/reflections/lib/reflections-0.9.5.jar b/reflections/lib/reflections-0.9.5.jar deleted file mode 100644 index bc4eee6..0000000 Binary files a/reflections/lib/reflections-0.9.5.jar and /dev/null differ diff --git a/reflections/src/com/clarkparsia/empire/util/ReflectionsAnnotationProvider.java b/reflections/main/src/com/clarkparsia/empire/util/ReflectionsAnnotationProvider.java similarity index 100% rename from reflections/src/com/clarkparsia/empire/util/ReflectionsAnnotationProvider.java rename to reflections/main/src/com/clarkparsia/empire/util/ReflectionsAnnotationProvider.java diff --git a/reflections/pom.xml b/reflections/pom.xml deleted file mode 100644 index 12daa8c..0000000 --- a/reflections/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - 4.0.0 - - - com.clarkparsia.empire - Empire-parent - 0.8.4 - - - com.clarkparsia.empire - reflections - jar - - - - com.clarkparsia.empire - empire - ${project.version} - - - org.reflections - reflections - 0.9.8 - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - src - - - - - - - - - - \ No newline at end of file diff --git a/sdb/main/src/com/clarkparsia/empire/jena/AbstractDelegateModel.java b/sdb/main/src/com/clarkparsia/empire/jena/AbstractDelegateModel.java deleted file mode 100644 index bbc21ae..0000000 --- a/sdb/main/src/com/clarkparsia/empire/jena/AbstractDelegateModel.java +++ /dev/null @@ -1,1501 +0,0 @@ -/* - * Copyright (c) 2009-2012 Clark & Parsia, LLC. - * Copyright (c) 2010, Ultan O'Carroll - * - * 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 com.clarkparsia.empire.jena; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.util.Calendar; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import com.hp.hpl.jena.datatypes.RDFDatatype; -import com.hp.hpl.jena.graph.Graph; -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.graph.Triple; -import com.hp.hpl.jena.graph.query.QueryHandler; -import com.hp.hpl.jena.rdf.model.Alt; -import com.hp.hpl.jena.rdf.model.AnonId; -import com.hp.hpl.jena.rdf.model.Bag; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelChangedListener; -import com.hp.hpl.jena.rdf.model.NodeIterator; -import com.hp.hpl.jena.rdf.model.NsIterator; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.RDFList; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.RDFReader; -import com.hp.hpl.jena.rdf.model.RDFWriter; -import com.hp.hpl.jena.rdf.model.RSIterator; -import com.hp.hpl.jena.rdf.model.ReifiedStatement; -import com.hp.hpl.jena.rdf.model.ResIterator; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.ResourceF; -import com.hp.hpl.jena.rdf.model.Selector; -import com.hp.hpl.jena.rdf.model.Seq; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -import com.hp.hpl.jena.shared.Command; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.shared.PrefixMapping; -import com.hp.hpl.jena.shared.ReificationStyle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Simple delegate for Jena model so that we can control jdbc and model commits in SDB. - * - * @author uoccou - * @see SDBModelWithStore - * @since 0.7 - * @version 0.7 - */ -class AbstractDelegateModel implements Model { - - protected final Logger log = LoggerFactory.getLogger(this.getClass()); - - private final Model mModel; - - /** - * Create a new AbstractDelegateModel - * @param m the model that will serve as the delegate - */ - public AbstractDelegateModel(Model m) { - this.mModel = m; - } - - /** - * @inheritDoc - */ - public Model abort() { - return mModel.abort(); - } - - /** - * @inheritDoc - */ - public Model add(List statements) { - return mModel.add(statements); - } - - /** - * @inheritDoc - */ - public Model add(Model m, boolean suppressReifications) { - return mModel.add(m, suppressReifications); - } - - /** - * @inheritDoc - */ - public Model add(Model m) { - return mModel.add(m); - } - - /** - * @inheritDoc - */ - public Model add(Resource s, Property p, RDFNode o) { - return mModel.add(s, p, o); - } - - /** - * @inheritDoc - */ - public Model add(Resource s, Property p, String o, boolean wellFormed) { - return mModel.add(s, p, o, wellFormed); - } - - /** - * @inheritDoc - */ - public Model add(Resource s, Property p, String lex, RDFDatatype datatype) { - return mModel.add(s, p, lex, datatype); - } - - /** - * @inheritDoc - */ - public Model add(Resource s, Property p, String o, String l) { - return mModel.add(s, p, o, l); - } - - /** - * @inheritDoc - */ - public Model add(Resource s, Property p, String o) { - return mModel.add(s, p, o); - } - - /** - * @inheritDoc - */ - public Model add(Statement s) { - return mModel.add(s); - } - - /** - * @inheritDoc - */ - public Model add(Statement[] statements) { - return mModel.add(statements); - } - - /** - * @inheritDoc - */ - public Model add(StmtIterator iter) { - return mModel.add( iter ); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, boolean o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, char o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, double o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, float o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, int o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, Literal o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, long o) { - return mModel.addLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public Model addLiteral(Resource s, Property p, Object o) { - return mModel.addLiteral( s, p, o ); - } - - /** - * @inheritDoc - */ - public RDFNode asRDFNode(Node n) { - return mModel.asRDFNode( n ); - } - - /** - * @inheritDoc - */ - public Resource wrapAsResource(final Node theNode) { - return mModel.wrapAsResource( theNode ); - } - - /** - * @inheritDoc - */ - public Statement asStatement(Triple t) { - return mModel.asStatement( t ); - } - - /** - * @inheritDoc - */ - public Model begin() { - return mModel.begin(); - } - - /** - * @inheritDoc - */ - public void close() { - mModel.close(); - } - - /** - * @inheritDoc - */ - public Model commit() { - return mModel.commit(); - } - - /** - * @inheritDoc - */ - public boolean contains(Resource s, Property p, RDFNode o) { - return mModel.contains(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean contains(Resource s, Property p, String o, String l) { - return mModel.contains(s, p, o, l); - } - - /** - * @inheritDoc - */ - public boolean contains(Resource s, Property p, String o) { - return mModel.contains(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean contains(Resource s, Property p) { - return mModel.contains(s, p); - } - - /** - * @inheritDoc - */ - public boolean contains(Statement s) { - return mModel.contains( s ); - } - - /** - * @inheritDoc - */ - public boolean containsAll(Model model) { - return mModel.containsAll(model); - } - - /** - * @inheritDoc - */ - public boolean containsAll(StmtIterator iter) { - return mModel.containsAll( iter ); - } - - /** - * @inheritDoc - */ - public boolean containsAny(Model model) { - return mModel.containsAny(model); - } - - /** - * @inheritDoc - */ - public boolean containsAny(StmtIterator iter) { - return mModel.containsAny( iter ); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, boolean o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, char o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, double o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, float o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, int o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, long o) { - return mModel.containsLiteral(s, p, o); - } - - /** - * @inheritDoc - */ - public boolean containsLiteral(Resource s, Property p, Object o) { - return mModel.containsLiteral( s, p, o ); - } - - /** - * @inheritDoc - */ - public boolean containsResource(RDFNode r) { - return mModel.containsResource( r ); - } - - /** - * @inheritDoc - */ - public Alt createAlt() { - return mModel.createAlt(); - } - - /** - * @inheritDoc - */ - public Alt createAlt(String uri) { - return mModel.createAlt( uri ); - } - - /** - * @inheritDoc - */ - public Bag createBag() { - return mModel.createBag(); - } - - /** - * @inheritDoc - */ - public Bag createBag(String uri) { - return mModel.createBag( uri ); - } - - /** - * @inheritDoc - */ - public RDFList createList() { - return mModel.createList(); - } - - /** - * @inheritDoc - */ - public RDFList createList(Iterator members) { - return mModel.createList(members); - } - - /** - * @inheritDoc - */ - public RDFList createList(RDFNode[] members) { - return mModel.createList( members ); - } - - /** - * @inheritDoc - */ - public Literal createLiteral(String v, boolean wellFormed) { - return mModel.createLiteral(v, wellFormed); - } - - /** - * @inheritDoc - */ - public Literal createLiteral(String v, String language) { - return mModel.createLiteral(v, language); - } - - /** - * @inheritDoc - */ - public Literal createLiteral(String v) { - return mModel.createLiteral( v ); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, boolean o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, char o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, double o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, float o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, int o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, long o) { - return mModel.createLiteralStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createLiteralStatement(Resource s, Property p, Object o) { - return mModel.createLiteralStatement( s, p, o ); - } - - /** - * @inheritDoc - */ - public Property createProperty(String nameSpace, String localName) { - return mModel.createProperty(nameSpace, localName); - } - - /** - * @inheritDoc - */ - public Property createProperty(String uri) { - return mModel.createProperty( uri ); - } - - /** - * @inheritDoc - */ - public ReifiedStatement createReifiedStatement(Statement s) { - return mModel.createReifiedStatement(s); - } - - /** - * @inheritDoc - */ - public ReifiedStatement createReifiedStatement(String uri, Statement s) { - return mModel.createReifiedStatement( uri, s ); - } - - /** - * @inheritDoc - */ - public Resource createResource() { - return mModel.createResource(); - } - - /** - * @inheritDoc - */ - public Resource createResource(AnonId id) { - return mModel.createResource(id); - } - - /** - * @inheritDoc - */ - public Resource createResource(Resource type) { - return mModel.createResource(type); - } - - /** - * @inheritDoc - */ - public Resource createResource(ResourceF f) { - return mModel.createResource(f); - } - - /** - * @inheritDoc - */ - public Resource createResource(String uri, Resource type) { - return mModel.createResource(uri, type); - } - - /** - * @inheritDoc - */ - public Resource createResource(String uri, ResourceF f) { - return mModel.createResource(uri, f); - } - - /** - * @inheritDoc - */ - public Resource createResource(String uri) { - return mModel.createResource( uri ); - } - - /** - * @inheritDoc - */ - public Seq createSeq() { - return mModel.createSeq(); - } - - /** - * @inheritDoc - */ - public Seq createSeq(String uri) { - return mModel.createSeq( uri ); - } - - /** - * @inheritDoc - */ - public Statement createStatement(Resource s, Property p, RDFNode o) { - return mModel.createStatement(s, p, o); - } - - /** - * @inheritDoc - */ - public Statement createStatement(Resource s, Property p, String o, - boolean wellFormed) { - return mModel.createStatement(s, p, o, wellFormed); - } - - /** - * @inheritDoc - */ - public Statement createStatement(Resource s, Property p, String o, - String l, boolean wellFormed) { - return mModel.createStatement(s, p, o, l, wellFormed); - } - - /** - * @inheritDoc - */ - public Statement createStatement(Resource s, Property p, String o, String l) { - return mModel.createStatement(s, p, o, l); - } - - /** - * @inheritDoc - */ - public Statement createStatement(Resource s, Property p, String o) { - return mModel.createStatement( s, p, o ); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(boolean v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(Calendar d) { - return mModel.createTypedLiteral(d); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(char v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(double v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(float v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(int v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(long v) { - return mModel.createTypedLiteral(v); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(Object value, RDFDatatype dtype) { - return mModel.createTypedLiteral(value, dtype); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(Object value, String typeURI) { - return mModel.createTypedLiteral(value, typeURI); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(Object value) { - return mModel.createTypedLiteral(value); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(String lex, RDFDatatype dtype) { - return mModel.createTypedLiteral(lex, dtype); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(String lex, String typeURI) { - return mModel.createTypedLiteral(lex, typeURI); - } - - /** - * @inheritDoc - */ - public Literal createTypedLiteral(String v) { - return mModel.createTypedLiteral( v ); - } - - /** - * @inheritDoc - */ - public Model difference(Model model) { - return mModel.difference(model); - } - - /** - * @inheritDoc - */ - public void enterCriticalSection(boolean readLockRequested) { - mModel.enterCriticalSection(readLockRequested); - } - - /** - * @inheritDoc - */ - @Override - public boolean equals(Object m) { - return mModel.equals( m ); - } - - /** - * @inheritDoc - */ - public Object executeInTransaction(Command cmd) { - return mModel.executeInTransaction( cmd ); - } - - /** - * @inheritDoc - */ - public String expandPrefix(String prefixed) { - return mModel.expandPrefix( prefixed ); - } - - /** - * @inheritDoc - */ - public Alt getAlt(Resource r) { - return mModel.getAlt(r); - } - - /** - * @inheritDoc - */ - public Alt getAlt(String uri) { - return mModel.getAlt( uri ); - } - - /** - * @inheritDoc - */ - public Resource getAnyReifiedStatement(Statement s) { - return mModel.getAnyReifiedStatement( s ); - } - - /** - * @inheritDoc - */ - public Bag getBag(Resource r) { - return mModel.getBag(r); - } - - /** - * @inheritDoc - */ - public Bag getBag(String uri) { - return mModel.getBag( uri ); - } - - /** - * @inheritDoc - */ - public Graph getGraph() { - return mModel.getGraph(); - } - - /** - * @inheritDoc - */ - public Lock getLock() { - return mModel.getLock(); - } - - /** - * @inheritDoc - */ - public Map getNsPrefixMap() { - return mModel.getNsPrefixMap(); - } - - /** - * @inheritDoc - */ - public String getNsPrefixURI(String prefix) { - return mModel.getNsPrefixURI( prefix ); - } - - /** - * @inheritDoc - */ - public String getNsURIPrefix(String uri) { - return mModel.getNsURIPrefix( uri ); - } - - /** - * @inheritDoc - */ - public Statement getProperty(Resource s, Property p) { - return mModel.getProperty(s, p); - } - - /** - * @inheritDoc - */ - public Property getProperty(String nameSpace, String localName) { - return mModel.getProperty(nameSpace, localName); - } - - /** - * @inheritDoc - */ - public Property getProperty(String uri) { - return mModel.getProperty( uri ); - } - - /** - * @inheritDoc - */ - public RDFNode getRDFNode(Node n) { - return mModel.getRDFNode( n ); - } - - /** - * @inheritDoc - */ - public RDFReader getReader() { - return mModel.getReader(); - } - - /** - * @inheritDoc - */ - public RDFReader getReader(String lang) { - return mModel.getReader( lang ); - } - - /** - * @inheritDoc - */ - public ReificationStyle getReificationStyle() { - return mModel.getReificationStyle(); - } - - /** - * @inheritDoc - */ - public Statement getRequiredProperty(Resource s, Property p) { - return mModel.getRequiredProperty( s, p ); - } - - /** - * @inheritDoc - */ - public Resource getResource(String uri, ResourceF f) { - return mModel.getResource(uri, f); - } - - /** - * @inheritDoc - */ - public Resource getResource(String uri) { - return mModel.getResource( uri ); - } - - /** - * @inheritDoc - */ - public Seq getSeq(Resource r) { - return mModel.getSeq(r); - } - - /** - * @inheritDoc - */ - public Seq getSeq(String uri) { - return mModel.getSeq( uri ); - } - - /** - * @inheritDoc - */ - public RDFWriter getWriter() { - return mModel.getWriter(); - } - - /** - * @inheritDoc - */ - public RDFWriter getWriter(String lang) { - return mModel.getWriter( lang ); - } - - /** - * @inheritDoc - */ - public boolean independent() { - return mModel.independent(); - } - - /** - * @inheritDoc - */ - public Model intersection(Model model) { - return mModel.intersection( model ); - } - - /** - * @inheritDoc - */ - public boolean isClosed() { - return mModel.isClosed(); - } - - /** - * @inheritDoc - */ - public boolean isEmpty() { - return mModel.isEmpty(); - } - - /** - * @inheritDoc - */ - public boolean isIsomorphicWith(Model g) { - return mModel.isIsomorphicWith( g ); - } - - /** - * @inheritDoc - */ - public boolean isReified(Statement s) { - return mModel.isReified(s); - } - - /** - * @inheritDoc - */ - public void leaveCriticalSection() { - mModel.leaveCriticalSection(); - } - - /** - * @inheritDoc - */ - public StmtIterator listLiteralStatements(Resource subject, - Property predicate, boolean object) { - return mModel.listLiteralStatements(subject, predicate, object); - } - - /** - * @inheritDoc - */ - public StmtIterator listLiteralStatements(Resource subject, - Property predicate, char object) { - return mModel.listLiteralStatements(subject, predicate, object); - } - - /** - * @inheritDoc - */ - public StmtIterator listLiteralStatements(Resource subject, - Property predicate, double object) { - return mModel.listLiteralStatements(subject, predicate, object); - } - - /** - * @inheritDoc - */ - public StmtIterator listLiteralStatements(Resource subject, - Property predicate, float object) { - return mModel.listLiteralStatements(subject, predicate, object); - } - - /** - * @inheritDoc - */ - public StmtIterator listLiteralStatements(Resource subject, Property predicate, long object) { - return mModel.listLiteralStatements( subject, predicate, object ); - } - - /** - * @inheritDoc - */ - public NsIterator listNameSpaces() { - return mModel.listNameSpaces(); - } - - /** - * @inheritDoc - */ - public NodeIterator listObjects() { - return mModel.listObjects(); - } - - /** - * @inheritDoc - */ - public NodeIterator listObjectsOfProperty(Property p) { - return mModel.listObjectsOfProperty(p); - } - - /** - * @inheritDoc - */ - public NodeIterator listObjectsOfProperty(Resource s, Property p) { - return mModel.listObjectsOfProperty( s, p ); - } - - /** - * @inheritDoc - */ - public RSIterator listReifiedStatements() { - return mModel.listReifiedStatements(); - } - - /** - * @inheritDoc - */ - public RSIterator listReifiedStatements(Statement st) { - return mModel.listReifiedStatements( st ); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, boolean o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, char o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, double o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, float o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, long o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, Object o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p, RDFNode o) { - return mModel.listResourcesWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listResourcesWithProperty(Property p) { - return mModel.listResourcesWithProperty( p ); - } - - /** - * @inheritDoc - */ - public StmtIterator listStatements() { - return mModel.listStatements(); - } - - /** - * @inheritDoc - */ - public StmtIterator listStatements(Resource s, Property p, RDFNode o) { - return mModel.listStatements(s, p, o); - } - - /** - * @inheritDoc - */ - public StmtIterator listStatements(Resource subject, Property predicate, String object, String lang) { - return mModel.listStatements(subject, predicate, object, lang); - } - - /** - * @inheritDoc - */ - public StmtIterator listStatements(Resource subject, Property predicate, - String object) { - return mModel.listStatements(subject, predicate, object); - } - - /** - * @inheritDoc - */ - public StmtIterator listStatements(Selector s) { - return mModel.listStatements( s ); - } - - /** - * @inheritDoc - */ - public ResIterator listSubjects() { - return mModel.listSubjects(); - } - - /** - * @inheritDoc - */ - public ResIterator listSubjectsWithProperty(Property p, RDFNode o) { - return mModel.listSubjectsWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listSubjectsWithProperty(Property p, String o, String l) { - return mModel.listSubjectsWithProperty(p, o, l); - } - - /** - * @inheritDoc - */ - public ResIterator listSubjectsWithProperty(Property p, String o) { - return mModel.listSubjectsWithProperty(p, o); - } - - /** - * @inheritDoc - */ - public ResIterator listSubjectsWithProperty(Property p) { - return mModel.listSubjectsWithProperty( p ); - } - - /** - * @inheritDoc - */ - public PrefixMapping lock() { - return mModel.lock(); - } - - /** - * @inheritDoc - */ - public Model notifyEvent(Object e) { - return mModel.notifyEvent( e ); - } - - /** - * @inheritDoc - */ - public String qnameFor(String uri) { - return mModel.qnameFor( uri ); - } - - /** - * @inheritDoc - */ - public Model query(Selector s) { - return mModel.query( s ); - } - - /* - * @inritDoc - // sotty : apparently not defined in Jena 2.10.0, which is imported by empire-jena. - public QueryHandler queryHandler() { - return mModel.queryHandler(); - } - */ - - /** - * @inheritDoc - */ - public Model read(InputStream in, String base, String lang) { - return mModel.read(in, base, lang); - } - - /** - * @inheritDoc - */ - public Model read(InputStream in, String base) { - return mModel.read(in, base); - } - - /** - * @inheritDoc - */ - public Model read(Reader reader, String base, String lang) { - return mModel.read(reader, base, lang); - } - - /** - * @inheritDoc - */ - public Model read(Reader reader, String base) { - return mModel.read(reader, base); - } - - /** - * @inheritDoc - */ - public Model read(String url, String base, String lang) { - return mModel.read(url, base, lang); - } - - /** - * @inheritDoc - */ - public Model read(String url, String lang) { - return mModel.read(url, lang); - } - - /** - * @inheritDoc - */ - public Model read(String url) { - return mModel.read(url); - } - - /** - * @inheritDoc - */ - public Model register(ModelChangedListener listener) { - return mModel.register(listener); - } - - /** - * @inheritDoc - */ - public Model remove(List statements) { - return mModel.remove(statements); - } - - /** - * @inheritDoc - */ - public Model remove(Model m, boolean suppressReifications) { - return mModel.remove(m, suppressReifications); - } - - /** - * @inheritDoc - */ - public Model remove(Model m) { - return mModel.remove(m); - } - - /** - * @inheritDoc - */ - public Model remove(Resource s, Property p, RDFNode o) { - return mModel.remove(s, p, o); - } - - /** - * @inheritDoc - */ - public Model remove(Statement s) { - return mModel.remove(s); - } - - /** - * @inheritDoc - */ - public Model remove(Statement[] statements) { - return mModel.remove(statements); - } - - /** - * @inheritDoc - */ - public Model remove(StmtIterator iter) { - return mModel.remove(iter); - } - - /** - * @inheritDoc - */ - public Model removeAll() { - return mModel.removeAll(); - } - - /** - * @inheritDoc - */ - public Model removeAll(Resource s, Property p, RDFNode r) { - return mModel.removeAll(s, p, r); - } - - /** - * @inheritDoc - */ - public void removeAllReifications(Statement s) { - mModel.removeAllReifications(s); - } - - /** - * @inheritDoc - */ - public PrefixMapping removeNsPrefix(String prefix) { - return mModel.removeNsPrefix(prefix); - } - - /** - * @inheritDoc - */ - public void removeReification(ReifiedStatement rs) { - mModel.removeReification(rs); - } - - /** - * @inheritDoc - */ - public boolean samePrefixMappingAs(PrefixMapping other) { - return mModel.samePrefixMappingAs(other); - } - - /** - * @inheritDoc - */ - public PrefixMapping setNsPrefix(String prefix, String uri) { - return mModel.setNsPrefix(prefix, uri); - } - - /** - * @inheritDoc - */ - public PrefixMapping setNsPrefixes(Map map) { - return mModel.setNsPrefixes(map); - } - - /** - * @inheritDoc - */ - public PrefixMapping setNsPrefixes(PrefixMapping other) { - return mModel.setNsPrefixes(other); - } - - /** - * @inheritDoc - */ - public String setReaderClassName(String lang, String className) { - return mModel.setReaderClassName(lang, className); - } - - /** - * @inheritDoc - */ - public String setWriterClassName(String lang, String className) { - return mModel.setWriterClassName(lang, className); - } - - /** - * @inheritDoc - */ - public String shortForm(String uri) { - return mModel.shortForm(uri); - } - - /** - * @inheritDoc - */ - public long size() { - return mModel.size(); - } - - /** - * @inheritDoc - */ - public boolean supportsSetOperations() { - return mModel.supportsSetOperations(); - } - - /** - * @inheritDoc - */ - public boolean supportsTransactions() { - return mModel.supportsTransactions(); - } - - /** - * @inheritDoc - */ - public Model union(Model model) { - return mModel.union(model); - } - - /** - * @inheritDoc - */ - public Model unregister(ModelChangedListener listener) { - return mModel.unregister(listener); - } - - /** - * @inheritDoc - */ - public PrefixMapping withDefaultMappings(PrefixMapping map) { - return mModel.withDefaultMappings(map); - } - - /** - * @inheritDoc - */ - public Model write(OutputStream out, String lang, String base) { - return mModel.write(out, lang, base); - } - - /** - * @inheritDoc - */ - public Model write(OutputStream out, String lang) { - return mModel.write(out, lang); - } - - /** - * @inheritDoc - */ - public Model write(OutputStream out) { - return mModel.write(out); - } - - /** - * @inheritDoc - */ - public Model write(Writer writer, String lang, String base) { - return mModel.write(writer, lang, base); - } - - /** - * @inheritDoc - */ - public Model write(Writer writer, String lang) { - return mModel.write(writer, lang); - } - - /** - * @inheritDoc - */ - public Model write(Writer writer) { - return mModel.write(writer); - } - - /** - * @inheritDoc - */ - @Override - public int hashCode() { - return super.hashCode(); - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/jena/SDBDataSourceFactory.java b/sdb/main/src/com/clarkparsia/empire/jena/SDBDataSourceFactory.java deleted file mode 100644 index a6727df..0000000 --- a/sdb/main/src/com/clarkparsia/empire/jena/SDBDataSourceFactory.java +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright (c) 2009-2013 Clark & Parsia, LLC. - * - * 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 com.clarkparsia.empire.jena; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; - -import javax.naming.NamingException; -import javax.sql.DataSource; - -import com.clarkparsia.empire.config.EmpireConfiguration; -import com.clarkparsia.empire.config.io.impl.PropertiesConfigReader; -import com.clarkparsia.empire.ds.Alias; -import com.clarkparsia.empire.ds.DataSourceException; - -import com.clarkparsia.empire.sql.DSSettings; -import com.google.common.collect.Maps; -import com.google.inject.Inject; -import com.google.inject.name.Named; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.sdb.SDBFactory; -import com.hp.hpl.jena.sdb.Store; -import com.hp.hpl.jena.sdb.StoreDesc; -import com.hp.hpl.jena.sdb.sql.SDBConnection; -import com.hp.hpl.jena.sdb.store.DatabaseType; -import com.hp.hpl.jena.sdb.store.LayoutType; -import com.hp.hpl.jena.sdb.util.StoreUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

DataSourceFactory implementation for creating a DataSource instance backed by SDB.

- * - * @author Michael Grove - * @author uoccou - * @since 1.0 - * @version 1.0 - */ -@Alias("sdb") -public class SDBDataSourceFactory extends AbstractJenaDataSourceFactory { - /** - * the logger - */ - private static final Logger LOGGER = LoggerFactory.getLogger(SDBDataSourceFactory.class); - - /** - * Configuration parameter for specifying the key name of a NON container (jndi) datasource - * - * there should be corresponding global config entries on that keyname that can be used - * to populate {@link DSSettings} - */ - public static final String LOCAL_DS = "localDS"; - - /** - * Configuration parameter for specifying the key name of a container (jndi) datasource - */ - public static final String JNDI_DS = "jndiDS"; - - /** - * Configuration parameter for specifying the database type Jena expects for SDB StoreDesc - * {@link DatabaseType} - * will default to "MySQL" if not present - */ - public static final String DATABASE_TYPE = "databaseType"; - - /** - * Configuration parameter for specifying the layout type Jena expects for SDB StoreDesc - * {@link LayoutType} - * will default to "layout2/index" if not present - */ - public static final String LAYOUT_TYPE = "layoutType"; - - /** - * Configuration parameter for specifying that SDB database initialisation should happen. Check NOT performed unless - * this is set. That is, by default the database is assumed to have been initialised. - */ - public static final String INIT_SDB = "initSDB"; - - private static Map nameSdbDsCache = Maps.newHashMap();//ds name to DataSource - private static Map unitSdbDsCache = Maps.newHashMap();//configName to DataSource - - private EmpireConfiguration mConfig; - - @Inject - public SDBDataSourceFactory(@Named("ec") EmpireConfiguration theContainerConfig) { - mConfig = theContainerConfig; - } - - /** - * @inheritDoc - */ - @Override - public boolean canCreate(final Map theMap) { - return true; - } - - @Override - public com.clarkparsia.empire.ds.DataSource create(final Map theMap) throws DataSourceException { - - com.clarkparsia.empire.ds.DataSource aSource = null; - Model aModel = getSDBModel(theMap); - initSDBIfRequired(theMap); - - if (aModel != null) { - - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Got a model - creating DataSource "); - } - - if (theMap.containsKey(STREAM) && theMap.containsKey(FORMAT)) { - load(aModel, - asReader(theMap.get(STREAM)), - theMap.get(FORMAT).toString(), - theMap.containsKey(BASE) ? theMap.get(BASE).toString() : ""); - } - - if (theMap.containsKey(FILES)) { - loadFiles(aModel, - theMap.get(FILES).toString(), - theMap.containsKey(BASE) ? theMap.get(BASE).toString() : ""); - } - - if (aModel.supportsTransactions()) { - aSource = new JenaDataSourceSupportingTransactions(aModel); - } - else { - aSource = new JenaDataSource(aModel); - } - } - else { - LOGGER.error("Could not get a model - not creating DataSource. "); - } - - return aSource; - } - - /** - * Check for a locally defined non-container Datasource ref and create a DBCP based DataSource. - * if not available check for a JNDI data source ref and try and get a DataSource from JNDI. - * - * Override to provide direct context lookup if and when the datasource name gets passed from the persistenceUnitInfo - * - * @param theConfign the app configuration - * @return the DataSource for theConfig, or null - */ - protected DataSource getDataSource(Map theConfig) { - String unitName = theConfig.get(PropertiesConfigReader.KEY_NAME).toString(); - DataSource ds = unitSdbDsCache.get(unitName); - Map unitConfig = createUnitConfig(unitName); - - if (ds == null) { - if (unitConfig.containsKey(LOCAL_DS)) { - - String localDsName = unitConfig.get(LOCAL_DS).toString(); - if (null != localDsName) { - ds = createLocalDS(unitName, localDsName, unitConfig); - } - } - else if (unitConfig.containsKey(JNDI_DS)) { - String jndiDsName = unitConfig.get(JNDI_DS).toString(); - if (null != jndiDsName) { - ds = createJndiDS(unitName, jndiDsName); - } - } - } - return ds; - } - - /** - * Create the unit specific configuration properties by grabbing unit configuration from the Empire config - * - * @param theUnitName the name of the persistence unit configuration to retrieve - * @return the unit configuration - */ - private Map createUnitConfig(final String theUnitName) { - - Map aConfig = new HashMap(); - - if (mConfig.hasUnit(theUnitName)) { - aConfig.putAll(mConfig.getUnitConfig(theUnitName)); - } - - aConfig.putAll(mConfig.getGlobalConfig()); - - return aConfig; - } - - /** - * Create a DataSource using a JNDI context lookup - * - * @param unitName the unit name - * @param jndiDsName the ds name - * @return the DataSource via JNDI - */ - private DataSource createJndiDS(String unitName, String jndiDsName) { - DataSource ds = nameSdbDsCache.get(jndiDsName); - - if (ds == null) { - try { - ds = DSSettings.jndi(jndiDsName).build(); - } - catch (NamingException ne) { - LOGGER.error("Cant get JNDI name '" + jndiDsName + "' for config unit '" + unitName); - LOGGER.error("There will be connection and SQL exceptions !"); - } - } - - if (ds != null) { - cacheDataSource(jndiDsName, unitName, ds); - } - - return ds; - } - - /** - * create a Local (non-container) datasource, cache it by name, and by unitName - * Uses empire.properties to define DataSource - * - * @param unitName - * @param dsName - * @param theConfig - * @return - */ - private DataSource createLocalDS(String unitName, String dsName, Map theConfig) { - DataSource ds = nameSdbDsCache.get(dsName); - - if (ds == null) { - DSSettings config = new DSSettings(dsName); - - if (theConfig.containsKey(dsName + ".url")) { - config.setUrl(theConfig.get(dsName + ".url").toString()); - } - if (theConfig.containsKey(dsName + ".db")) { - config.setDb(theConfig.get(dsName + ".db").toString()); - } - if (theConfig.containsKey(dsName + ".driver")) { - config.setDriver(theConfig.get(dsName + ".driver").toString()); - } - if (theConfig.containsKey(dsName + ".user")) { - config.setUser(theConfig.get(dsName + ".user").toString()); - } - if (theConfig.containsKey(dsName + ".password")) { - config.setPassword(theConfig.get(dsName + ".password").toString()); - } - if (theConfig.containsKey(dsName + ".autocommit")) { - config.setAutocommit(theConfig.get(dsName + ".autocommit").toString()); - } - if (theConfig.containsKey(dsName + ".isolation")) { - config.setIsolation(theConfig.get(dsName + ".isolation").toString()); - } - if (theConfig.containsKey(dsName + ".maxActive")) { - config.setMaxActive(theConfig.get(dsName + ".maxActive").toString()); - } - if (theConfig.containsKey(dsName + ".maxIdle")) { - config.setMaxIdle(theConfig.get(dsName + ".maxIdle").toString()); - } - if (theConfig.containsKey(dsName + ".maxWait")) { - config.setMaxWait(theConfig.get(dsName + ".maxWait").toString()); - } - - //create the data source and bind the context name - //@TODO : what if context name already exists in context ? - try { - ds = config.c3po().build(); - } - catch (NamingException ne) { - LOGGER.error("Cant get local Datasource of name '" + dsName + "' for config unit '" + unitName); - LOGGER.error("There will be connection and SQL exceptions !"); - } - } - - cacheDataSource(dsName, unitName, ds); - - return ds; - } - - private void cacheDataSource(String dsName, String unitName, DataSource ds) { - if (ds != null) { - nameSdbDsCache.put(dsName, ds); - - //shold this be preserved as well ? will this ever happen ? - can a datasource - //for a unit config be changed dynamically ? - unitSdbDsCache.put(unitName, ds); - } - } - - /** - * if the config contains {@link com.clarkparsia.empire.jena.JenaConfig.INIT_SDB}=true then initialise the database in the DataStore - * for this config. If not present, no initialisation check is done, or performed - so use it first time, then remove - * to avoid checking - */ - private void initSDBIfRequired(Map theConfig) { - - if (theConfig.containsKey(INIT_SDB)) { - - String isInit = theConfig.get(INIT_SDB).toString(); - - if (Boolean.valueOf(isInit)) { - // next get a Jena Store - - DataSource ds = getDataSource(theConfig); - - Store store = null; - Connection jdbcConn = null; - try { - jdbcConn = ds.getConnection(); - - if (null != jdbcConn) { - - store = getSDBStore(theConfig, jdbcConn); - - - try { - if (!StoreUtils.isFormatted(store)) { - store.getTableFormatter().create(); - } - } - catch (SQLException e) { - e.printStackTrace(); - } - finally { - store.close(); - } - } - } - catch (SQLException sqle) { - LOGGER.error("Cant get connection to datasource " + ds.toString() + " - null model will be returned !"); - } - } - } - - } - - /** - * Create and SDB model for a particular configUnit. If the unit has ontology, then create an ontModel and add the - * created SDB model. Initial call gets a DataSource depending on presence of JenaConfig.JNDI or JenaConfig.DS. - *

- * It is possible to get a Null return from this method, if factory fails, or if the SDB model cannot be added to the ontModel. - * - * @param theConfig the configuration - * @return an SDB model - */ - private Model getSDBModel(Map theConfig) { - - String configName = theConfig.get(PropertiesConfigReader.KEY_NAME).toString(); - - DataSource ds = getDataSource(theConfig); - - Model m = null; - SDBModelWithStore ms = null; - Store store = null; - Connection jdbcConn = null; - - if (null != ds) { - try { - jdbcConn = ds.getConnection(); - - if (null != jdbcConn) { - store = getSDBStore(theConfig, jdbcConn); - //next connect to the store. You can connect to the default graph or to a named graph - //connect to the default graph - - //@TODO NameGraph/model support - Model aModel = SDBFactory.connectDefaultModel(store); - - Model mm = getCachedOntModel(configName); - if (mm != null) { - mm.add(m); - m = mm; - } - else { - m = aModel; - } - } - } - catch (SQLException sqle) { - LOGGER.error("Cant get connection to datasource " + ds.toString() + " - null model will be returned !"); - } - } - - if (null != m) { - ms = new SDBModelWithStore(m, jdbcConn); // allow JPA (in theory) to control jdbc and model commits and close - } - - return ms; - //return m; //if you do this, rather than return a SDBModelWithStore, Jena will consume all connections in the pool - } - - - /** - * Get a Jena Store object so that we can connect to DB and create Model - * - * @param theConfig the app configuration - * @param jdbcConn the JDBC connection - * @return the SDB store - */ - private Store getSDBStore(Map theConfig, Connection jdbcConn) { - SDBConnection conn; - Store store = null; - if (null != jdbcConn) { - conn = new SDBConnection(jdbcConn); - //store.getLoader().setUseThreading(true); - //store.getLoader().setChunkSize(128); - //@TODO cache the StoreDesc ?, Store (theyre lightweight, maybe not much advantage) - String layout = theConfig.containsKey(LAYOUT_TYPE) ? theConfig.get(LAYOUT_TYPE).toString() : LayoutType.LayoutTripleNodesIndex.getName(); - String databaseType = theConfig.containsKey(DATABASE_TYPE) ? theConfig.get(DATABASE_TYPE).toString() : DatabaseType.MySQL.getName(); - StoreDesc desc = new StoreDesc(layout, databaseType); - store = SDBFactory.connectStore(conn, desc); - } - return store; - } - - /** - * Get a Jena Store object so that we can connect to DB and create Model - * - * @param theConfig the app config - * @param jdbcConn the JDBC connectino for SDB - * @return the SDB store - */ - private Store getSDBStore(Map theConfig, DataSource jdbcConn) { - SDBConnection conn = null; - Store store = null; - if (null != jdbcConn) { - try { - conn = new SDBConnection(jdbcConn); - } - catch (SQLException e) { - e.printStackTrace(); - } - //store.getLoader().setUseThreading(true); - //store.getLoader().setChunkSize(128); - //@TODO cache the StoreDesc ?, Store (theyre lightweight, maybe not much advantage) - String layout = theConfig.containsKey(LAYOUT_TYPE) ? theConfig.get(LAYOUT_TYPE).toString() : LayoutType.LayoutTripleNodesIndex.getName(); - String databaseType = theConfig.containsKey(DATABASE_TYPE) ? theConfig.get(DATABASE_TYPE).toString() : DatabaseType.MySQL.getName(); - StoreDesc desc = new StoreDesc(layout, databaseType); - store = SDBFactory.connectStore(conn, desc); - } - return store; - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/jena/SDBModelWithStore.java b/sdb/main/src/com/clarkparsia/empire/jena/SDBModelWithStore.java deleted file mode 100644 index 7021e1e..0000000 --- a/sdb/main/src/com/clarkparsia/empire/jena/SDBModelWithStore.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2009-2013 Clark & Parsia, LLC. - * - * 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 com.clarkparsia.empire.jena; - -import java.sql.Connection; -import java.sql.SQLException; - -import com.hp.hpl.jena.rdf.model.Model; - -/** - * Simple override of Jena Model for use with JPA so that pooled jdbc connection from DataSource and Jena Model - * can be committed and closed in synchrony. - * - * @author uoccou - * @since 0.7 - * @version 1.0 - */ -final class SDBModelWithStore extends AbstractDelegateModel { - - /** - * JDBC connection to the actual store - */ - private Connection sdbc = null; - - /** - * Create a new ModelWithStore - * - * @param m the jena model of SDB - * @param sdbc the jdbc connection - */ - public SDBModelWithStore(Model m, Connection sdbc) { - super(m); - this.sdbc = sdbc; - } - - /** - * @inheritDoc - */ - @Override - public void enterCriticalSection(boolean readLockRequested) { - //super.enterCriticalSection(readLockRequested); - log.debug("spoofing critical section"); - } - - /** - * @inheritDoc - */ - @Override - public void leaveCriticalSection() { - //super.leaveCriticalSection(); - log.debug("end of spoof critical section"); - } - - /** - * @inheritDoc - */ - @Override - public void close() { - - try { - if (null != sdbc && !sdbc.isClosed()) { - sdbc.close(); - } - } - catch (SQLException e) { - e.printStackTrace(); - } - super.close(); - } - - /** - * @inheritDoc - */ - @Override - public Model commit() { - Model m = null; - try { - - if (null != sdbc && !sdbc.isClosed()) { - sdbc.commit(); - } - - m = super.commit(); - } - catch (SQLException e) { - log.error("SQL Exception trying to commit to the underlying JDBC connection", e); - } - return m; - } - - /** - * @inheritDoc - */ - @Override - public Model begin() { - Model m = super.begin(); - - try { - sdbc.setAutoCommit(false); - } - catch (SQLException e) { - log.error("SQL Exception trying to disable auto commit", e); - } - - return m; - } - - public Connection getSDBConnection() { - return sdbc; - } - - public void setSDBConnection(Connection sdbc) { - this.sdbc = sdbc; - } -} \ No newline at end of file diff --git a/sdb/main/src/com/clarkparsia/empire/sql/AbstractSqlDS.java b/sdb/main/src/com/clarkparsia/empire/sql/AbstractSqlDS.java deleted file mode 100644 index d775161..0000000 --- a/sdb/main/src/com/clarkparsia/empire/sql/AbstractSqlDS.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2009-2012 Clark & Parsia, LLC. - * Copyright (c) 2010, Ultan O'Carroll - * - * 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 com.clarkparsia.empire.sql; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; - -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.sql.DataSource; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract basic functionality for DataSource wrappers - * - * @author uoccou - * @author Michael Grove - * @version 0.7 - * @since 0.7 - */ -abstract class AbstractSqlDS implements DataSource { - - protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); - - private DataSource ds = null; - - private DSSettings config = null; - - private InitialContext ctx = null; - - /* - * Lookup the DataSource, which will be backed by a pool - * that the application server provides. DataSource instances - * are also a good candidate for caching as an instance - * variable, as JNDI lookups can be expensive as well. - */ - private String contextName = "java/ds"; - - AbstractSqlDS(final DSSettings theConfig) { - config = theConfig; - - contextName = theConfig.getContextName(); - } - - public abstract void init() throws NamingException; - - public InitialContext getInitialContext() { - return ctx; - } - - public void setInitialContext(InitialContext ctx) { - this.ctx = ctx; - } - - public String getContextName() { - return contextName; - } - - public void setContextName(String contextName) { - this.contextName = contextName; - } - - /** - * @inheritDoc - */ - public Connection getConnection() { - - Connection con = null; - - try { - con = getDataSource().getConnection(); - con.setAutoCommit(false); - } - catch (SQLException e) { - LOGGER.warn("Exception getting connection to database : " + e.toString()); - } - - return con; - } - - /** - * @inheritDoc - */ - public Connection getConnection(String username, String password) { - - Connection con = null; - - try { - con = getDataSource().getConnection(username, password); - con.setAutoCommit(false); - //reset from default MySQL of repeatable_read - con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); - - } - catch (SQLException e) { - LOGGER.warn("Exception getting connection to database : " + e.toString()); - } - - return con; - } - - /** - * @inheritDoc - */ - public PrintWriter getLogWriter() throws SQLException { - return ds.getLogWriter(); - } - - /** - * @inheritDoc - */ - public int getLoginTimeout() throws SQLException { - return ds.getLoginTimeout(); - } - - /** - * @inheritDoc - */ - public void setLogWriter(PrintWriter out) throws SQLException { - ds.setLogWriter(out); - } - - /** - * @inheritDoc - */ - public void setLoginTimeout(int seconds) throws SQLException { - ds.setLoginTimeout(seconds); - } - - /** - * @inheritDoc - */ - public boolean isWrapperFor(Class iface) throws SQLException { - return ds.isWrapperFor(iface); - } - - /** - * @inheritDoc - */ - public T unwrap(Class iface) throws SQLException { - return ds.unwrap(iface); - } - - public DataSource getDataSource() { - DataSource ds = null; - - try { - ds = (DataSource) getInitialContext().lookup(getContextName()); - } - catch (NamingException e) { - e.printStackTrace(); - } - - return ds; - } - - public void setDataSource(DataSource ds) { - this.ds = ds; - } - - public DSSettings getConfig() { - return config; - } - - public void setConfig(DSSettings config) { - this.config = config; - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/sql/DSC3poContext.java b/sdb/main/src/com/clarkparsia/empire/sql/DSC3poContext.java deleted file mode 100644 index 165b376..0000000 --- a/sdb/main/src/com/clarkparsia/empire/sql/DSC3poContext.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.clarkparsia.empire.sql; - -import java.beans.PropertyVetoException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.logging.Logger; - -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import javax.sql.DataSource; - -import com.mchange.v2.c3p0.ComboPooledDataSource; - -/** - * javax.sql.Datasource using DBCP BasicDataSourceFactory - * - * @author uoccou - * @author Michael Grove - * @since 0.7 - * @version 0.7 - */ -class DSC3poContext extends AbstractSqlDS { - - DSC3poContext(DSSettings theConfig) throws NamingException { - super(theConfig); - - init(); - } - - public void init() throws NamingException { - - /* - * - */ - - try { - InitialContext aContext = new InitialContext(); - setInitialContext(aContext); - - ComboPooledDataSource cpds = new ComboPooledDataSource(); - - cpds.setDriverClass(getConfig().getDriver()); - - //loads the jdbc driver - cpds.setJdbcUrl(getConfig().getUrl()); - cpds.setUser(getConfig().getUser()); - cpds.setPassword(getConfig().getPassword()); - cpds.setMaxPoolSize(Integer.valueOf(getConfig().getMaxActive())); - cpds.setMinPoolSize(Integer.valueOf(getConfig().getMaxIdle())); - cpds.setAcquireIncrement(1); - - aContext.rebind(getContextName(), cpds); - setDataSource((DataSource) aContext.lookup(getContextName())); - } - catch (PropertyVetoException e) { - e.printStackTrace(); - } - catch (NamingException ne) { - ne.printStackTrace(); - } - } - - /** - * Added due to DataSource evolution in Java7. Sorry, but I can't understand the beginning of that - * @return - * @throws SQLFeatureNotSupportedException - * @see javax.sql.CommonDataSource#getParentLogger() - */ - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(new UnsupportedOperationException("method "+DSC3poContext.class.getName()+"#getParentLogger has not yet been implemented AT ALL")); - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/sql/DSContext.java b/sdb/main/src/com/clarkparsia/empire/sql/DSContext.java deleted file mode 100644 index 9ac79fc..0000000 --- a/sdb/main/src/com/clarkparsia/empire/sql/DSContext.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2009-2012 Clark & Parsia, LLC. - * Copyright (c) 2010, Ultan O'Carroll - * - * 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 com.clarkparsia.empire.sql; - -import java.sql.SQLFeatureNotSupportedException; -import java.util.logging.Logger; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.naming.Reference; -import javax.naming.StringRefAddr; -import javax.sql.DataSource; - -/** - * javax.sql.Datasource using DBCP BasicDataSourceFactory - * - * @author uoccou - * @author Michael Grove - * @since 0.7 - * @version 0.7 - */ -class DSContext extends AbstractSqlDS { - - private String contextFactoryName = "com.sun.jndi.fscontext.RefFSContextFactory"; - - private String providerUrl = "file:///tmp"; - - private String dataSourceFactory = "org.apache.commons.dbcp.BasicDataSourceFactory"; - - DSContext(DSSettings config, String contextFactoryName, - String providerUrl, String dataSourceFactory) throws NamingException { - super(config); - this.contextFactoryName = contextFactoryName; - this.providerUrl = providerUrl; - this.dataSourceFactory = dataSourceFactory; - init(); - } - - DSContext(DSSettings config) throws NamingException { - super(config); - init(); - } - - public void init() throws NamingException { - System.setProperty(Context.INITIAL_CONTEXT_FACTORY, getContextFactoryName()); - System.setProperty(Context.PROVIDER_URL, getProviderUrl()); - - setInitialContext(new InitialContext()); - - // Construct BasicDataSource reference - Reference ref = new Reference("javax.sql.DataSource", getDataSourceFactory(), null); - - ref.add(new StringRefAddr("driverClassName", getConfig().getDriver())); - ref.add(new StringRefAddr("url", getConfig().getUrl())); - ref.add(new StringRefAddr("username", getConfig().getUser())); - ref.add(new StringRefAddr("password", getConfig().getPassword())); - ref.add(new StringRefAddr("defaultAutoCommit", getConfig().getAutocommit())); - - ref.add(new StringRefAddr("maxActive", getConfig().getMaxActive())); - ref.add(new StringRefAddr("maxIdle", getConfig().getMaxIdle())); - ref.add(new StringRefAddr("maxWait", getConfig().getMaxWait())); - ref.add(new StringRefAddr("validationQuery", "/* ping */")); - - getInitialContext().rebind(getContextName(), ref); - setDataSource((DataSource) getInitialContext().lookup(getContextName())); - } - - public String getContextFactoryName() { - return contextFactoryName; - } - - public void setContextFactoryName(String contextFactoryName) { - this.contextFactoryName = contextFactoryName; - } - - public String getProviderUrl() { - return providerUrl; - } - - public void setProviderUrl(String providerUrl) { - this.providerUrl = providerUrl; - } - - public String getDataSourceFactory() { - return dataSourceFactory; - } - - public void setDataSourceFactory(String dataSourceFactory) { - this.dataSourceFactory = dataSourceFactory; - } - - /** - * Added due to DataSource evolution in Java7. Sorry, but I can't understand the beginning of that - * @return - * @throws SQLFeatureNotSupportedException - * @see javax.sql.CommonDataSource#getParentLogger() - */ - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(new UnsupportedOperationException("method "+DSContext.class.getName()+"#getParentLogger has not yet been implemented AT ALL")); - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/sql/DSJndi.java b/sdb/main/src/com/clarkparsia/empire/sql/DSJndi.java deleted file mode 100644 index be75cad..0000000 --- a/sdb/main/src/com/clarkparsia/empire/sql/DSJndi.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2009-2012 Clark & Parsia, LLC. - * Copyright (c) 2010, Ultan O'Carroll - * - * 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 com.clarkparsia.empire.sql; - -import java.sql.SQLFeatureNotSupportedException; -import java.util.logging.Logger; - -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import javax.sql.DataSource; - -/** - * Datasource using JNDI context to provide connections. - * - * @author uoccou - * @author Michael Grove - * @version 0.7 - * @since 0.7 - */ -class DSJndi extends AbstractSqlDS { - - /* - * Create a JNDI Initial context to be able to - * lookup the DataSource - * - * In production-level code, this should be cached as - * an instance or static variable, as it can - * be quite expensive to create a JNDI context. - * - * Note: This code only works when you are using servlets - * or EJBs in a J2EE application server. If you are - * using connection pooling in standalone Java code, you - * will have to create/configure datasources using whatever - * mechanisms your particular connection pooling library - * provides. - * @see DSContext - */ - DSJndi(DSSettings theConfig, InitialContext theContext) throws NamingException { - super(theConfig); - - setInitialContext(theContext); - - init(); - } - - DSJndi(DSSettings theConfig) throws NamingException { - super(theConfig); - init(); - } - - /** - * @inheritDoc - */ - public void init() throws NamingException { - if (getInitialContext() == null) { - setInitialContext(new InitialContext()); - } - - setDataSource((DataSource) getInitialContext().lookup(getContextName())); - } - - /** - * Added due to DataSource evolution in Java7. Sorry, but I can't understand the beginning of that - * @return - * @throws SQLFeatureNotSupportedException - * @see javax.sql.CommonDataSource#getParentLogger() - */ - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(new UnsupportedOperationException("method "+DSJndi.class.getName()+"#getParentLogger has not yet been implemented AT ALL")); - } -} diff --git a/sdb/main/src/com/clarkparsia/empire/sql/DSSettings.java b/sdb/main/src/com/clarkparsia/empire/sql/DSSettings.java deleted file mode 100644 index f53875a..0000000 --- a/sdb/main/src/com/clarkparsia/empire/sql/DSSettings.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2009-2012 Clark & Parsia, LLC. - * Copyright (c) 2010, Ultan O'Carroll - * - * 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 com.clarkparsia.empire.sql; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.sql.DataSource; -import javax.naming.NamingException; - -/** - *

Dumb Mutable value object for DataSource connection settings

- *
    - *
  • url (default : "jdbc:mysql://localhost:3306/")
  • - *
  • db (name)
  • - *
  • driver (FQ jdbc driver Class name)
  • - *
  • user
  • - *
  • password
  • - *
  • autocommit (default false)
  • - *
  • isolation (default TRANSACTION_READ_COMMITTED)
  • - *
  • maxActive (default 10)
  • - *
  • maxIdle (default 5)
  • - *
  • maxWait (default 5000)
  • - *
- * http://purl.org/skytwenty/regperson.owl#Location/http://purl.org/skytwenty/regperson.owl#Location/http%3A%2F%2Fpurl.org%2Fskytwenty%2Fregperson.owl%23OpenIDRegisteredPerson%2Fhttp%253A%252F%252Fwww.google.com%252Fprofiles%252FTreasureCorpIsland%252F_ANY_Midp21+Device_84766997133853%2F - * - * @author uoccou - * @author Michael Grove - * @since 0.7 - * @version 0.7 - */ -public class DSSettings { - protected final Logger _logger = LoggerFactory.getLogger(this.getClass()); - - private String url = "jdbc:mysql://localhost:3306/"; - private String db = "abcdef"; - private String driver = "com.mysql.jdbc.Driver"; - private String user = "root"; - private String password = "abcdef"; - private String autocommit = "false"; - private String isolcation = "TRANSACTION_READ_COMMITTED"; - private String maxActive = "10"; - private String maxIdle = "5"; - private String maxWait = "5000"; //ms waiting for a conn - - private String contextName = JDBC_CONTEXT_NAME; - - private static final String JNDI_CONTEXT_NAME = "java/js"; - private static final String JDBC_CONTEXT_NAME = "jdbc/js"; - - public static DSSettings jndi(final String theJndiDsName) { - return new DSSettings(theJndiDsName).jndi(); - } - - private enum Type { - JNDI, C3PO, Plain - } - - private Type type = Type.Plain; - - public DSSettings() { - } - - public DSSettings(final String theContextName) { - contextName = theContextName; - } - - public DataSource build() throws NamingException { - switch (type) { - case JNDI: - return new DSJndi(this); - case C3PO: - return new DSC3poContext(this); - default: - return new DSContext(this); - } - } - - public DSSettings setContextName(String theName) { - contextName = theName; - return this; - } - - public String getContextName() { - return contextName; - } - - public DSSettings jndi() { - type = Type.JNDI; - return this; - } - - public DSSettings jdbc() { - type = Type.Plain; - return this; - } - - public DSSettings c3po() { - type = Type.C3PO; - return this; - } - - public String getUrl() { - return url; - } - - public DSSettings setUrl(String url) { - this.url = url; - return this; - } - - public String getDb() { - return db; - } - - public void setDb(String db) { - this.db = db; - } - - public String getDriver() { - return driver; - } - - public DSSettings setDriver(String driver) { - this.driver = driver; - return this; - } - - public String getUser() { - return user; - } - - public DSSettings setUser(String user) { - this.user = user; - return this; - } - - public String getPassword() { - return password; - } - - public DSSettings setPassword(String password) { - this.password = password; - return this; - } - - public void init() { - try { - // Instantiate database driver - Class.forName(getDriver()); - } - catch (ClassNotFoundException e) { - _logger.error("Unable to declare DB Driver: " + getDriver(), e); - } - } - - public String getAutocommit() { - return autocommit; - } - - public DSSettings setAutocommit(String autocommit) { - this.autocommit = autocommit; - return this; - } - - public String getIsolation() { - return isolcation; - } - - public DSSettings setIsolation(String isolcation) { - this.isolcation = isolcation; - return this; - } - - public String getMaxActive() { - return maxActive; - } - - public DSSettings setMaxActive(String maxActive) { - this.maxActive = maxActive; - return this; - } - - public String getMaxWait() { - return maxWait; - } - - public DSSettings setMaxWait(String maxWait) { - this.maxWait = maxWait; - return this; - } - - public String getMaxIdle() { - return maxIdle; - } - - public DSSettings setMaxIdle(String maxIdle) { - this.maxIdle = maxIdle; - return this; - } -} diff --git a/sdb/pom.xml b/sdb/pom.xml deleted file mode 100644 index 18d21fd..0000000 --- a/sdb/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - com.clarkparsia.empire - Empire-parent - 0.8.4 - - - 4.0.0 - com.clarkparsia.empire - sdb - jar - http://www.clarkparsia.com - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - main/src - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - 1.6 - 1.6 - - - - - - - - com.clarkparsia.empire - empire - ${project.version} - - - com.clarkparsia.empire - sesame - ${project.version} - - - com.clarkparsia.empire - jena - ${project.version} - - - com.hp.hpl.jena - sdb - 1.3.4 - - - c3p0 - c3p0 - 0.9.1.2 - - - diff --git a/sesame/.gitignore b/sesame/.gitignore deleted file mode 100644 index 28c6fce..0000000 --- a/sesame/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.DS_Store -build -dist -out -*.iml -target diff --git a/sesame/build.gradle b/sesame/build.gradle new file mode 100644 index 0000000..20de634 --- /dev/null +++ b/sesame/build.gradle @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + compile project(":core") + testCompile project(path: ":core", configuration: "testRuntime") +} + +test { + workingDir = projectDir +// debug = true // for attaching the IDE to the gradle cli + + // set JVM arguments for the test JVM(s) + jvmArgs '-XX:MaxPermSize=256m', '-enableassertions' + include"**/SesameTestSuite.class" +} \ No newline at end of file diff --git a/sesame/build.xml b/sesame/build.xml deleted file mode 100644 index 0a63a77..0000000 --- a/sesame/build.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - Empire: Sesame - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sesame/ivy.xml b/sesame/ivy.xml deleted file mode 100644 index f092300..0000000 --- a/sesame/ivy.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Empire: JPA for the Semantic Web. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sesame/main/src/com/clarkparsia/empire/sesame/OpenRdfEmpireModule.java b/sesame/main/src/com/clarkparsia/empire/sesame/OpenRdfEmpireModule.java index 8da0a00..7a125bc 100644 --- a/sesame/main/src/com/clarkparsia/empire/sesame/OpenRdfEmpireModule.java +++ b/sesame/main/src/com/clarkparsia/empire/sesame/OpenRdfEmpireModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2013 Clark & Parsia, LLC. + * Copyright (c) 2009-2015 Clark & Parsia, LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/sesame/pom.template b/sesame/pom.template deleted file mode 100644 index 445dc25..0000000 --- a/sesame/pom.template +++ /dev/null @@ -1,79 +0,0 @@ -${ivy.pom.license} -${ivy.pom.header} - - - - com.clarkparsia.empire - Empire-parent - 0.8.6 - - - 4.0.0 - ${ivy.pom.groupId} - ${ivy.pom.artifactId} - ${ivy.pom.packaging} - ${ivy.pom.version} - ${ivy.pom.name} - ${ivy.pom.description} - ${ivy.pom.url} - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - main/src - - - - - add-test-source - generate-test-sources - - add-test-source - - - - test/src - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12.4 - - - **/SesameTestSuite.java - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - 1.6 - 1.6 - - - - - - - diff --git a/sesame/pom.xml b/sesame/pom.xml deleted file mode 100644 index 3d6eec8..0000000 --- a/sesame/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - com.clarkparsia.empire - Empire-parent - 0.8.4 - - - 4.0.0 - com.clarkparsia.empire - sesame - jar - 0.8.4 - http://www.clarkparsia.com - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.1 - - - add-source - generate-sources - - add-source - - - - main/src - - - - - add-test-source - generate-test-sources - - add-test-source - - - - test/src - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12.4 - - - **/SesameTestSuite.java - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3 - - 1.6 - 1.6 - - - - - - - - - com.clarkparsia.empire - empire - 0.8.4 - tests - test - - - com.clarkparsia.empire - empire - 0.8.4 - compile - - - com.google.guava - guava - 15.0 - compile - - - com.google.code.findbugs - * - - - - - org.openrdf.sesame - sesame-runtime - 2.7.10 - compile - - - org.slf4j - * - - - - - org.slf4j - slf4j-api - 1.7.5 - compile - - - org.slf4j - slf4j-jdk14 - 1.7.5 - compile - - - com.google.inject - guice - 3.0 - compile - - - com.google.inject.extensions - guice-multibindings - 3.0 - compile - - - commons-dbcp - commons-dbcp - 1.3 - compile - - - junit - junit - 4.8.2 - compile - - - diff --git a/sesame/test/src/com/clarkparsia/empire/sesame/SesameEntityManagerTestSuite.java b/sesame/test/src/com/clarkparsia/empire/sesame/SesameEntityManagerTestSuite.java index b5def80..ee4d5a6 100644 --- a/sesame/test/src/com/clarkparsia/empire/sesame/SesameEntityManagerTestSuite.java +++ b/sesame/test/src/com/clarkparsia/empire/sesame/SesameEntityManagerTestSuite.java @@ -15,8 +15,6 @@ package com.clarkparsia.empire.sesame; -import java.io.File; - import com.clarkparsia.empire.ds.DataSourceFactory; import com.clarkparsia.empire.EntityManagerTestSuite; diff --git a/sesame/test/src/com/clarkparsia/empire/sesame/SesameTestSuite.java b/sesame/test/src/com/clarkparsia/empire/sesame/SesameTestSuite.java index a3d24f7..d35e6de 100644 --- a/sesame/test/src/com/clarkparsia/empire/sesame/SesameTestSuite.java +++ b/sesame/test/src/com/clarkparsia/empire/sesame/SesameTestSuite.java @@ -15,9 +15,6 @@ package com.clarkparsia.empire.sesame; -import java.io.File; -import java.net.URL; - import com.clarkparsia.empire.Empire; import com.clarkparsia.empire.util.DefaultEmpireModule; diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ea6d442 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + + include ':core', ':examples', ':jena', ':reflections', ':sesame', ':stardog' diff --git a/settings/ivysettings.xml b/settings/ivysettings.xml deleted file mode 100644 index 3e06180..0000000 --- a/settings/ivysettings.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings/lib/com/complexible/common/core/3.1.1/cp-common-utils-3.1.1.jar b/settings/lib/com/complexible/common/core/3.1.1/cp-common-utils-3.1.1.jar deleted file mode 100644 index b4f0922..0000000 Binary files a/settings/lib/com/complexible/common/core/3.1.1/cp-common-utils-3.1.1.jar and /dev/null differ diff --git a/settings/lib/com/complexible/common/core/3.1.1/ivy.xml b/settings/lib/com/complexible/common/core/3.1.1/ivy.xml deleted file mode 100644 index 037d7f6..0000000 --- a/settings/lib/com/complexible/common/core/3.1.1/ivy.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - Core utility classes for various common tasks. In many cases classes extend or supplement - functionality provided by Guava, but also includes a number of general purpose utility classes. - - - - - - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/com/complexible/common/openrdf/2.0.2/cp-common-openrdf-2.0.2.jar b/settings/lib/com/complexible/common/openrdf/2.0.2/cp-common-openrdf-2.0.2.jar deleted file mode 100644 index 5fab2c4..0000000 Binary files a/settings/lib/com/complexible/common/openrdf/2.0.2/cp-common-openrdf-2.0.2.jar and /dev/null differ diff --git a/settings/lib/com/complexible/common/openrdf/2.0.2/ivy.xml b/settings/lib/com/complexible/common/openrdf/2.0.2/ivy.xml deleted file mode 100644 index d18ba2b..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.2/ivy.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - This is a small library of some basic utility classes for working with the OpenRdf Sesame API. - - - - - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar b/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar deleted file mode 100644 index e81e8f3..0000000 Binary files a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar and /dev/null differ diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.md5 b/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.md5 deleted file mode 100644 index c45e902..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -88565703691a1475cbfaba9278110ca1 \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.sha1 b/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.sha1 deleted file mode 100644 index 60c80a8..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.3/cp-common-openrdf-2.0.3.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -76c5392bcf6b886594fadaec4fb6f5141279f09f \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml b/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml deleted file mode 100644 index 89a1d88..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - This is a small library of some basic utility classes for working with the OpenRdf Sesame API. - - - - - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.md5 b/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.md5 deleted file mode 100644 index 2b1eb95..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.md5 +++ /dev/null @@ -1 +0,0 @@ -6d28755df4e2875f350b02092112898a \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.sha1 b/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.sha1 deleted file mode 100644 index 9a04604..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.3/ivy.xml.sha1 +++ /dev/null @@ -1 +0,0 @@ -2cb8d6a09b0670d2f0ad8c003a425fdfe587ea42 \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar b/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar deleted file mode 100644 index da09b18..0000000 Binary files a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar and /dev/null differ diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.md5 b/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.md5 deleted file mode 100644 index 80641f3..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -97ed7e0469de64c373047b26febac4e6 \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.sha1 b/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.sha1 deleted file mode 100644 index 10c5cdd..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.4/cp-common-openrdf-2.0.4.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d4abade400bc12bd5bea6af09f561d1ac626f638 \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml b/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml deleted file mode 100644 index dd31a78..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - This is a small library of some basic utility classes for working with the OpenRdf Sesame API. - - - - - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.md5 b/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.md5 deleted file mode 100644 index 60cf0f2..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.md5 +++ /dev/null @@ -1 +0,0 @@ -d412758ddd0d9e08add59f3ea5f2c81e \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.sha1 b/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.sha1 deleted file mode 100644 index ffd09ab..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0.4/ivy.xml.sha1 +++ /dev/null @@ -1 +0,0 @@ -c8de49ff2f84d71ba624db6d1e442ee45526b576 \ No newline at end of file diff --git a/settings/lib/com/complexible/common/openrdf/2.0/cp-common-openrdf-2.0.jar b/settings/lib/com/complexible/common/openrdf/2.0/cp-common-openrdf-2.0.jar deleted file mode 100644 index 2c64e39..0000000 Binary files a/settings/lib/com/complexible/common/openrdf/2.0/cp-common-openrdf-2.0.jar and /dev/null differ diff --git a/settings/lib/com/complexible/common/openrdf/2.0/ivy.xml b/settings/lib/com/complexible/common/openrdf/2.0/ivy.xml deleted file mode 100644 index 27692ff..0000000 --- a/settings/lib/com/complexible/common/openrdf/2.0/ivy.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - This is a small library of some basic utility classes for working with the OpenRdf Sesame API. - - - - - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/ivy.xml b/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/ivy.xml deleted file mode 100644 index 24660c5..0000000 --- a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/ivy.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - built on 2012-06-15 from https://github.com/tristan/jsonld-java - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-1.0.1-SNAPSHOT.jar b/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-1.0.1-SNAPSHOT.jar deleted file mode 100644 index dd10e91..0000000 Binary files a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-1.0.1-SNAPSHOT.jar and /dev/null differ diff --git a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-sesame-1.0.1-SNAPSHOT.jar b/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-sesame-1.0.1-SNAPSHOT.jar deleted file mode 100644 index 1897c3c..0000000 Binary files a/settings/lib/dfki/km/json/jsonld-java/1.0.1-SNAPSHOT/jsonld-java-sesame-1.0.1-SNAPSHOT.jar and /dev/null differ diff --git a/settings/lib/org/openrdf/sesame/sesame/2.7.10/ivy.xml b/settings/lib/org/openrdf/sesame/sesame/2.7.10/ivy.xml deleted file mode 100644 index e57f1fc..0000000 --- a/settings/lib/org/openrdf/sesame/sesame/2.7.10/ivy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/settings/lib/org/openrdf/sesame/sesame/2.7.10/openrdf-sesame-2.7.10.jar b/settings/lib/org/openrdf/sesame/sesame/2.7.10/openrdf-sesame-2.7.10.jar deleted file mode 100644 index 530ea4c..0000000 Binary files a/settings/lib/org/openrdf/sesame/sesame/2.7.10/openrdf-sesame-2.7.10.jar and /dev/null differ diff --git a/settings/lib/org/openrdf/sesame/sesame/2.7.7/ivy.xml b/settings/lib/org/openrdf/sesame/sesame/2.7.7/ivy.xml deleted file mode 100644 index 18dad22..0000000 --- a/settings/lib/org/openrdf/sesame/sesame/2.7.7/ivy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/settings/lib/org/openrdf/sesame/sesame/2.7.7/openrdf-sesame-2.7.7.jar b/settings/lib/org/openrdf/sesame/sesame/2.7.7/openrdf-sesame-2.7.7.jar deleted file mode 100644 index 128eb2d..0000000 Binary files a/settings/lib/org/openrdf/sesame/sesame/2.7.7/openrdf-sesame-2.7.7.jar and /dev/null differ diff --git a/stardog/build.gradle b/stardog/build.gradle new file mode 100644 index 0000000..4ec7a76 --- /dev/null +++ b/stardog/build.gradle @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +dependencies { + compile project(":core") + + // client api modules + compile "com.complexible.stardog.reasoning:stardog-reasoning-api:${stardogVersion}" + compile "com.complexible.stardog.icv:stardog-icv-api:${stardogVersion}" + compile "com.complexible.stardog.icv:stardog-icv-api_snarl:${stardogVersion}" + compile "com.complexible.stardog.search:stardog-search-api:${stardogVersion}" + compile "com.complexible.stardog.jena:stardog-jena:${stardogVersion}" + compile "com.complexible.stardog.repair:stardog-repair:${stardogVersion}" + compile "com.complexible.stardog.versioning:stardog-versioning-api:${stardogVersion}" + compile "com.complexible.stardog.sesame:stardog-sesame-core:${stardogVersion}" + + testCompile project(path: ":core", configuration: "testRuntime") + + // server core modules + testCompile "com.complexible.stardog.core:stardog:${stardogVersion}" + testCompile "com.complexible.stardog.security:stardog-core-security:${stardogVersion}" + testCompile "com.complexible.stardog.logging:stardog-logging:${stardogVersion}" + + // server snarl modules + testCompile "com.complexible.stardog.protocols.snarl:stardog-protocols-snarl-server:${stardogVersion}" + + // client snarl modules + testCompile "com.complexible.stardog.protocols.snarl:stardog-protocols-snarl-client:${stardogVersion}" +} + +test { + workingDir = projectDir + minHeapSize = "2g" + maxHeapSize = "2g" +// debug = true // for attaching the IDE to the gradle cli + + jvmArgs '-XX:MaxPermSize=256m', '-enableassertions' + if (project.hasProperty("stardogHome")) { + jvmArgs "-Dstardog.home=${stardogHome}" + } +} diff --git a/stardog/main/src/com/complexible/stardog/empire/StardogEmpireAnnotationProvider.java b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireAnnotationProvider.java new file mode 100644 index 0000000..d90b178 --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireAnnotationProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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 com.complexible.stardog.empire; + +import java.lang.annotation.Annotation; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import com.clarkparsia.empire.util.EmpireAnnotationProvider; + +/** + * @author Evren Sirin + * @version 0.9.0 + * @since 0.9.0 + */ +public class StardogEmpireAnnotationProvider implements EmpireAnnotationProvider { + + private static Map,Collection>> mAnnotatedClasses = new HashMap,Collection>>(); + + public static void setAnnotatedClasses(Class theAnnotation, Collection> theClasses) { + mAnnotatedClasses.put(theAnnotation, theClasses); + } + + @Override + public Collection> getClassesWithAnnotation(Class theAnnotation) { + return mAnnotatedClasses.containsKey(theAnnotation)? mAnnotatedClasses.get(theAnnotation) + : Collections.>emptySet(); + } +} diff --git a/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSource.java b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSource.java new file mode 100644 index 0000000..f3772f3 --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSource.java @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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 com.complexible.stardog.empire; + +import java.net.ConnectException; + +import com.clarkparsia.empire.ds.DataSourceException; +import com.clarkparsia.empire.ds.MutableDataSource; +import com.clarkparsia.empire.ds.QueryException; +import com.clarkparsia.empire.ds.ResultSet; +import com.clarkparsia.empire.ds.SupportsTransactions; +import com.clarkparsia.empire.ds.impl.AbstractDataSource; +import com.clarkparsia.empire.impl.RdfQueryFactory; +import com.clarkparsia.empire.impl.sparql.SPARQLDialect; +import com.complexible.common.openrdf.model.Graphs; +import com.complexible.common.openrdf.util.AdunaIterations; +import org.openrdf.query.GraphQueryResult; +import org.openrdf.query.TupleQueryResult; +import com.complexible.stardog.StardogException; +import com.complexible.stardog.api.Connection; +import com.complexible.stardog.api.ConnectionConfiguration; +import org.openrdf.model.Graph; +import org.openrdf.query.BindingSet; +import org.openrdf.query.QueryEvaluationException; + +/** + *

+ * + * @author Michael Grove + * @since 0.9.0 + * @version 0.9.0 + */ +public class StardogEmpireDataSource extends AbstractDataSource implements MutableDataSource, SupportsTransactions { + private Connection mConnection; + private final ConnectionConfiguration mConfig; + + public StardogEmpireDataSource(final ConnectionConfiguration theConfiguration) { + mConfig = theConfiguration; + + setQueryFactory(new RdfQueryFactory(this, SPARQLDialect.instance())); + } + + /** + * @inheritDoc + */ + @Override + public void connect() throws ConnectException { + if (mConnection == null) { + try { + mConnection = mConfig.connect(); + setConnected(true); + } + catch (StardogException e) { + throw new ConnectException(e.getMessage()); + } + } + } + + /** + * @inheritDoc + */ + @Override + public void disconnect() { + if (mConnection != null) { + try { + mConnection.close(); + setConnected(false); + } + catch (StardogException e) { + // TODO: log me + System.err.println(e.getMessage()); + } + } + } + + /** + * @inheritDoc + */ + @Override + public ResultSet selectQuery(final String theQuery) throws QueryException { + assertConnected(); + + try { + final TupleQueryResult aResults = mConnection.select(theQuery).execute(); + return new ResultSet() { + @Override + public void close() { + AdunaIterations.closeQuietly(aResults); + } + + @Override + public boolean hasNext() { + try { + return aResults.hasNext(); + } + catch (QueryEvaluationException e) { + throw new RuntimeException(e); + } + } + + @Override + public BindingSet next() { + try { + return aResults.next(); + } + catch (QueryEvaluationException e) { + throw new RuntimeException(e); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + catch (StardogException e) { + throw new QueryException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public Graph graphQuery(final String theQuery) throws QueryException { + assertConnected(); + + GraphQueryResult aResult = null; + + try { + aResult = mConnection.graph(theQuery).execute(); + return Graphs.newGraph(aResult); + } + catch (QueryEvaluationException e) { + throw new QueryException(e); + } + catch (StardogException e) { + throw new QueryException(e); + } + finally { + if (aResult != null) { + try { + aResult.close(); + } + catch (QueryEvaluationException e) { + // TODO: log me + System.err.println("There was an error closing a query result: " + e.getMessage()); + } + } + } + } + + /** + * @inheritDoc + */ + @Override + public boolean ask(final String theQuery) throws QueryException { + assertConnected(); + + try { + return mConnection.ask(theQuery).execute(); + } + catch (StardogException e) { + throw new QueryException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public Graph describe(final String theQuery) throws QueryException { + return graphQuery(theQuery); + } + + /** + * @inheritDoc + */ + @Override + public void add(final Graph theGraph) throws DataSourceException { + assertConnected(); + try { + mConnection.add().graph(theGraph); + } + catch (StardogException e) { + throw new DataSourceException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public void remove(final Graph theGraph) throws DataSourceException { + assertConnected(); + try { + mConnection.remove().graph(theGraph); + } + catch (StardogException e) { + throw new DataSourceException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public void begin() throws DataSourceException { + assertConnected(); + + try { + mConnection.begin(); + } + catch (StardogException e) { + throw new DataSourceException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public void commit() throws DataSourceException { + assertConnected(); + + try { + mConnection.commit(); + } + catch (StardogException e) { + throw new DataSourceException(e); + } + } + + /** + * @inheritDoc + */ + @Override + public void rollback() throws DataSourceException { + assertConnected(); + + try { + mConnection.rollback(); + } + catch (StardogException e) { + throw new DataSourceException(e); + } + } +} diff --git a/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSourceFactory.java b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSourceFactory.java new file mode 100644 index 0000000..61e691b --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireDataSourceFactory.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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 com.complexible.stardog.empire; + +import java.util.Map; + +import com.clarkparsia.empire.ds.Alias; +import com.clarkparsia.empire.ds.DataSourceException; +import com.clarkparsia.empire.ds.DataSourceFactory; +import com.complexible.stardog.api.ConnectionConfiguration; + +/** + *

Implementation of the {@link DataSourceFactory} interface for creating Stardog connection objects.

+ * + * @author Hector Perez-Urbina + * @since 0.9.0 + * @version 0.9.0 + */ +@Alias(StardogEmpireDataSourceFactory.ALIAS) +public class StardogEmpireDataSourceFactory implements DataSourceFactory, StardogEmpireFactoryKeys { + /** + * @inheritDoc + */ + public boolean canCreate(final Map theMap) { + return theMap.containsKey(URL); + } + + /** + * @inheritDoc + */ + public StardogEmpireDataSource create(final Map theMap) throws DataSourceException { + if (!canCreate(theMap)) { + throw new DataSourceException("Invalid configuration map: " + theMap); + } + + try { + String aConnURL = (String) theMap.get(URL); + + ConnectionConfiguration connConf = ConnectionConfiguration.from(aConnURL); + + StardogEmpireDataSource aDataSource = new StardogEmpireDataSource(connConf); + + if (theMap.containsKey(AUTO_COMMIT)) { + System.out.println("Auto commit is no longer supported"); + } + + return aDataSource; + + } + catch (Exception e) { + throw new DataSourceException(e); + } + } +} diff --git a/stardog/main/src/com/complexible/stardog/empire/StardogEmpireFactoryKeys.java b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireFactoryKeys.java new file mode 100644 index 0000000..d9f1496 --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireFactoryKeys.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2009-2010 Clark & Parsia, LLC. + * + * 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 com.complexible.stardog.empire; + +/** + *

Set of valid keys and (some) values for use with the {@link StardogEmpireDataSourceFactory}.

+ * + * @author Hector Perez-Urbina + * @since 0.7 + * @version 0.7 + */ +public interface StardogEmpireFactoryKeys { + + /** + * Global alias for this factory + */ + public static final String ALIAS = "stardog"; + + /** + * Connection string for Stardog instance + */ + public static final String URL = "url"; + + /** + * Flag that determines if the connection backing the StardogDataSource will be in auto-commit mode + */ + public static final String AUTO_COMMIT = "auto.commit"; +} diff --git a/stardog/main/src/com/complexible/stardog/empire/StardogEmpireModule.java b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireModule.java new file mode 100644 index 0000000..e8c692f --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/StardogEmpireModule.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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 com.complexible.stardog.empire; + +import com.clarkparsia.empire.ds.DataSourceFactory; +import com.clarkparsia.empire.util.EmpireModule; +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +/** + *

Guice module for the Stardog Empire plugin.

+ * + * @author Evren Sirin + * @since 0.9.0 + * @version 0.9.0 + */ +public class StardogEmpireModule extends AbstractModule implements EmpireModule { + + /** + * @inheritDoc + */ + protected void configure() { + Multibinder.newSetBinder(binder(), DataSourceFactory.class) + .addBinding().to(StardogEmpireDataSourceFactory.class); + } +} diff --git a/stardog/main/src/com/complexible/stardog/empire/package-info.java b/stardog/main/src/com/complexible/stardog/empire/package-info.java new file mode 100644 index 0000000..12f7f31 --- /dev/null +++ b/stardog/main/src/com/complexible/stardog/empire/package-info.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2009-2015 Clark & Parsia, LLC. + * + * 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. + */ + +/** + *

Bindings for using Stardog as a {@link com.clarkparsia.empire.ds.DataSource} for the Empire library

+ * + * @author Michael Grove + * @author Evren Sirin + * @author Hector Perez Urbina + * @since 0.9.0 + * @version 0.9. + * + * @see Stardog based data source tests for backing an EntityManager in Empire

+ * + * @author Michael Grove + * @version 0.9.0 + * @since 0.9.0 + */ +public class StardogEntityManagerTestSuite extends EntityManagerTestSuite { + private static Server SERVER; + private final static String DB = "mem"; + @BeforeClass + public static void beforeClass() { + + try { + SERVER = Stardog .buildServer() + .bind(SNARLProtocolConstants.EMBEDDED_ADDRESS) + .start(); + + StardogEmpireAnnotationProvider.setAnnotatedClasses(NamedQuery.class, Arrays.>asList(MissionRole.class, Spacecraft.class)); + + EmpireConfiguration config = new EmpireConfiguration(); + config.setAnnotationProvider(StardogEmpireAnnotationProvider.class); + config.getGlobalConfig().put(StardogEmpireFactoryKeys.AUTO_COMMIT, "true"); + + Empire.init(config); + + EntityManagerTestSuite.beforeClass(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + @AfterClass + public static void afterClass() { + SERVER.stop(); + } + + @Before + public void before() { + try { + AdminConnection aAdminConnection = AdminConnectionConfiguration.toEmbeddedServer() + .credentials("admin", "admin") + .connect(); + + try { + if (aAdminConnection.list().contains(DB)) { + aAdminConnection.drop(DB); + } + aAdminConnection.createMemory(DB); + } + finally { + aAdminConnection.close(); + } + } + catch (Exception e) { + Throwables.propagate(e); + } + } + + @Override + protected DataSourceFactory createDataSourceFactory() { + return new StardogEmpireDataSourceFactory() { + @Override + public StardogEmpireDataSource create(Map theMap) throws DataSourceException { + theMap.put(StardogEmpireFactoryKeys.URL, "snarl://local/mem;username=admin;password=admin"); + theMap.put(StardogEmpireFactoryKeys.AUTO_COMMIT, "true"); + return super.create(theMap); + } + }; + } +}