From: <my...@us...> - 2010-07-08 15:59:42
|
Revision: 2387 http://aperture.svn.sourceforge.net/aperture/?rev=2387&view=rev Author: mylka Date: 2010-07-08 15:59:36 +0000 (Thu, 08 Jul 2010) Log Message: ----------- [3024352] a version of the data source maven plugin that seems to do what it's supposed to Modified Paths: -------------- aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DATASOURCE_VOCABULARY.java aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DataSourceClassGenerator.java aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/resources/org/semanticdesktop/aperture/datasource/mojo/source2.rdfs aperture-tools/maven-plugins/trunk/pom.xml Modified: aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DATASOURCE_VOCABULARY.java =================================================================== --- aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DATASOURCE_VOCABULARY.java 2010-07-07 15:18:36 UTC (rev 2386) +++ aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DATASOURCE_VOCABULARY.java 2010-07-08 15:59:36 UTC (rev 2387) @@ -50,6 +50,12 @@ public static final URI DataSourceDescription = new URIImpl("http://aperture.semanticdesktop.org/ontology/2007/08/12/source#DataSourceDescription"); /** * Type: Class <br/> + * Label: MovableDataSource <br/> + * Comment: A data source which can be moved. <br/> + */ + public static final URI MovableDataSource = new URIImpl("http://aperture.semanticdesktop.org/ontology/2007/08/12/source#MovableDataSource"); + /** + * Type: Class <br/> * Label: Pattern <br/> */ public static final URI Pattern = new URIImpl("http://aperture.semanticdesktop.org/ontology/2007/08/12/source#Pattern"); @@ -133,6 +139,14 @@ public static final URI includePattern = new URIImpl("http://aperture.semanticdesktop.org/ontology/2007/08/12/source#includePattern"); /** * Type: Property <br/> + * Label: Movable Identifier <br/> + * Comment: An identifier to use in movable URIs <br/> + * Domain: http://aperture.semanticdesktop.org/ontology/2007/08/12/source#MovableDataSource <br/> + * Range: http://www.w3.org/2000/01/rdf-schema#Literal <br/> + */ + public static final URI movableIdentifier = new URIImpl("http://aperture.semanticdesktop.org/ontology/2007/08/12/source#movableIdentifier"); + /** + * Type: Property <br/> * Label: Timeout <br/> * Comment: The timeout between two consecutive crawls (in miliseconds) <br/> * Domain: http://aperture.semanticdesktop.org/ontology/2007/08/12/source#DataSource <br/> Modified: aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DataSourceClassGenerator.java =================================================================== --- aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DataSourceClassGenerator.java 2010-07-07 15:18:36 UTC (rev 2386) +++ aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/java/org/semanticdesktop/aperture/datasource/mojo/DataSourceClassGenerator.java 2010-07-08 15:59:36 UTC (rev 2387) @@ -100,9 +100,12 @@ /** Set of java reserved words */ public static final Set<String> JAVA_RESERVED_WORDS_SET = prepareJavaKeywordSet(); + private static final String APERTURE_DATASOURC_FQCN = "org.semanticdesktop.aperture.vocabulary.DATASOURCE"; + private DataSource dataSource; private boolean domainBoundableDataSource = false; + private boolean movableDataSource = false; private Model myModel = null; @@ -219,6 +222,7 @@ // first prepare the options list URI fresnelLensURI = getFresnelLensURI(myModel, dataSource.getDataSourceClass()); List<URI> optionsList = getConfigurationOptionsList(fresnelLensURI); + movableDataSource = isMovable(myModel, dataSource.getDataSourceClass()); // preamble outputStream.println("/*"); @@ -239,6 +243,9 @@ if (domainBoundableDataSource) { outputStream.println("import org.semanticdesktop.aperture.datasource.config.DomainBoundableDataSource;"); } + if (movableDataSource) { + outputStream.println("import org.semanticdesktop.aperture.datasource.config.MovableDataSource;"); + } outputStream.println("import org.semanticdesktop.aperture.rdf.util.ModelUtil;"); outputStream.println("import java.util.Collection;"); outputStream.println("import java.util.List;"); @@ -251,13 +258,18 @@ outputStream.println(" * class uri: " + dataSource.getDataSourceClass()); outputStream.println(" */"); outputStream.println("public class " + dataSource.getClassName() + " extends " - + ((domainBoundableDataSource) ? "DomainBoundableDataSource" : "DataSourceBase") + " {"); + + ((domainBoundableDataSource) ? "DomainBoundableDataSource" : "DataSourceBase") + + ((movableDataSource) ? " implements MovableDataSource " : "") + "{"); outputStream.println(); generateGetTypeMethod(); for (URI uri : optionsList) { generateElement(uri); } + + if (movableDataSource) { + generateMovableDataSourceElements(); + } // end outputStream.println("}"); @@ -317,6 +329,38 @@ uriToLocalName.put(uri.toString(), localName); } + + private void generateMovableDataSourceElements() throws Exception + { + + generateSingleValuedProperty("movableIdentifier", "MovableIdentifier", "movable identifier, see {@link MovableDataSource} for more information.", "String", APERTURE_DATASOURC_FQCN); + + outputStream.println(); + outputStream.println(" public String getCommonURISubstring() {"); + outputStream.println(" return " + dataSource.getClassName() + "Factory.getCommonURISubstring(this);"); + outputStream.println(" }"); + outputStream.println(); + + outputStream.println(" public String getAbsoluteURI(String movableURI) {"); + outputStream.println(" String movableId = getMovableIdentifier();"); + outputStream.println(" if (movableId == null) {"); + outputStream.println(" return movableURI;"); + outputStream.println(" } else {"); + outputStream.println(" return movableURI.replaceAll(\"aperture://\" + movableId + \"/\",getCommonURISubstring());"); + outputStream.println(" }"); + outputStream.println(" }"); + outputStream.println(); + + outputStream.println(" public String getMovableURI(String absoluteURI) {"); + outputStream.println(" String movableId = getMovableIdentifier();"); + outputStream.println(" if (movableId == null) {"); + outputStream.println(" return absoluteURI;"); + outputStream.println(" } else {"); + outputStream.println(" return absoluteURI.replaceAll(getCommonURISubstring(),\"aperture://\" + movableId + \"/\");"); + outputStream.println(" }"); + outputStream.println(" }"); + outputStream.println(); + } private void generateSingleValuedProperty(String localName, String capitalizedLocalName, String comment, String javaRangeType, String currentVocabularyClassName) @@ -581,7 +625,7 @@ private String getVocabularyClassName(URI range) { if (range.toString().startsWith(DATASOURCE_VOCABULARY.NS_DATASOURCE.toString())) { - return "org.semanticdesktop.aperture.vocabulary.DATASOURCE"; + return APERTURE_DATASOURC_FQCN; } else { return dataSource.getOntologyClass(); @@ -781,7 +825,7 @@ String namespace = classUri.substring(0, classUri.length() - localName.length()); DataSource dataSource = new DataSource(inputRdfFilePath, namespace, vocabularyClassName, - outputDirectoryPath, packageName + "." + outputFileName, forceGeneration); + outputDirectoryPath, packageName + "." + localName, forceGeneration); new DataSourceClassGenerator().go(dataSource); } @@ -839,6 +883,18 @@ } return null; } + + private boolean isMovable(Model model, String typeString) { + URI typeUri = new URIImpl(typeString); + try { + List<Node> list = ModelUtil.getAllPropertyValues(model, typeUri, RDFS.subClassOf); + return list.contains(DATASOURCE_VOCABULARY.MovableDataSource); + } + catch (ClassCastException me) { + log.warn("Couldn't figure out if the data source is movable", me); + } + return false; + } private List<URI> getConfigurationOptionsList(URI fresnelLensURI) { List<URI> resultList = new LinkedList<URI>(); Modified: aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/resources/org/semanticdesktop/aperture/datasource/mojo/source2.rdfs =================================================================== --- aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/resources/org/semanticdesktop/aperture/datasource/mojo/source2.rdfs 2010-07-07 15:18:36 UTC (rev 2386) +++ aperture-tools/maven-plugins/trunk/datasource-maven-plugin/src/main/resources/org/semanticdesktop/aperture/datasource/mojo/source2.rdfs 2010-07-08 15:59:36 UTC (rev 2387) @@ -19,6 +19,11 @@ <rdfs:comment>A human-readable description of a datasource. Adds icons, texts etc.</rdfs:comment> <rdfs:subClassOf rdf:resource="&rdfs;Resource"/> </rdfs:Class> +<rdfs:Class rdf:about="&source;MovableDataSource" + rdfs:label="MovableDataSource"> + <rdfs:comment>A data source which can be moved.</rdfs:comment> + <rdfs:subClassOf rdf:resource="&nie;DataSource"/> +</rdfs:Class> <rdfs:Class rdf:about="&source;Pattern" rdfs:label="Pattern"> <rdfs:subClassOf rdf:resource="&rdfs;Resource"/> @@ -83,6 +88,12 @@ <rdfs:domain rdf:resource="&nie;DataSource"/> <rdfs:range rdf:resource="&source;Pattern"/> </rdf:Property> +<rdf:Property rdf:about="&source;movableIdentifier" + rdfs:comment="An identifier to use in movable URIs" + rdfs:label="Movable Identifier"> + <rdfs:domain rdf:resource="&source;MovableDataSource"/> + <rdfs:range rdf:resource="&rdfs;Literal"/> +</rdf:Property> <rdf:Property rdf:about="&source;timeout" rdfs:comment="The timeout between two consecutive crawls (in miliseconds)" rdfs:label="Timeout"> Modified: aperture-tools/maven-plugins/trunk/pom.xml =================================================================== --- aperture-tools/maven-plugins/trunk/pom.xml 2010-07-07 15:18:36 UTC (rev 2386) +++ aperture-tools/maven-plugins/trunk/pom.xml 2010-07-08 15:59:36 UTC (rev 2387) @@ -133,5 +133,10 @@ <name>Aperture Maven Repository</name> <url>sftp://web.sourceforge.net/home/groups/a/ap/aperture/htdocs/maven</url> </repository> + <snapshotRepository> + <id>aperture-repo</id> + <name>Aperture Maven Repository</name> + <url>sftp://web.sourceforge.net/home/groups/a/ap/aperture/htdocs/maven</url> + </snapshotRepository> </distributionManagement> </project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |