diff --git a/.hgignore b/.hgignore deleted file mode 100644 index ea261dd..0000000 --- a/.hgignore +++ /dev/null @@ -1,24 +0,0 @@ -syntax: glob -bin -target -*.class -*.log -*.zip -*pom.xml.versionsBackup -build.properties -.settings -.classpath -doc/javadoc -doc/doc -.metadata -.directory -*/\${builder} -doc/build.properties -majortom-postgresimporter/src/test/resources/db.properties -*.orig -*.ctm -*.xtm -*.xctm -syntax: regexp -^majortom-db/data$ - diff --git a/Architecture.md b/Architecture.md new file mode 100644 index 0000000..eeda5c2 --- /dev/null +++ b/Architecture.md @@ -0,0 +1,9 @@ +# Architecture # + +On top of the architecture is a Java RESTful web service which uses the [odata4j library](http://code.google.com/p/odata4j/). This service provides the HTTP interface to handle client requests and result transformation into JSON or Atompub. The OData service is obliged to provide a service description. Usually, the producer generates the OData content directly by accessing the real data source. For improved flexibility we extend the service architecture by a content provider, which uses TMQL queries to fetch data sets needed for the current request or for meta-data extraction. + +![http://tm2o.googlecode.com/files/architecture.png](http://tm2o.googlecode.com/files/architecture.png) + +The queries are executed by the Java-based Topic Maps query engine [TMQL4J](http://code.google.com/p/tmql/). The usage of queries enables a decoupled architecture which in turn allows accessing distributed data sources. The mapping of the query results is realized by the TM2O module, which transforms the Topic Maps content to the EDM. + +The data storage for the underlying topic maps is realized by the Topic Maps Engine [majortom](http://code.google.com/p/majortom), which provides an abstraction layer on top of the real storage paradigm, like relational databases or memory. The whole webservice is running in a [majortom webserver](http://code.google.com/p/majortom-server) which is based on the [Spring Framework](http://www.springsource.org/). \ No newline at end of file diff --git a/Configuration.md b/Configuration.md new file mode 100644 index 0000000..eb7e7cb --- /dev/null +++ b/Configuration.md @@ -0,0 +1,37 @@ +# Configuration # + +To configure your TM2O web service you can use a property file or the web interface to do so. + +## Using the Property File ## + +If you want to use a property file to configure the TM2O service, the following steps are necessary: + +# Open your home directory. +# Create a new folder with the name '.tm2o' and open it. +# Create a new file with name 'tm2o.properties'. +# Edit the file with a text editor. + +The following properties are supported: + +|**property name**|**description**|**values**|**mandatory**| +|:----------------|:--------------|:---------|:------------| +|namespace |The namespace of your OData service|Any string|yes | +|association-mode |The mode of mapping associations.|FLAT\_ASSOCIATION or STRONG\_ASSOCIATION|yes | +|content-provider |The class name of used content provider|de.topicmapslab.odata.content.memory.MemoryOdataContentProvider or de.topicmapslab.odata.content.remote.RemoteOdataContentProvider|yes | +|path |The file to a topic map file(.ctm,.xtm,.ltm)|The absolute path| yes (in case of memory content provider)| +|server |The address of the remote server|a valide URL|yes (in case of remote content provider)| +|api-key |The API key of the user of the remote server|a valide API key|yes (in case of remote content provider)| + +## Using the web Interface ## + +After the deployment of your TM2O service, a configuration interface is avalaible under the service root: _your-webserver-root/tm2o_ + +You can edit the namespace of your TM2O webservice using any non empty string, which does not contain any whitespaces. + +For association mode you can choose FLAT or STRONG mode. + +The content provider can be choosed by select the Remote Content Provider or Local Content Provider. + +For local content providers you should be upload any topic map file to the server. If you choose the remote provider you must be enter a valid address of a MaJorToM server. If the URL is invalid, it will be colored red. + +![http://tm2o.googlecode.com/files/figure-tm2o-configuration.png](http://tm2o.googlecode.com/files/figure-tm2o-configuration.png) \ No newline at end of file diff --git a/Deployment.md b/Deployment.md new file mode 100644 index 0000000..8c569d3 --- /dev/null +++ b/Deployment.md @@ -0,0 +1,15 @@ +# Deployment # + +This wiki page explain the deployment process of the TM2O webservice. + +## Dependencies ## + +The TM2O service is designed as a Java web service which runs on a servlet container (e.g. [Apache Tomcat](http://tomcat.apache.org/download-70.cgi). To use the remote content provider of a TM2O web service the [MaJorToM Webserver](http://code.google.com/p/majortom-server) is required. + +## Deploy the service ## + +The service is provided by a web archive file (.war). At first this file has to be deployed in your web server (e.g. tomcat). There are two possibilities to do so - using the HTML manager or copy the file to working directory of tomcat. Please note that the HTML manager is an optional component. After the deployment the TM2O service is avalaibe under the following URL: + +_your-web-server-root/tm2o_ + +![http://tm2o.googlecode.com/files/figure-start-screen.png](http://tm2o.googlecode.com/files/figure-start-screen.png) \ No newline at end of file diff --git a/GettingStarted.md b/GettingStarted.md new file mode 100644 index 0000000..866edda --- /dev/null +++ b/GettingStarted.md @@ -0,0 +1,61 @@ +# Getting Started with TM2O # + +Here you will find a short description how you can get started with the TM2O service. + +## Deployment ## + +In the first step you have to deploy the service at your webserver. Get all information about the deployment [here](http://code.google.com/p/tm2o/wiki/Deployment). Once you have deployed the service (i.e. at localhost:8080) you can access the service at + +_http://localhost:8080/tm2o/_ + +If you successfully deployed the service you should see the tm2o start screen. + +![http://tm2o.googlecode.com/files/figure-start-screen.png](http://tm2o.googlecode.com/files/figure-start-screen.png) + +## TM2O Configuration ## + +In the section "Available Services" you will now read + +**No topic maps created yet, go to administration interface to upload a new file!** or **The MaJorToM server does not response to any request.** + +Before your get a list of OData services you have to configure the connection to your data sources. Follow the link "here" in the section "TM2O Configuration" to access the configuration interface. + +In the configuration interface you have to specify some basic characteristics (use Namespace "OData" and "FLAT" association mode to get started) and the data provider for the TM2O service. Full details about the configuration are available [here](http://code.google.com/p/tm2o/wiki/Configuration). + +![http://tm2o.googlecode.com/files/figure-tm2o-configuration.png](http://tm2o.googlecode.com/files/figure-tm2o-configuration.png) + +To get started with the TM2O service you simply choose the URL of a running majortom server or you upload a topic map to the server. In the section [Provider](http://code.google.com/p/tm2o/wiki/Provider) you get full information about the provider concept in tm2o. + + * If a running instance of a majrotom server is available chhose the Option "Remote Content Provider" and enter the URL of the server, like _http://nemo.tm.informatik.uni-leipzig.de:8080/majortom-server/_. + + * If no running instance of a majortom server is available choose the Option "Local Content Provider" and upload the [ToyTM](http://tm2o.googlecode.com/files/download%5B2%5D.xtm). + +After pressing the button "Set" the configuration of the TM2O service is changed. Now follow the link "available services listed here" at the bottom of the page. + +## Create a OData service ## + +Now you can see a list of topic maps which are available by the remote majortom server (or locally stored by your tm2o service). + +To create a OData service for one of this maps you have to press at the according topic map. With this click you will trigger the autogeneration of the OData Schema based on the topic map. Dependent on the complexity of the underlying topic map this process might take a while. + +After the successful creation of the OData service you will see the service description delivered by the service URL, like + +_http://localhost:8080/tm2o/odata.svc/3d46a9abbb1b6f98ddd4c0c7dc2c671_ + +The seervice description delivers you a number of references to collections. If you want the data for a collection - let's say "Park" - packed in JSON you have to specify the following URL + +_http://localhost:8080/tm2o/odata.svc/3d46a9abbb1b6f98ddd4c0c7dc2c671/Park?$format=json_ + +## Using the data ## + +Once you have created your OData service out of a topic map, you can use the data in the existing OData infrastructure. [Here](http://www.odata.org/consumers) you will find a list of existing OData consumers. + +One of these consumers is the [Sesame Data Browser](http://metasapiens.com/sesame/data-browser/). + +![http://tm2o.googlecode.com/files/sesame%20data%20browser.png](http://tm2o.googlecode.com/files/sesame%20data%20browser.png) + +Download and install the data browser locally. After starting the data browser you can open a new connection. To open a connection with the OData service you have to enter the URL of the service description, like: + +_http://localhost:8080/tm2o/odata.svc/3d46a9abbb1b6f98ddd4c0c7dc2c671_ + +If your OData service (and the data provider behind the OData service) is running correctly, you can start to browse in your data as it is depicted in the figure above. \ No newline at end of file diff --git a/Main.md b/Main.md new file mode 100644 index 0000000..0918c44 --- /dev/null +++ b/Main.md @@ -0,0 +1,3 @@ +# TM2O # + +TM2O is a generic tool to provide information stored within a topic map as an OData service. \ No newline at end of file diff --git a/ODataService.md b/ODataService.md new file mode 100644 index 0000000..2d431fd --- /dev/null +++ b/ODataService.md @@ -0,0 +1,25 @@ +# OData Service # + +After the deployment and configuration of the TM2O service, the web module provides a OData service, which can be used by any avalaible OData browsers like Microsoft© SQL Server© PowerPivot for Excel©. + +The OData service is avalaible under + +_your-web-server-root/tm2o/odata.svc/{topic-map-id}_ + +Example: _http://localhost:8080/tm2o/odata.svc/bddddba8f4c25fa590be1250d41261_ + +## Topic Map Id ## + +Any topic map stored in MaJorToM server or local get an identification number. In case of remote content providers the id of the topic map can be read under the following url: + +_your-majortom-server-address/tm/topicmaps_ + +In case of local mode, the topic map id currently has no relevance an can be set to any number but may not missed. + +## Format ## + +The OData service delivers the data either in ATOMpub or in JSON format. Use the _format_ parameter to specify the desired format. + +| Atom (default) | _your-web-server-root/tm2o/odata.svc/{topic-map-id}?$format=atom_ | +|:---------------|:------------------------------------------------------------------| +| JSON | _your-web-server-root/tm2o/odata.svc/{topic-map-id}?$format=json_ | diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..0d45995 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,9 @@ +# Overview # + +TM2O is a generic tool to provide information stored within a topic map as an OData service. This OData services uses [majortom](http://code.google.com/p/majortom/) as local topic maps backend or a remote [majortom server](http://code.google.com/p/majortom-server/). The implementation bases on [odata4j](http://code.google.com/p/odata4j/) and heavily uses the [TMQL](http://www.topicmapslab.de/glossary/TMQL) engine [TMQL4J](http://code.google.com/p/tmql/). + +## Getting started ## + +We have prepared a [getting started guideline](http://code.google.com/p/tm2o/wiki/GettingStarted) for you. Here you will learn to set-up the TM2O service, and to create and use OData service out of your topic maps. + +![http://tm2o.googlecode.com/files/figure-start-screen.png](http://tm2o.googlecode.com/files/figure-start-screen.png) \ No newline at end of file diff --git a/Provider.md b/Provider.md new file mode 100644 index 0000000..017bb89 --- /dev/null +++ b/Provider.md @@ -0,0 +1,11 @@ +# Provider # + +The TM2O service is designed as a modulare and flexible service, which allows to access remote semantic data using a special content provider. As an alternative, the semantic data can be stored within an in-process topic map. + +## Local Content Provider ## + +The local content provider store the semantic data in a memory based topic map. The topic map is protected and handled by the [MaJorToM Topic Maps Engine](http://code.google.com/p/majortom). To do so, the user should provide a topic map file, which contains the semantic information which should be mapped as OData. The file type will be estimated automatically. + +## Remote Content Provider ## + +The remote content provider fetches any semantic information from an external MaJorToM server. The communcation is done by using TMQL and a JTMQR messages. See the documentation of MaJorToM server and [TMQL4J](http://code.google.com/p/tmql) for more information or contact the developer. \ No newline at end of file diff --git a/TableOfContent.md b/TableOfContent.md new file mode 100644 index 0000000..1363c4c --- /dev/null +++ b/TableOfContent.md @@ -0,0 +1,7 @@ + * [Getting Started](http://code.google.com/p/tm2o/wiki/GettingStarted) + * [Topic Maps 2 OData](http://code.google.com/p/tm2o/wiki/TopicMaps2OData) + * [Architecture](http://code.google.com/p/tm2o/wiki/Architecture) + * [Provider](http://code.google.com/p/tm2o/wiki/Provider) + * [Deployment](http://code.google.com/p/tm2o/wiki/Deployment) + * [Configuration ](http://code.google.com/p/tm2o/wiki/Configuration) + * [OData Service](http://code.google.com/p/tm2o/wiki/ODataService) \ No newline at end of file diff --git a/TopicMaps2OData.md b/TopicMaps2OData.md new file mode 100644 index 0000000..53d74ce --- /dev/null +++ b/TopicMaps2OData.md @@ -0,0 +1,28 @@ +# Topic Maps 2 OData # + +To understand the workflow of the TM2O service, this wiki page provides an overview about the transformation rules. + +## Entity Types ## + +The first class objects in topic maps are topics. Each topic represents one specific subject of interest. Similar to EDM where entities are instances of an entity type, topics can have one or more types. This analogy is used to define a mapping between topics and entities as core concepts. +In EDM the only attribute of entity types is a unique and human readable name as an identifier. Hence, if a topic type should become an entity type, it is necessary to generate such a name automatically. + +## Entity Properties ## + +In the TMDM, topics may have names and a set of occurrences, like date of birth or coordinates of a place. This is similar to the entity properties of the EDM and can be mapped in a generic way. The EDM key of a property can be understood as the kind or type of information the value represents. This key is represented as a human readable string literal. It is similar to the concept of name types or occurrence types in the TMDM and can be used similar to topic types . + +The TMDM contains the concept of scopes as a set of themes, which represents the validity of a statement, for example the language a name is written in. Because of that, characteristics of the same type but in different scopes may not map to the same EDM property type. Each of these scoping topics should be used to generate more specific property types. The TM2O service uses any themes to generate more specific identifiers for the properties. For example a name which is only valid in english, will be identified by the key _NameEnglish_. + +In the TMDM, occurrences have datatypes, which can be interpreted as the property type in EDM. Usually, the datatype system in topic maps is based on XML scheme definition (XSD) datatypes, which in most cases overlap with the EDM type system. Hence, it is straightforward to map XSD datatypes to the EDM type system. In case no corresponding type in the EDM system is available, the datatype Edm.String is used. A name or an occurrence of a specific type may exist zero, one or many times. Because of that, they should be marked as dynamic in the context of OData. + +## Navigation Properties ## + +Alongside topics, the associations are the second top level concept of the TMDM. They represent relationships between topic instances or topic types. Associations are typed and contain a set of roles, which are also typed and played by one topic instance of the topic map. In contrast to the EDM, associations are not compulsorily binary. But to enable a generic mapping of all associations, the non-binary associations of the topic map are split to a set of binary ones. In general, we developed two possible mapping rules of associations: a flat and a more complex one. + +### Flat assoiations ### + +The flat associations only use the type of the players and ignore the role types and the association types. In this case the EDM role names are equal to the entity type name as described above. The name of the association is a combination of both role names to represent the relation between both types in a human readable way. The pattern of this name looks like _Name of Left Entity Type-Name of Right Entity Type_. + +### Strong associations ### + +The strong associations regard any information of the TMDM association, the association type, the player types and the role types. If we use the information of the role types, the EDM role names can be set to the label of the role type, which is also a topic type. The association name is more complicated than the easy mapping of the type, because the EDM does not support the same relationship between different entity types in contrast to the TMDM. Because of that, the names of associations have to combine the label of the association type and the label of the counter-player’s type as in the following pattern: _Name of Association Type-Name of Right Entity Type_. \ No newline at end of file diff --git a/tm2o-core/.project b/tm2o-core/.project deleted file mode 100644 index e2bb135..0000000 --- a/tm2o-core/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - tm2o-core - - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/tm2o-core/META-INF/MANIFEST.MF b/tm2o-core/META-INF/MANIFEST.MF deleted file mode 100644 index 1517713..0000000 --- a/tm2o-core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,36 +0,0 @@ -Manifest-Version: 1.0 -Export-Package: de.topicmapslab.odata.content.empty;uses:="de.topicmap - slab.odata.edm,de.topicmapslab.odata.content,de.topicmapslab.odata,de - .topicmapslab.odata.exception,de.topicmapslab.odata.config",de.topicm - apslab.odata.content;uses:="de.topicmapslab.odata.edm,de.topicmapslab - .odata,de.topicmapslab.odata.exception,de.topicmapslab.odata.config,d - e.topicmapslab.odata.util,de.topicmapslab.odata.dao,de.topicmapslab.o - data.tmql",de.topicmapslab.odata.util;uses:="de.topicmapslab.odata.co - ntent,de.topicmapslab.odata.exception,de.topicmapslab.odata.edm,de.to - picmapslab.odata.tmql",de.topicmapslab.odata.dao;uses:="de.topicmapsl - ab.odata.edm,de.topicmapslab.odata.exception,de.topicmapslab.odata.ut - il",de.topicmapslab.odata.exception,de.topicmapslab.odata.config,de.t - opicmapslab.odata.edm;uses:="de.topicmapslab.odata.dao",de.topicmapsl - ab.odata;uses:="de.topicmapslab.odata.content.empty,de.topicmapslab.o - data.content,de.topicmapslab.odata.exception",de.topicmapslab.odata.t - mql;uses:="de.topicmapslab.odata.dao,de.topicmapslab.odata.util,de.to - picmapslab.odata.edm",de.topicmapslab.odata.content.remote;uses:="de. - topicmapslab.odata.content,de.topicmapslab.odata.exception,de.topicma - pslab.odata.tmql",de.topicmapslab.odata.content.memory;uses:="de.topi - cmapslab.odata.content,de.topicmapslab.odata.exception,de.topicmapsla - b.odata.tmql" -Bundle-ActivationPolicy: lazy -Tool: Bnd-1.15.0 -Bundle-Name: ODate 4 Topic Maps -Created-By: 1.6.0_20 (Sun Microsystems Inc.) -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.tmapi;bundle-version="2.0.3" -Bundle-Version: 0.0.1 -Bnd-LastModified: 1302766755140 -Bundle-ManifestVersion: 2 -Bundle-Description: Odata for Topic Maps -Import-Package: org.osgi.framework;version="[1.4,2)",org.slf4j;version - ="1.6.1" -Bundle-SymbolicName: de.topicmapslab.odata4tm -Originally-Created-By: 1.6.0_20 (Sun Microsystems Inc.) - diff --git a/tm2o-core/pom.xml b/tm2o-core/pom.xml deleted file mode 100644 index 21ee39b..0000000 --- a/tm2o-core/pom.xml +++ /dev/null @@ -1,197 +0,0 @@ - - 4.0.0 - de.topicmapslab.odata - tm2o-core - 1.0.0 - Odata 4 Topic Maps - Odata for Topic Maps - - - - org.apache.maven.wagon - wagon-ssh - 1.0-beta-2 - - - - - META-INF - ${project.build.directory}/classes/META-INF - - - src/main/resources - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - - - META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - true - 2.2.0 - - - - bundle-manifest - process-classes - - manifest - - - - - - - jar - - META-INF - - 0.0.1 - - de.topicmapslab.odata.* - - - org.tmapi;bundle-version="2.0.3" - - - org.osgi.framework, - org.slf4j;version="1.6.1" - - de.topicmapslab.odata4tm - ODate 4 Topic Maps - lazy - JavaSE-1.6 - - - - - - - - - tmlab - http://maven.topicmapslab.de/public - - - tmlabi - http://maven.topicmapslab.de/internal - - - ontopia - http://ontopia.googlecode.com/svn/maven-repository/ - - - ontopia snapshot - http://ontopia.googlecode.com/svn/maven-snapshot-repository/ - - - tmapi-snap - http://www.tmapi.org/maven-repository/snapshots/ - http://www.tmapi.org/maven-repository/snapshots/ - - - tmapi - http://www.tmapi.org/maven-repository/ - http://www.tmapi.org/maven-repository/ - - - - - org.slf4j - slf4j-api - 1.6.1 - jar - compile - - - org.osgi - org.osgi.core - 4.1.0 - jar - compile - - - de.topicmapslab.majortom - majortom-inMemory - 1.2.0-SNAPSHOT - test - - - de.topicmapslab.majortom - majortom-core - 1.2.0-SNAPSHOT - - - de.topicmapslab.tmql4j - tmql4j-hibernate - 3.1.0-SNAPSHOT - jar - compile - - - org.tmapix - tmapix-io - 1.0.1-SNAPSHOT - - - slf4j-jdk14 - org.slf4j - - - slf4j-log4j - org.slf4j - - - slf4j-api - org.slf4j - - - org.tmapi - tmapi - - - net.ontopia - ontopia-mio - - - org.tinytim - tinytim - - - - - org.odata4j - odata4j-core - 0.4.0-SNAPSHOT - - - de.topicmapslab - format-estimator - 0.1-SNAPSHOT - - - - - - topicmapslab-public - Topic Maps Lab Repositiory - scp://atlantis.tm.informatik.uni-leipzig.de/disk/localhome/maven/webdir/maven.topicmapslab.de/public/public - - - \ No newline at end of file diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapMetadata.java b/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapMetadata.java deleted file mode 100644 index 0876b10..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapMetadata.java +++ /dev/null @@ -1,249 +0,0 @@ -package de.topicmapslab.odata; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.odata4j.core.ODataConstants; -import org.odata4j.core.OEntity; -import org.odata4j.edm.EdmAssociation; -import org.odata4j.edm.EdmDataServices; -import org.odata4j.edm.EdmEntityContainer; -import org.odata4j.edm.EdmEntitySet; -import org.odata4j.edm.EdmEntityType; -import org.odata4j.edm.EdmSchema; -import org.odata4j.producer.QueryInfo; - -import de.topicmapslab.odata.content.IOdataContentProvider; -import de.topicmapslab.odata.content.empty.EmptyOdataContentProvider; - -/** - * the topic map meta data provider - * - * @author Sven Krosse - */ -public class TopicMapMetadata { - private static final String CONTAINER_NAME = "Container"; - private Class contentProviderClass; - private Properties properties; - private String namespace; - private final Map contentProviders = new HashMap(); - private final Map services = new HashMap(); - - /** - * constructor - * - * @param contentProvider - * the contentProvider - * @param namespace - * the namespace - */ - public TopicMapMetadata(final Class contentProviderClazz, final Properties properties, final String namespace) { - this.contentProviderClass = contentProviderClazz; - this.properties = properties; - this.namespace = namespace; - } - - /** - * Reload the configuration of this OData service - * - * @param contentProviderClazz - * the provider class - * @param properties - * the properties - * @param namespace - * the namespace - */ - public void reload(final Class contentProviderClazz, final Properties properties, final String namespace) { - this.contentProviderClass = contentProviderClazz; - this.properties = properties; - this.namespace = namespace; - /* - * clear existing ones - */ - contentProviders.clear(); - services.clear(); - } - - /** - * Get internal properties - * - * @return the properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Returns the interal set namespace - * - * @return the namespace - */ - public String getNamespace() { - return namespace; - } - - /** - * Returns the content provider class - * - * @return the class - */ - public Class getContentProviderClass() { - return contentProviderClass; - } - - /** - * Utility method to build OData service schema from topic map - * - * @return the - */ - private EdmDataServices buildDataService(final String topicMapId) { - IOdataContentProvider contentProvider = getContentProvider(topicMapId); - List schemas = new ArrayList(); - List containers = new ArrayList(); - List entitySets = contentProvider.getEntitySets(); - List entityTypes = contentProvider.getEntityTypes(); - List associations = contentProvider.getAssociations(); - /* - * create container - */ - EdmEntityContainer container = new EdmEntityContainer(CONTAINER_NAME, true, null, entitySets, null, null); - containers.add(container); - /* - * create schema - */ - EdmSchema schema = new EdmSchema(namespace, null, entityTypes, null, associations, containers); - schemas.add(schema); - return new EdmDataServices(ODataConstants.DATA_SERVICE_VERSION, schemas); - } - - /** - * Checks if the service for the given topic map id is loaded - * - * @param topicMapId - * the topic map id - * @return true if the service is loaded, false otherwise. - */ - public boolean isLoadedService(final String topicMapId) { - return services.containsKey(topicMapId); - } - - /** - * Returns the EDM Data service representing the meta model - * - * @param topicMapId - * the topic map Id - * @return the meta model - */ - public EdmDataServices getService(final String topicMapId) { - /* - * check if topic map id already bound to a EDM service - */ - if (!services.containsKey(topicMapId)) { - /* - * build new service - */ - services.put(topicMapId, buildDataService(topicMapId)); - } - /* - * return service - */ - return services.get(topicMapId); - } - - /** - * Returns the entity for the given entity id - * - * @param topicMapId - * the topic map id - * @param entitySetName - * the name of the entity set name - * @param entityId - * the entity id - * @return the entity and never null - */ - public OEntity getEntity(final String topicMapId, final String entitySetName, final String entityId) { - /* - * get entity set - */ - EdmEntitySet entitySet = getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - return getContentProvider(topicMapId).getEntity(entitySet, entitySet.type.name, entityId); - } - - /** - * Returns all entities of the given entity set - * - * @param topicMapId - * the topic map id - * @param entitySetName - * the name of the entity set name - * @param queryInfo - * the query info - * @return a possible empty list of entities - */ - public List getEntities(final String topicMapId, final String entitySetName, final QueryInfo queryInfo) { - /* - * get entity set - */ - EdmEntitySet entitySet = getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - return getContentProvider(topicMapId).getEntities(entitySet, queryInfo); - } - - /** - * Returns all counter entities of the given entity set - * - * @param entitySetName - * the name of the entity set name - * @param entityId - * the Id of left hand navigation node - * @param navProperty - * the navigation property - * @param counterType - * the counter type - * @param queryInfo - * the query info - * @return a possible empty list of entities - */ - public List getEntities(final String topicMapId, final String entitySetName, final String entityId, final String navProperty, - final QueryInfo queryInfo) { - /* - * get entity set - */ - EdmEntitySet entitySet = getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - return getContentProvider(topicMapId).getEntities(entitySet, entityId, navProperty, queryInfo); - } - - /** - * Internal method to get the content provider of the given topic map id - * - * @param topicMapId - * the topic map id - * @return the content provider and never null - */ - private IOdataContentProvider getContentProvider(final String topicMapId) { - if (contentProviders.containsKey(topicMapId)) { - return contentProviders.get(topicMapId); - } - try { - IOdataContentProvider contentProvider = contentProviderClass.getConstructor(String.class).newInstance(topicMapId); - contentProvider.initialize(namespace, properties); - contentProvider.setService(this); - contentProviders.put(topicMapId, contentProvider); - return contentProvider; - } catch (Exception e) { - e.printStackTrace(System.err); - return new EmptyOdataContentProvider(); - } - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducer.java b/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducer.java deleted file mode 100644 index ae717f8..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducer.java +++ /dev/null @@ -1,191 +0,0 @@ -package de.topicmapslab.odata; - -import java.util.List; -import java.util.Properties; - -import org.odata4j.core.OEntity; -import org.odata4j.edm.EdmDataServices; -import org.odata4j.edm.EdmEntitySet; -import org.odata4j.producer.EntitiesResponse; -import org.odata4j.producer.EntityResponse; -import org.odata4j.producer.InlineCount; -import org.odata4j.producer.ODataProducer; -import org.odata4j.producer.QueryInfo; - -import de.topicmapslab.odata.content.IOdataContentProvider; - -public class TopicMapODataProducer implements ODataProducer { - - private final TopicMapMetadata metadata; - - /** - * constructor - * - * @param contentProvider - * the content provider - * @param namespace - * the namespace - */ - public TopicMapODataProducer(final Class contentProviderClazz, final Properties properties, - final String namespace) { - this.metadata = new TopicMapMetadata(contentProviderClazz, properties, namespace); - } - - public TopicMapMetadata getService() { - return metadata; - } - - /** - * {@inheritDoc} - */ - public void close() { - // VOID - } - - /** - * {@inheritDoc} - */ - public EntityResponse createEntity(String entitySetName, OEntity entity) { - throw new UnsupportedOperationException("Not yet supported"); - } - - /** - * {@inheritDoc} - */ - public void deleteEntity(String entitySetName, Object entityKey) { - throw new UnsupportedOperationException("Not yet supported"); - } - - /** - * {@inheritDoc} - */ - public EntitiesResponse getEntities(final String topicMapId, String entitySetName, QueryInfo queryInfo) { - /* - * get entity set - */ - final EdmEntitySet entitySet = metadata.getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - /* - * generate entities - */ - final List entities = metadata.getEntities(topicMapId, entitySetName, queryInfo); - final Integer inlineCount = queryInfo.inlineCount == InlineCount.ALLPAGES ? entities.size() : null; - return new EntitiesResponse() { - - @Override - public List getEntities() { - return entities; - } - - @Override - public EdmEntitySet getEntitySet() { - return entitySet; - } - - @Override - public Integer getInlineCount() { - return inlineCount; - } - - @Override - public String getSkipToken() { - return null; - } - }; - } - - /** - * {@inheritDoc} - */ - public EntityResponse getEntity(final String topicMapId, String entitySetName, Object entityKey) { - /* - * get entity set - */ - final EdmEntitySet entitySet = metadata.getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - /* - * get entity - */ - final OEntity entity = metadata.getEntity(topicMapId, entitySetName, entityKey.toString()); - return new EntityResponse() { - @Override - public EdmEntitySet getEntitySet() { - return entitySet; - } - - @Override - public OEntity getEntity() { - return entity; - } - }; - } - - /** - * {@inheritDoc} - */ - public EdmDataServices getMetadata(final String topicMapId) { - return metadata.getService(topicMapId); - } - - /** - * {@inheritDoc} - */ - public void mergeEntity(String entitySetName, Object entityKey, OEntity entity) { - throw new UnsupportedOperationException("Not yet supported"); - } - - /** - * {@inheritDoc} - */ - public void updateEntity(String entitySetName, Object entityKey, OEntity entity) { - throw new UnsupportedOperationException("Not yet supported"); - } - - @Override - public EntityResponse createEntity(String entitySetName, Object entityKey, String navProp, OEntity entity) { - throw new UnsupportedOperationException("Not yet supported"); - } - - @Override - public EntitiesResponse getNavProperty(final String topicMapId, String entitySetName, Object entityKey, String navProp, QueryInfo queryInfo) { - /* - * get entity set - */ - final EdmEntitySet entitySet = metadata.getService(topicMapId).getEdmEntitySet(entitySetName); - if (entitySet == null) { - throw new RuntimeException("Entity set for name '" + entitySetName + "' not found!"); - } - /* - * generate entities - */ - final List entities = metadata.getEntities(topicMapId, entitySetName, entityKey.toString(), navProp, queryInfo); - final Integer inlineCount = queryInfo.inlineCount == InlineCount.ALLPAGES ? entities.size() : null; - return new EntitiesResponse() { - - @Override - public List getEntities() { - return entities; - } - - @Override - public EdmEntitySet getEntitySet() { - return entitySet; - } - - @Override - public Integer getInlineCount() { - return inlineCount; - } - - @Override - public String getSkipToken() { - return null; - } - }; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducerFactory.java b/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducerFactory.java deleted file mode 100644 index 9ab195e..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/TopicMapODataProducerFactory.java +++ /dev/null @@ -1,137 +0,0 @@ -package de.topicmapslab.odata; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.odata4j.producer.ODataProducer; -import org.odata4j.producer.ODataProducerFactory; - -import de.topicmapslab.odata.content.IOdataContentProvider; -import de.topicmapslab.odata.exception.TopicMapsODataException; - -public class TopicMapODataProducerFactory implements ODataProducerFactory { - - private static TopicMapODataProducer producer; - - /** - * Returns the internal producer - * - * @return the producer - */ - public static TopicMapODataProducer getProducerInstance() { - if (producer == null) { - producer = createStatic(); - } - return producer; - } - - /** - * Static method to load a new data producer instance - * - * @param properties - * the properties - * @return the new data producer - */ - @SuppressWarnings("unchecked") - public static TopicMapODataProducer createStatic() { - Properties properties = loadProperties(); - Object oContentProviderClass = properties.get("contentProvider"); - if (oContentProviderClass == null) { - throw new RuntimeException("Missing required properties 'contentProvider'"); - } - /* - * load properties - */ - Object oNamespace = properties.get("namespace"); - if (oNamespace == null) { - throw new TopicMapsODataException("Missing required properties 'namespace'"); - } - try { - Class clazz = (Class) Class.forName(oContentProviderClass.toString()); - String namespace = oNamespace.toString(); - /* - * create content provider - */ - producer = new TopicMapODataProducer(clazz, properties, namespace); - return producer; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public ODataProducer create(Properties properties) { - return getProducerInstance(); - } - - public static final String PATH = System.getProperty("user.home") + "/.tm2o"; - private static final String FILE = PATH + "/tm2o.properties"; - - /** - * Writes the given properties to user dir - * - * @param clazz - * the class - * @param properties - * the properties - * @param namespace - * the namespace - */ - public static void writeProperties(Class clazz, Properties properties, String namespace) { - File file = new File(FILE); - if (!file.exists()) { - try { - new File(PATH).mkdirs(); - file.createNewFile(); - } catch (Exception e) { - System.err.println("Cannot create properties file"); - return; - } - } - try { - Properties toPersist = new Properties(); - toPersist.putAll(properties); - toPersist.remove("file"); - toPersist.put("namespace", namespace); - toPersist.put("contentProvider", clazz.getName()); - toPersist.store(new FileOutputStream(file), "TM2O"); - } catch (Exception e) { - System.err.println("Cannot write properties to file"); - return; - } - } - - /** - * Loads the properties from file - * - * @return the properties - */ - public static Properties loadProperties() { - File file = new File(FILE); - InputStream is; - if (file.exists()) { - try { - is = new FileInputStream(file); - } catch (FileNotFoundException e) { - is = TopicMapODataProducerFactory.class.getResourceAsStream("tm2o.properties"); - } - } else { - is = TopicMapODataProducerFactory.class.getResourceAsStream("tm2o.properties"); - } - Properties p = new Properties(); - try { - p.load(is); - } catch (IOException e) { - throw new RuntimeException("Cannot load properties from file!", e); - } - return p; - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/config/EContentProviderConfiguration.java b/tm2o-core/src/main/java/de/topicmapslab/odata/config/EContentProviderConfiguration.java deleted file mode 100644 index d5c9e52..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/config/EContentProviderConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.topicmapslab.odata.config; - -/** - * Enumeration of configuration properties for the OData mapper - * - * @author Sven Krosse - */ -public enum EContentProviderConfiguration { - - /** - * associations are only split by player types. Association type and role type will be ignored.
- *
- * The created navigation property looks like: TopyType2: TopicType1->TopicType2 - */ - FLAT_ASSOCIATION, - /** - * associations are only split by player types, association type and role types.
- *
- * The created navigation property looks like: AssociationType-TopicType2: RoleType1->RoleType2 - */ - STRONG_ASSOCIATION, - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/IOdataContentProvider.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/IOdataContentProvider.java deleted file mode 100644 index d613aee..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/IOdataContentProvider.java +++ /dev/null @@ -1,151 +0,0 @@ -package de.topicmapslab.odata.content; - -import java.util.List; -import java.util.Properties; - -import org.odata4j.core.OEntity; -import org.odata4j.edm.EdmAssociation; -import org.odata4j.edm.EdmEntitySet; -import org.odata4j.edm.EdmEntityType; -import org.odata4j.producer.QueryInfo; - -import de.topicmapslab.odata.TopicMapMetadata; -import de.topicmapslab.odata.config.EContentProviderConfiguration; -import de.topicmapslab.odata.edm.IEdmPropertyIdentifier; -import de.topicmapslab.odata.exception.TopicMapsODataException; - -/** - * Interface definition of an OData content provider accessing the topic maps source - * - * @author Sven Krosse - */ -public interface IOdataContentProvider { - - /** - * token for combination of relationship and counter player type - */ - public static final String RELATIONSHIP_DELIMER = "-"; - /** - * key constant - */ - public static final String ID_PROPNAME = "id"; - - /** - * Returns all entity sets of the content provider - * - * @return the entity sets - */ - public List getEntitySets(); - - /** - * Returns all EDM associations of the content provider - * - * @return the associations - */ - public List getAssociations(); - - /** - * Register the service - * - * @param service - * the service - */ - public void setService(TopicMapMetadata service); - - /** - * Method called to initialize the content provider. - * - * @param namespace - * the namespace of this service - * @param properties - * properties containing all arguments necessary to initialize the content provider - * @throws TopicMapsODataException - * thrown if the initialization failed - */ - public void initialize(String namespace, Properties properties) throws TopicMapsODataException; - - /** - * Returns all topic types of the topic map. - * - * @return the list of EDM entity types - */ - public List getEntityTypes(); - - /** - * Return the entity for the given id and entity set - * - * @param entitySet - * the entity set - * @param entityType - * the name of the entity type - * @param id - * the id of the entity - * @return the created entity - */ - public OEntity getEntity(final EdmEntitySet entitySet, final String entityType, final String id) throws TopicMapsODataException; - - /** - * Returns all entities of the given entity set - * - * @param entitySet - * the entity set - * @param queryInfo - * the query info - * @return a possible empty list of entities - */ - public List getEntities(final EdmEntitySet entitySet, final QueryInfo queryInfo); - - /** - * Returns the namespace of this OData service - * - * @return the namespace - */ - public String getNamespace(); - - /** - * Returns the entity id of an entity - * - * @param entityName - * the entity name - * @return the id and never null - * @throws TopicMapsODataException - * thrown if id is missed - */ - public String getEntityId(final String entityName) throws TopicMapsODataException; - - /** - * Returns the property identifier of an property - * - * @param property - * the property - * @return the identifier and never null - * @throws TopicMapsODataException - * thrown if property is missed - */ - public IEdmPropertyIdentifier getPropertyType(final String property) throws TopicMapsODataException; - - /** - * Returns all entities for the given entity set and the navigation property - * - * @param entitySet - * the entity set - * @param entityId - * the Id of left hand navigation node - * @param navigationPropertyId - * the association type - * @param info - * the query info - * @return the list of matching entities - */ - public List getEntities(final EdmEntitySet entitySet, final String entityId, final String navigationProperty, final QueryInfo info); - - /** - * Modify the mode of internal association mapping to {@link EContentProviderConfiguration#FLAT_ASSOCIATION} or - * {@link EContentProviderConfiguration#STRONG_ASSOCIATION} - * - * @param cfg - * the new mode {@link EContentProviderConfiguration#FLAT_ASSOCIATION} or - * {@link EContentProviderConfiguration#STRONG_ASSOCIATION} - */ - public void configAssociationHandling(EContentProviderConfiguration cfg); -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/OdataContentProviderImpl.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/OdataContentProviderImpl.java deleted file mode 100644 index 7f3a11e..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/OdataContentProviderImpl.java +++ /dev/null @@ -1,857 +0,0 @@ -package de.topicmapslab.odata.content; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.core4j.Enumerable; -import org.joda.time.LocalTime; -import org.odata4j.core.OEntities; -import org.odata4j.core.OEntity; -import org.odata4j.core.OLink; -import org.odata4j.core.OLinks; -import org.odata4j.core.OProperties; -import org.odata4j.core.OProperty; -import org.odata4j.edm.EdmAssociation; -import org.odata4j.edm.EdmAssociationEnd; -import org.odata4j.edm.EdmEntitySet; -import org.odata4j.edm.EdmEntityType; -import org.odata4j.edm.EdmMultiplicity; -import org.odata4j.edm.EdmNavigationProperty; -import org.odata4j.edm.EdmProperty; -import org.odata4j.edm.EdmType; -import org.odata4j.expression.CommonExpression; -import org.odata4j.expression.EntitySimpleProperty; -import org.odata4j.expression.OrderByExpression; -import org.odata4j.producer.QueryInfo; - -import de.topicmapslab.majortom.model.namespace.Namespaces; -import de.topicmapslab.odata.TopicMapMetadata; -import de.topicmapslab.odata.config.EContentProviderConfiguration; -import de.topicmapslab.odata.dao.AssociationTypeDAO; -import de.topicmapslab.odata.dao.CharacteristicsTypeDAO; -import de.topicmapslab.odata.dao.CounterPartDAO; -import de.topicmapslab.odata.dao.NameTypeDAO; -import de.topicmapslab.odata.dao.OccurrenceTypeDAO; -import de.topicmapslab.odata.dao.TopicTypeDAO; -import de.topicmapslab.odata.edm.EdmNavigationPropertyIdentifier; -import de.topicmapslab.odata.edm.EdmPropertyIdentifier; -import de.topicmapslab.odata.edm.IEdmNavigationPropertyIdentifier; -import de.topicmapslab.odata.edm.IEdmPropertyIdentifier; -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.odata.tmql.TmqlHelper; -import de.topicmapslab.odata.tmql.TmqlQueryBuilder; -import de.topicmapslab.odata.util.ODataUtils; -import de.topicmapslab.tmql4j.hibernate.criterion.ICriterion; -import de.topicmapslab.tmql4j.util.LiteralUtils; - -/** - * Abstract implementation of {@link IOdataContentProvider} - * - * @author Sven Krosse - */ -public abstract class OdataContentProviderImpl implements IOdataContentProvider { - - /** - * list of all EDM entity sets - */ - private List edmEntitySets = new ArrayList(); - /** - * list of all EDM entity types - */ - private List edmEntityTypes = new ArrayList(); - /** - * list of all EDM associations - */ - private List edmAssociations = new ArrayList(); - /** - * Mapping of EDM entity type id and its definition - */ - private Map edmEntityTypesById = new HashMap(); - /** - * Mapping of the entity type name and its id - */ - private Map edmEntityTypeIds = new HashMap(); - /** - * Mapping of EDM entity property id and its identifier for the topic map source - */ - private Map edmPropertyTypeIds = new HashMap(); - /** - * Map of the TMQL queries builder containing the queries to access entities of a specific EDM entity type - */ - private Map queryBuilders; - /** - * the namespace - */ - private String namespace; - /** - * the meta data service for the OData service - */ - private TopicMapMetadata service; - /** - * the association mode - */ - private EContentProviderConfiguration associationMode = EContentProviderConfiguration.STRONG_ASSOCIATION; - /** - * the topic map Id - */ - private final String topicMapId; - - /** - * constructor - * - * @param topicMapId - * the topic map id - */ - public OdataContentProviderImpl(final String topicMapId) { - this.topicMapId = topicMapId; - } - - /** - * {@inheritDoc} - */ - @Override - public String getNamespace() { - return namespace; - } - - @Override - public void setService(TopicMapMetadata service) { - this.service = service; - } - - /** - * {@inheritDoc} - */ - @Override - public void initialize(String namespace, Properties properties) throws TopicMapsODataException { - /* - * get association mode property - */ - Object oAssociationMode = properties.get("association-mode"); - if (oAssociationMode != null) { - try { - associationMode = EContentProviderConfiguration.valueOf(oAssociationMode.toString()); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } - this.namespace = namespace; - List topicTypes = getTopicTypesByTmql(); - /* - * convert topic types to entity type - */ - for (TopicTypeDAO topicType : topicTypes) { - final String typeId = topicType.getTypeId(); - final String typeLabel = topicType.getTypeLabel(); - List edmProperties = new ArrayList(); - /* - * initialize query builder - */ - TmqlQueryBuilder queryBuilder = new TmqlQueryBuilder(); - /* - * convert names to property - */ - List nameTypes = getNameTypesByTmql(typeId); - for (NameTypeDAO nameType : nameTypes) { - handleCharacteristicsDAO(edmProperties, queryBuilder, nameType); - } - /* - * convert occurrences to property - */ - List occurrenceTypes = getOccurrenceTypesByTmql(typeId); - for (OccurrenceTypeDAO occurrenceType : occurrenceTypes) { - handleCharacteristicsDAO(edmProperties, queryBuilder, occurrenceType); - } - /* - * create entity type - */ - EdmEntityType entityType = new EdmEntityType(getNamespace(), null, typeLabel, null, Enumerable.create(ID_PROPNAME).toList(), - edmProperties, new ArrayList()); - EdmEntitySet entitySet = new EdmEntitySet(typeLabel, entityType); - edmEntitySets.add(entitySet); - this.edmEntityTypeIds.put(typeLabel, typeId); - this.edmEntityTypes.add(entityType); - this.edmEntityTypesById.put(typeId, entityType); - getTmqlHelper().registerInstancePreparedStatement(typeId, queryBuilder.toInstanceQuery()); - getTmqlHelper().registerTypePreparedStatement(typeId, queryBuilder.toInstancesQuery()); - registerQueryBuilder(typeId, queryBuilder); - } - - /* - * convert associations to navigation entry - */ - List associationSignatures = getAssociationSignaturesByTmql(); - if (getAssociationMode() == EContentProviderConfiguration.STRONG_ASSOCIATION) { - handleStrongAssociation(associationSignatures); - } else { - handleFlatAssociation(associationSignatures); - } - } - - /** - * Internal method to handle a characteristics DAO. - * - * @param edmProperties - * the properties - * @param queryBuilder - * the query builder - * @param dao - * the DAO to handle - */ - private void handleCharacteristicsDAO(List edmProperties, TmqlQueryBuilder queryBuilder, CharacteristicsTypeDAO dao) { - /* - * iterate over all identifiers - */ - for (EdmPropertyIdentifier identifier : dao.getEdmPropertyIdentifiers()) { - /* - * create property - */ - EdmProperty property = new EdmProperty(identifier.getPropertyName(), dao.getDatatype(), true); - edmProperties.add(property); - /* - * add to TMQL query builder - */ - queryBuilder.fetch(identifier); - /* - * store for later reuse - */ - edmPropertyTypeIds.put(identifier.getPropertyName(), identifier); - } - } - - /** - * Method handle association signatures as flat associations - * - * @param associationSignatures - * the association signatures - */ - protected void handleFlatAssociation(List associationSignatures) { - Set alreadyKnown = new HashSet(); - /* - * iterate over all DAO - */ - for (AssociationTypeDAO dao : associationSignatures) { - /* - * ignore type-instance and supertype-subtype - */ - if (dao.getTypeLabel() == null || dao.getTypeLabel().equalsIgnoreCase(Namespaces.TMDM.SUPERTYPE_SUBTYPE) - || dao.getTypeLabel().equalsIgnoreCase(Namespaces.TMDM.TYPE_INSTANCE)) { - continue; - } - /* - * ignore topics without type - */ - if (dao.getRightPlayerTypeDAO() == null) { - continue; - } - /* - * get entity types - */ - EdmEntityType fromRoleET = this.edmEntityTypesById.get(dao.getLeftPlayerTypeDAO().getTypeId()); - EdmEntityType toRoleET = this.edmEntityTypesById.get(dao.getRightPlayerTypeDAO().getTypeId()); - /* - * ignore missed entity types - */ - if (fromRoleET == null || toRoleET == null) { - continue; - } - /* - * iterate over all identifiers - */ - for (EdmNavigationPropertyIdentifier identifier : dao.getFlatRelationshipIdentifier()) { - /* - * is already bound - */ - if (alreadyKnown.contains(identifier)) { - System.out.println(identifier.getPropertyName() + " already known and will be ignored!"); - continue; - } - alreadyKnown.add(identifier); - /* - * create roles - */ - EdmAssociationEnd fromRole = new EdmAssociationEnd(dao.getLeftPlayerTypeDAO().getTypeLabel(), fromRoleET, EdmMultiplicity.MANY); - EdmAssociationEnd toRole = new EdmAssociationEnd(dao.getRightPlayerTypeDAO().getTypeLabel(), toRoleET, EdmMultiplicity.MANY); - /* - * create relationship - */ - EdmAssociation relationship = new EdmAssociation(namespace, null, identifier.getPropertyName(), fromRole, toRole); - edmAssociations.add(relationship); - edmPropertyTypeIds.put(identifier.getPropertyName(), identifier); - /* - * create navigation properties - */ - EdmNavigationProperty navigationPropertyFrom = new EdmNavigationProperty(identifier.getPropertyName(), relationship, fromRole, toRole); - fromRoleET.navigationProperties.add(navigationPropertyFrom); - EdmNavigationProperty navigationPropertyTo = new EdmNavigationProperty(identifier.getPropertyName(), relationship, toRole, fromRole); - toRoleET.navigationProperties.add(navigationPropertyTo); - } - } - } - - /** - * Method handle association signatures as strong associations - * - * @param associationSignatures - * the association signatures - */ - protected void handleStrongAssociation(List associationSignatures) { - Set alreadyKnown = new HashSet(); - /* - * iterate over all signatures - */ - for (AssociationTypeDAO associationSignature : associationSignatures) { - /* - * ignore type-instance and supertype-subtype - */ - if (associationSignature.getTypeLabel() == null - || associationSignature.getTypeLabel().equalsIgnoreCase(Namespaces.TMDM.SUPERTYPE_SUBTYPE) - || associationSignature.getTypeLabel().equalsIgnoreCase(Namespaces.TMDM.TYPE_INSTANCE)) { - continue; - } - /* - * ignore topics without type - */ - if (associationSignature.getRightPlayerTypeDAO() == null) { - continue; - } - /* - * get information of association signature - */ - final String fromPlayerTypeId = associationSignature.getLeftPlayerTypeDAO().getTypeId(); - final String fromPlayerTypeLabel = associationSignature.getLeftPlayerTypeDAO().getTypeLabel(); - final String fromRoleId = associationSignature.getLeftRoleTypeDAO().getTypeId(); - final String fromRoleLabel = associationSignature.getLeftRoleTypeDAO().getTypeLabel(); - final String toRoleId = associationSignature.getRightRoleTypeDAO().getTypeId(); - final String toRoleLabel = associationSignature.getRightRoleTypeDAO().getTypeLabel(); - final String toPlayerTypeId = associationSignature.getRightPlayerTypeDAO().getTypeId(); - final String toPlayerTypeLabel = associationSignature.getRightPlayerTypeDAO().getTypeLabel(); - /* - * get EDM entity types - */ - EdmEntityType fromRoleET = this.edmEntityTypesById.get(fromPlayerTypeId); - EdmEntityType toRoleET = this.edmEntityTypesById.get(toPlayerTypeId); - /* - * ignore missed entity types - */ - if (fromRoleET == null || toRoleET == null) { - continue; - } - /* - * iterate over all identifier - */ - for (EdmNavigationPropertyIdentifier identifier : associationSignature.getStrongRelationshipIdentifier()) { - /* - * check if already known - */ - if (alreadyKnown.contains(identifier)) { - continue; - } - alreadyKnown.add(identifier); - /* - * create 'fromRole' - */ - EdmAssociationEnd fromRole = new EdmAssociationEnd(fromRoleLabel, fromRoleET, EdmMultiplicity.MANY); - this.edmEntityTypeIds.put(fromRoleLabel, fromRoleId); - this.edmEntityTypeIds.put(fromPlayerTypeLabel, fromPlayerTypeId); - /* - * create 'toRole' - */ - EdmAssociationEnd toRole = new EdmAssociationEnd(toRoleLabel, toRoleET, EdmMultiplicity.MANY); - this.edmEntityTypeIds.put(toRoleLabel, toRoleId); - this.edmEntityTypeIds.put(toPlayerTypeLabel, toPlayerTypeId); - - /* - * create relationship - */ - EdmAssociation relationship = new EdmAssociation(namespace, null, identifier.getPropertyName(), fromRole, toRole); - this.edmPropertyTypeIds.put(identifier.getPropertyName(), identifier); - /* - * create navigation properties - */ - EdmNavigationProperty fromNavigationProperty = new EdmNavigationProperty(identifier.getPropertyName(), relationship, fromRole, toRole); - edmAssociations.add(relationship); - fromRoleET.navigationProperties.add(fromNavigationProperty); - EdmNavigationProperty toNavigationProperty = new EdmNavigationProperty(identifier.getPropertyName(), relationship, toRole, fromRole); - edmAssociations.add(relationship); - toRoleET.navigationProperties.add(toNavigationProperty); - } - } - } - - /** - * Returns the EDM entity type by id of an entity - * - * @param id - * the entity type id - * @return the EDM entity type and never null - * @throws TopicMapsODataException - * thrown if id is missed - */ - public EdmEntityType getEntityTypeById(final String id) throws TopicMapsODataException { - /* - * get type id - */ - final EdmEntityType type = edmEntityTypesById.get(id); - if (type == null) { - throw new TopicMapsODataException("Missing entity type for id '" + id + "'!"); - } - return type; - } - - /** - * Returns the entity id of an entity - * - * @param entityName - * the entity name - * @return the id and never null - * @throws TopicMapsODataException - * thrown if id is missed - */ - public String getEntityId(final String entityName) throws TopicMapsODataException { - /* - * get type id - */ - final String typeId = edmEntityTypeIds.get(entityName); - if (typeId == null) { - throw new TopicMapsODataException("Missing type id for entity type '" + entityName + "'!"); - } - return typeId; - } - - /** - * {@inheritDoc} - */ - @Override - public List getEntityTypes() { - return edmEntityTypes; - } - - /** - * {@inheritDoc} - */ - @Override - public List getEntitySets() { - return edmEntitySets; - } - - /** - * {@inheritDoc} - */ - @Override - public List getAssociations() { - return edmAssociations; - } - - /** - * {@inheritDoc} - */ - @Override - public OEntity getEntity(EdmEntitySet entitySet, String entityType, String id) throws TopicMapsODataException { - /* - * get property values - */ - Object[] values = getEntityData(getEntityId(entityType), id); - if (values.length == 0) { - throw new TopicMapsODataException("The entity with key '" + id + "' not found!"); - } - /* - * translate values to EDM properties - */ - List edmProperties = entitySet.type.properties; - return createEntity(entitySet, edmProperties, values); - } - - /** - * {@inheritDoc} - */ - @Override - public List getEntities(EdmEntitySet entitySet, QueryInfo queryInfo) { - final String typeId = getEntityId(entitySet.type.name); - /* - * get the query builder - */ - TmqlQueryBuilder queryBuilder = queryBuilders.get(typeId); - if (queryBuilder == null) { - throw new TopicMapsODataException("Missing querybuilder for entity set '" + entitySet.type.name + "'!"); - } - try { - queryBuilder = queryBuilder.clone(); - } catch (CloneNotSupportedException e) { - throw new TopicMapsODataException(e); - } - /* - * create filters and oder query parts - */ - try { - proceedQueryInfo(queryBuilder, queryInfo); - } catch (Exception e) { - e.printStackTrace(System.err); - return Collections.emptyList(); - } - /* - * create results - */ - List entities = new ArrayList(); - Object[][] values = getEntityData(typeId, queryBuilder); - for (Object value[] : values) { - OEntity entity = createEntity(entitySet, entitySet.type.properties, value); - entities.add(entity); - } - return entities; - } - - /** - * Method called to proceed the query info given by the request. The method can be override to change behavior. - * - * @param queryBuilder - * the query builder - * @param queryInfo - * the query info - * @throws TopicMapsODataException - * thrown if anything fails - */ - protected void proceedQueryInfo(TmqlQueryBuilder queryBuilder, QueryInfo queryInfo) throws TopicMapsODataException { - /* - * check offset value defined by $skip - */ - if (queryInfo.skip != null && queryInfo.skip > 0L) { - queryBuilder.offset(queryInfo.skip - 1); - } - /* - * check limit value defined by $top - */ - if (queryInfo.top != null && queryInfo.top > 0L) { - queryBuilder.limit(queryInfo.top); - } - /* - * check order by - */ - if (queryInfo.orderBy != null) { - for (OrderByExpression orderBy : queryInfo.orderBy) { - CommonExpression expression = orderBy.getExpression(); - if (!(expression instanceof EntitySimpleProperty)) { - throw new TopicMapsODataException("Current implementation only supports simple property expressions"); - } - final IEdmPropertyIdentifier identifier = getPropertyType(((EntitySimpleProperty) expression).getPropertyName()); - queryBuilder.orderBy(identifier, orderBy.isAscending()); - } - } - /* - * check filter - */ - if (queryInfo.filter != null) { - ICriterion criterion = ODataUtils.transformToTmql(this, queryBuilder, queryInfo.filter); - queryBuilder.where(criterion); - } - } - - /** - * Internal method called to get data of a entity by its id and type. The order of results should be similar to - * their definition. - * - * - * @param typeId - * the id of type - * @param entityId - * the id of entity - * - * @return the string array - */ - protected abstract Object[] getEntityData(final String typeId, final String entityId); - - /** - * Internal method called to get data of all entities by their type. The order of results should be similar to their - * definition. - * - * @param typeId - * the id of type - * @param query - * the query builder - * - * @return the string array - */ - protected abstract Object[][] getEntityData(final String typeId, final TmqlQueryBuilder query); - - /** - * Internal method called to get data of the topic types by TMQL. - * - * @return the list of DAO - */ - protected abstract List getTopicTypesByTmql(); - - /** - * Internal method called to get data of the name type by TMQL in context of the given topic type. - * - * @param typeId - * the id of type - * @return the list of DAO - */ - protected abstract List getNameTypesByTmql(final String typeId); - - /** - * Internal method called to get data of the occurrence type by TMQL in context of the given topic type. - * - * @param typeId - * the id of type - * @return the list of DAO - */ - protected abstract List getOccurrenceTypesByTmql(final String typeId); - - /** - * Internal method called to get all association signatures of an entity - * - * @param entityId - * the entity - * @return the association signatures - */ - protected abstract List getAssociationSignaturesOfEntityByTmql(final String entityId); - - /** - * Internal method called to get all counter players of the given entity. If the association type is given, only - * counter players of an association with this type are returned. If counter player type is given, only counter - * players of this type are returned. If the theme is given, only associations with a scope containing this theme - * are returned. If the theme is null, only association with the unconstrained scope are returned. - * - * @param entityId - * the entity id - * @param associationTypeId - * the association type id - * @param counterTypeId - * the counter player type id - * @param themeId - * the theme id - * @return a list of counter players - */ - protected abstract List getCounterPlayers(final String entityId, final String associationTypeId, final String counterTypeId, - final String themeId); - - /** - * Returns all counter players returned as result of the given query. - * - * @param query - * the query - * @return the counter players - */ - protected abstract List getCounterPlayers(final String query); - - /** - * Internal method called to get data of the association signatures by TMQL in context of the given topic type. - * - * @return the list of DAO - */ - protected abstract List getAssociationSignaturesByTmql(); - - /** - * method called to store the builder for a type id - * - * @param typeId - * the type id - * @param builder - * the builder - */ - protected void registerQueryBuilder(final String typeId, final TmqlQueryBuilder builder) { - if (queryBuilders == null) { - queryBuilders = new HashMap(); - } - queryBuilders.put(typeId, builder); - } - - /** - * Internal method to create the entity from given string values - * - * @param entitySet - * the entity set - * @param edmProperties - * the EDM properties - * @param values - * the values - * @return the created {@link OEntity} - */ - protected OEntity createEntity(EdmEntitySet entitySet, List edmProperties, Object[] values) { - final List> properties = new ArrayList>(); - final String entityId = values[0].toString(); - properties.add(OProperties.int64(ID_PROPNAME, Long.parseLong(entityId))); - /* - * extract properties - */ - for (int i = 0; i < edmProperties.size() && i + 1 < values.length; i++) { - EdmProperty edmProperty = edmProperties.get(i); - Object value_ = values[i + 1]; - if (value_ == null) { - continue; - } - String value = value_.toString(); - try { - /* - * set property by its data type - */ - if (edmProperty.type == EdmType.STRING) { - properties.add(OProperties.string(edmProperty.name, value)); - } else if (edmProperty.type == EdmType.INT32) { - properties.add(OProperties.int32(edmProperty.name, Integer.valueOf(value))); - } else if (edmProperty.type == EdmType.INT64) { - properties.add(OProperties.int64(edmProperty.name, Long.valueOf(value))); - } else if (edmProperty.type == EdmType.DATETIME) { - properties.add(OProperties.datetime(edmProperty.name, LiteralUtils.asDateTime(value).getTime())); - } else if (edmProperty.type == EdmType.TIME) { - properties.add(OProperties.time(edmProperty.name, LocalTime.fromCalendarFields(LiteralUtils.asTime(value)))); - } else if (edmProperty.type == EdmType.DECIMAL) { - properties.add(OProperties.decimal(edmProperty.name, new BigDecimal(value))); - } else if (edmProperty.type == EdmType.DOUBLE) { - properties.add(OProperties.decimal(edmProperty.name, Double.valueOf(value))); - } else if (edmProperty.type == EdmType.BOOLEAN) { - properties.add(OProperties.boolean_(edmProperty.name, Boolean.valueOf(value))); - } - } catch (Exception e) { - e.printStackTrace(System.err); - } - } - /* - * check OLink - */ - List olinks = createOLinks(getEntityId(entitySet.type.name), entityId); - /* - * create entity - */ - return OEntities.create(entitySet, properties, olinks, entityId); - } - - /** - * Method generate OLinks for the given entity type and entity Id - */ - protected List createOLinks(final String entityTypeId, final String entityId) { - EdmEntityType type = getEntityTypeById(entityTypeId); - List olinks = new ArrayList(); - for (EdmNavigationProperty property : type.navigationProperties) { - final String name = property.relationship.name; - IEdmPropertyIdentifier identifier = getPropertyType(name); - if (!(identifier instanceof IEdmNavigationPropertyIdentifier)) { - throw new RuntimeException("Missed or invalid property identifier for '" + name + "'"); - } - IEdmNavigationPropertyIdentifier navProperty = (IEdmNavigationPropertyIdentifier) identifier; - OLink olink = OLinks.link(identifier.getPropertyName(), navProperty.getDAO().getRightPlayerTypeDAO().getTypeLabel(), navProperty.getDAO() - .getRightPlayerTypeDAO().getTypeLabel()); - olinks.add(olink); - } - return olinks; - } - - /** - * {@inheritDoc} - */ - @Override - public List getEntities(EdmEntitySet counterPlayerEdmEntitySet, String entityId, String navigationProperty, QueryInfo queryInfo) { - /* - * extract IDs - */ - IEdmPropertyIdentifier identifier = getPropertyType(navigationProperty); - if (!(identifier instanceof IEdmNavigationPropertyIdentifier)) { - throw new RuntimeException("Missed or invalid property identifier for '" + navigationProperty + "'"); - } - EdmNavigationPropertyIdentifier navProperty = (EdmNavigationPropertyIdentifier) identifier; - /* - * extract entities - */ - List entities = new ArrayList(); - /* - * get counter parts - */ - List counterParts; - TopicTypeDAO counterDAO = navProperty.getDAO().getCounterPlayerDAO(counterPlayerEdmEntitySet.type.name); - EdmEntitySet edmEntitySet = getService().getService(getTopicMapId()).getEdmEntitySet(counterDAO.getTypeLabel()); - List allCounterParts = getEntities(edmEntitySet, queryInfo); - /* - * extract filter matches as ID of matching entities - */ - List filterMatches = new ArrayList(); - for (OEntity e : allCounterParts) { - filterMatches.add(e.getId().toString()); - } - /* - * no instance found matching the condition - */ - if (filterMatches.isEmpty()) { - return entities; - } - /* - * get navigation property and the counter players - */ - counterParts = getCounterPlayers(entityId, navProperty.getAssociationTypeId(), counterDAO.getTypeId(), navProperty.getThemeId()); - /* - * transform - */ - for (CounterPartDAO dao : counterParts) { - /* - * is filter match? - */ - if (filterMatches.contains(dao.getCounterPlayerId())) { - entities.add(getEntity(edmEntitySet, counterDAO.getTypeLabel(), dao.getCounterPlayerId())); - } - } - return entities; - } - - /** - * Access the internal topic map service - * - * @return the service - */ - protected TopicMapMetadata getService() { - return service; - } - - /** - * {@inheritDoc} - */ - @Override - public void configAssociationHandling(EContentProviderConfiguration cfg) { - if (cfg != EContentProviderConfiguration.FLAT_ASSOCIATION && cfg != EContentProviderConfiguration.STRONG_ASSOCIATION) { - throw new RuntimeException("Only FLAT_ASSOCIATION or STRONG_ASSOCIATION are allowed as association mode."); - } - associationMode = cfg; - } - - /** - * Returns the association mode - * - * @return the association mode - */ - EContentProviderConfiguration getAssociationMode() { - return associationMode; - } - - /** - * {@inheritDoc} - */ - @Override - public IEdmPropertyIdentifier getPropertyType(String property) throws TopicMapsODataException { - if (edmPropertyTypeIds.containsKey(property)) { - return edmPropertyTypeIds.get(property); - } - throw new TopicMapsODataException("Missing type for proeprty '" + property + "'!"); - } - - /** - * Returns the topic map id - * - * @return the topic map id - */ - protected String getTopicMapId() { - return topicMapId; - } - - /** - * Returns the internal reference of the TMQL helper - * - * @return TMQL helper - */ - protected abstract TmqlHelper getTmqlHelper(); -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/TmqlOdataContentProviderImpl.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/TmqlOdataContentProviderImpl.java deleted file mode 100644 index d54ab8a..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/TmqlOdataContentProviderImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -package de.topicmapslab.odata.content; - -import java.util.ArrayList; -import java.util.List; - -import de.topicmapslab.odata.dao.AssociationTypeDAO; -import de.topicmapslab.odata.dao.CounterPartDAO; -import de.topicmapslab.odata.dao.NameTypeDAO; -import de.topicmapslab.odata.dao.OccurrenceTypeDAO; -import de.topicmapslab.odata.dao.TopicTypeDAO; -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.odata.tmql.TmqlHelper; -import de.topicmapslab.odata.tmql.TmqlQueryBuilder; - -/** - * Abstract content provider using TMQL helpers to manage TMQL requests - * - * @author Sven Krosse - * @param - * the type of TMQL helper - */ -public abstract class TmqlOdataContentProviderImpl extends OdataContentProviderImpl { - - /** - * constructor - * - * @param topicMapId - * the topic map id - */ - public TmqlOdataContentProviderImpl(final String topicMapId) { - super(topicMapId); - } - - /** - * {@inheritDoc} - */ - @Override - protected Object[] getEntityData(String typeId, String entityId) { - Object[][] values = getTmqlHelper().getProperties(typeId, entityId); - if (values.length == 0) { - throw new TopicMapsODataException("Missing values for entity with id '" + entityId + "'!"); - } - return values[0]; - } - - /** - * {@inheritDoc} - */ - @Override - protected Object[][] getEntityData(String typeId, TmqlQueryBuilder query) { - return getTmqlHelper().runQuery(query.toInstancesQuery(), typeId); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getTopicTypesByTmql() { - return getTmqlHelper().getTopicTypes(); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getNameTypesByTmql(String typeId) { - return getTmqlHelper().getNameTypes(typeId); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getOccurrenceTypesByTmql(String typeId) { - return getTmqlHelper().getOccurrenceTypes(typeId); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getAssociationSignaturesByTmql() { - return getTmqlHelper().getAssociationSignatures(); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getAssociationSignaturesOfEntityByTmql(String entityId) { - return getTmqlHelper().getAssociationSignaturesOfEntityByTmql(entityId); - } - - /** - * {@inheritDoc} - */ - @Override - protected void registerQueryBuilder(String typeId, TmqlQueryBuilder builder) { - super.registerQueryBuilder(typeId, builder); - /* - * register prepared statement - */ - getTmqlHelper().registerInstancePreparedStatement(typeId, builder.toInstanceQuery()); - getTmqlHelper().registerTypePreparedStatement(typeId, builder.toInstancesQuery()); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getCounterPlayers(String entityId, String associationTypeId, String counterTypeId, String themeId) { - return getTmqlHelper().getCounterPlayers(entityId, associationTypeId, counterTypeId, themeId); - } - - /** - * {@inheritDoc} - */ - @Override - protected List getCounterPlayers(String query) { - List daos = new ArrayList(); - for (Object[] values : getTmqlHelper().runQuery(query)) { - daos.add(new CounterPartDAO(values[0].toString())); - } - return daos; - } - - /** - * {@inheritDoc} - */ - @Override - protected abstract T getTmqlHelper(); - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/empty/EmptyOdataContentProvider.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/empty/EmptyOdataContentProvider.java deleted file mode 100644 index 9acc17c..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/empty/EmptyOdataContentProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package de.topicmapslab.odata.content.empty; - -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.odata4j.core.OEntities; -import org.odata4j.core.OEntity; -import org.odata4j.core.OLink; -import org.odata4j.core.OProperty; -import org.odata4j.edm.EdmAssociation; -import org.odata4j.edm.EdmEntitySet; -import org.odata4j.edm.EdmEntityType; -import org.odata4j.producer.QueryInfo; - -import de.topicmapslab.odata.TopicMapMetadata; -import de.topicmapslab.odata.config.EContentProviderConfiguration; -import de.topicmapslab.odata.content.IOdataContentProvider; -import de.topicmapslab.odata.edm.IEdmPropertyIdentifier; -import de.topicmapslab.odata.exception.TopicMapsODataException; - -public class EmptyOdataContentProvider implements IOdataContentProvider { - - private String namespace; - - @Override - public List getEntitySets() { - return Collections.emptyList(); - } - - @Override - public List getAssociations() { - return Collections.emptyList(); - } - - @Override - public void setService(TopicMapMetadata service) { - // VOID - } - - @Override - public void initialize(String namespace, Properties properties) throws TopicMapsODataException { - this.namespace = namespace; - } - - @Override - public List getEntityTypes() { - return Collections.emptyList(); - } - - @Override - public OEntity getEntity(EdmEntitySet entitySet, String entityType, String id) throws TopicMapsODataException { - List> props = Collections.emptyList(); - List olinks = Collections.emptyList(); - return OEntities.create(entitySet, props, olinks, id); - } - - @Override - public List getEntities(EdmEntitySet entitySet, QueryInfo queryInfo) { - return Collections.emptyList(); - } - - @Override - public String getNamespace() { - return namespace; - } - - @Override - public String getEntityId(String entityName) throws TopicMapsODataException { - return null; - } - - @Override - public IEdmPropertyIdentifier getPropertyType(String property) throws TopicMapsODataException { - return null; - } - - @Override - public List getEntities(EdmEntitySet entitySet, String entityId, String navigationProperty, QueryInfo info) { - return Collections.emptyList(); - } - - @Override - public void configAssociationHandling(EContentProviderConfiguration cfg) { - // VOID - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryOdataContentProvider.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryOdataContentProvider.java deleted file mode 100644 index 6e0f04b..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryOdataContentProvider.java +++ /dev/null @@ -1,119 +0,0 @@ -package de.topicmapslab.odata.content.memory; - -import java.io.File; -import java.io.FileReader; -import java.util.Properties; - -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicMapSystemFactory; -import org.tmapix.io.CTMTopicMapReader; -import org.tmapix.io.LTMTopicMapReader; -import org.tmapix.io.TopicMapReader; -import org.tmapix.io.XTMTopicMapReader; - -import de.topicmapslab.format_estimator.FormatEstimator; -import de.topicmapslab.odata.content.TmqlOdataContentProviderImpl; -import de.topicmapslab.odata.exception.TopicMapsODataException; - -/** - * Content provider using a in memory topic map source running in a MaJorToM topic maps engine - * - * @author Sven Krosse - */ -public class MemoryOdataContentProvider extends TmqlOdataContentProviderImpl { - - /** - * the TMQL helper - */ - private MemoryTmqlHelper helper; - - /** - * constructor - * - * @param topicMapId - * the topic map id - */ - public MemoryOdataContentProvider(final String topicMapId) { - super(topicMapId); - } - - /** - * {@inheritDoc} - */ - @Override - public void initialize(String namespace, Properties properties) throws TopicMapsODataException { - /* - * load properties - */ - Object oPath = properties.get("path"); - Object oFile = properties.get("file"); - if (oPath == null && oFile == null) { - throw new TopicMapsODataException("Missing required properties"); - } - /* - * load from file - */ - try { - /* - * create topic map - */ - TopicMap topicMap = TopicMapSystemFactory.newInstance().newTopicMapSystem().createTopicMap("http://local.tm2o.topicmap.de"); - /* - * get topic map reader by format - */ - TopicMapReader topicMapReader; - File file = null; - if (oPath != null) { - file = new File(oPath.toString()); - } else { - file = (File) oFile; - } - FileReader reader = new FileReader(file); - switch (FormatEstimator.guessFormat(reader)) { - case CTM: - case CTM_1_0: { - topicMapReader = new CTMTopicMapReader(topicMap, file); - } - break; - case XTM_1_0: - case XTM_1_1: - case XTM_2_0: - case XTM_2_1: { - topicMapReader = new XTMTopicMapReader(topicMap, file); - } - break; - case LTM: - case LTM_1_0: - case LTM_1_1: - case LTM_1_2: - case LTM_1_3: { - topicMapReader = new LTMTopicMapReader(topicMap, file); - } - break; - default: { - throw new TopicMapsODataException("Unsupported topic map file format!"); - } - } - /* - * load topic map - */ - topicMapReader.read(); - /* - * create memory helper - */ - helper = new MemoryTmqlHelper(topicMap); - } catch (Exception e) { - throw new RuntimeException(e); - } - super.initialize(namespace, properties); - } - - /** - * {@inheritDoc} - */ - @Override - protected MemoryTmqlHelper getTmqlHelper() { - return helper; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryTmqlHelper.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryTmqlHelper.java deleted file mode 100644 index 0490891..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/memory/MemoryTmqlHelper.java +++ /dev/null @@ -1,85 +0,0 @@ -package de.topicmapslab.odata.content.memory; - -import org.tmapi.core.TopicMap; - -import de.topicmapslab.odata.tmql.TmqlHelper; -import de.topicmapslab.tmql4j.components.processor.prepared.IPreparedStatement; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * TMQL helper instance using memory calls to execute queries on remote server - * - * @author Sven Krosse - */ -public class MemoryTmqlHelper extends TmqlHelper { - - /** - * the topic map - */ - private final TopicMap topicMap; - - /** - * constructor - * - * @param topicMap - * the topic map - */ - public MemoryTmqlHelper(TopicMap topicMap) { - this.topicMap = topicMap; - } - - /** - * Returns the topic map - * - * @return the topic map - */ - public TopicMap getTopicMap() { - return topicMap; - } - - /** - * Utility method to execute a prepared statement - * - * @param stmt - * the statement - * @param arguments - * the arguments - * @return the results set - */ - @Override - protected IResultSet runPreparedStatement(final IPreparedStatement stmt, Object... arguments) { - while (!lock.tryLock()) { - // VOID - } - try { - stmt.setTopicMap(topicMap); - stmt.run(arguments); - IResultSet rs = stmt.getResults(); - stmt.setTopicMap(null); - return rs; - } finally { - lock.unlock(); - } - } - - /** - * Utility method to execute a query - * - * @param query - * the query - * @param arguments - * the arguments - * @return the results as string array - */ - @Override - public Object[][] runQuery(final String query, Object... arguments) { - while (!lock.tryLock()) { - // VOID - } - try { - return toArray(getRuntime().run(topicMap, query, arguments).getResults()); - } finally { - lock.unlock(); - } - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/MaJorToMJSONReader.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/MaJorToMJSONReader.java deleted file mode 100644 index 35ea592..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/MaJorToMJSONReader.java +++ /dev/null @@ -1,130 +0,0 @@ -package de.topicmapslab.odata.content.remote; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.codehaus.jackson.JsonEncoding; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; - -import de.topicmapslab.tmql4j.components.processor.results.jtmqr.reader.JTMQRReader; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * JSON reader for MaJorToM server - * - * @author Sven Krosse - */ -public class MaJorToMJSONReader { - - /** - * State returns by MaJorToM server if request was valid - */ - public static final int STATE_OK = 0; - /** - * State returns by MaJorToM server if request was invalid - */ - public static final int STATE_ERROR = 1; - /** - * State set before first request - */ - public static final int STATE_INVALID = -1; - - /** - * the last message received from server - */ - private String lastMessage; - /** - * the last state received from server - */ - private int lastState = STATE_INVALID; - /** - * the result set - */ - private IResultSet resultSet; - - /** - * the input stream used to read the incoming JSON - */ - private InputStream stream; - - /** - * constructor - * - * @param stream - * the stream - */ - public MaJorToMJSONReader(InputStream stream) { - this.stream = stream; - } - - /** - * Reads the result of MaJorToM server - * - * @throws JsonParseException - * thrown if JSON cannot be parsed - * @throws JsonMappingException - * thrown if JSON cannot be created - * @throws IOException - * thrown if any I/O error occur - */ - public void read() throws JsonParseException, JsonMappingException, IOException { - ObjectMapper m = new ObjectMapper(); - JsonNode rootNode = m.readValue(stream, JsonNode.class); - JsonNode code = rootNode.path("code"); - try { - lastState = Integer.parseInt(code.getValueAsText()); - } catch (NumberFormatException e) { - lastState = -1; - } - JsonNode msg = rootNode.path("msg"); - lastMessage = msg.getTextValue(); - if (lastState == 0) { - JsonNode data = rootNode.path("data"); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - JsonFactory factory = new JsonFactory(); - JsonGenerator gen = factory.createJsonGenerator(os, JsonEncoding.UTF8); - gen.setCodec(m); - gen.writeTree(data); - resultSet = new JTMQRReader(new ByteArrayInputStream(os.toByteArray())).readResultSet(); - - } - } - - /** - * Returns the result set - * - * @return the result set - */ - public IResultSet getResultSet() { - return resultSet; - } - - /** - * Returns the last message received from server. If the message is called before the first request, the return - * value is null. - * - * @return the message or null - */ - public String getLastMessage() { - return lastMessage; - } - - /** - * Returns the last state receiver from server. If the message is called before the first request, the return value - * is {@link #STATE_INVALID}. - * - * @return {@link #STATE_OK}({@value #STATE_OK}), {@link #STATE_ERROR}({@value #STATE_ERROR}) or - * {@link #STATE_INVALID}({@value #STATE_INVALID}) - */ - public int getLastState() { - return lastState; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteOdataContentProvider.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteOdataContentProvider.java deleted file mode 100644 index 8178e8d..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteOdataContentProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -package de.topicmapslab.odata.content.remote; - -import java.util.Properties; - -import de.topicmapslab.odata.content.TmqlOdataContentProviderImpl; -import de.topicmapslab.odata.exception.TopicMapsODataException; - -/** - * Content provider using a remote topic map data source running in a MaJorToM server - * - * @author Sven Krosse - */ -public class RemoteOdataContentProvider extends TmqlOdataContentProviderImpl { - - private RemoteTmqlHelper helper; - private String server; - private String apiKey; - - /** - * constructor - * - * @param topicMapId - * the topic map id - */ - public RemoteOdataContentProvider(String topicMapId) { - super(topicMapId); - } - - /** - * {@inheritDoc} - */ - @Override - public void initialize(String namespace, Properties properties) throws TopicMapsODataException { - /* - * load properties - */ - Object oServer = properties.get("server"); - if (oServer == null) { - throw new TopicMapsODataException("Missing required property of server URL"); - } - Object oAPIKey = properties.get("api-key"); - if (oAPIKey == null) { - throw new TopicMapsODataException("Missing required property of API Key of MaJorToM server"); - } - server = oServer.toString(); - apiKey = oAPIKey.toString(); - helper = new RemoteTmqlHelper(getServerUrl(), getApiKey(), getTopicMapId()); - super.initialize(namespace, properties); - } - - /** - * {@inheritDoc} - */ - @Override - protected RemoteTmqlHelper getTmqlHelper() { - return helper; - } - - /** - * Returns the server URL - * - * @return the server URL - */ - protected String getServerUrl() { - return server; - } - - /** - * Returns the API key - * - * @return the API key - */ - protected String getApiKey() { - return apiKey; - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteTmqlHelper.java b/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteTmqlHelper.java deleted file mode 100644 index db0aa17..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/content/remote/RemoteTmqlHelper.java +++ /dev/null @@ -1,176 +0,0 @@ -package de.topicmapslab.odata.content.remote; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; -import java.text.MessageFormat; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.odata.tmql.TmqlHelper; -import de.topicmapslab.tmql4j.components.processor.prepared.IPreparedStatement; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * TMQL helper instance using HTTP communication to execute queries on remote server - * - * @author Sven Krosse - */ -public class RemoteTmqlHelper extends TmqlHelper { - - /** - * encoding - */ - private static final String UTF_8 = "utf-8"; - /** - * message of I/O error - */ - private static final String IOERROR = "An I/O error occur during communication with the server."; - /** - * the topic map ID of remote server - */ - private final String topicMapId; - /** - * the URL of remote server - */ - private final String uri; - /** - * the API Key of remote server - */ - private final String apiKey; - - /** - * URL pattern for POST request - */ - private final String PATTERN = "{0}/tm/tmql/{1}"; - - /** - * constructor - * - * @param server - * the server URL - * @param apiKey - * the API key - * @param topicMapId - * the topic map id - */ - public RemoteTmqlHelper(final String server, final String apiKey, final String topicMapId) { - this.topicMapId = topicMapId; - this.apiKey = apiKey; - this.uri = MessageFormat.format(PATTERN, server, topicMapId); - } - - /** - * Returns the topic map id - * - * @return the topic map id - */ - public String getTopicMapId() { - return topicMapId; - } - - /** - * Utility method to execute a prepared statement - * - * @param stmt - * the statement - * @param arguments - * the arguments - * @return the results set - */ - @Override - protected IResultSet runPreparedStatement(final IPreparedStatement stmt, Object... arguments) { - while (!lock.tryLock()) { - // VOID - } - try { - int i = 0; - for (Object o : arguments) { - stmt.set(i++, o); - } - return remoteExecute(stmt.getNonParameterizedQueryString()); - } finally { - lock.unlock(); - } - } - - /** - * Utility method to execute a query - * - * @param query - * the query - * @param arguments - * the arguments - * @return the results as string array - */ - @Override - public Object[][] runQuery(final String query, Object... arguments) { - while (!lock.tryLock()) { - // VOID - } - try { - IPreparedStatement stmt = getRuntime().preparedStatement(query); - IResultSet set = runPreparedStatement(stmt, arguments); - return toArray(set); - } finally { - lock.unlock(); - } - } - - /** - * Internal method to send a request to the server and proceed the response results. - * - * @param query - * the query to send - * @return the result of querying as result set - */ - private IResultSet remoteExecute(final String query) { - try { - /* - * build POST message - */ - final String msg = "apikey=" + apiKey + "&query=" + query; - /* - * open streams - */ - URL url = new URL(uri); - URLConnection connection = url.openConnection(); - connection.setDoInput(true); - connection.setDoOutput(true); - /* - * send POST message - */ - OutputStream os = connection.getOutputStream(); - os.write(msg.getBytes(UTF_8)); - os.flush(); - BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream(), UTF_8)); - StringBuilder builder = new StringBuilder(); - String line = r.readLine(); - while (line != null) { - builder.append(line + "\r\n"); - line = r.readLine(); - } - r.close(); - System.out.println(builder.toString()); - /* - * proceed response as extended JTMQR - */ - MaJorToMJSONReader reader = new MaJorToMJSONReader(new ByteArrayInputStream(builder.toString().getBytes("utf-8"))); - reader.read(); - IResultSet set = reader.getResultSet(); - /* - * check incoming state - */ - if (reader.getLastState() != MaJorToMJSONReader.STATE_OK) { - throw new TopicMapsODataException(reader.getLastMessage()); - } - return set; - } catch (IOException e) { - throw new TopicMapsODataException(IOERROR, e); - } - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/AssociationTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/AssociationTypeDAO.java deleted file mode 100644 index a419781..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/AssociationTypeDAO.java +++ /dev/null @@ -1,300 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.util.ArrayList; -import java.util.List; - -import de.topicmapslab.odata.edm.EdmNavigationPropertyIdentifier; -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * DAO containing all information about an association signature - * - * @author Sven Krosse - */ -public class AssociationTypeDAO extends ScopedTypeDAO { - - private TopicTypeDAO leftPlayerTypeDAO; - private TopicTypeDAO leftRoleTypeDAO; - private TopicTypeDAO rightRoleTypeDAO; - private TopicTypeDAO rightPlayerTypeDAO; - - /** - * constructor - */ - public AssociationTypeDAO() { - // VOID - } - - /** - * constructor - * - * @param typeId - * the ID of association type - * @param typeLabel - * the label of type - * @param themeDAOs - * the themes - * @param nonScopedInstance - * flag indicates if there is at least one instance of this DAO without a scope - * @param leftPlayerTypeDAO - * the DAO of left hand player type - * @param leftRoleTypeDAO - * the DAO of left hand role type - * @param rightRoleTypeDAO - * the DAO of right role type - * @param rightPlayerTypeDAO - * the DAO of right player type - */ - public AssociationTypeDAO(String typeId, String typeLabel, List themeDAOs, boolean nonScopedInstance, - TopicTypeDAO leftPlayerTypeDAO, TopicTypeDAO leftRoleTypeDAO, TopicTypeDAO rightRoleTypeDAO, TopicTypeDAO rightPlayerTypeDAO) { - super(typeId, typeLabel, themeDAOs, nonScopedInstance); - this.leftPlayerTypeDAO = leftPlayerTypeDAO; - this.leftRoleTypeDAO = leftRoleTypeDAO; - this.rightRoleTypeDAO = rightRoleTypeDAO; - this.rightPlayerTypeDAO = rightPlayerTypeDAO; - } - - /** - * the DAO of left hand player type - */ - public TopicTypeDAO getLeftPlayerTypeDAO() { - return leftPlayerTypeDAO; - } - - /** - * the DAO of association type - */ - public TopicTypeDAO getLeftRoleTypeDAO() { - return leftRoleTypeDAO; - } - - /** - * the DAO of right player type - */ - public TopicTypeDAO getRightPlayerTypeDAO() { - return rightPlayerTypeDAO; - } - - /** - * the DAO of right role type - */ - public TopicTypeDAO getRightRoleTypeDAO() { - return rightRoleTypeDAO; - } - - /** - * {@inheritDoc} - */ - @Override - public void load(IResult result) throws TopicMapsODataException { - if (result == null || result.size() < 10) { - throw new TopicMapsODataException("The number of arguments is invalid. DAO expects 7 arguments."); - } - - Object leftPlayerTypeDAOId = result.get(0); - Object leftPlayerTypeDAOLabel = result.get(1); - leftPlayerTypeDAO = new TopicTypeDAO(leftPlayerTypeDAOId.toString(), leftPlayerTypeDAOLabel.toString()); - - Object leftRoleTypeDAOId = result.get(2); - Object leftRoleTypeDAOLabel = result.get(3); - leftRoleTypeDAO = new TopicTypeDAO(leftRoleTypeDAOId.toString(), leftRoleTypeDAOLabel.toString()); - - setTypeId(result.get(4).toString()); - setTypeLabel(result.get(5).toString()); - - Object rightRoleTypeDAOId = result.get(6); - Object rightRoleTypeDAOLabel = result.get(7); - rightRoleTypeDAO = new TopicTypeDAO(rightRoleTypeDAOId.toString(), rightRoleTypeDAOLabel.toString()); - - Object rightPlayerTypeDAOId = result.get(8); - Object rightPlayerTypeDAOLabel = result.get(9); - if (rightPlayerTypeDAOId != null) { - rightPlayerTypeDAO = new TopicTypeDAO(rightPlayerTypeDAOId.toString(), rightPlayerTypeDAOLabel.toString()); - } - setThemes(result.get(10), result.get(11)); - hasNonScopedInstance(result.get(12)); - } - - /** - * Returns the list of EDM identifiers for flat relationships representing an entry of this DAO - * - * @return a list of relationship identifiers - */ - public List getFlatRelationshipIdentifier() { - if (getRightPlayerTypeDAO() == null) { - throw new RuntimeException("Counter part is null!"); - } - List list = new ArrayList(); - /* - * has themes? - */ - if (isMultiple()) { - for (TopicTypeDAO themeDAO : getThemeDAOs()) { - /* - * calculate name of property as combination of player type labels and theme label - */ - final String name = getLeftPlayerTypeDAO().getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel() + themeDAO.getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, null, getRightPlayerTypeDAO().getTypeId(), themeDAO.getTypeId())); - } - /* - * add non scoped part - */ - if (hasNonScopedInstance()) { - final String name = getLeftPlayerTypeDAO().getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, null, getRightPlayerTypeDAO().getTypeId(), null)); - } - } - /* - * there are no themes - */ - else { - /* - * calculate name of property as combination of player type labels - */ - final String name = getLeftPlayerTypeDAO().getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, null, getRightPlayerTypeDAO().getTypeId(), null)); - } - return list; - } - - /** - * Returns the list of EDM identifiers for strong relationships representing an entry of this DAO - * - * @return a list of relationship identifiers - */ - public List getStrongRelationshipIdentifier() { - if (getRightPlayerTypeDAO() == null || getRightRoleTypeDAO() == null) { - throw new RuntimeException("Counter part is null!"); - } - List list = new ArrayList(); - /* - * has themes? - */ - if (isMultiple()) { - for (TopicTypeDAO themeDAO : getThemeDAOs()) { - /* - * calculate name of property as combination of association and counter player type labels and theme - * label - */ - final String name = getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel() + themeDAO.getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, getTypeId(), getRightPlayerTypeDAO().getTypeId(), themeDAO.getTypeId())); - } - /* - * add non scoped part - */ - if (hasNonScopedInstance()) { - final String name = getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, getTypeId(), getRightPlayerTypeDAO().getTypeId(), null)); - } - } - /* - * there are no themes - */ - else { - /* - * calculate name of property as combination of association and counter player type labels - */ - final String name = getTypeLabel() + getRightPlayerTypeDAO().getTypeLabel(); - list.add(new EdmNavigationPropertyIdentifier(this, name, getTypeId(), getRightPlayerTypeDAO().getTypeId(), null)); - } - return list; - } - - /** - * Method extracts the association type DAOs form the given result set - * - * @param resultSet - * the result set - * @return the list of DAOs - * @throws TopicMapsODataException - * throws if conversation failed - */ - public static List getAssociationDAOs(IResultSet resultSet) throws TopicMapsODataException { - List daos = new ArrayList(); - for (IResult r : resultSet) { - AssociationTypeDAO dao = new AssociationTypeDAO(); - dao.load(r); - daos.add(dao); - } - return daos; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof AssociationTypeDAO) { - AssociationTypeDAO other = (AssociationTypeDAO) obj; - /* - * same themes and same type - */ - if (!super.equals(other)) { - return false; - } - /* - * left role types are equal - */ - if (getLeftRoleTypeDAO().equals(other.getLeftRoleTypeDAO())) { - /* - * left player type, right role type and right role player type should be equal - */ - boolean r = getLeftPlayerTypeDAO().equals(other.getLeftPlayerTypeDAO()); - r &= getRightRoleTypeDAO().equals(other.getRightRoleTypeDAO()); - r &= getRightPlayerTypeDAO() == null ? other.getRightPlayerTypeDAO() == null : getRightPlayerTypeDAO().equals( - other.getRightPlayerTypeDAO()); - return r; - } - /* - * left role type equals others right role type - */ - else if (getLeftRoleTypeDAO().equals(other.getRightRoleTypeDAO())) { - /* - * left player type = right player type, right role type = left role type and right role player type = - * left role player type - */ - boolean r = getLeftPlayerTypeDAO().equals(other.getRightPlayerTypeDAO()); - r &= getRightRoleTypeDAO().equals(other.getLeftRoleTypeDAO()); - r &= getRightPlayerTypeDAO() == null ? other.getLeftPlayerTypeDAO() == null : getRightPlayerTypeDAO().equals( - other.getLeftPlayerTypeDAO()); - return r; - } - } - return false; - } - - /** - * Return the topic type DAO of the counter player type - * - * @param typeLabel - * the label of the current topic type - * @return the counter type DAO - */ - public TopicTypeDAO getCounterPlayerDAO(final String typeLabel) { - /* - * incoming player type is left player - */ - if (getLeftPlayerTypeDAO().getTypeLabel().equalsIgnoreCase(typeLabel)) { - return getRightPlayerTypeDAO(); - } - /* - * incoming player type is right player - */ - else { - return getLeftPlayerTypeDAO(); - } - } - - @Override - public int hashCode() { - int hash = super.hashCode(); - hash |= getLeftPlayerTypeDAO().hashCode(); - hash |= getLeftRoleTypeDAO().hashCode(); - hash |= getRightRoleTypeDAO().hashCode(); - hash |= getRightPlayerTypeDAO() == null ? 0 : getRightPlayerTypeDAO().hashCode(); - return hash; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CharacteristicsTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CharacteristicsTypeDAO.java deleted file mode 100644 index 5249a6f..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CharacteristicsTypeDAO.java +++ /dev/null @@ -1,127 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.util.ArrayList; -import java.util.List; - -import org.odata4j.edm.EdmType; - -import de.topicmapslab.odata.edm.EdmPropertyIdentifier; - -/** - * DAO containing all information about characteristics. - * - * @author Sven Krosse - */ -public abstract class CharacteristicsTypeDAO extends ScopedTypeDAO { - - /** - * dynamic flag - */ - private boolean isDynamic; - /** - * the datatype - */ - private EdmType datatype = EdmType.STRING; - - /** - * constructor - */ - public CharacteristicsTypeDAO() { - // VOID - } - - /** - * constructor - * - * @param typeId - * the topic type ID - * @param typeLabel - * the topic type label - * @param datatype - * the EDM data type - * @param isDynamic - * flag if this characteristics DAO is dynamic - * @param themeDAOs - * the theme DAOs - * @param nonScopedInstance - * flag indicates if there is at least one instance of this DAO without a scope - */ - public CharacteristicsTypeDAO(String typeId, String typeLabel, EdmType datatype, boolean isDynamic, List themeDAOs, - boolean nonScopedInstance) { - super(typeId, typeLabel, themeDAOs, nonScopedInstance); - this.datatype = datatype; - this.isDynamic = isDynamic; - } - - /** - * Modify the dynamic state. It is only dynamic if at least one instance of an entity type does not have this - * property. - * - * @param isDynamic - * true if it is dynamic. - */ - void setDynamic(boolean isDynamic) { - this.isDynamic = isDynamic; - } - - /** - * Checks if the DAO is dynamic. It is only dynamic if at least one instance of an entity type does not have this - * property. - * - * @return true if it is dynamic, false otherwise. - */ - public boolean isDynamic() { - return isDynamic; - } - - /** - * Returns the data type of this occurrences as EDM type - * - * @return the EDM type - */ - public EdmType getDatatype() { - return datatype; - } - - /** - * Modify the internal datatype variable - * - * @param datatype - * the new datatype - */ - void setDatatype(EdmType datatype) { - this.datatype = datatype; - } - - /** - * Returns the list of corresponding EDM property identifiers created by contained members - * - * @return the list of EDM properties - */ - public List getEdmPropertyIdentifiers() { - List list = new ArrayList(); - /* - * there are scopes - */ - if (isMultiple()) { - for (TopicTypeDAO themeDAO : getThemeDAOs()) { - final String name = getTypeLabel() + themeDAO.getTypeLabel(); - list.add(new EdmPropertyIdentifier(name, getTypeId(), themeDAO.getTypeId())); - } - /* - * has non scoped instance - */ - if (hasNonScopedInstance()) { - list.add(new EdmPropertyIdentifier(getTypeLabel(), getTypeId(), null)); - } - } - /* - * there are no scopes - */ - else { - list.add(new EdmPropertyIdentifier(getTypeLabel(), getTypeId(), null)); - } - return list; - } - -} \ No newline at end of file diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CounterPartDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CounterPartDAO.java deleted file mode 100644 index e651a2a..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/CounterPartDAO.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.util.ArrayList; -import java.util.List; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * DAO containing information about a counter player - * - * @author Sven Krosse - */ -public class CounterPartDAO implements IDAO { - - private String counterPlayerId; - - /** - * constructor - */ - public CounterPartDAO() { - // VOID - } - - /** - * constructor - * - * @param counterPlayerId - * the ID of counter player - */ - public CounterPartDAO(final String counterPlayerId) { - this.counterPlayerId = counterPlayerId; - } - - /** - * {@inheritDoc} - */ - @Override - public void load(IResult result) throws TopicMapsODataException { - if (result == null || result.size() < 1) { - throw new TopicMapsODataException("The number of arguments is invalid. DAO expects 1 arguments."); - } - this.counterPlayerId = result.get(0); - } - - /** - * Returns the id of counter player - * - * @return the ID of counter player - */ - public String getCounterPlayerId() { - return counterPlayerId; - } - - /** - * Method extracts the counter player DAOs form the given result set - * - * @param resultSet - * the result set - * @return the list of DAOs - * @throws TopicMapsODataException - * throws if conversation failed - */ - public static List getDAOs(IResultSet resultSet) throws TopicMapsODataException { - List daos = new ArrayList(); - for (IResult r : resultSet) { - CounterPartDAO dao = new CounterPartDAO(); - dao.load(r); - daos.add(dao); - } - return daos; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/IDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/IDAO.java deleted file mode 100644 index a917726..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/IDAO.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.topicmapslab.odata.dao; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; - -/** - * Interface definition of a DAO - * - * @author Sven Krosse - */ -public interface IDAO { - - /** - * Transforms the given result set to a DAO object - * - * @param result - * the result - */ - public void load(IResult result) throws TopicMapsODataException; - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/NameTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/NameTypeDAO.java deleted file mode 100644 index 2c04b50..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/NameTypeDAO.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.odata4j.edm.EdmType; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * DAO containing all information about a name signature - * - * @author Sven Krosse - */ -public class NameTypeDAO extends CharacteristicsTypeDAO { - - /** - * constructor - */ - public NameTypeDAO() { - // VOID - } - - /** - * constructor - * - * @param typeId - * the topic type ID - * @param typeLabel - * the topic type label - * @param isDynamic - * dynamic property - * @param themeDAOs - * the theme DAOs - * @param nonScopedInstance - * flag indicates if there is at least one instance of this DAO without a scope - */ - public NameTypeDAO(String typeId, String typeLabel, boolean isDynamic, List themeDAOs, boolean nonScopedInstance) { - super(typeId, typeLabel, EdmType.STRING, isDynamic, themeDAOs, nonScopedInstance); - } - - /** - * {@inheritDoc} - */ - @Override - public void load(IResult result) throws TopicMapsODataException { - super.load(result); - if (result == null || result.size() < 7) { - throw new TopicMapsODataException("The number of arguments is invalid. DAO expects 7 arguments but was " + result.size() + "."); - } - BigInteger minOcc = result.get(2); - setDynamic(minOcc.longValue() == 0); - setThemes(result.get(4), result.get(5)); - hasNonScopedInstance(result.get(6)); - } - - /** - * Method extracts the name type DAOs form the given result set - * - * @param resultSet - * the result set - * @return the list of DAOs - * @throws TopicMapsODataException - * throws if conversation failed - */ - public static List getNameTypeDAOs(IResultSet resultSet) throws TopicMapsODataException { - List daos = new ArrayList(); - for (IResult r : resultSet) { - NameTypeDAO dao = new NameTypeDAO(); - dao.load(r); - daos.add(dao); - } - return daos; - } - -} \ No newline at end of file diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/OccurrenceTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/OccurrenceTypeDAO.java deleted file mode 100644 index d5ddf92..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/OccurrenceTypeDAO.java +++ /dev/null @@ -1,85 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.odata4j.edm.EdmType; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.odata.util.EdmUtils; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * DAO containing all information about an occurrence signature - * - * @author Sven Krosse - */ -public class OccurrenceTypeDAO extends CharacteristicsTypeDAO { - /** - * constructor - */ - public OccurrenceTypeDAO() { - // VOID - } - - /** - * constructor - * - * @param typeId - * the topic type ID - * @param typeLabel - * the topic type label - * @param datatype - * the data type - * @param isDynamic - * the dynamic flag - * @param maxOcc - * maximum occurrence - * @param themeDAOs - * the theme DAOs - * @param nonScopedInstance - * flag indicates if there is at least one instance of this DAO without a scope - */ - public OccurrenceTypeDAO(String typeId, String typeLabel, EdmType datatype, boolean isDynamic, List themeDAOs, - boolean nonScopedInstance) { - super(typeId, typeLabel, datatype, isDynamic, themeDAOs, nonScopedInstance); - } - - /** - * {@inheritDoc} - */ - @Override - public void load(IResult result) throws TopicMapsODataException { - super.load(result); - if (result == null || result.size() < 8) { - throw new TopicMapsODataException("The number of arguments is invalid. DAO expects 8 arguments but was " + result.size() + "."); - } - setDatatype(EdmUtils.xsdToEdm(result.get(2).toString())); - BigInteger minOcc = result.get(3); - setDynamic(minOcc.longValue() == 0); - setThemes(result.get(5), result.get(6)); - hasNonScopedInstance(result.get(7)); - } - - /** - * Method extracts the occurrence type DAOs form the given result set - * - * @param resultSet - * the result set - * @return the list of DAOs - * @throws TopicMapsODataException - * throws if conversation failed - */ - public static List getOccurrenceTypeDAOs(IResultSet resultSet) throws TopicMapsODataException { - System.out.println(resultSet); - List daos = new ArrayList(); - for (IResult r : resultSet) { - OccurrenceTypeDAO dao = new OccurrenceTypeDAO(); - dao.load(r); - daos.add(dao); - } - return daos; - } -} \ No newline at end of file diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/ScopedTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/ScopedTypeDAO.java deleted file mode 100644 index 9503a7d..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/ScopedTypeDAO.java +++ /dev/null @@ -1,113 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * DAO containing all information about a scoped construct - * - * @author Sven Krosse - */ -public abstract class ScopedTypeDAO extends TopicTypeDAO { - - private List themeDAOs; - private boolean nonScopedInstance; - - /** - * constructor - */ - public ScopedTypeDAO() { - // VOID - } - - /** - * constructor - * - * @param typeId - * the topic type ID - * @param typeLabel - * the topic type label - * @param themeDAOs - * the theme DAOs - * @param nonScopedInstance - * flag indicates if there is at least one instance of this DAO without a scope - */ - public ScopedTypeDAO(String typeId, String typeLabel, List themeDAOs, boolean nonScopedInstance) { - super(typeId, typeLabel); - this.themeDAOs = themeDAOs; - this.nonScopedInstance = nonScopedInstance; - } - - /** - * Internal method to extract theme DAO from given content - * - * @param themes - * the themes - * @param themeIds - * the theme IDs - */ - void setThemes(Object themes, Object themeIds) { - if (themes instanceof List) { - List themeList = (List) themes; - List themeIdList = (List) themeIds; - this.themeDAOs = new ArrayList(); - for (int i = 0; i < themeList.size(); i++) { - this.themeDAOs.add(new TopicTypeDAO(themeIdList.get(i).toString(), themeList.get(i).toString())); - } - } - } - - /** - * Returns the theme DAOs - * - * @return the DAOs - */ - public List getThemeDAOs() { - if (themeDAOs == null) { - return Collections.emptyList(); - } - return themeDAOs; - } - - /** - * Check if the DAO has themes, which results in multiple properties - * - * @return true if themes are present, false otherwise - */ - public boolean isMultiple() { - return themeDAOs != null && themeDAOs.size() > 1; - } - - /** - * Checks if there is an instance of this DAO, which has no scope - * - * @return true if at least one instance has no scope, false otherwise - */ - public boolean hasNonScopedInstance() { - return nonScopedInstance; - } - - /** - * Setter of internal flag, indicates if there is at least one instance without the scope - * - * @param nonScopedInstance - * true if there is at least one instance without the scope otherwise false - */ - void hasNonScopedInstance(boolean nonScopedInstance) { - this.nonScopedInstance = nonScopedInstance; - } - - /** - * Setter of internal flag, indicates if there is at least one instance without the scope - * - * @param nonScopedInstance - * the result part containing the information about the minimum number of themes - */ - void hasNonScopedInstance(Object nonScopedInstance) { - if (nonScopedInstance instanceof List) { - final String first = ((List) nonScopedInstance).get(0).toString(); - this.nonScopedInstance = "0".equalsIgnoreCase(first); - } - } -} \ No newline at end of file diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/TopicTypeDAO.java b/tm2o-core/src/main/java/de/topicmapslab/odata/dao/TopicTypeDAO.java deleted file mode 100644 index fe47ef5..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/dao/TopicTypeDAO.java +++ /dev/null @@ -1,178 +0,0 @@ -package de.topicmapslab.odata.dao; - -import java.util.ArrayList; -import java.util.List; - -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; - -/** - * a simple data object containing all information of the - * - * @author Sven Krosse - */ -public class TopicTypeDAO implements IDAO { - - private String typeId; - private String typeLabel; - - /** - * constructor - * - * @param typeId - * the topic type ID - * @param typeLabel - * the topic type label - */ - public TopicTypeDAO(String typeId, String typeLabel) { - this.typeId = typeId; - this.typeLabel = cleanPropertyKey(typeLabel); - } - - /** - * constructor - */ - public TopicTypeDAO() { - // VOID - } - - /** - * {@inheritDoc} - */ - @Override - public void load(IResult result) throws TopicMapsODataException { - if (result == null || result.size() < 2) { - throw new TopicMapsODataException("The number of arguments is invalid. DAO expects 2 arguments"); - } - this.typeId = result.get(0); - this.typeLabel = cleanPropertyKey(result.get(1)); - } - - /** - * Returns the internal ID - * - * @return the id - */ - public String getTypeId() { - return typeId; - } - - void setTypeId(String typeId) { - this.typeId = typeId; - } - - /** - * Returns the internal label - * - * @return the label - */ - public String getTypeLabel() { - return typeLabel; - } - - void setTypeLabel(String typeLabel) { - this.typeLabel = typeLabel; - } - - /** - * Method extracts the topic type DAOs form the given result set - * - * @param resultSet - * the result set - * @return the list of DAOs - * @throws TopicMapsODataException - * throws if conversation failed - */ - public static List getDAOs(IResultSet resultSet) throws TopicMapsODataException { - List daos = new ArrayList(); - for (IResult r : resultSet) { - TopicTypeDAO dao = new TopicTypeDAO(); - dao.load(r); - daos.add(dao); - } - return daos; - } - - /** - * utility method to clean to key from white spaces and anything else - * - * @param key - * the key - * @return the cleaned key - */ - public static String cleanPropertyKey(Object key) { - if (key == null) { - return null; - } - String key_ = key.toString(); - /* - * contains slash - */ - if (key_.contains("/")) { - key_ = key_.substring(key_.lastIndexOf("/") + 1); - } - /* - * contains colon - */ - if (key_.contains(":")) { - key_ = key_.substring(key_.lastIndexOf(":") + 1); - } - /* - * contains hash - */ - if (key_.contains("#")) { - key_ = key_.substring(key_.lastIndexOf("#") + 1); - } - /* - * clean white space - */ - StringBuffer buffer = new StringBuffer(); - boolean nextUp = true; - for (int i = 0; i < key_.length(); i++) { - char c = key_.charAt(i); - /* - * is white space - */ - if (c == ' ' || c == '-') { - nextUp = true; - } - /* - * character must be upper case - */ - else if (nextUp) { - nextUp = false; - String up = c + ""; - buffer.append(up.toUpperCase()); - } - /* - * normal add character - */ - else { - buffer.append(c); - } - } - - return buffer.toString(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof TopicTypeDAO) { - if (typeId == null) { - return ((TopicTypeDAO) obj).typeId == null; - } - return ((TopicTypeDAO) obj).typeId.equalsIgnoreCase(typeId); - } - return false; - } - - @Override - public int hashCode() { - return typeId == null ? 0 : typeId.hashCode(); - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmIdentifier.java b/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmIdentifier.java deleted file mode 100644 index 2ac0099..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmIdentifier.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.topicmapslab.odata.edm; - -/** - * Abstract base implementation of an {@link IEdmNavigationPropertyIdentifier} - * - * @author Sven Krosse - */ -public abstract class EdmIdentifier implements IEdmPropertyIdentifier { - - private String themeId; - private String name; - - /** - * Constructor - * - * @param name - * the property name - * @param themeId - * the ID of theme - */ - public EdmIdentifier(String name, String themeId) { - this.name = name; - this.themeId = themeId; - } - - /** - * Returns the theme ID - * - * @return the theme ID - */ - public String getThemeId() { - return themeId; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPropertyName() { - return name; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof EdmIdentifier) { - EdmIdentifier other = (EdmIdentifier) obj; - boolean r = (themeId == null) ? other.themeId == null : other.themeId == themeId; - r &= name.equalsIgnoreCase(other.name); - return r; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hash = themeId == null ? 0 : themeId.hashCode(); - hash |= name.hashCode(); - return hash; - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmNavigationPropertyIdentifier.java b/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmNavigationPropertyIdentifier.java deleted file mode 100644 index 481a11c..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmNavigationPropertyIdentifier.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.topicmapslab.odata.edm; - -import de.topicmapslab.odata.dao.AssociationTypeDAO; - -/** - * Identifier of an EDM navigation property - * - * @author Sven Krosse - */ -public class EdmNavigationPropertyIdentifier extends EdmIdentifier implements IEdmNavigationPropertyIdentifier { - - private String associationTypeId; - private String counterPlayerTypeId; - private AssociationTypeDAO dao; - - /** - * constructor - * - * @param dao - * the DAO containing the information - * @param name - * the name of the navigation property - * @param associationTypeId - * the id of association type - * @param counterPlayerTypeId - * the id of counter player type - * @param themeId - * the id of the theme or null - */ - public EdmNavigationPropertyIdentifier(final AssociationTypeDAO dao, final String name, final String associationTypeId, - final String counterPlayerTypeId, final String themeId) { - super(name, themeId); - this.associationTypeId = associationTypeId; - this.dao = dao; - this.counterPlayerTypeId = counterPlayerTypeId; - } - - /** - * Returns the id of the counter player type - * - * @return the id - */ - public String getCounterPlayerTypeId() { - return counterPlayerTypeId; - } - - /** - * {@inheritDoc} - */ - @Override - public AssociationTypeDAO getDAO() { - return dao; - } - - /** - * Returns the id of the association type - * - * @return the id - */ - public String getAssociationTypeId() { - return associationTypeId; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof EdmNavigationPropertyIdentifier) { - EdmNavigationPropertyIdentifier other = (EdmNavigationPropertyIdentifier) obj; - boolean r = (getThemeId() == null) ? other.getThemeId() == null : getThemeId().equalsIgnoreCase(other.getThemeId()); - r &= dao.equals(((EdmNavigationPropertyIdentifier) obj).dao); - return r; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hash = super.hashCode(); - hash |= dao.hashCode(); - return hash; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmPropertyIdentifier.java b/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmPropertyIdentifier.java deleted file mode 100644 index 4c0d9ec..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/EdmPropertyIdentifier.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.topicmapslab.odata.edm; - -/** - * Bean class storing the information of EDM property - * - * @author Sven Krosse - */ -public class EdmPropertyIdentifier extends EdmIdentifier { - - private String typeId; - - /** - * Constructor - * - * @param name - * the property name - * @param typeId - * the ID of characteristics type - * @param themeId - * the ID of theme - */ - public EdmPropertyIdentifier(final String name, String typeId, String themeId) { - super(name, themeId); - this.typeId = typeId; - } - - /** - * Returns the ID of type - * - * @return the type - */ - public String getTypeId() { - return typeId; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof EdmPropertyIdentifier) { - EdmPropertyIdentifier other = (EdmPropertyIdentifier) obj; - boolean r = other.typeId == typeId; - r &= super.equals(obj); - return r; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hash = super.hashCode(); - hash |= typeId.hashCode(); - return hash; - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmNavigationPropertyIdentifier.java b/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmNavigationPropertyIdentifier.java deleted file mode 100644 index ce2905b..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmNavigationPropertyIdentifier.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.topicmapslab.odata.edm; - -import de.topicmapslab.odata.dao.AssociationTypeDAO; - -/** - * Interface definition of an identifier of an EDM navigation property - * - * @author Sven Krosse - */ -public interface IEdmNavigationPropertyIdentifier { - - /** - * Returns the corresponding DAO. - * - * @return the DAO - */ - public AssociationTypeDAO getDAO(); - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmPropertyIdentifier.java b/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmPropertyIdentifier.java deleted file mode 100644 index 2a339f4..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/edm/IEdmPropertyIdentifier.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.topicmapslab.odata.edm; - -/** - * Base implementation of an identifier of an EDM property - * - * @author Sven Krosse - */ -public interface IEdmPropertyIdentifier { - - /** - * Returns the theme ID - * - * @return the theme ID - */ - public String getThemeId(); - - /** - * Returns the property name of OData - * - * @return the name - */ - public String getPropertyName(); - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/exception/TopicMapsODataException.java b/tm2o-core/src/main/java/de/topicmapslab/odata/exception/TopicMapsODataException.java deleted file mode 100644 index c1db38a..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/exception/TopicMapsODataException.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.topicmapslab.odata.exception; - -/** - * base exception thrown by the library - * - * @author Sven Krosse - * - */ -public class TopicMapsODataException extends RuntimeException { - - private static final long serialVersionUID = -7780777507871926259L; - - /** - * constructor - */ - public TopicMapsODataException() { - } - - /** - * constructor - * - * @param message - * the message - */ - public TopicMapsODataException(String message) { - super(message); - } - - /** - * constructor - * - * @param cause - * the cause - */ - public TopicMapsODataException(Throwable cause) { - super(cause); - } - - /** - * constructor - * - * @param message - * the message - * @param cause - * the cause - */ - public TopicMapsODataException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/ITmqlQueries.java b/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/ITmqlQueries.java deleted file mode 100644 index 4364bf0..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/ITmqlQueries.java +++ /dev/null @@ -1,188 +0,0 @@ -package de.topicmapslab.odata.tmql; - -/** - * Interface containing all pre-defined queries - * - * @author Sven Krosse - */ -public interface ITmqlQueries { - - /** - * description: Getting all topic types.
- * parameters: -
- * result:
- *
    - *
  • id of topic type
  • - *
  • best label of the topic type
  • - *
- *
- */ - public static final String TOPICTYPES = "FOR $tt IN fn:get-topic-types ( ) RETURN $tt >> id , fn:best-label( $tt )"; - - /** - * description: Getting all name types of a specific topic type.
- * parameters: the id of topic type
- * result:
- *
    - *
  • id of name type
  • - *
  • best label of the name type
  • - *
  • minimum number of occurrence
  • - *
  • maximum number of occurrence
  • - *
  • a list of theme best label
  • - *
  • a list of theme IDs
  • - *
  • smallest number of themes
  • - *
- *
- * - */ - public static final String NAMETYPES = "FOR $t IN ? << id" - + " GROUP BY $0, $1, $2, $3 " - + " UNIQUE " - + " RETURN {" - + " FOR $nt IN fn:get-name-types ( $t ) " - + " RETURN $nt >> id , fn:best-label( $nt ), " - + " fn:min ( $t >> instances , fn:count ( . >> characteristics $nt ))," - + " fn:max ( $t >> instances , fn:count ( . >> characteristics $nt )), " - + " fn:best-label ( fn:uniq ( $t >> instances >> characteristics $nt >> scope )), fn:uniq ( $t >> instances >> characteristics $nt >> scope >> id )," - + " fn:min ( $t >> instances >> characteristics $nt , fn:count ( . >> scope))}"; - - /** - * description: Getting all occurrence types of a specific topic type.
- * parameters: the id of topic type
- * result:
- *
    - *
  • id of occurrence type
  • - *
  • best label of the occurrence type
  • - *
  • the data types
  • - *
  • minimum number of occurrence
  • - *
  • maximum number of occurrence
  • - *
  • a list of theme best label
  • - *
  • a list of theme IDs
  • - *
  • smallest number of themes
  • - *
- *
- */ - public static final String OCCURRENCETYPES = "FOR $t IN ? << id" - + " GROUP BY $0, $1, $2, $3, $4 " - + " UNIQUE " - + " RETURN {" - + " FOR $ot IN fn:get-occurrence-types ( $t )" - + " RETURN $ot >> id , fn:best-label( $ot ), " - + " fn:uniq ( fn:has-datatype ( $ot >> typed )), " - + " fn:min ( $t >> instances , fn:count ( . >> characteristics $ot ))," - + " fn:max ( $t >> instances , fn:count ( . >> characteristics $ot )) , " - + " fn:best-label ( fn:uniq ( $t >> instances >> characteristics $ot >> scope )), fn:uniq ( $t >> instances >> characteristics $ot >> scope >> id ), " - + " fn:min ( $t >> instances >> characteristics $ot , fn:count ( . >> scope))}"; - - /** - * description: Getting all association signatures.
- * parameters: -
- * result:
- *
    - *
  • the id of left player type
  • - *
  • the best label of left player type
  • - *
  • the id of left role type
  • - *
  • the best label of left role type
  • - *
  • the id of association type
  • - *
  • the best label of association type
  • - *
  • the id of right role type
  • - *
  • the best label of right role type
  • - *
  • the id of right player type
  • - *
  • the best label of right player type
  • - *
  • a list of best labels of all themes
  • - *
  • a list of IDs of all themes
  • - *
  • the smallest number of themes
  • - *
- *
- */ - public static final String ASSOCIATION_SIGNATURES = "For $tt IN fn:get-topic-types ( )" - + " UNIQUE" - + " GROUP BY $0, $1, $2, $3, $4, $5, $6, $7, $8, $9 " - + " RETURN {" - + " FOR $o IN $tt >> instances << players" - + " RETURN {" - + " FOR $rt IN fn:uniq ( $o >> types ) MINUS { http://psi.topicmaps.org/iso13250/model/instance UNION http://psi.topicmaps.org/iso13250/model/type } " - + " RETURN {" - + " FOR $a IN $o << roles [ fn:count ( . >> roles ) == 2 OR fn:count( . >> roletypes ) == 2 ] " - + " RETURN {" - + " FOR $or IN $a >> roles [ fn:count( $a >> roles ) == 2 OR . >> types != $rt ]" - + " RETURN { FOR $oor IN $or MINUS $o " - + " RETURN $tt >> id , fn:best-label( $tt ) , $rt >> id , fn:best-label( $rt) , " - + " $a >> types >> id , fn:best-label( $a >> types )," - + " $or >> types >> id , fn:best-label($or >> types), " - + " $or >> players >> types [0] >> id , fn:best-label ($or >> players >> types [0]) , fn:best-label( $a >> types >> typed >> scope ) , $a >> types >> typed >> scope >> id, fn:min ( $a >> types >> typed , fn:count ( . >> scope ))" - + " } } } } }"; - /** - * description: Getting all association signatures of a specific topic type.
- * parameters: the id of topic type
- * result:
- *
    - *
  • the id of left player type
  • - *
  • the best label of left player type
  • - *
  • the id of left role type
  • - *
  • the best label of left role type
  • - *
  • the id of association type
  • - *
  • the best label of association type
  • - *
  • the id of right role type
  • - *
  • the best label of right role type
  • - *
  • the id of right player type
  • - *
  • the best label of right player type
  • - *
  • a list of best labels of all themes
  • - *
  • a list of IDs of all themes
  • - *
  • the smallest number of themes
  • - *
- *
- */ - public static final String ASSOCIATIONS = "FOR $t IN ? << id" - + " GROUP BY $0,$1,$2" - + " RETURN {" - + " FOR $r IN $t << players [ . >> types MINUS { http://psi.topicmaps.org/iso13250/model/instance UNION http://psi.topicmaps.org/iso13250/model/type } ]" - + " RETURN {" - + " FOR $a IN $r << roles [ fn:count( . >> roles ) == 2 OR fn:count( . >> roles >> types ) > 1 ]" - + " RETURN {" - + " FOR $or IN $a >> roles [ fn:count( . << roles >> roles ) == 2 OR . >> types MINUS $r >> types ]" - + " RETURN {" - + " FOR $oor IN $or MINUS $r" - + " RETURN $t >> id ," - + " fn:best-label( $r >> types ) , $r >> types >> id , fn:best-label( $r >> types ), " - + " $a >> types >> id, fn:best-label( $a >> types ) ," - + "$or >> types >> id , fn:best-label( $or >> types ), " - + " $or >> players >> id, " - + " fn:best-label ( $or >> players ), fn:best-label( $a >> types >> typed >> scope ) , $a >> types >> typed >> scope >> id, fn:min ( $a >> types >> typed , fn:count ( . >> scope ))" - + " } } } }"; - - /** - * description: Getting all counter players of a topic with recognition of the association type and counter - * player type.
- * parameters: the id of topic type, the id of association type, the id of counter player type
- * result: the id of the counter player
- */ - public static final String COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE = "FOR $t IN ? << id " + " FOR $at IN ? << id" + " FOR $ot IN ? << id" - + " RETURN fn:uniq ( $t << players << roles $at [ fn:count ( . >> scope ) == 0 ] >> roles >> players $ot >> id MINUS $t >> id )"; - - /** - * description: Getting all counter players of a topic with recognition of the association type, a theme and - * counter player type.
- * parameters: the id of topic type, the id of association type, the id of counter player type, the theme id
- * result: the id of the counter player
- */ - public static final String COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE_AND_SCOPE = "FOR $t IN ? << id " + " FOR $at IN ? << id" - + " FOR $ot IN ? << id FOR $theme IN ? << id " - + " RETURN fn:uniq ( $t << players << roles $at [ . >> scope == $theme ] >> roles >> players $ot >> id MINUS $t >> id )"; - - /** - * description: Getting all counter players of a topic with recognition of a theme and counter player type.
- * parameters: the id of topic type, the id of counter player type, the theme id
- * result: the id of the counter player
- */ - public static final String COUNTER_PLAYERS_WITH_SCOPE = "FOR $t IN ? << id " + " FOR $ot IN ? << id FOR $theme IN ? << id " - + " RETURN fn:uniq ( $t << players << roles [ . >> scope == $theme ] >> roles >> players $ot >> id MINUS $t >> id )"; - - /** - * description: Getting all counter players of a topic with recognition of the counter player type.
- * parameters: the id of topic type, the id of counter player type
- * result: the id of the counter player
- */ - public static final String COUNTER_PLAYERS = "FOR $t IN ? << id " + " FOR $ot IN ? << id" - + " RETURN fn:uniq ( $t << players << roles [ fn:count ( . >> scope ) == 0 ] >> roles >> players $ot >> id MINUS $t >> id )"; -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlHelper.java b/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlHelper.java deleted file mode 100644 index a35eff7..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlHelper.java +++ /dev/null @@ -1,449 +0,0 @@ -package de.topicmapslab.odata.tmql; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import de.topicmapslab.odata.dao.AssociationTypeDAO; -import de.topicmapslab.odata.dao.CounterPartDAO; -import de.topicmapslab.odata.dao.NameTypeDAO; -import de.topicmapslab.odata.dao.OccurrenceTypeDAO; -import de.topicmapslab.odata.dao.TopicTypeDAO; -import de.topicmapslab.tmql4j.components.processor.prepared.IPreparedStatement; -import de.topicmapslab.tmql4j.components.processor.results.model.IResult; -import de.topicmapslab.tmql4j.components.processor.results.model.IResultSet; -import de.topicmapslab.tmql4j.components.processor.runtime.ITMQLRuntime; -import de.topicmapslab.tmql4j.components.processor.runtime.TMQLRuntimeFactory; -import de.topicmapslab.tmql4j.path.components.processor.runtime.TmqlRuntime2007; - -/** - * Abstract TMQL helper - * - * @author Sven Krosse - */ -public abstract class TmqlHelper { - - /** - * the locker - */ - protected static final Lock lock = new ReentrantLock(true); - /** - * the TMQL runtime - */ - private final ITMQLRuntime runtime = TMQLRuntimeFactory.newFactory().newRuntime(TmqlRuntime2007.TMQL_2007); - - /** - * the prepared statement for {@link ITmqlQueries#TOPICTYPES} - */ - private IPreparedStatement stmtTopicTypes; - /** - * the prepared statement for {@link ITmqlQueries#NAMETYPES} - */ - private IPreparedStatement stmtNameTypes; - /** - * the prepared statement for {@link ITmqlQueries#OCCURRENCETYPES} - */ - private IPreparedStatement stmtOccurrenceTypes; - /** - * the prepared statement for {@link ITmqlQueries#ASSOCIATIONS} - */ - private IPreparedStatement stmtAssociations; - /** - * the prepared statement for {@link ITmqlQueries#ASSOCIATION_SIGNATURES} - */ - private IPreparedStatement stmtAssociationSignatures; - /** - * the prepared statement for {@link ITmqlQueries#COUNTER_PLAYERS} - */ - private IPreparedStatement stmtCounterPlayers; - /** - * the prepared statement for {@link ITmqlQueries#COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE} - */ - private IPreparedStatement stmtCounterPlayersWithType; - /** - * the prepared statement for {@link ITmqlQueries#COUNTER_PLAYERS_WITH_SCOPE} - */ - private IPreparedStatement stmtCounterPlayersWithScope; - /** - * the prepared statement for {@link ITmqlQueries#COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE_AND_SCOPE} - */ - private IPreparedStatement stmtCounterPlayersWithTypeAndScope; - /** - * a map of all stored prepared statements to access information of a entity - */ - private Map instanceStatements; - /** - * a map of all stored prepared statements to access information of a whole entity type - */ - private Map typeStatements; - - /** - * Get all topic types. - * - * @return the results as list of DAO - */ - public List getTopicTypes() { - while (!lock.tryLock()) { - // VOID - } - try { - /* - * lazy load - */ - if (stmtTopicTypes == null) { - stmtTopicTypes = runtime.preparedStatement(ITmqlQueries.TOPICTYPES); - } - /* - * execute statement - */ - IResultSet set = runPreparedStatement(stmtTopicTypes); - return TopicTypeDAO.getDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Get all names types. - * - * @param typeId - * the typeId - * @return the results as list of DAO - */ - public List getNameTypes(final String typeId) { - while (!lock.tryLock()) { - // VOID - } - try { - /* - * lazy load - */ - if (stmtNameTypes == null) { - stmtNameTypes = runtime.preparedStatement(ITmqlQueries.NAMETYPES); - } - /* - * execute statement - */ - IResultSet set = runPreparedStatement(stmtNameTypes, typeId); - return NameTypeDAO.getNameTypeDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Get all occurrence types. - * - * @param typeId - * the typeId - * @return the results as list of DAO - */ - public List getOccurrenceTypes(final String typeId) { - while (!lock.tryLock()) { - // VOID - } - try { - /* - * lazy load - */ - if (stmtOccurrenceTypes == null) { - stmtOccurrenceTypes = runtime.preparedStatement(ITmqlQueries.OCCURRENCETYPES); - } - /* - * execute - */ - IResultSet set = runPreparedStatement(stmtOccurrenceTypes, typeId); - return OccurrenceTypeDAO.getOccurrenceTypeDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Get all association signatures of the given entity - * - * @param entityId - * the entity - * @return a list of association signatures represented by their DAO. - */ - public List getAssociationSignaturesOfEntityByTmql(final String entityId) { - while (!lock.tryLock()) { - // VOID - } - try { - /* - * lazy load - */ - if (stmtAssociations == null) { - stmtAssociations = runtime.preparedStatement(ITmqlQueries.ASSOCIATIONS); - } - /* - * execute - */ - IResultSet set = runPreparedStatement(stmtAssociations, entityId); - return AssociationTypeDAO.getAssociationDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Get all association signatures. - * - * @return the results as list of DAO - */ - public List getAssociationSignatures() { - while (!lock.tryLock()) { - // VOID - } - try { - /* - * lazy load - */ - if (stmtAssociationSignatures == null) { - stmtAssociationSignatures = runtime.preparedStatement(ITmqlQueries.ASSOCIATION_SIGNATURES); - } - /* - * execute - */ - IResultSet set = runPreparedStatement(stmtAssociationSignatures); - return AssociationTypeDAO.getAssociationDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Utility method to convert the results to string array - * - * @param resultSet - * the results set - * @return the string array - */ - protected synchronized Object[][] toArray(IResultSet resultSet) { - Object results[][] = new Object[resultSet.size()][]; - int i = 0; - for (IResult r : resultSet) { - Object[] data = new Object[r.size()]; - int j = 0; - for (Object o : r) { - data[j++] = o; - } - results[i++] = data; - } - return results; - } - - /** - * Register a new TMQL query as prepared statement for the given type id. The query is designed to get all - * properties of an instance. - * - * @param typeId - * the id of type - * @param query - * the query - */ - public void registerInstancePreparedStatement(final String typeId, final String query) { - while (!lock.tryLock()) { - // VOID - } - try { - if (instanceStatements == null) { - instanceStatements = new HashMap(); - } - instanceStatements.put(typeId, runtime.preparedStatement(query)); - } finally { - lock.unlock(); - } - } - - /** - * Register a new TMQL query as prepared statement for the given type id. The query is designed to get all - * properties of all instances - * - * @param typeId - * the id of type - * @param query - * the query - */ - public void registerTypePreparedStatement(final String typeId, final String query) { - while (!lock.tryLock()) { - // VOID - } - try { - if (typeStatements == null) { - typeStatements = new HashMap(); - } - typeStatements.put(typeId, runtime.preparedStatement(query)); - } finally { - lock.unlock(); - } - } - - /** - * Returns all properties of all instances of the given type id - * - * @param typeId - * the type id - * @return an array containing all property values - */ - public Object[][] getProperties(final String typeId) { - while (!lock.tryLock()) { - // VOID - } - try { - if (typeStatements == null || !typeStatements.containsKey(typeId)) { - throw new RuntimeException("Missing prepared statement for given type id!"); - } - IPreparedStatement stmt = typeStatements.get(typeId); - IResultSet set = runPreparedStatement(stmt, typeId); - return toArray(set); - } finally { - lock.unlock(); - } - } - - /** - * Returns all properties of the topic identified by the given id - * - * @param typeId - * the type id - * @param entityId - * the entity id - * @return an array containing all property values - */ - public Object[][] getProperties(final String typeId, final String entityId) { - while (!lock.tryLock()) { - // VOID - } - try { - if (instanceStatements == null || !instanceStatements.containsKey(typeId)) { - throw new RuntimeException("Missing prepared statement for given type id!"); - } - IPreparedStatement stmt = instanceStatements.get(typeId); - IResultSet set = runPreparedStatement(stmt, entityId); - return toArray(set); - } finally { - lock.unlock(); - } - } - - /** - * Utility method to execute a prepared statement - * - * @param stmt - * the statement - * @param arguments - * the arguments - * @return the results set - */ - protected abstract IResultSet runPreparedStatement(final IPreparedStatement stmt, Object... arguments); - - /** - * Utility method to execute a query - * - * @param query - * the query - * @param arguments - * the arguments - * @return the results as string array - */ - public abstract Object[][] runQuery(final String query, Object... arguments); - - /** - * Fetch all counter players of the given entity. If the association type is given, it is used to filter out counter - * players of associations with this type. If the theme id is given, it is used to filter out all associations with - * the given theme in scope. If the theme is missed, only associations without any scope are recognized. If the - * counter player type is given, only topics with this type are recognized as counter player. - * - * @param entityId - * the id of entity - * @param associationTypeId - * the id of association type - * @param counterTypeId - * the id of counter player type - * @param themeId - * the id of theme - * @return a list of counter player DAOs - */ - public List getCounterPlayers(String entityId, String associationTypeId, String counterTypeId, final String themeId) { - while (!lock.tryLock()) { - // VOID - } - try { - Object[] arguments; - IPreparedStatement stmt; - - if (associationTypeId == null) { - /* - * without theme - */ - if (themeId == null) { - /* - * lazy load - */ - if (stmtCounterPlayers == null) { - stmtCounterPlayers = runtime.preparedStatement(ITmqlQueries.COUNTER_PLAYERS); - } - arguments = new Object[] { entityId, counterTypeId }; - stmt = stmtCounterPlayers; - } - /* - * with theme - */ - else { - /* - * lazy load - */ - if (stmtCounterPlayersWithScope == null) { - stmtCounterPlayersWithScope = runtime.preparedStatement(ITmqlQueries.COUNTER_PLAYERS_WITH_SCOPE); - } - arguments = new Object[] { entityId, counterTypeId, themeId }; - stmt = stmtCounterPlayersWithScope; - } - } else { - /* - * without theme - */ - if (themeId == null) { - /* - * lazy load - */ - if (stmtCounterPlayersWithType == null) { - stmtCounterPlayersWithType = runtime.preparedStatement(ITmqlQueries.COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE); - } - arguments = new Object[] { entityId, associationTypeId, counterTypeId }; - stmt = stmtCounterPlayersWithType; - } - /* - * with theme - */ - else { - /* - * lazy load - */ - if (stmtCounterPlayersWithTypeAndScope == null) { - stmtCounterPlayersWithTypeAndScope = runtime.preparedStatement(ITmqlQueries.COUNTER_PLAYERS_WITH_ASSOCIATIONTYPE_AND_SCOPE); - } - arguments = new Object[] { entityId, associationTypeId, counterTypeId, themeId }; - stmt = stmtCounterPlayersWithTypeAndScope; - } - } - IResultSet set = runPreparedStatement(stmt, arguments); - return CounterPartDAO.getDAOs(set); - } finally { - lock.unlock(); - } - } - - /** - * Returns the internal runtime - * - * @return the runtime - */ - protected ITMQLRuntime getRuntime() { - return runtime; - } -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlQueryBuilder.java b/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlQueryBuilder.java deleted file mode 100644 index b23bfec..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/tmql/TmqlQueryBuilder.java +++ /dev/null @@ -1,256 +0,0 @@ -package de.topicmapslab.odata.tmql; - -import java.util.Map; - -import de.topicmapslab.majortom.util.HashUtil; -import de.topicmapslab.odata.edm.EdmPropertyIdentifier; -import de.topicmapslab.odata.edm.IEdmPropertyIdentifier; -import de.topicmapslab.odata.util.ODataUtils; -import de.topicmapslab.tmql4j.grammar.lexical.Wildcard; -import de.topicmapslab.tmql4j.hibernate.builder.FlwrQueryBuilder; -import de.topicmapslab.tmql4j.hibernate.criterion.ICriterion; -import de.topicmapslab.tmql4j.hibernate.exception.InvalidModelException; -import de.topicmapslab.tmql4j.hibernate.path.Navigation; -import de.topicmapslab.tmql4j.hibernate.path.Step; -import de.topicmapslab.tmql4j.hibernate.path.filter.IndexFilter; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisAtomify; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisCharacteristics; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisId; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisInstances; - -/** - * Utility class to build TMQL queries - * - * @author Sven Krosse - */ -public class TmqlQueryBuilder { - - /** - * The variable prefix for characteristic types - */ - private static final String VARIABLE = "$ct"; - - /** - * The topic variable - */ - public static final String TOPIC = "$t"; - - /** - * Internal FLWR query builder for one instance - */ - private FlwrQueryBuilder qbInstance; - /** - * Internal FLWR query builder for all instances of the type - */ - private FlwrQueryBuilder qbInstances; - /** - * current number of arguments - */ - private int numberOfArgs = 0; - // /** - // * Map of variables of a selected characteristic type by its id - // */ - // private Map variablesForType = HashUtil.getHashMap(); - /** - * Map of variable of a selected characteristic type by its identifier - */ - private Map variables = HashUtil.getHashMap(); - - /** - * constructor - */ - public TmqlQueryBuilder() { - qbInstance = new FlwrQueryBuilder(); - /* - * create for clause of topic - */ - Navigation nav = new Navigation(Wildcard.TOKEN); - nav.addStep(new Step(AxisId.class, false)); - qbInstance.for_(TOPIC, nav); - /* - * create return clause - */ - nav = new Navigation(TOPIC); - nav.addStep(new Step(AxisId.class, true)); - qbInstance.return_(nav); - - qbInstances = new FlwrQueryBuilder(); - /* - * create for clause of topic - */ - nav = new Navigation(Wildcard.TOKEN); - nav.addStep(new Step(AxisId.class, false)); - nav.addStep(new Step(AxisInstances.class, true)); - qbInstances.for_(TOPIC, nav); - /* - * create return clause - */ - nav = new Navigation(TOPIC); - nav.addStep(new Step(AxisId.class, true)); - qbInstances.return_(nav); - } - - /** - * Adding a new return and for part to TMQL query - * - * @param identifier - * the identifier of name or occurrence - */ - public void fetch(final EdmPropertyIdentifier identifier) { - /* - * add variable for type if not set before - */ - String var = null; - boolean newForClause = false; - /* - * type not already known as for clause component - */ - if (!variables.containsKey(identifier)) { - var = VARIABLE + numberOfArgs; - // variablesForType.put(identifier.getTypeId(), var); - variables.put(identifier, var); - newForClause = true; - } - /* - * type already known - */ - else { - var = variables.get(identifier); - } - fetch(qbInstance, identifier, newForClause); - fetch(qbInstances, identifier, newForClause); - /* - * increment only if necessary - */ - if (newForClause) { - numberOfArgs++; - } - } - - /** - * Internal method to add a new return and for part to TMQL query - * - * @param qb - * the query builder to add - * @param identifier - * identifier of name or occurrence - */ - private void fetch(FlwrQueryBuilder qb, final EdmPropertyIdentifier identifier, boolean newForClause) { - /* - * create for clause - */ - final String variable = variables.get(identifier); - if (newForClause) { - Navigation nav = new Navigation(identifier.getTypeId()); - nav.addStep(new Step(AxisId.class, false)); - qb.for_(variable, nav); - } - /* - * create return clause - */ - Navigation nav = new Navigation(TOPIC); - Step step = new Step(AxisCharacteristics.class, true, variable); - if (identifier.getThemeId() != null) { - step.setFilter(ODataUtils.getScopeFilter(identifier.getThemeId())); - } else { - step.setFilter(ODataUtils.getEmptyScopeFilter()); - } - nav.addStep(step); - step = new Step(AxisAtomify.class, true); - step.setFilter(new IndexFilter(0)); - nav.addStep(step); - qb.return_(nav); - } - - /** - * {@inheritDoc} - */ - public String toInstancesQuery() throws InvalidModelException { - return qbInstances.toQueryString(); - } - - /** - * {@inheritDoc} - */ - public String toInstanceQuery() throws InvalidModelException { - return qbInstance.toQueryString(); - } - - /** - * {@inheritDoc} - */ - @Override - public TmqlQueryBuilder clone() throws CloneNotSupportedException { - TmqlQueryBuilder builder = new TmqlQueryBuilder(); - builder.numberOfArgs = numberOfArgs; - builder.qbInstance = qbInstance.clone(); - builder.qbInstances = qbInstances.clone(); - builder.variables = variables; - return builder; - } - - /** - * Adding a new order by part - * - * @param typeId - * the typeId of property to select - * @param ascending - * the ordering order - */ - public void orderBy(final IEdmPropertyIdentifier identifier, boolean ascending) { - String variable = variables.get(identifier); - if (variable == null) { - throw new RuntimeException("No variable set for given type identifier '" + identifier.getPropertyName() + "'."); - } - Navigation nav = new Navigation(TOPIC); - nav.addStep(AxisCharacteristics.class, true, variable); - nav.addStep(AxisAtomify.class, true); - qbInstances.orderBy(nav, ascending); - qbInstance.orderBy(nav, ascending); - } - - /** - * Adds an limit clause to embedded query - * - * @param limit - * the limit - */ - public void limit(long limit) { - qbInstance.limit(limit); - qbInstances.limit(limit); - } - - /** - * Adds an offset clause to embedded query - * - * @param offset - * the offset - */ - public void offset(long offset) { - qbInstance.offset(offset); - qbInstances.offset(offset); - } - - /** - * Returns the variable name for the given type identifier - * - * @param identifier - * the identifier - * @return the variable - */ - public String getVariable(IEdmPropertyIdentifier identifier) { - return variables.get(identifier); - } - - /** - * Adding a criterion as part of the where clause - * - * @param criterion - * the criterion - */ - public void where(ICriterion criterion) { - qbInstance.conjunction(criterion); - qbInstances.conjunction(criterion); - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/util/EdmUtils.java b/tm2o-core/src/main/java/de/topicmapslab/odata/util/EdmUtils.java deleted file mode 100644 index 85b8d71..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/util/EdmUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.topicmapslab.odata.util; - -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.BOOLEAN; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.DATE; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.DATETIME; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.DECIMAL; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.DOUBLE; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.FLOAT; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.INT; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.INTEGER; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.LONG; -import static de.topicmapslab.majortom.model.namespace.Namespaces.XSD.TIME; - -import org.odata4j.edm.EdmType; -import org.tmapi.core.Locator; - -public class EdmUtils { - - /** - * utility method to transform a given XSD locator to a {@link EdmType} - * - * @param locator - * the locator - * @return the {@link EdmType} - */ - public static EdmType xsdToEdm(Locator locator) { - final String reference = locator.getReference(); - return xsdToEdm(reference); - } - - /** - * utility method to transform a given XSD locator to a {@link EdmType} - * - * @param reference - * the reference - * @return the {@link EdmType} - */ - public static EdmType xsdToEdm(String reference) { - if (BOOLEAN.equalsIgnoreCase(reference)) { - return EdmType.BOOLEAN; - } else if (INT.equalsIgnoreCase(reference)) { - return EdmType.INT32; - } else if (INTEGER.equalsIgnoreCase(reference)) { - return EdmType.INT32; - } else if (LONG.equalsIgnoreCase(reference)) { - return EdmType.INT64; - } else if (DATE.equalsIgnoreCase(reference)) { - return EdmType.DATETIME; - } else if (DATETIME.equalsIgnoreCase(reference)) { - return EdmType.DATETIME; - } else if (TIME.equalsIgnoreCase(reference)) { - return EdmType.TIME; - } else if (DECIMAL.equalsIgnoreCase(reference)) { - return EdmType.DECIMAL; - } else if (DOUBLE.equalsIgnoreCase(reference)) { - return EdmType.DOUBLE; - } else if (FLOAT.equalsIgnoreCase(reference)) { - return EdmType.SINGLE; - } - return EdmType.STRING; - } - -} diff --git a/tm2o-core/src/main/java/de/topicmapslab/odata/util/ODataUtils.java b/tm2o-core/src/main/java/de/topicmapslab/odata/util/ODataUtils.java deleted file mode 100644 index 133573e..0000000 --- a/tm2o-core/src/main/java/de/topicmapslab/odata/util/ODataUtils.java +++ /dev/null @@ -1,296 +0,0 @@ -package de.topicmapslab.odata.util; - -import org.odata4j.expression.AddExpression; -import org.odata4j.expression.AndExpression; -import org.odata4j.expression.BinaryCommonExpression; -import org.odata4j.expression.BoolCommonExpression; -import org.odata4j.expression.CommonExpression; -import org.odata4j.expression.DivExpression; -import org.odata4j.expression.EntitySimpleProperty; -import org.odata4j.expression.EqExpression; -import org.odata4j.expression.Expression; -import org.odata4j.expression.GeExpression; -import org.odata4j.expression.GtExpression; -import org.odata4j.expression.LeExpression; -import org.odata4j.expression.LiteralExpression; -import org.odata4j.expression.LtExpression; -import org.odata4j.expression.MethodCallExpression; -import org.odata4j.expression.ModExpression; -import org.odata4j.expression.MulExpression; -import org.odata4j.expression.NeExpression; -import org.odata4j.expression.NotExpression; -import org.odata4j.expression.OrExpression; -import org.odata4j.expression.SubExpression; - -import de.topicmapslab.odata.content.IOdataContentProvider; -import de.topicmapslab.odata.edm.EdmPropertyIdentifier; -import de.topicmapslab.odata.edm.IEdmPropertyIdentifier; -import de.topicmapslab.odata.exception.TopicMapsODataException; -import de.topicmapslab.odata.tmql.TmqlQueryBuilder; -import de.topicmapslab.tmql4j.hibernate.IQueryPart; -import de.topicmapslab.tmql4j.hibernate.core.NonInterpreted; -import de.topicmapslab.tmql4j.hibernate.criterion.Addition; -import de.topicmapslab.tmql4j.hibernate.criterion.Conjunction; -import de.topicmapslab.tmql4j.hibernate.criterion.Criterion; -import de.topicmapslab.tmql4j.hibernate.criterion.Disjunction; -import de.topicmapslab.tmql4j.hibernate.criterion.Division; -import de.topicmapslab.tmql4j.hibernate.criterion.Equals; -import de.topicmapslab.tmql4j.hibernate.criterion.Exists; -import de.topicmapslab.tmql4j.hibernate.criterion.GreaterEquals; -import de.topicmapslab.tmql4j.hibernate.criterion.GreaterThan; -import de.topicmapslab.tmql4j.hibernate.criterion.ICriteria; -import de.topicmapslab.tmql4j.hibernate.criterion.ICriterion; -import de.topicmapslab.tmql4j.hibernate.criterion.LowerEquals; -import de.topicmapslab.tmql4j.hibernate.criterion.LowerThan; -import de.topicmapslab.tmql4j.hibernate.criterion.Modulo; -import de.topicmapslab.tmql4j.hibernate.criterion.Multiplication; -import de.topicmapslab.tmql4j.hibernate.criterion.Negation; -import de.topicmapslab.tmql4j.hibernate.criterion.Subtraction; -import de.topicmapslab.tmql4j.hibernate.criterion.UnEquals; -import de.topicmapslab.tmql4j.hibernate.path.Navigation; -import de.topicmapslab.tmql4j.hibernate.path.Step; -import de.topicmapslab.tmql4j.hibernate.path.filter.Filter; -import de.topicmapslab.tmql4j.hibernate.path.function.CountFunction; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisAtomify; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisCharacteristics; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisId; -import de.topicmapslab.tmql4j.path.grammar.lexical.AxisScope; -import de.topicmapslab.tmql4j.path.grammar.lexical.Dot; -import de.topicmapslab.tmql4j.util.LiteralUtils; - -public class ODataUtils { - - /** - * Transforms the given OData boolean expression to a TMQL-Hibernate {@link ICriterion}. - * - * @param contentProvider - * the calling content provider - * @param queryBuilder - * the query builder - * @param booleanExpression - * the boolean expression - * @return the {@link ICriterion} - * @throws TopicMapsODataException - * thrown if transformation is not possible - */ - public static final ICriterion transformToTmql(IOdataContentProvider contentProvider, TmqlQueryBuilder queryBuilder, - BoolCommonExpression booleanExpression) { - if (booleanExpression instanceof BinaryCommonExpression) { - return transformToTmql(contentProvider, queryBuilder, (BinaryCommonExpression) booleanExpression); - } else if (booleanExpression instanceof AndExpression) { - AndExpression and = (AndExpression) booleanExpression; - Conjunction conjunction = new Conjunction(); - conjunction.add(transformToTmql(contentProvider, queryBuilder, and.getLHS())); - conjunction.add(transformToTmql(contentProvider, queryBuilder, and.getRHS())); - return conjunction; - } else if (booleanExpression instanceof OrExpression) { - OrExpression or = (OrExpression) booleanExpression; - Disjunction disjunction = new Disjunction(); - disjunction.add(transformToTmql(contentProvider, queryBuilder, or.getLHS())); - disjunction.add(transformToTmql(contentProvider, queryBuilder, or.getRHS())); - return disjunction; - } else if (booleanExpression instanceof NotExpression) { - NotExpression not = (NotExpression) booleanExpression; - Negation negation = new Negation(); - IQueryPart part = transformToTmql(contentProvider, queryBuilder, not.getExpression()); - negation.add(part instanceof ICriterion ? (ICriterion) part : new Exists(part)); - return negation; - } - throw new UnsupportedOperationException("Current content provider does not support given expression type '" - + booleanExpression.getClass().getSimpleName() + "'!"); - } - - public static final IQueryPart transformToTmql(IOdataContentProvider contentProvider, TmqlQueryBuilder queryBuilder, CommonExpression expression) { - /* - * is simple member access - */ - if (expression instanceof EntitySimpleProperty) { - final IEdmPropertyIdentifier identifier = contentProvider.getPropertyType((((EntitySimpleProperty) expression).getPropertyName())); - if (!(identifier instanceof EdmPropertyIdentifier)) { - throw new RuntimeException("Invalid identifier type of property"); - } - final String variableName = queryBuilder.getVariable(identifier); - Navigation navigation = new Navigation(variableName); - Step step = new Step(AxisAtomify.class, true); - /* - * add theme notification - */ - if (identifier.getThemeId() != null) { - step.setFilter(ODataUtils.getScopeFilter(identifier.getThemeId())); - } - navigation.addStep(step); - return navigation; - } - /* - * is method access - */ - if (expression instanceof MethodCallExpression) { - // MethodCallExpression me = (MethodCallExpression) expression; - throw new UnsupportedOperationException("Current content provider does not support given expression type '" - + expression.getClass().getSimpleName() + "'!"); - } - /* - * is literal expression - */ - if (expression instanceof LiteralExpression) { - return new NonInterpreted(getLiteral((LiteralExpression) expression)); - } - /* - * is boolean expression - */ - if (expression instanceof BoolCommonExpression) { - return transformToTmql(contentProvider, queryBuilder, (BoolCommonExpression) expression); - } - throw new UnsupportedOperationException("Current content provider does not support given expression type '" - + expression.getClass().getSimpleName() + "'!"); - } - - /** - * Transforms the given binary expression to its corresponding TMQL numerical or comparison criteria - * - * @param contentProvider - * the content provider - * @param queryBuilder - * the query builder - * @param expression - * the expression - * @return the criteria - */ - public static final ICriterion transformToTmql(IOdataContentProvider contentProvider, TmqlQueryBuilder queryBuilder, - BinaryCommonExpression expression) { - ICriteria criteria; - /* - * left hand side only supports entity name - */ - if (!(expression.getLHS() instanceof EntitySimpleProperty)) { - throw new UnsupportedOperationException("Current content provider only supports simple property expressions"); - } - EntitySimpleProperty lhs = (EntitySimpleProperty) expression.getLHS(); - /* - * transform left hand - */ - final IEdmPropertyIdentifier identifier = contentProvider.getPropertyType(lhs.getPropertyName()); - final String variableName = queryBuilder.getVariable(identifier); - Navigation navigation = new Navigation(TmqlQueryBuilder.TOPIC); - Step c = new Step(AxisCharacteristics.class, true, variableName); - if (identifier.getThemeId() != null) { - c.setFilter(ODataUtils.getScopeFilter(identifier.getThemeId())); - } - navigation.addStep(c); - - Step step = new Step(AxisAtomify.class, true); - /* - * add theme notification - */ - if (identifier.getThemeId() != null) { - step.setFilter(ODataUtils.getScopeFilter(identifier.getThemeId())); - } - navigation.addStep(step); - /* - * right hand side only supports literals - */ - if (!(expression.getRHS() instanceof LiteralExpression)) { - throw new UnsupportedOperationException("Current content provider only supports simple property expressions"); - } - LiteralExpression rhs = (LiteralExpression) expression.getRHS(); - /* - * create criteria - */ - if (expression instanceof EqExpression) { - criteria = new Equals(); - } else if (expression instanceof NeExpression) { - criteria = new UnEquals(); - } else if (expression instanceof GtExpression) { - criteria = new GreaterThan(); - } else if (expression instanceof GeExpression) { - criteria = new GreaterEquals(); - } else if (expression instanceof LtExpression) { - criteria = new LowerThan(); - } else if (expression instanceof LeExpression) { - criteria = new LowerEquals(); - } else if (expression instanceof AddExpression) { - criteria = new Addition(); - } else if (expression instanceof SubExpression) { - criteria = new Subtraction(); - } else if (expression instanceof DivExpression) { - criteria = new Division(); - } else if (expression instanceof MulExpression) { - criteria = new Multiplication(); - } else if (expression instanceof ModExpression) { - criteria = new Modulo(); - } - /* - * unknown type - */ - else { - throw new TopicMapsODataException("Currently the given binary expression '" + expression.getClass().getSimpleName() + "' is not support!"); - } - /* - * add left and right hand - */ - criteria.add(new Exists(navigation)); - criteria.add(new Criterion(getLiteral(rhs))); - return criteria; - } - - /** - * Utility method transform the given value to a TMQL literal - * - * @param expression - * the expression - * @return the literal - */ - public static String getLiteral(LiteralExpression expression) { - Object value = Expression.literalValue(expression); - if (value instanceof String) { - return "\"\"\"" + LiteralUtils.asString(value) + "\"\"\""; - } - return value.toString(); - } - - /** - * Utility method to create a scope filter - * - * @param themeId - * the theme Id - * @return the scope filter - */ - public static Filter getScopeFilter(final String themeId) { - /* - * create . >> scope - */ - Navigation left = new Navigation(Dot.TOKEN); - left.addStep(new Step(AxisScope.class, true)); - left.addStep(AxisId.class, true); - /* - * create "id" << id - */ - Navigation right = new Navigation("\"" + themeId + "\""); - // right.addStep(new Step(AxisId.class, false)); - /* - * create equality as filter - */ - Equals eq = new Equals(); - eq.add(new Exists(left)); - eq.add(new Exists(right)); - return new Filter(eq); - } - - /** - * Utility method to create an empty scope filter - * - * @return the scope filter - */ - public static Filter getEmptyScopeFilter() { - /* - * create . >> scope - */ - Navigation left = new Navigation(Dot.TOKEN); - left.addStep(new Step(AxisScope.class, true)); - CountFunction fct = new CountFunction(left); - Equals eq = new Equals(); - eq.add(new Exists(fct)); - eq.add(new Exists(new NonInterpreted("0"))); - return new Filter(eq); - } -} diff --git a/tm2o-core/src/main/resources/de/topicmapslab/odata/tm2o.properties b/tm2o-core/src/main/resources/de/topicmapslab/odata/tm2o.properties deleted file mode 100644 index 14d16bf..0000000 --- a/tm2o-core/src/main/resources/de/topicmapslab/odata/tm2o.properties +++ /dev/null @@ -1,5 +0,0 @@ -contentProvider = de.topicmapslab.odata.content.remote.RemoteOdataContentProvider -namespace = OData -server = http://localhost:8080/majortom-server -api-key = 1234567890 -association-mode = FLAT_ASSOCIATION \ No newline at end of file diff --git a/tm2o-core/src/main/webapp/WEB-INF/lib/odata4j-nojpabundle-SNAPSHOT-20101214.jar b/tm2o-core/src/main/webapp/WEB-INF/lib/odata4j-nojpabundle-SNAPSHOT-20101214.jar deleted file mode 100644 index a2a4510..0000000 Binary files a/tm2o-core/src/main/webapp/WEB-INF/lib/odata4j-nojpabundle-SNAPSHOT-20101214.jar and /dev/null differ diff --git a/tm2o-core/src/main/webapp/WEB-INF/tm-web.xml b/tm2o-core/src/main/webapp/WEB-INF/tm-web.xml deleted file mode 100644 index 8ab98fe..0000000 --- a/tm2o-core/src/main/webapp/WEB-INF/tm-web.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - odata4tm-sample - 2 - - - - - - - \ No newline at end of file diff --git a/tm2o-core/src/main/webapp/WEB-INF/web.xml b/tm2o-core/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index ba49e6c..0000000 --- a/tm2o-core/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - OData - com.sun.jersey.spi.container.servlet.ServletContainer - - com.sun.jersey.config.property.resourceConfigClass - org.odata4j.producer.resources.ODataResourceConfig - - 1 - - - OData - /odata.svc/* - - - - - CrossDomain - com.sun.jersey.spi.container.servlet.ServletContainer - - com.sun.jersey.config.property.resourceConfigClass - org.odata4j.producer.resources.CrossDomainResourceConfig - - 1 - - - CrossDomain - /* - - - - diff --git a/tm2o-core/src/test/java/dasdas.java b/tm2o-core/src/test/java/dasdas.java deleted file mode 100644 index 814cd37..0000000 --- a/tm2o-core/src/test/java/dasdas.java +++ /dev/null @@ -1,124 +0,0 @@ -import java.io.File; -import java.util.Properties; - -import org.odata4j.core.OEntity; -import org.odata4j.core.OLink; -import org.odata4j.core.OProperty; -import org.odata4j.edm.EdmDataServices; -import org.odata4j.edm.EdmEntityType; -import org.odata4j.producer.EntitiesResponse; -import org.odata4j.producer.InlineCount; -import org.odata4j.producer.QueryInfo; -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicMapSystemFactory; -import org.tmapix.io.CTMTopicMapReader; - -import de.topicmapslab.odata.TopicMapODataProducer; -import de.topicmapslab.odata.content.memory.MemoryOdataContentProvider; -import de.topicmapslab.odata.content.remote.RemoteTmqlHelper; -import de.topicmapslab.odata.dao.AssociationTypeDAO; -import de.topicmapslab.odata.dao.NameTypeDAO; -import de.topicmapslab.odata.dao.OccurrenceTypeDAO; -import de.topicmapslab.odata.dao.TopicTypeDAO; -import de.topicmapslab.tmql4j.components.processor.runtime.ITMQLRuntime; -import de.topicmapslab.tmql4j.components.processor.runtime.TMQLRuntimeFactory; -import de.topicmapslab.tmql4j.path.components.processor.runtime.TmqlRuntime2007; - -public class dasdas { - - /** - * @param args - */ - public static void main(String[] args) throws Exception { - tmql(); - } - - public static final void tmql() throws Exception { - TopicMap tm = TopicMapSystemFactory.newInstance().newTopicMapSystem().createTopicMap("http://e"); - CTMTopicMapReader reader = new CTMTopicMapReader(tm, new File( - "C:/Programme/Apache Software Foundation/Tomcat 7.0/webapps/odata4j-web/WEB-INF/data/odata.ctm")); - reader.read(); - String q = "FOR $t IN http://psi.topicmapslab.de/p/odata/person >> instances FOR $ot IN http://psi.topicmapslab.de/p/odata/institution RETURN fn:uniq ( $t << players << roles [ fn:count ( . >> scope ) == 0 ] >> roles >> players $ot MINUS $t )"; - - ITMQLRuntime runtime = TMQLRuntimeFactory.newFactory().newRuntime(TmqlRuntime2007.TMQL_2007); - System.out.println(runtime.run(tm, q).getResults()); - } - - public static final void local() throws Exception { - - Properties properties = new Properties(); - properties.put("path", "C:/Programme/Apache Software Foundation/Tomcat 7.0/webapps/odata4j-web/WEB-INF/data/toytm.ctm"); - properties.put("base-locator", "http://lala.de"); - - String topicMapId = "123"; - TopicMapODataProducer producer = new TopicMapODataProducer(MemoryOdataContentProvider.class, properties, "Lala"); - EdmDataServices service = producer.getMetadata(topicMapId); - for (EdmEntityType type : service.getEntityTypes()) { - QueryInfo queryInfo = new QueryInfo(InlineCount.NONE, null, null, null, null, null, null, null, null); - EntitiesResponse res = producer.getEntities(topicMapId, type.name, queryInfo); - if (!res.getEntities().isEmpty()) { - for (OEntity entity : res.getEntities()) { - System.out.println("+++++++++++++++++++++++++"); - System.out.println("Counter players of :"); - print(entity); - for (OLink link : entity.getLinks()) { - String navProp = link.getRelation(); - EntitiesResponse r = producer.getNavProperty(topicMapId, type.name, entity.getId(), navProp, queryInfo); - if (!r.getEntities().isEmpty()) { - System.out.println("Navigation property: " + navProp); - System.out.println("======================="); - for (OEntity o : r.getEntities()) { - print(o); - System.out.println("----------------------"); - } - } - } - System.out.println("+++++++++++++++++++++++++"); - } - } - } - - } - - public static final void print(OEntity entity) { - System.out.println("Id : " + entity.getId()); - for (OProperty prop : entity.getProperties()) { - System.out.println(prop.getName() + ": " + prop.getValue().toString()); - } - } - - public static final void remote() { - - final String uri = "http://localhost:9090/majortom-server"; - final String topicMapId = "fe717c45763d7b36067cc17a4b1b5d6"; - RemoteTmqlHelper helper = new RemoteTmqlHelper(uri, "123456789", topicMapId); - - for (TopicTypeDAO dao : helper.getTopicTypes()) { - System.out.println("DAO: " + dao.getTypeLabel() + "(" + dao.getTypeId() + ")"); - for (NameTypeDAO nDao : helper.getNameTypes(dao.getTypeId())) { - System.out.print("Name-DAO: " + nDao.getTypeLabel() + "(" + nDao.getTypeId() + ") @ "); - for (TopicTypeDAO theme : nDao.getThemeDAOs()) { - System.out.print(theme.getTypeLabel() + " "); - } - } - System.out.println(); - for (OccurrenceTypeDAO oDao : helper.getOccurrenceTypes(dao.getTypeId())) { - System.out.print("Occ-DAO: " + oDao.getTypeLabel() + "(" + oDao.getTypeId() + ") ^^ " + oDao.getDatatype() + " @ "); - for (TopicTypeDAO theme : oDao.getThemeDAOs()) { - System.out.print(theme.getTypeLabel() + " "); - } - } - System.out.println("----------------------------"); - System.out.println(); - } - - for (AssociationTypeDAO dao : helper.getAssociationSignatures()) { - System.out.print("Association: " + dao.getTypeLabel() + "(" + dao.getTypeId() + ")"); - System.out.print(dao.getLeftRoleTypeDAO().getTypeLabel() + "(" + dao.getLeftRoleTypeDAO().getTypeId() + ") : "); - System.out.print(dao.getLeftPlayerTypeDAO().getTypeLabel() + "(" + dao.getLeftPlayerTypeDAO().getTypeId() + ") , "); - System.out.print(dao.getRightRoleTypeDAO().getTypeLabel() + "(" + dao.getRightRoleTypeDAO().getTypeId() + ") : "); - System.out.println(dao.getRightPlayerTypeDAO().getTypeLabel() + "(" + dao.getRightPlayerTypeDAO().getTypeId() + ") ) "); - } - - } -} diff --git a/tm2o/.project b/tm2o/.project deleted file mode 100644 index 1bfad1f..0000000 --- a/tm2o/.project +++ /dev/null @@ -1,42 +0,0 @@ - - - tm2o - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.jdt.core.javanature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/tm2o/META-INF/MANIFEST.MF b/tm2o/META-INF/MANIFEST.MF deleted file mode 100644 index 43e9098..0000000 --- a/tm2o/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ActivationPolicy: lazy -Tool: Bnd-1.15.0 -Bundle-Name: ODate 4 Topic Maps -Created-By: 1.6.0_20 (Sun Microsystems Inc.) -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.tmapi;bundle-version="2.0.3" -Bundle-Version: 0.0.1 -Bnd-LastModified: 1298452223140 -Bundle-ManifestVersion: 2 -Import-Package: org.osgi.framework;version="[1.4,2)",org.slf4j;version - ="1.6.1" -Bundle-SymbolicName: de.topicmapslab.odata4tm -Originally-Created-By: 1.6.0_20 (Sun Microsystems Inc.) - diff --git a/tm2o/build/classes/META-INF/MANIFEST.MF b/tm2o/build/classes/META-INF/MANIFEST.MF deleted file mode 100644 index 5e94951..0000000 --- a/tm2o/build/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/tm2o/build/classes/WEB-INF/web.xml b/tm2o/build/classes/WEB-INF/web.xml deleted file mode 100644 index 48611fd..0000000 --- a/tm2o/build/classes/WEB-INF/web.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - odata4j-web - - index.html - index.htm - index.jsp - default.html - default.htm - default.jsp - - \ No newline at end of file diff --git a/tm2o/pom.xml b/tm2o/pom.xml deleted file mode 100644 index 3dd3a78..0000000 --- a/tm2o/pom.xml +++ /dev/null @@ -1,249 +0,0 @@ - - 4.0.0 - de.topicmapslab.odata - tm2o - war - 1.0.0 - - UTF-8 - 2.0.2 - 1.1.5 - http://localhost:8080 - - - - - META-INF - ${project.build.directory}/classes/META-INF - - - src/main/resources - - - - - org.mortbay.jetty - jetty-maven-plugin - 7.2.0.v20101020 - - 5 - 9966 - foo - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - - - META-INF/MANIFEST.MF - - - - - org.codehaus.mojo - tomcat-maven-plugin - 1.1 - - tomcat-server - ${project.build.directory}/${project.build.finalName}.war - true - ${server.url}/manager/html - ${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml - - - - org.apache.felix - maven-bundle-plugin - true - 2.2.0 - - - - bundle-manifest - process-classes - - manifest - - - - - - - jar - - META-INF - - 0.0.1 - - de.topicmapslab.odata.* - - - org.tmapi;bundle-version="2.0.3" - - - org.osgi.framework, - org.slf4j;version="1.6.1" - - de.topicmapslab.odata4tm - ODate 4 Topic Maps - lazy - JavaSE-1.6 - - - - - - - - - tmlab - http://maven.topicmapslab.de/public - - - ontopia - http://ontopia.googlecode.com/svn/maven-repository/ - - - ontopia snapshot - http://ontopia.googlecode.com/svn/maven-snapshot-repository/ - - - tmapi-snap - http://www.tmapi.org/maven-repository/snapshots/ - http://www.tmapi.org/maven-repository/snapshots/ - - - tmapi - http://www.tmapi.org/maven-repository/ - http://www.tmapi.org/maven-repository/ - - - eclipse.org - eclipse repository - http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo - - - java.net - java.net repository - http://download.java.net/maven/2 - - - - - org.slf4j - slf4j-api - 1.6.1 - jar - compile - - - org.osgi - org.osgi.core - 4.1.0 - jar - compile - - - de.topicmapslab.majortom - majortom-inMemory - 1.2.0-SNAPSHOT - - - org.tmapix - tmapix-io - 1.0.1-SNAPSHOT - - - slf4j-jdk14 - org.slf4j - - - slf4j-log4j - org.slf4j - - - slf4j-api - org.slf4j - - - org.tmapi - tmapi - - - net.ontopia - ontopia-mio - - - org.tinytim - tinytim - - - - - de.topicmapslab.odata - tm2o-core - 1.0.0 - jar - compile - - - - com.sun.jersey - jersey-bundle - ${jersey.version} - - - org.eclipse.persistence - javax.persistence - ${eclipselink.version} - - - org.eclipse.persistence - eclipselink - ${eclipselink.version} - - - - org.apache.tomcat - tomcat-coyote - 7.0.11 - jar - compile - - - javax.servlet - servlet-api - 2.5 - provided - - - \ No newline at end of file diff --git a/tm2o/src/main/java/de/topicmapslab/odata/web/IOUtis.java b/tm2o/src/main/java/de/topicmapslab/odata/web/IOUtis.java deleted file mode 100644 index cafef07..0000000 --- a/tm2o/src/main/java/de/topicmapslab/odata/web/IOUtis.java +++ /dev/null @@ -1,177 +0,0 @@ -package de.topicmapslab.odata.web; - -import java.io.File; -import java.io.FileWriter; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.tomcat.util.http.fileupload.FileItem; -import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory; -import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; - -import de.topicmapslab.odata.TopicMapODataProducerFactory; -import de.topicmapslab.odata.config.EContentProviderConfiguration; -import de.topicmapslab.odata.content.IOdataContentProvider; -import de.topicmapslab.odata.content.memory.MemoryOdataContentProvider; -import de.topicmapslab.odata.content.remote.RemoteOdataContentProvider; - -public class IOUtis { - - /** - * Utility method to parse multi-part content of the POST request - * - * @param request - * the request - * @return the configuration extracted from POST request - */ - public static ODataConfiguration post(HttpServletRequest request) { - try { - /* - * Create a factory for disk-based file items - */ - DiskFileItemFactory factory = new DiskFileItemFactory(); - /* - * create variables to fill - */ - boolean flatAssociation = false; - boolean local = false; - String namespace = null; - String address = null; - String apiKey = null; - File f = null; - /* - * Create a new file upload handler - */ - ServletFileUpload upload = new ServletFileUpload(factory); - List items = upload.parseRequest(request); - Iterator iter = items.iterator(); - while (iter.hasNext()) { - FileItem item = (FileItem) iter.next(); - String name = item.getFieldName(); - String value = item.getString(); - /* - * is normal form field - */ - if (item.isFormField()) { - if ("flat".equalsIgnoreCase(name)) { - flatAssociation = true; - } else if ("locPro".equalsIgnoreCase(name)) { - local = true; - } else if ("address".equalsIgnoreCase(name)) { - address = value; - } else if ("namespace".equalsIgnoreCase(name)) { - namespace = value; - } else if ("api-key".equalsIgnoreCase(name)) { - apiKey = value; - } - } - /* - * is file upload - */ - else if (name.equalsIgnoreCase("file") && !item.getName().isEmpty()) { - InputStream uploadedStream = item.getInputStream(); - try { - File path = new File(TopicMapODataProducerFactory.PATH); - if (!path.exists()) { - path.mkdirs(); - } - f = new File(TopicMapODataProducerFactory.PATH + "/" + item.getName()); - - System.out.println(f.getAbsolutePath()); - if (!f.exists()) { - f.createNewFile(); - } - } catch (Exception e) { - e.printStackTrace(System.out); - System.err.println("Cannot copy file, use tempory file"); - f = File.createTempFile("tm2o", "tm"); - } - FileWriter writer = new FileWriter(f); - int i = uploadedStream.read(); - while (i != -1) { - writer.write(i); - i = uploadedStream.read(); - } - writer.flush(); - writer.close(); - uploadedStream.close(); - } - } - /* - * create configuration - */ - Properties properties = new Properties(); - properties.put("association-mode", flatAssociation ? EContentProviderConfiguration.FLAT_ASSOCIATION.name() - : EContentProviderConfiguration.STRONG_ASSOCIATION.name()); - if (address != null) { - properties.put("server", address); - } - if (apiKey != null) { - properties.put("api-key", apiKey); - } - if (f != null) { - properties.put("file", f); - properties.put("path", f.getAbsolutePath()); - } - Class clazz = local ? MemoryOdataContentProvider.class : RemoteOdataContentProvider.class; - return new ODataConfiguration(clazz, properties, namespace); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Utility method to fetch all topic map IDs from server - * - * @param serverAddress - * the server address - * - * @param apiKey - * the API key - * @return a possible empty map of locator and ID - */ - public static Map getTopicMapIds(final String serverAddress, final String apiKey) { - Map topicMaps = new HashMap(); - - try { - /* - * open streams - */ - URL url = new URL(serverAddress + "/tm/topicmaps?apikey=" + apiKey); - URLConnection connection = url.openConnection(); - connection.setDoInput(true); - /* - * proceed response as extended JTMQR - */ - InputStream is = connection.getInputStream(); - ObjectMapper m = new ObjectMapper(); - JsonNode rootNode = m.readValue(is, JsonNode.class); - JsonNode data = rootNode.path("data"); - if (!data.isMissingNode()) { - JsonNode tm = data.path("topicmaps"); - if (!tm.isMissingNode()) { - Iterator tms = tm.getElements(); - while (tms.hasNext()) { - JsonNode n = tms.next(); - topicMaps.put(n.get("locator").getTextValue(), n.get("id").getTextValue()); - } - } - } - } catch (Exception e) { - return null; - } - - return topicMaps; - } - -} diff --git a/tm2o/src/main/java/de/topicmapslab/odata/web/ODataConfiguration.java b/tm2o/src/main/java/de/topicmapslab/odata/web/ODataConfiguration.java deleted file mode 100644 index 4b9c56e..0000000 --- a/tm2o/src/main/java/de/topicmapslab/odata/web/ODataConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package de.topicmapslab.odata.web; - -import java.util.Properties; - -import de.topicmapslab.odata.content.IOdataContentProvider; - -public class ODataConfiguration { - - private final String namespace; - private final Class clazz; - private final Properties properties; - - /** - * @param clazz - * the class - * @param properties - * the properties - * @param namespace - * the namespace - */ - public ODataConfiguration(Class clazz, Properties properties, String namespace) { - this.namespace = namespace; - this.clazz = clazz; - this.properties = properties; - } - - /** - * Returns the properties - * - * @return the properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Returns the content provider class - * - * @return the class - */ - public Class getClazz() { - return clazz; - } - - /** - * Returns the namespace - * - * @return the namespace - */ - public String getNamespace() { - return namespace; - } - -} diff --git a/tm2o/src/main/webapp/META-INF/MANIFEST.MF b/tm2o/src/main/webapp/META-INF/MANIFEST.MF deleted file mode 100644 index 5e94951..0000000 --- a/tm2o/src/main/webapp/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/tm2o/src/main/webapp/WEB-INF/tm-web.xml b/tm2o/src/main/webapp/WEB-INF/tm-web.xml deleted file mode 100644 index 8ab98fe..0000000 --- a/tm2o/src/main/webapp/WEB-INF/tm-web.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - odata4tm-sample - 2 - - - - - - - \ No newline at end of file diff --git a/tm2o/src/main/webapp/WEB-INF/web.xml b/tm2o/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 961b21b..0000000 --- a/tm2o/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - tm2o - - services.jsp - - - OData - com.sun.jersey.spi.container.servlet.ServletContainer - - com.sun.jersey.config.property.resourceConfigClass - org.odata4j.producer.resources.ODataResourceConfig - - - odata4j.producerfactory - de.topicmapslab.odata.TopicMapODataProducerFactory - - 1 - - - OData - /odata.svc/* - - \ No newline at end of file diff --git a/tm2o/src/main/webapp/clientaccesspolicy.xml b/tm2o/src/main/webapp/clientaccesspolicy.xml deleted file mode 100644 index b12ce9c..0000000 --- a/tm2o/src/main/webapp/clientaccesspolicy.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tm2o/src/main/webapp/configuration.jsp b/tm2o/src/main/webapp/configuration.jsp deleted file mode 100644 index 86e7381..0000000 --- a/tm2o/src/main/webapp/configuration.jsp +++ /dev/null @@ -1,210 +0,0 @@ -<%@page import="de.topicmapslab.odata.web.ODataConfiguration"%> -<%@page import="de.topicmapslab.odata.web.IOUtis"%> -<%@page import="java.io.FileWriter"%> -<%@page import="java.io.FileReader"%> -<%@page import="java.io.InputStream"%> -<%@page import="java.io.File"%> -<%@page import="org.apache.tomcat.util.http.fileupload.FileItem"%> -<%@page import="java.util.Iterator"%> -<%@page import="java.util.List"%> -<%@page - import="org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory"%> -<%@page - import="org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload"%> -<%@page - import="de.topicmapslab.odata.content.remote.RemoteOdataContentProvider"%> -<%@page import="java.security.Provider"%> -<%@page - import="de.topicmapslab.odata.config.EContentProviderConfiguration"%> -<%@page - import="de.topicmapslab.odata.edm.EdmNavigationPropertyIdentifier"%> -<%@page import="java.util.Properties"%> -<%@page - import="de.topicmapslab.odata.content.memory.MemoryOdataContentProvider"%> -<%@page import="de.topicmapslab.odata.TopicMapMetadata"%> -<%@page import="de.topicmapslab.odata.TopicMapODataProducer"%> -<%@page import="de.topicmapslab.odata.TopicMapODataProducerFactory"%> -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -Configuration of TM2O Service - - - - - - - - -
- -
  -

Configuration

-
- Please add something like: If you need help for the configuration please read the here. -
-
- <% - TopicMapODataProducer producer = TopicMapODataProducerFactory.getProducerInstance(); - TopicMapMetadata mt = producer.getService(); - boolean local = false; - String namespace = null; - Properties prop = null; - String file = null; - String url = null; - String apiKey = null; - boolean flatAssociation = false; - /* - * is get request - */ - if (request.getMethod().equalsIgnoreCase("GET")) { - local = MemoryOdataContentProvider.class.isAssignableFrom(mt.getContentProviderClass()); - namespace = mt.getNamespace(); - prop = mt.getProperties(); - file = ""; - apiKey = !local ? (prop.containsKey("api-key")?prop.get("api-key").toString():"") : ""; - url = !local ? prop.get("server").toString() : ""; - flatAssociation = prop.get("association-mode").toString().equalsIgnoreCase(EContentProviderConfiguration.FLAT_ASSOCIATION.name()); - } - /* - * is post - */ - else if (request.getMethod().equalsIgnoreCase("POST")) { - /* - * - */ - ODataConfiguration cfg = IOUtis.post(request); - /* - * update ODATA service - */ - mt.reload(cfg.getClazz(), cfg.getProperties(), cfg.getNamespace()); - TopicMapODataProducerFactory.writeProperties(cfg.getClazz(), cfg.getProperties(), cfg.getNamespace()); - /* - * set outside values - */ - local = MemoryOdataContentProvider.class.isAssignableFrom(cfg.getClazz()); - namespace = cfg.getNamespace(); - prop = cfg.getProperties(); - file = ""; - apiKey = !local ? (prop.containsKey("api-key")?prop.get("api-key").toString():"") : ""; - url = !local ? prop.get("server").toString() : ""; - flatAssociation = prop.get("association-mode").toString().equalsIgnoreCase(EContentProviderConfiguration.FLAT_ASSOCIATION.name()); - } - %> -
- - <% if (request.getMethod().equalsIgnoreCase("POST") ) { %> - - - - <% } %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Operation was successful -
Namespace:
Association Mode: - onclick="document.getElementById('strong').checked = false;"> - FLAT - onclick="document.getElementById('flat').checked = false;"> - STRONG
Local Content Provider: - onclick="document.getElementById('remPro').checked = false;">
File:
Remote Content Provider: - onclick="document.getElementById('locPro').checked = false;">
-
MaJorToM Server Address:
MaJorToM API Key:
-
-
-
-
- Available services listed "> here
-
-
- - - \ No newline at end of file diff --git a/tm2o/src/main/webapp/resources/css/maiana.css b/tm2o/src/main/webapp/resources/css/maiana.css deleted file mode 100644 index 3a87ec1..0000000 --- a/tm2o/src/main/webapp/resources/css/maiana.css +++ /dev/null @@ -1,162 +0,0 @@ -/* default font color */ -h1, h2, h3, h4, h5, h6, -body { - color: #444444; -} - -body { - background: #fff; - } -#footer { background-color: #352217; } -#footer, -#footer a, -.orangeFont { - color: #FFAC3F; -} -#user-session a { - color: #FEAB3F; -} - -.right { float: right; } -.left { float: left; } -.space-before-1 { margin-top: 0; } -.space-before-1 { margin-top: 1em; } -.space-before-2 { margin-top: 2em; } -.space-before-3 { margin-top: 3em; } -.space-before-4 { margin-top: 4em; } -.space-before-5 { margin-top: 5em; } - -.space-after-0 { margin-bottom: 0; } -.space-after-1 { margin-bottom: 1em; } -.space-after-2 { margin-bottom: 2em; } -.space-after-3 { margin-bottom: 3em; } -.space-after-4 { margin-bottom: 4em; } -.space-after-5 { margin-bottom: 5em; } - -/* Common styles */ -ul.horizontal { padding-left: 0px; } -ul.horizontal li { - float: left; - margin-right: 2em; -} - -ul.right { - margin: 0px; - float: none; -} -ul.right li { - float: right; - margin-right: 0em; - margin-left: 2em; -} - -.noBullet { list-style-type: none; } -a { - text-decoration: underline; - color: inherit; -} -/* Some blue print fixes */ -input[type="text"], input[type="password"], input.text, input.title, textarea, select { - margin: .2em 0 .5em 0; -} - -h1 { font-size: 2.2em; } - -legend { - color:gray; - padding-left:2px; - padding-right:5px; -} - -label { - display:block; - font-size:1.1em; - padding-top:.3em; - } - form.wide-form label { - display:inline-block; - width: 180px; - } - -body { word-wrap: break-word; } - -#wrapper { - height: auto !important; - /*margin: 0 auto -100px;*/ - min-height: 100%; -} - -#header { - background-image: url(../images/header-background.png); - background-repeat: repeat-x; -} - -#sub-header { - margin-top: 2em; - } - #sub-header h2 { - font-size: 1.7em; - color: white; - text-shadow: 1px 1px 1px #000; - margin: 0; - margin-top: .3em; - } - #sub-header p { - color: #eee; - text-shadow: 1px 1px 1px #000; - } - -#logo { - background: transparent url(../images/maiana-logo.png) no-repeat 0 15px; - height: 69px; -} - -#logo a, -#logo h1 { - position: relative; -} - -#logo h1 { visibility: hidden; } -#logo a img { - width: 300px; - height: 65px; -} - -#content { - background: transparent url(../images/content-top-background.gif) repeat-x; - padding-left: 20px; -} - -#mainContent textarea#container_description { height: 50px; } - -/* Footer */ -#footer { - height: 40px; - line-height: 38px; - width: 100%; - background: url(../images/footer-background.gif) repeat-x; - bottom: 0; - position: fixed; -} -#footer ul li { - padding-left: 20px; - list-style: none; -} - -#footer #bug_report { - position: absolute; - padding-left: 420px; - width: 352px; - height: 210px; - overflow: hidden; -} -#footer #bug_report fieldset { - background: white; - border: 3px solid; - margin-top:-1px; -} -#footer #bug_report textarea { - width: 300px; - height: 80px; -} - diff --git a/tm2o/src/main/webapp/resources/css/print.css b/tm2o/src/main/webapp/resources/css/print.css deleted file mode 100644 index fdb8220..0000000 --- a/tm2o/src/main/webapp/resources/css/print.css +++ /dev/null @@ -1,29 +0,0 @@ -/* ----------------------------------------------------------------------- - - - Blueprint CSS Framework 0.9 - http://blueprintcss.org - - * Copyright (c) 2007-Present. See LICENSE for more info. - * See README for instructions on how to use Blueprint. - * For credits and origins, see AUTHORS. - * This is a compressed file. See the sources in the 'src' directory. - ------------------------------------------------------------------------ */ - -/* print.css */ -body {line-height:1.5;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;color:#000;background:none;font-size:10pt;} -.container {background:none;} -hr {background:#ccc;color:#ccc;width:100%;height:2px;margin:2em 0;padding:0;border:none;} -hr.space {background:#fff;color:#fff;visibility:hidden;} -h1, h2, h3, h4, h5, h6 {font-family:"Helvetica Neue", Arial, "Lucida Grande", sans-serif;} -code {font:.9em "Courier New", Monaco, Courier, monospace;} -a img {border:none;} -p img.top {margin-top:0;} -blockquote {margin:1.5em;padding:1em;font-style:italic;font-size:.9em;} -.small {font-size:.9em;} -.large {font-size:1.1em;} -.quiet {color:#999;} -.hide {display:none;} -a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;} -a:link:after, a:visited:after {content:" (" attr(href) ")";font-size:90%;} \ No newline at end of file diff --git a/tm2o/src/main/webapp/resources/css/screen.css b/tm2o/src/main/webapp/resources/css/screen.css deleted file mode 100644 index a563ac7..0000000 --- a/tm2o/src/main/webapp/resources/css/screen.css +++ /dev/null @@ -1,260 +0,0 @@ -/* ----------------------------------------------------------------------- - - - Blueprint CSS Framework 0.9 - http://blueprintcss.org - - * Copyright (c) 2007-Present. See LICENSE for more info. - * See README for instructions on how to use Blueprint. - * For credits and origins, see AUTHORS. - * This is a compressed file. See the sources in the 'src' directory. - ------------------------------------------------------------------------ */ - -/* reset.css */ -/*html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} -*/ -html, body, #header h1 {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} -body {line-height:1.5;} -table {border-collapse:separate;border-spacing:0;} -caption, th, td {text-align:left;font-weight:normal;} -table, td, th {vertical-align:middle;} -blockquote:before, blockquote:after, q:before, q:after {content:"";} -blockquote, q {quotes:"" "";} -a img {border:none;} - -/* typography.css */ -html {font-size:100.01%;} -body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;} -h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;} -h1 {font-size:3em;line-height:1;margin-bottom:0.5em;} -h2 {font-size:2em;margin-bottom:0.75em;} -h3 {font-size:1.5em;line-height:1;margin-bottom:1em;} -h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;} -h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;} -h6 {font-size:1em;font-weight:bold;} -h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;} -p {margin:0 0 1.5em;} -p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;} -p img.right {float:right;margin:1.5em 0 1.5em 1.5em;} -a:focus, a:hover {color:#000;} -a {color:#009;text-decoration:underline;} -blockquote {margin:1.5em;color:#666;font-style:italic;} -strong {font-weight:bold;} -em, dfn {font-style:italic;} -dfn {font-weight:bold;} -sup, sub {line-height:0;} -abbr, acronym {border-bottom:1px dotted #666;} -address {margin:0 0 1.5em;font-style:italic;} -del {color:#666;} -pre {margin:1.5em 0;white-space:pre;} -pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;} -li ul, li ol {margin:0 1.5em;} -ul, ol {margin:0 1.5em 1.5em 1.5em;} -ul {list-style-type:disc;} -ol {list-style-type:decimal;} -dl {margin:0 0 1.5em 0;} -dl dt {font-weight:bold;} -dd {margin-left:1.5em;} -table {margin-bottom:1.4em;width:100%;} -th {font-weight:bold;} -thead th {background:#c3d9ff;} -th, td, caption {padding:4px 10px 4px 5px;} -tr.even td {background:#e5ecf9;} -tfoot {font-style:italic;} -caption {background:#eee;} -.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;} -.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;} -.hide {display:none;} -.quiet {color:#666;} -.loud {color:#000;} -.highlight {background:#ff0;} -.added {background:#060;color:#fff;} -.removed {background:#900;color:#fff;} -.first {margin-left:0;padding-left:0;} -.last {margin-right:0;padding-right:0;} -.top {margin-top:0;padding-top:0;} -.bottom {margin-bottom:0;padding-bottom:0;} - -/* forms.css */ -label {font-weight:bold;} -fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;} -legend {font-weight:bold;font-size:1.2em;} -input[type=text], input[type=password], input.text, input.title, textarea, select {background-color:#fff;border:1px solid #bbb;} -input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus, select:focus {border-color:#666;} -input[type=text], input[type=password], input.text, input.title, textarea, select {margin:0.5em 0;} -input.text, input.title {width:300px;padding:5px;} -input.title {font-size:1.5em;} -textarea {width:390px;height:250px;padding:5px;} -input[type=checkbox], input[type=radio], input.checkbox, input.radio {position:relative;top:.25em;} -form.inline {line-height:3;} -form.inline p {margin-bottom:0;} -.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;} -.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;} -.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;} -.success {background:#E6EFC2;color:#264409;border-color:#C6D880;} -.tmql_error {padding:.8em;margin-bottom:1em;color:#8a1f11;} -.error a {color:#8a1f11;} -.notice a {color:#514721;} -.success a {color:#264409;} - -/* grid.css */ -.container {width:950px;margin:0 auto;} -.showgrid {background:url(src/grid.png);} -.column, div.span-1, div.span-2, div.span-3, div.span-4, div.span-5, div.span-6, div.span-7, div.span-8, div.span-9, div.span-10, div.span-11, div.span-12, div.span-13, div.span-14, div.span-15, div.span-16, div.span-17, div.span-18, div.span-19, div.span-20, div.span-21, div.span-22, div.span-23, div.span-24 {float:left;margin-right:10px;} -.last, div.last {margin-right:0;} -.span-1 {width:30px;} -.span-2 {width:70px;} -.span-3 {width:110px;} -.span-4 {width:150px;} -.span-5 {width:190px;} -.span-6 {width:230px;} -.span-7 {width:270px;} -.span-8 {width:310px;} -.span-9 {width:350px;} -.span-10 {width:390px;} -.span-11 {width:430px;} -.span-12 {width:470px;} -.span-13 {width:510px;} -.span-14 {width:550px;} -.span-15 {width:590px;} -.span-16 {width:630px;} -.span-17 {width:670px;} -.span-18 {width:710px;} -.span-19 {width:750px;} -.span-20 {width:790px;} -.span-21 {width:830px;} -.span-22 {width:870px;} -.span-23 {width:910px;} -.span-24, div.span-24 {width:950px;margin-right:0;} -input.span-1, textarea.span-1, input.span-2, textarea.span-2, input.span-3, textarea.span-3, input.span-4, textarea.span-4, input.span-5, textarea.span-5, input.span-6, textarea.span-6, input.span-7, textarea.span-7, input.span-8, textarea.span-8, input.span-9, textarea.span-9, input.span-10, textarea.span-10, input.span-11, textarea.span-11, input.span-12, textarea.span-12, input.span-13, textarea.span-13, input.span-14, textarea.span-14, input.span-15, textarea.span-15, input.span-16, textarea.span-16, input.span-17, textarea.span-17, input.span-18, textarea.span-18, input.span-19, textarea.span-19, input.span-20, textarea.span-20, input.span-21, textarea.span-21, input.span-22, textarea.span-22, input.span-23, textarea.span-23, input.span-24, textarea.span-24 {border-left-width:1px!important;border-right-width:1px!important;padding-left:5px!important;padding-right:5px!important;} -input.span-1, textarea.span-1 {width:18px!important;} -input.span-2, textarea.span-2 {width:58px!important;} -input.span-3, textarea.span-3 {width:98px!important;} -input.span-4, textarea.span-4 {width:138px!important;} -input.span-5, textarea.span-5 {width:178px!important;} -input.span-6, textarea.span-6 {width:218px!important;} -input.span-7, textarea.span-7 {width:258px!important;} -input.span-8, textarea.span-8 {width:298px!important;} -input.span-9, textarea.span-9 {width:338px!important;} -input.span-10, textarea.span-10 {width:378px!important;} -input.span-11, textarea.span-11 {width:418px!important;} -input.span-12, textarea.span-12 {width:458px!important;} -input.span-13, textarea.span-13 {width:498px!important;} -input.span-14, textarea.span-14 {width:538px!important;} -input.span-15, textarea.span-15 {width:578px!important;} -input.span-16, textarea.span-16 {width:618px!important;} -input.span-17, textarea.span-17 {width:658px!important;} -input.span-18, textarea.span-18 {width:698px!important;} -input.span-19, textarea.span-19 {width:738px!important;} -input.span-20, textarea.span-20 {width:778px!important;} -input.span-21, textarea.span-21 {width:818px!important;} -input.span-22, textarea.span-22 {width:858px!important;} -input.span-23, textarea.span-23 {width:898px!important;} -input.span-24, textarea.span-24 {width:938px!important;} -.append-1 {padding-right:40px;} -.append-2 {padding-right:80px;} -.append-3 {padding-right:120px;} -.append-4 {padding-right:160px;} -.append-5 {padding-right:200px;} -.append-6 {padding-right:240px;} -.append-7 {padding-right:280px;} -.append-8 {padding-right:320px;} -.append-9 {padding-right:360px;} -.append-10 {padding-right:400px;} -.append-11 {padding-right:440px;} -.append-12 {padding-right:480px;} -.append-13 {padding-right:520px;} -.append-14 {padding-right:560px;} -.append-15 {padding-right:600px;} -.append-16 {padding-right:640px;} -.append-17 {padding-right:680px;} -.append-18 {padding-right:720px;} -.append-19 {padding-right:760px;} -.append-20 {padding-right:800px;} -.append-21 {padding-right:840px;} -.append-22 {padding-right:880px;} -.append-23 {padding-right:920px;} -.prepend-1 {padding-left:40px;} -.prepend-2 {padding-left:80px;} -.prepend-3 {padding-left:120px;} -.prepend-4 {padding-left:160px;} -.prepend-5 {padding-left:200px;} -.prepend-6 {padding-left:240px;} -.prepend-7 {padding-left:280px;} -.prepend-8 {padding-left:320px;} -.prepend-9 {padding-left:360px;} -.prepend-10 {padding-left:400px;} -.prepend-11 {padding-left:440px;} -.prepend-12 {padding-left:480px;} -.prepend-13 {padding-left:520px;} -.prepend-14 {padding-left:560px;} -.prepend-15 {padding-left:600px;} -.prepend-16 {padding-left:640px;} -.prepend-17 {padding-left:680px;} -.prepend-18 {padding-left:720px;} -.prepend-19 {padding-left:760px;} -.prepend-20 {padding-left:800px;} -.prepend-21 {padding-left:840px;} -.prepend-22 {padding-left:880px;} -.prepend-23 {padding-left:920px;} -div.border {padding-right:4px;margin-right:5px;border-right:1px solid #eee;} -div.colborder {padding-right:24px;margin-right:25px;border-right:1px solid #eee;} -.pull-1 {margin-left:-40px;} -.pull-2 {margin-left:-80px;} -.pull-3 {margin-left:-120px;} -.pull-4 {margin-left:-160px;} -.pull-5 {margin-left:-200px;} -.pull-6 {margin-left:-240px;} -.pull-7 {margin-left:-280px;} -.pull-8 {margin-left:-320px;} -.pull-9 {margin-left:-360px;} -.pull-10 {margin-left:-400px;} -.pull-11 {margin-left:-440px;} -.pull-12 {margin-left:-480px;} -.pull-13 {margin-left:-520px;} -.pull-14 {margin-left:-560px;} -.pull-15 {margin-left:-600px;} -.pull-16 {margin-left:-640px;} -.pull-17 {margin-left:-680px;} -.pull-18 {margin-left:-720px;} -.pull-19 {margin-left:-760px;} -.pull-20 {margin-left:-800px;} -.pull-21 {margin-left:-840px;} -.pull-22 {margin-left:-880px;} -.pull-23 {margin-left:-920px;} -.pull-24 {margin-left:-960px;} -.pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;} -.push-1 {margin:0 -40px 1.5em 40px;} -.push-2 {margin:0 -80px 1.5em 80px;} -.push-3 {margin:0 -120px 1.5em 120px;} -.push-4 {margin:0 -160px 1.5em 160px;} -.push-5 {margin:0 -200px 1.5em 200px;} -.push-6 {margin:0 -240px 1.5em 240px;} -.push-7 {margin:0 -280px 1.5em 280px;} -.push-8 {margin:0 -320px 1.5em 320px;} -.push-9 {margin:0 -360px 1.5em 360px;} -.push-10 {margin:0 -400px 1.5em 400px;} -.push-11 {margin:0 -440px 1.5em 440px;} -.push-12 {margin:0 -480px 1.5em 480px;} -.push-13 {margin:0 -520px 1.5em 520px;} -.push-14 {margin:0 -560px 1.5em 560px;} -.push-15 {margin:0 -600px 1.5em 600px;} -.push-16 {margin:0 -640px 1.5em 640px;} -.push-17 {margin:0 -680px 1.5em 680px;} -.push-18 {margin:0 -720px 1.5em 720px;} -.push-19 {margin:0 -760px 1.5em 760px;} -.push-20 {margin:0 -800px 1.5em 800px;} -.push-21 {margin:0 -840px 1.5em 840px;} -.push-22 {margin:0 -880px 1.5em 880px;} -.push-23 {margin:0 -920px 1.5em 920px;} -.push-24 {margin:0 -960px 1.5em 960px;} -.push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;} -.prepend-top {margin-top:1.5em;} -.append-bottom {margin-bottom:1.5em;} -.box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;} -hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;} -hr.space {background:#fff;color:#fff;visibility:hidden;} -.clearfix:after, .container:after {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;} -.clearfix, .container {display:block;} -.clear {clear:both;} \ No newline at end of file diff --git a/tm2o/src/main/webapp/resources/css/tmlabbanner.css b/tm2o/src/main/webapp/resources/css/tmlabbanner.css deleted file mode 100644 index b58b8d8..0000000 --- a/tm2o/src/main/webapp/resources/css/tmlabbanner.css +++ /dev/null @@ -1,16 +0,0 @@ -#sideLabel { - position: fixed; - right: 0px; - bottom: 50px; - display: block; - background: url("../images/sidelabel_right.png") no-repeat scroll; - text-indent: 40000px; - width: 24px; - height: 181px; - z-index: 100001; -} - -#sideLabelLink { - text-decoration: none; -} - \ No newline at end of file diff --git a/tm2o/src/main/webapp/resources/images/content-top-background.gif b/tm2o/src/main/webapp/resources/images/content-top-background.gif deleted file mode 100644 index e4c362c..0000000 Binary files a/tm2o/src/main/webapp/resources/images/content-top-background.gif and /dev/null differ diff --git a/tm2o/src/main/webapp/resources/images/footer-background.gif b/tm2o/src/main/webapp/resources/images/footer-background.gif deleted file mode 100644 index 880d424..0000000 Binary files a/tm2o/src/main/webapp/resources/images/footer-background.gif and /dev/null differ diff --git a/tm2o/src/main/webapp/resources/images/header-background.png b/tm2o/src/main/webapp/resources/images/header-background.png deleted file mode 100644 index c51aca5..0000000 Binary files a/tm2o/src/main/webapp/resources/images/header-background.png and /dev/null differ diff --git a/tm2o/src/main/webapp/resources/images/maiana-logo.png b/tm2o/src/main/webapp/resources/images/maiana-logo.png deleted file mode 100644 index 515c16d..0000000 Binary files a/tm2o/src/main/webapp/resources/images/maiana-logo.png and /dev/null differ diff --git a/tm2o/src/main/webapp/resources/images/odata.png b/tm2o/src/main/webapp/resources/images/odata.png deleted file mode 100644 index 2f86c15..0000000 Binary files a/tm2o/src/main/webapp/resources/images/odata.png and /dev/null differ diff --git a/tm2o/src/main/webapp/resources/images/spacer.gif b/tm2o/src/main/webapp/resources/images/spacer.gif deleted file mode 100644 index 1e52e19..0000000 Binary files a/tm2o/src/main/webapp/resources/images/spacer.gif and /dev/null differ diff --git a/tm2o/src/main/webapp/services.jsp b/tm2o/src/main/webapp/services.jsp deleted file mode 100644 index d6fffa1..0000000 --- a/tm2o/src/main/webapp/services.jsp +++ /dev/null @@ -1,105 +0,0 @@ -<%@page import="java.util.Map.Entry"%> -<%@page import="java.util.Map"%> -<%@page import="de.topicmapslab.odata.web.IOUtis"%> -<%@page import="de.topicmapslab.odata.content.memory.MemoryOdataContentProvider"%> -<%@page import="de.topicmapslab.odata.TopicMapODataProducerFactory"%> -<%@page import="de.topicmapslab.odata.TopicMapODataProducer"%> -<%@page import="de.topicmapslab.odata.TopicMapMetadata"%> -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - - - - - -OData services - - -
- -
  -

TM2O

-This services exposes Topic Maps data as Odata. The Open Data Protocol (OData) is a Web protocol for querying (and updating) data that provides a way to unlock the data and free it from silos that exist in applications today. -Usually the topic maps exposed by this service as OData are managed by an external MaJorToM Server , but can also be stored locally in this service. You will find a list of OData consumers here. -
-

Available Services

-<% - TopicMapODataProducer producer = TopicMapODataProducerFactory.getProducerInstance(); - TopicMapMetadata mt = producer.getService(); - boolean local = MemoryOdataContentProvider.class.isAssignableFrom(mt.getContentProviderClass()); - - if ( local ){ -%> - ">Local OData Service<%=mt.isLoadedService("local")?"(loaded)":"(not loaded)" %> -<% - }else{ - Object serverAddress = mt.getProperties().get("server"); - Object apiKey = mt.getProperties().get("api-key"); - if ( serverAddress != null && apiKey != null ){ - Map tms = IOUtis.getTopicMapIds(serverAddress.toString(),apiKey.toString()); - if ( tms == null ){ -%> - The MaJorToM server does not response to any request. -<% - }else if ( tms.isEmpty()){ - %> - No topic maps created yet, go to ">administration interface to upload a new file! - <% - }else{ - for ( Entry tm : tms.entrySet()){ - String topicMapId = tm.getValue(); - String topicMapLocator = tm.getKey(); - String url = getServletContext().getContextPath() + "/odata.svc/" + topicMapId; -%> - OData Service of "<%= topicMapLocator %>" <%=mt.isLoadedService(topicMapId)?"(loaded)":"(not loaded)" %>
-<% - } -%> -
- Go to ">administration interface to upload a new topic map! -<% - - } - }else{ -%> - Missing <%=serverAddress==null?"server address":"API key"%> for remote content provider! -<% - } - - } -%> -
-

TM2O Configuration

-You can configure your TM2O service "> here
-
- -
- - \ No newline at end of file