diff --git a/artemis_sqlmap/Cvterm.xml b/artemis_sqlmap/Cvterm.xml new file mode 100644 index 0000000000000000000000000000000000000000..3bb8526a4c44a817a0579f9f8cb8e6d524edf961 --- /dev/null +++ b/artemis_sqlmap/Cvterm.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!DOCTYPE sqlMap + PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" + "http://ibatis.apache.org/dtd/sql-map-2.dtd"> + + +<sqlMap namespace="Cvterm"> + + <resultMap id="select-cvterm-names-result" class="uk.ac.sanger.ibatis.Cvterm"> + <result property="id" column="cvterm_id"/> + <result property="name" column="name"/> + </resultMap> + + <!-- look up cvterms names and id --> + <select id="getCvterm" resultMap="select-cvterm-names-result"> + SELECT + cvterm.CVTERM_ID, cvterm.NAME + FROM cvterm, cv WHERE cv.cv_id = cvterm.cv_id + </select> + +</sqlMap> diff --git a/artemis_sqlmap/Feature.xml b/artemis_sqlmap/Feature.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa91e9122a722ca8a382c246ff1293db2ab849a4 --- /dev/null +++ b/artemis_sqlmap/Feature.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!DOCTYPE sqlMap + PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" + "http://ibatis.apache.org/dtd/sql-map-2.dtd"> + + +<sqlMap namespace="Feature"> + + <resultMap id="select-feature-properties-result" class="uk.ac.sanger.ibatis.Feature"> + <result property="timelastmodified" column="timelastmodified"/> + <result property="id" column="id"/> + <result property="object_id" column="object_id"/> + <result property="strand" column="strand"/> + <result property="fmin" column="fmin"/> + <result property="fmax" column="fmax"/> + <result property="uniquename" column="uniquename"/> + <result property="type_id" column="type_id"/> + <result property="prop_type_id" column="prop_type_id"/> + <result property="value" column="value"/> + </resultMap> + + <resultMap id="select-feature-sequence-result" class="uk.ac.sanger.ibatis.Feature"> + <result property="name" column="name"/> + <result property="residues" column="residues"/> + </resultMap> + + <resultMap id="select-feature-with-residues-result" class="uk.ac.sanger.ibatis.Feature"> + <result property="abbreviation" column="abbreviation"/> + <result property="name" column="name"/> + <result property="id" column="feature_id"/> + <result property="type_id" column="type_id"/> + </resultMap> + + <!-- get feature name --> + <select id="getFeatureName" parameterClass="java.lang.String" resultClass="java.lang.String"> + SELECT + name + FROM feature WHERE feature_id=#value# + </select> + + <select id="getGffLine" parameterClass="int" resultMap="select-feature-properties-result"> + SELECT + timelastmodified, + feature.feature_id AS id, + object_id, + strand, + fmin, + fmax, + uniquename, + feature.type_id AS type_id, + featureprop.type_id AS prop_type_id, + featureprop.value AS value + FROM featureloc, feature + LEFT JOIN feature_relationship ON feature_relationship.subject_id=feature.feature_id + LEFT JOIN featureprop ON featureprop.feature_id=feature.feature_id + WHERE srcfeature_id=#value# and featureloc.feature_id=feature.feature_id + and (featureloc.rank=feature_relationship.rank OR feature_relationship.rank IS NULL) + ORDER BY feature.type_id, uniquename + </select> + + <select id="getSequence" parameterClass="int" resultMap="select-feature-sequence-result"> + SELECT + name, + residues + FROM feature + WHERE feature_id=#value# + </select> + + <select id="getResidueType" resultClass="java.lang.String"> + SELECT DISTINCT type_id FROM feature WHERE residues notnull + </select> + + <select id="getResidueFeatures" parameterClass="java.util.List" resultMap="select-feature-with-residues-result"> + SELECT + abbreviation, + name, + feature_id, + type_id + FROM organism, feature WHERE + organism.organism_id=feature.organism_id AND + residues notnull + <iterate prepend="AND" conjunction="OR" open="(" close=")"> + type_id=#[]# + </iterate> + ORDER BY abbreviation + </select> +</sqlMap> diff --git a/artemis_sqlmap/Organism.xml b/artemis_sqlmap/Organism.xml new file mode 100644 index 0000000000000000000000000000000000000000..5fe0a3e0a8c306b704898905888b906b48b0cffb --- /dev/null +++ b/artemis_sqlmap/Organism.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!DOCTYPE sqlMap + PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" + "http://ibatis.apache.org/dtd/sql-map-2.dtd"> + +<sqlMap namespace="Organism"> + + <!-- Use primitive wrapper type (e.g. Integer) as parameter and allow results to + be auto-mapped results to Organism object (JavaBean) properties --> + <select id="getOrganism" parameterClass="java.lang.String" resultClass="uk.ac.sanger.ibatis.Organism"> + SELECT + ORGANISM_ID as id, + ABBREVIATION, + GENUS, + SPECIES, + COMMON_NAME, + COMMENT + FROM Organism WHERE COMMON_NAME = #value# + </select> + +</sqlMap> diff --git a/artemis_sqlmap/chado_iBatis_config.properties b/artemis_sqlmap/chado_iBatis_config.properties new file mode 100644 index 0000000000000000000000000000000000000000..f1f289fc28fa76bd3727a78b33a6270790ef4906 --- /dev/null +++ b/artemis_sqlmap/chado_iBatis_config.properties @@ -0,0 +1,9 @@ +# This is just a simple properties file that simplifies automated configuration +# of the SQL Maps configuration file (e.g. by Ant builds or continuous +# integration tools for different environments... etc.) +# These values can be used in any property value in the file above (e.g. ${driver}) +# Using a properties file such as this is completely optional. + +driver=org.postgresql.Driver +url=jdbc:postgresql://localhost:2999/test +username=tjc diff --git a/artemis_sqlmap/chado_iBatis_config.xml b/artemis_sqlmap/chado_iBatis_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..8294f0c0ad53f001725924f04ebd475f5953574e --- /dev/null +++ b/artemis_sqlmap/chado_iBatis_config.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!DOCTYPE sqlMapConfig + PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" + "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> + +<!-- Always ensure to use the correct XML header as above! --> + +<sqlMapConfig> + + <!-- The properties (name=value) in the file specified here can be used placeholders in this config + file (e.g. ${driver}. The file is usually relative to the classpath and is optional. --> + + <!-- + <properties resource="artemis_sqlmap/chado_iBatis_config.properties" /> + --> + + <!-- These settings control SqlMap configuration details, primarily to do with transaction + management. They are all optional (see the Developer Guide for more). --> + + <settings + cacheModelsEnabled="true" + enhancementEnabled="true" + lazyLoadingEnabled="true" + maxRequests="32" + maxSessions="10" + maxTransactions="5" + useStatementNamespaces="false" + /> + + <!-- Type aliases allow you to use a shorter name for long fully qualified class names. --> + + <typeAlias alias="order" type="testdomain.Order"/> + + <!-- Configure a datasource to use with this SQL Map using SimpleDataSource. + Notice the use of the properties from the above resource --> + + <transactionManager type="JDBC" > + <dataSource type="SIMPLE"> + <property name="JDBC.Driver" value="org.postgresql.Driver"/> + <property name="JDBC.ConnectionURL" value="jdbc:postgresql://${chado}"/> + <property name="JDBC.Username" value="${username}"/> + <property name="JDBC.Password" value="${password}"/> + </dataSource> + </transactionManager> + + <!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice the paths + are relative to the classpath. For now, we only have one... --> + + <sqlMap resource="artemis_sqlmap/Organism.xml" /> + <sqlMap resource="artemis_sqlmap/Cvterm.xml" /> + <sqlMap resource="artemis_sqlmap/Feature.xml" /> + +</sqlMapConfig> +