dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09528
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2551: Added the api and services for DataElement Target
------------------------------------------------------------
revno: 2551
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2011-01-13 12:36:44 +0530
message:
Added the api and services for DataElement Target
added:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetMember.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetStore.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValue.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueStore.java
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/
local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTarget.hbm.xml
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetDataValue.hbm.xml
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetMember.hbm.xml
modified:
local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget'
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.source.Source;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTarget.java Jan 11, 2011 4:13:29 PM
+ */
+@SuppressWarnings("serial")
+public class DeTarget implements Serializable
+{
+ /**
+ * The unique identifier for this DataElement Target.
+ */
+ private int id;
+
+ /**
+ * The name of this DataElement Target. Required and unique.
+ */
+ private String name;
+
+ /**
+ * Short name of DataElement Target. Required and unique.
+ */
+ private String shortName;
+
+ /**
+ * All DataElements associated with this DataElement Target.
+ */
+ // private Collection<DataElement> dataelements = new HashSet<DataElement>();
+
+ /**
+ * All DataElement Category Option Combo associated with this DataElement Target.
+ */
+ //private Collection<DataElementCategoryOptionCombo> decategoryOptionCombo = new HashSet<DataElementCategoryOptionCombo>();
+
+
+ /**
+ * All Sources that register data with this DataElement Target.
+ */
+ private Set<Source> sources = new HashSet<Source>();
+
+ /**
+ * Description of this DataElement Target.
+ */
+ private String description;
+
+ /**
+ * URL for lookup of additional information of DataElement Target on the web.
+ */
+ private String url;
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public DeTarget()
+ {
+ }
+
+ public DeTarget( String name, String shortName )
+ {
+ this.name = name;
+ this.shortName = shortName;
+ }
+
+ public DeTarget( String name, String shortName, String url, String description )
+ {
+ this.name = name;
+ this.shortName = shortName;
+ this.url = url;
+ this.description = description;
+ }
+
+ // -------------------------------------------------------------------------
+ // hashCode, equals and toString
+ // -------------------------------------------------------------------------
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null )
+ {
+ return false;
+ }
+
+ if ( !(o instanceof DeTarget) )
+ {
+ return false;
+ }
+
+ final DeTarget other = (DeTarget) o;
+
+ return name.equals( other.getName() );
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + name + "]";
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getShortName()
+ {
+ return shortName;
+ }
+
+ public void setShortName( String shortName )
+ {
+ this.shortName = shortName;
+ }
+/*
+ public Collection<DataElement> getDataelements()
+ {
+ return dataelements;
+ }
+
+ public void setDataelements( Collection<DataElement> dataelements )
+ {
+ this.dataelements = dataelements;
+ }
+
+ public Collection<DataElementCategoryOptionCombo> getDecategoryOptionCombo()
+ {
+ return decategoryOptionCombo;
+ }
+
+ public void setDecategoryOptionCombo( Collection<DataElementCategoryOptionCombo> decategoryOptionCombo )
+ {
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ }
+*/
+ public Set<Source> getSources()
+ {
+ return sources;
+ }
+
+ public void setSources( Set<Source> sources )
+ {
+ this.sources = sources;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+}
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetMember.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetMember.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetMember.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget;
+
+import java.io.Serializable;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetMember.java Jan 12, 2011 10:52:22 AM
+ */
+@SuppressWarnings("serial")
+public class DeTargetMember implements Serializable
+{
+ /**
+ * Part of the DeTarget's composite ID
+ */
+ private DeTarget detarget;
+
+
+ /**
+ * All DataElements associated with this DataElement Target.
+ */
+ // private Collection<DataElement> dataelements = new HashSet<DataElement>();
+ private DataElement dataelements;
+
+ /**
+ * All DataElement Category Option Combo associated with this DataElement Target.
+ */
+ // private Collection<DataElementCategoryOptionCombo> decategoryOptionCombo = new HashSet<DataElementCategoryOptionCombo>();
+ private DataElementCategoryOptionCombo decategoryOptionCombo;
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public DeTargetMember()
+ {
+ }
+
+ public DeTargetMember( DeTarget detarget,DataElement dataelements, DataElementCategoryOptionCombo decategoryOptionCombo )
+ {
+ this.detarget = detarget;
+ this.dataelements = dataelements;
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ }
+
+ // -------------------------------------------------------------------------
+ // hashCode, equals and toString
+ // -------------------------------------------------------------------------
+/*
+ @Override
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+ */
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null )
+ {
+ return false;
+ }
+
+ if ( !(o instanceof DeTargetMember) )
+ {
+ return false;
+ }
+
+ final DeTargetMember other = ( DeTargetMember ) o;
+ return detarget.equals( other.getDetarget() ) && dataelements.equals( other.getDataelements() )
+ && decategoryOptionCombo.equals( other.getDecategoryOptionCombo() );
+ }
+
+ /*
+ public String toString()
+ {
+ return "[" + name + "]";
+ }
+ */
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
+
+
+/*
+ public Collection<DataElement> getDataelements()
+ {
+ return dataelements;
+ }
+
+ public void setDataelements( Collection<DataElement> dataelements )
+ {
+ this.dataelements = dataelements;
+ }
+
+ public Collection<DataElementCategoryOptionCombo> getDecategoryOptionCombo()
+ {
+ return decategoryOptionCombo;
+ }
+
+ public void setDecategoryOptionCombo( Collection<DataElementCategoryOptionCombo> decategoryOptionCombo )
+ {
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ }
+*/
+ public DeTarget getDetarget()
+ {
+ return detarget;
+ }
+
+ public void setDetarget( DeTarget detarget )
+ {
+ this.detarget = detarget;
+ }
+
+
+ public DataElement getDataelements()
+ {
+ return dataelements;
+ }
+
+ public void setDataelements( DataElement dataelements )
+ {
+ this.dataelements = dataelements;
+ }
+
+ public DataElementCategoryOptionCombo getDecategoryOptionCombo()
+ {
+ return decategoryOptionCombo;
+ }
+
+ public void setDecategoryOptionCombo( DataElementCategoryOptionCombo decategoryOptionCombo )
+ {
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ }
+
+}
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetService.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.source.Source;
+
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetService.java Jan 12, 2011 12:46:10 PM
+ */
+public interface DeTargetService
+{
+ String ID = DeTargetService.class.getName();
+ // -------------------------------------------------------------------------
+ // DeTarget
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTarget.
+ *
+ * @param DeTarget The DeTarget to add.
+ * @return The generated unique identifier for this Survey.
+ */
+ int addDeTarget( DeTarget deTarget );
+
+ /**
+ * Updates a DeTarget.
+ *
+ * @param DeTarget The DeTarget to update.
+ */
+ void updateDeTarget( DeTarget deTarget );
+
+ /**
+ * Deletes a DeTarget.
+ *
+ * @param survey The Survey to delete.
+ */
+ int deleteDeTarget( DeTarget deTarget );
+
+ /**
+ * Get a DeTarget
+ *
+ * @param id The unique identifier for the DeTarget to get.
+ * @return The DeTarget with the given id or null if it does not exist.
+ */
+ DeTarget getDeTarget( int id );
+
+ /**
+ * Returns a DeTarget with the given name.
+ *
+ * @param name The name.
+ * @return A DeTarget with the given name.
+ */
+ DeTarget getDeTargetByName( String name );
+
+ /**
+ * Returns the DeTarget with the given short name.
+ *
+ * @param shortName The short name.
+ * @return The DeTarget with the given short name.
+ */
+ DeTarget getDeTargetByShortName( String shortName );
+
+ /**
+ * Returns all DeTarget associated with the specified source.
+ */
+ Collection<DeTarget> getDeTargetBySource( Source source );
+
+ /**
+ * Returns all DeTarget associated with the specified dataelement.
+ */
+ Collection<DeTarget> getDeTargetsByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+ /**
+ * Returns all DeTarget associated with the specified sources.
+ */
+ //Collection<DeTarget> getDeTargetsBySources( Collection<? extends Source> sources );
+
+ /**
+ * Returns the number of Sources among the specified Sources associated with
+ * the specified Survey.
+ */
+ // int getSourcesAssociatedWithDeTarget( DeTarget deTarget, Collection<? extends Source> sources );
+
+ /**
+ * Get all DeTargets.
+ *
+ * @return A collection containing all DeTargets.
+ */
+ Collection<DeTarget> getAllDeTargets();
+
+
+ // -------------------------------------------------------------------------
+ // DeTargetMember
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTargetMember.
+ *
+ * @param survey The DeTarget to add.
+ * @return The generated unique identifier for this DeTarget.
+ */
+ int addDeTargetMember( DeTargetMember deTargetMember );
+
+ /**
+ * Updates a DeTargetMember.
+ *
+ * @param DeTargetMember The DeTargetMember to update.
+ */
+ void updateDeTargetMember( DeTargetMember deTargetMember );
+
+ /**
+ * Deletes a DeTargetMember.
+ *
+ * @param DeTargetMember The DeTargetMember to delete.
+ */
+ int deleteDeTargetMember( DeTargetMember deTargetMember,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+ /**
+ * Returns Collection of DeTarget members.
+ *
+ * @return List of DeTarget
+ */
+ Collection<DeTargetMember> getDeTargetMembers( DeTarget deTarget );
+
+
+}
+
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetStore.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetStore.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTargetStore.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.source.Source;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetStore.java Jan 12, 2011 2:54:47 PM
+ */
+public interface DeTargetStore
+{
+ String ID = DeTargetStore.class.getName();
+
+ // -------------------------------------------------------------------------
+ // DeTraget
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTarget.
+ *
+ * @param survey The DeTarget to add.
+ * @return The generated unique identifier for this DeTarget.
+ */
+ int addDeTarget( DeTarget deTarget );
+
+ /**
+ * Updates a DeTarget.
+ *
+ * @param survey The DeTarget to update.
+ */
+ void updateDeTarget( DeTarget deTarget );
+
+ /**
+ * Deletes a DeTarget.
+ *
+ * @param DeTarget The DeTarget to delete.
+ */
+ int deleteDeTarget( DeTarget deTarget );
+
+ /**
+ * Get a DeTarget
+ *
+ * @param id The unique identifier for the DeTarget to get.
+ * @return The DeTarget with the given id or null if it does not exist.
+ */
+ DeTarget getDeTarget( int id );
+
+ /**
+ * Returns a DeTarget with the given name.
+ *
+ * @param name The name.
+ * @return A DeTarget with the given name.
+ */
+ DeTarget getDeTargetByName( String name );
+
+ /**
+ * Returns the DeTarget with the given short name.
+ *
+ * @param shortName The short name.
+ * @return The DeTarget with the given short name.
+ */
+ DeTarget getDeTargetByShortName( String shortName );
+
+ /**
+ * Returns all DeTarget associated with the specified source.
+ */
+ Collection<DeTarget> getDeTargetsBySource( Source source );
+
+ /**
+ * Returns all DeTarget associated with the specified indicator.
+ */
+ Collection<DeTarget> getDeTargetsByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+ /**
+ * Get all DeTargets.
+ *
+ * @return A collection containing all Surveys.
+ */
+ Collection<DeTarget> getAllDeTargets();
+
+
+
+
+ // -------------------------------------------------------------------------
+ // DeTargetMember
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTargetMember.
+ *
+ * @param survey The DeTarget to add.
+ * @return The generated unique identifier for this DeTarget.
+ */
+ int addDeTargetMember( DeTargetMember deTargetMember );
+
+ /**
+ * Updates a DeTargetMember.
+ *
+ * @param DeTargetMember The DeTargetMember to update.
+ */
+ void updateDeTargetMember( DeTargetMember deTargetMember );
+
+ /**
+ * Deletes a DeTargetMember.
+ *
+ * @param DeTargetMember The DeTargetMember to delete.
+ */
+ int deleteDeTargetMember( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+ /**
+ * Returns Collection of DeTarget members.
+ *
+ * @return List of DeTarget
+ */
+ Collection<DeTargetMember> getDeTargetMembers( DeTarget deTarget );
+
+}
=== added directory 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue'
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValue.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValue.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValue.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detargetdatavalue;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.detarget.DeTarget;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.source.Source;
+import org.hisp.dhis.surveydatavalue.SurveyDataValue;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetDataValue.java Jan 12, 2011 3:17:51 PM
+ */
+@SuppressWarnings("serial")
+public class DeTargetDataValue implements Serializable
+{
+
+ /**
+ * Part of the DeTargetDataValue's composite ID
+ */
+ private DeTarget deTarget;
+
+ /**
+ *
+ */
+ private DataElement dataelement;
+
+ private DataElementCategoryOptionCombo decategoryOptionCombo;
+
+ /**
+ * Part of the DeTargetDataValue's composite ID
+ */
+ private Source source;
+
+ /**
+ *
+ */
+ private Period period;
+
+ /**
+ *
+ */
+ private String value;
+
+ /**
+ *
+ */
+ private String storedBy;
+
+ /**
+ *
+ */
+ private Date timestamp;
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public DeTargetDataValue()
+ {
+ }
+
+ public DeTargetDataValue( DeTarget deTarget, DataElement dataelement, DataElementCategoryOptionCombo decategoryOptionCombo, Source source, Period period, String value )
+ {
+ this.deTarget = deTarget;
+ this.dataelement = dataelement;
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ this.source = source;
+ this.period = period;
+ this.value = value;
+ }
+
+ public DeTargetDataValue( DeTarget deTarget, DataElement dataelement, DataElementCategoryOptionCombo decategoryOptionCombo, Source source, Period period ,String value, String storedBy,Date timestamp )
+ {
+ this.deTarget = deTarget;
+ this.dataelement = dataelement;
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ this.source = source;
+ this.period = period;
+ this.value = value;
+ this.storedBy = storedBy;
+ this.timestamp = timestamp;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // hashCode and equals
+ // -------------------------------------------------------------------------
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( o == null )
+ {
+ return false;
+ }
+
+ if ( !(o instanceof SurveyDataValue) )
+ {
+ return false;
+ }
+
+ final DeTargetDataValue other = (DeTargetDataValue) o;
+
+ return deTarget.equals( other.getDeTarget() ) && source.equals( other.getSource() );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+
+ result = result * prime + deTarget.hashCode();
+ result = result * prime + source.hashCode();
+
+ return result;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
+ public DeTarget getDeTarget()
+ {
+ return deTarget;
+ }
+
+ public void setDeTarget( DeTarget deTarget )
+ {
+ this.deTarget = deTarget;
+ }
+
+ public DataElement getDataelement()
+ {
+ return dataelement;
+ }
+
+ public void setDataelement( DataElement dataelement )
+ {
+ this.dataelement = dataelement;
+ }
+
+ public DataElementCategoryOptionCombo getDecategoryOptionCombo()
+ {
+ return decategoryOptionCombo;
+ }
+
+ public void setDecategoryOptionCombo( DataElementCategoryOptionCombo decategoryOptionCombo )
+ {
+ this.decategoryOptionCombo = decategoryOptionCombo;
+ }
+
+ public Source getSource()
+ {
+ return source;
+ }
+
+ public void setSource( Source source )
+ {
+ this.source = source;
+ }
+
+ public Period getPeriod()
+ {
+ return period;
+ }
+
+ public void setPeriodId( Period period )
+ {
+ this.period = period;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public void setStoredBy( String storedBy )
+ {
+ this.storedBy = storedBy;
+ }
+
+ public Date getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp( Date timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+
+
+}
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueService.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detargetdatavalue;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.detarget.DeTarget;
+import org.hisp.dhis.detarget.DeTargetMember;
+import org.hisp.dhis.source.Source;
+
+
+
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetDataValueService.java Jan 12, 2011 3:40:36 PM
+ */
+public interface DeTargetDataValueService
+{
+
+ String ID = DeTargetDataValueService.class.getName();
+
+ // -------------------------------------------------------------------------
+ // Basic DeTargetDataValue
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTargetDataValue. If both the value and the comment properties of the
+ * specified DeTargetDataValue object are null, then the object should not be
+ * persisted.
+ *
+ * @param DeTargetDataValue the DeTargetDataValue to add.
+ */
+ void addDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Updates a DeTargetDataValue. If both the value and the comment properties of the
+ * specified DeTargetDataValue object are null, then the object should be deleted
+ * from the underlying storage.
+ *
+ * @param DeTargetDataValue the SurveyDataValue to update.
+ */
+ void updateDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Deletes a DeTargetDataValue.
+ *
+ * @param DeTargetDataValue the DeTargetDataValue to delete.
+ */
+ void deleteDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Deletes all DeTargetDataValue connected to a Source.
+ *
+ * @param source the Source for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesBySource( Source source );
+
+ /**
+ * Deletes all DeTargetDataValue registered for the given DeTarget.
+ *
+ * @param dataElement the Survey for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesByDeTarget( DeTarget deTarget );
+
+ /**
+ * Deletes all DeTargetDataValue registered for the given Survey.
+ *
+ * @param dataElement the DeTarget for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+ int deleteDeTargetDataValuesByDeTargetDataElementCategoryOptionComboAndSource( DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo, Source source );
+
+ /**
+ * Returns a DeTargetDataValue.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return the DeTargetDataValue which corresponds to the given parameters, or null
+ * if no match.
+ */
+ DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget );
+
+ // -------------------------------------------------------------------------
+ // Collections of DataValues
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns all DeTargetDataValue.
+ *
+ * @return a collection of all DeTargetDataValue.
+ */
+ Collection<DeTargetDataValue> getAllDeTargetDataValues();
+
+ /**
+ * Returns all DeTargetDataValue for a given Source.
+ *
+ * @param period the Period of the DataValues.
+ * @return a collection of all DeTargetDataValue which match the given Source
+ * or an empty collection if no values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source );
+
+ /**
+ * Returns all DeTargetDataValue for a given Source and DeTarget.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given Source and
+ * DeTarget, or an empty collection if no values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source, DeTarget deTarget );
+
+ /**
+ * Returns all SurveyDataValues for a given collection of Sources and a
+ * Survey.
+ *
+ * @param sources the Sources of the SurveyDataValues.
+ * @param survey the Survey of the SurveyDataValues.
+ * @return a collection of all SurveyDataValues which match any of the given
+ * Sources and the Survey, or an empty collection if no values
+ * match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Collection<Source> sources, DeTarget deTarget );
+
+ /**
+ * Returns all DeTargetDataValue for a given Source, and collection of
+ * Surveys.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param period the Period of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given Source
+ * and any of the DeTarget, or an empty collection if no
+ * values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source, Collection<DeTarget> deTargets );
+
+ /**
+ * Returns all DataValues for a given DataElement, Period, and collection of
+ * Sources.
+ *
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @param period the Period of the DeTargetDataValue.
+ * @param sources the Sources of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given DeTarget,
+ * and Sources.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget, Collection<? extends Source> sources );
+
+ /**
+ * Returns all DataValues for a given collection of DataElements, collection of Periods, and
+ * collection of Sources, limited by a given start indexs and number of elements to return.
+ *
+ * @param deTargets the DeTarget of the DeTargetDataValue.
+ * @param sources the Sources of the DeTargetDataValue.
+ * @param firstResult the zero-based index of the first DataValue in the collection to return.
+ * @param maxResults the maximum number of SurveyDataValues to return. 0 means no restrictions.
+ * @return a collection of all DeTargetDataValue which match the given collection of DeTarget,
+ * and Sources, limited by the firstResult and maxResults property.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Collection<DeTarget> deTargets, Collection<? extends Source> sources, int firstResult, int maxResults );
+
+ /**
+ * Returns all DeTargetDataValue for a given collection of DeTarget.
+ *
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which mach the given collection of DeTarget.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget );
+
+ Collection<DeTargetDataValue> getDeTargetMemberDataValues( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo decategoryOptionCombo );
+
+
+ /**
+ *
+ * @param organisationUnit
+ * @param deTarget
+ * @param dataelement
+ * * @param deoptioncombo
+ * @return
+ */
+ DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+}
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueStore.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueStore.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detargetdatavalue/DeTargetDataValueStore.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detargetdatavalue;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.detarget.DeTarget;
+import org.hisp.dhis.source.Source;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DeTargetDataValueStore.java Jan 12, 2011 3:41:29 PM
+ */
+public interface DeTargetDataValueStore
+{
+ String ID = DeTargetDataValueStore.class.getName();
+
+ // -------------------------------------------------------------------------
+ // Basic DeTargetDataValue
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a DeTargetDataValue. If both the value and the comment properties of the
+ * specified DeTargetDataValue object are null, then the object should not be
+ * persisted.
+ *
+ * @param DeTargetDataValue the DeTargetDataValue to add.
+ */
+ void addDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Updates a DeTargetDataValue. If both the value and the comment properties of the
+ * specified DeTargetDataValue object are null, then the object should be deleted
+ * from the underlying storage.
+ *
+ * @param DeTargetDataValue the SurveyDataValue to update.
+ */
+ void updateDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Deletes a DeTargetDataValue.
+ *
+ * @param DeTargetDataValue the DeTargetDataValue to delete.
+ */
+ void deleteDeTargetDataValue( DeTargetDataValue deTargetDataValue );
+
+ /**
+ * Deletes all DeTargetDataValue connected to a Source.
+ *
+ * @param source the Source for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesBySource( Source source );
+
+ /**
+ * Deletes all DeTargetDataValue registered for the given DeTarget.
+ *
+ * @param dataElement the Survey for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesByDeTarget( DeTarget deTarget );
+
+ /**
+ * Deletes all DeTargetDataValue registered for the given Survey.
+ *
+ * @param dataElement the DeTarget for which the DeTargetDataValue should be deleted.
+ * @return the number of deleted DeTargetDataValue.
+ */
+ int deleteDeTargetDataValuesByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+ int deleteDeTargetDataValuesByDeTargetDataElementCategoryOptionComboAndSource( DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo, Source source );
+
+ /**
+ * Returns a DeTargetDataValue.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return the DeTargetDataValue which corresponds to the given parameters, or null
+ * if no match.
+ */
+ DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget );
+
+ // -------------------------------------------------------------------------
+ // Collections of DataValues
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns all DeTargetDataValue.
+ *
+ * @return a collection of all DeTargetDataValue.
+ */
+ Collection<DeTargetDataValue> getAllDeTargetDataValues();
+
+ /**
+ * Returns all DeTargetDataValue for a given Source.
+ *
+ * @param period the Period of the DataValues.
+ * @return a collection of all DeTargetDataValue which match the given Source
+ * or an empty collection if no values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source );
+
+ /**
+ * Returns all DeTargetDataValue for a given Source and DeTarget.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given Source and
+ * DeTarget, or an empty collection if no values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source, DeTarget deTarget );
+
+ /**
+ * Returns all DeTargetDataValue for a given collection of Sources and a
+ * DeTarget.
+ *
+ * @param sources the Sources of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match any of the given
+ * Sources and the Survey, or an empty collection if no values
+ * match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Collection<Source> sources, DeTarget deTarget );
+
+ /**
+ * Returns all DeTargetDataValue for a given Source, and collection of
+ * Surveys.
+ *
+ * @param source the Source of the DeTargetDataValue.
+ * @param period the Period of the DeTargetDataValue.
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given Source
+ * and any of the DeTarget, or an empty collection if no
+ * values match.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Source source, Collection<DeTarget> deTargets );
+
+ /**
+ * Returns all DataValues for a given DataElement, Period, and collection of
+ * Sources.
+ *
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @param period the Period of the DeTargetDataValue.
+ * @param sources the Sources of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which match the given DeTarget,
+ * and Sources.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget, Collection<? extends Source> sources );
+
+ /**
+ * Returns all DataValues for a given collection of DataElements, collection of Periods, and
+ * collection of Sources, limited by a given start indexs and number of elements to return.
+ *
+ * @param deTargets the DeTarget of the DeTargetDataValue.
+ * @param sources the Sources of the DeTargetDataValue.
+ * @param firstResult the zero-based index of the first DataValue in the collection to return.
+ * @param maxResults the maximum number of SurveyDataValues to return. 0 means no restrictions.
+ * @return a collection of all DeTargetDataValue which match the given collection of DeTarget,
+ * and Sources, limited by the firstResult and maxResults property.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( Collection<DeTarget> deTargets, Collection<? extends Source> sources, int firstResult, int maxResults );
+
+ /**
+ * Returns all DeTargetDataValue for a given collection of DeTarget.
+ *
+ * @param deTarget the DeTarget of the DeTargetDataValue.
+ * @return a collection of all DeTargetDataValue which mach the given collection of DeTarget.
+ */
+ Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget );
+
+
+ /**
+ *
+ * @param organisationUnit
+ * @param deTarget
+ * @param dataelement
+ * * @param deoptioncombo
+ * @return
+ */
+ DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo );
+
+}
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget'
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.source.Source;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DefaultDeTargetService.java Jan 13, 2011 10:34:54 AM
+ */
+public class DefaultDeTargetService implements DeTargetService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DeTargetStore deTargetStore;
+
+ public void setDeTargetStore( DeTargetStore deTargetStore )
+ {
+ this.deTargetStore = deTargetStore;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeTarget
+ // -------------------------------------------------------------------------
+
+ public int addDeTarget( DeTarget deTarget )
+ {
+ return deTargetStore.addDeTarget( deTarget );
+ }
+
+ public void updateDeTarget( DeTarget deTarget )
+ {
+ deTargetStore.updateDeTarget( deTarget );
+ }
+
+ public int deleteDeTarget( DeTarget deTarget )
+ {
+ return deTargetStore.deleteDeTarget( deTarget );
+ }
+
+ public DeTarget getDeTarget( int id )
+ {
+ return deTargetStore.getDeTarget( id );
+ }
+
+
+ public DeTarget getDeTargetByName( String name )
+ {
+ return deTargetStore.getDeTargetByName( name );
+ }
+
+ public DeTarget getDeTargetByShortName( String shortName )
+ {
+ return deTargetStore.getDeTargetByShortName( shortName );
+ }
+
+ public Collection<DeTarget> getDeTargetBySource( Source source )
+ {
+ return deTargetStore.getDeTargetsBySource( source );
+ }
+
+ public Collection<DeTarget> getDeTargetsByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+ {
+ return deTargetStore.getDeTargetsByDataElementAndCategoryOptionCombo( dataelement, deoptioncombo );
+ }
+
+ public Collection<DeTarget> getAllDeTargets()
+ {
+ return deTargetStore.getAllDeTargets();
+ }
+
+ // -------------------------------------------------------------------------
+ // DeTargetMember
+ // -------------------------------------------------------------------------
+
+ public Collection<DeTargetMember> getDeTargetMembers( DeTarget deTarget )
+ {
+ return deTargetStore.getDeTargetMembers( deTarget );
+ }
+
+ public int addDeTargetMember( DeTargetMember deTargetMember )
+ {
+ return deTargetStore.addDeTargetMember( deTargetMember );
+ }
+
+
+ public void updateDeTargetMember( DeTargetMember deTargetMember )
+ {
+ deTargetStore.updateDeTargetMember( deTargetMember );
+ }
+
+ public int deleteDeTargetMember( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+ {
+ return deTargetStore.deleteDeTargetMember( deTargetMember , dataelement, deoptioncombo );
+ }
+}
+
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate'
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detarget.hibernate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.detarget.DeTarget;
+import org.hisp.dhis.detarget.DeTargetMember;
+import org.hisp.dhis.detarget.DeTargetStore;
+import org.hisp.dhis.detargetdatavalue.DeTargetDataValue;
+import org.hisp.dhis.detargetdatavalue.DeTargetDataValueService;
+import org.hisp.dhis.source.Source;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version HibernateDeTargetStore.java Jan 13, 2011 10:35:49 AM
+ */
+public class HibernateDeTargetStore implements DeTargetStore
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ private DeTargetDataValueService deTargetDataValueService;
+
+ public void setDeTargetDataValueService( DeTargetDataValueService deTargetDataValueService )
+ {
+ this.deTargetDataValueService = deTargetDataValueService;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeTarget
+ // -------------------------------------------------------------------------
+
+ public int addDeTarget( DeTarget deTarget )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ return (Integer) session.save( deTarget );
+ }
+
+ public void updateDeTarget( DeTarget deTarget )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update( deTarget );
+ }
+
+ public int deleteDeTarget( DeTarget deTarget )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ List<DeTargetDataValue> deTargetDataValueList = new ArrayList<DeTargetDataValue>( deTargetDataValueService.getDeTargetDataValues( deTarget ) );
+
+ if( deTargetDataValueList == null || deTargetDataValueList.isEmpty() )
+ {
+ session.delete( deTarget );
+ }
+ else
+ {
+ return -1;
+ }
+
+ return 0;
+ }
+ public DeTarget getDeTarget( int id )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ return (DeTarget) session.get( DeTarget.class, id );
+ }
+
+ public DeTarget getDeTargetByName( String name )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DeTarget.class );
+ criteria.add( Restrictions.eq( "name", name ) );
+
+ return (DeTarget) criteria.uniqueResult();
+ }
+
+ public DeTarget getDeTargetByShortName( String shortName )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DeTarget.class );
+ criteria.add( Restrictions.eq( "shortName", shortName ) );
+
+ return (DeTarget) criteria.uniqueResult();
+
+ }
+
+ @SuppressWarnings( "unchecked" )
+
+ public Collection<DeTarget> getDeTargetsBySource( Source source )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DeTarget.class );
+ criteria.createAlias( "sources", "s" );
+ criteria.add( Restrictions.eq( "s.id", source.getId() ) );
+
+ return criteria.list();
+ }
+ @SuppressWarnings( "unchecked" )
+
+ public Collection<DeTarget> getDeTargetsByDataElementAndCategoryOptionCombo( DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DeTarget.class );
+ criteria.createAlias( "dataelements", "i" );
+ criteria.createAlias( "deoptioncombos", "j" );
+ criteria.add( Restrictions.eq( "i.id", dataelement.getId() ) );
+ criteria.add( Restrictions.eq( "j.id", deoptioncombo.getId() ) );
+
+ return criteria.list();
+ }
+ @SuppressWarnings( "unchecked" )
+ public Collection<DeTarget> getAllDeTargets()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ return session.createCriteria( DeTarget.class ).list();
+ }
+
+
+ // -------------------------------------------------------------------------
+ // DeTargetMember
+ // -------------------------------------------------------------------------
+
+ public int addDeTargetMember( DeTargetMember deTargetMember )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ return (Integer) session.save( deTargetMember );
+ }
+
+ public void updateDeTargetMember( DeTargetMember deTargetMember )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ session.update( deTargetMember );
+ }
+
+ public int deleteDeTargetMember( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ List<DeTargetDataValue> deTargetDataValueList = new ArrayList<DeTargetDataValue>( deTargetDataValueService.getDeTargetMemberDataValues( deTargetMember, dataelement, deoptioncombo ) );
+
+ if( deTargetDataValueList == null || deTargetDataValueList.isEmpty() )
+ {
+ session.delete( deTargetMember );
+ }
+ else
+ {
+ return -1;
+ }
+
+ return 0;
+ }
+ @SuppressWarnings( "unchecked" )
+ public List<DeTargetMember> getDeTargetMembers( DeTarget deTarget )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( DeTarget.class );
+ criteria.createAlias( "detargets", "d" );
+ criteria.add( Restrictions.eq( "d.id", deTarget.getId() ) );
+
+ return criteria.list();
+ }
+
+
+
+}
+
+
+
+
+
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue'
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detargetdatavalue;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version DefaultDeTargetDataValueService.java Jan 13, 2011 10:36:40 AM
+ */
+public class DefaultDeTargetDataValueService
+{
+
+}
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate'
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java 2011-01-13 07:06:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.detargetdatavalue.hibernate;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version HibernateDeTargetDataValueStore.java Jan 13, 2011 10:37:20 AM
+ */
+public class HibernateDeTargetDataValueStore
+{
+
+}
=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml 2010-06-20 07:27:46 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml 2011-01-13 07:06:44 +0000
@@ -4,7 +4,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-<!-- Store definitions -->
+<!-- Survey Store definitions -->
<bean id="org.hisp.dhis.survey.SurveyStore"
class="org.hisp.dhis.survey.hibernate.HibernateSurveyStore">
@@ -24,7 +24,7 @@
</bean>
-<!-- Service definitions -->
+<!-- Survey Service definitions -->
<bean id="org.hisp.dhis.survey.SurveyService"
class="org.hisp.dhis.survey.DefaultSurveyService">
@@ -44,4 +44,45 @@
ref="org.hisp.dhis.target.DeTargetMappingStore"/>
</bean>
+
+<!-- DeTarget Service definitions -->
+
+ <bean id="org.hisp.dhis.detarget.DeTargetService"
+ class="org.hisp.dhis.detarget.DefaultDeTargetService">
+ <property name="deTargetStore"
+ ref="org.hisp.dhis.detarget.DeTargetStore"/>
+ </bean>
+<!--
+ <bean id="org.hisp.dhis.surveydatavalue.SurveyDataValueService"
+ class="org.hisp.dhis.surveydatavalue.DefaultSurveyDataValueService">
+ <property name="surveyDataValueStore"
+ ref="org.hisp.dhis.surveydatavalue.SurveyDataValueStore"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.target.DeTargetMappingService"
+ class="org.hisp.dhis.target.DefaultDeTargetMappingService">
+ <property name="deTargetMappingStore"
+ ref="org.hisp.dhis.target.DeTargetMappingStore"/>
+ </bean>
+-->
+<!-- DeTarget Store definitions -->
+
+ <bean id="org.hisp.dhis.detarget.DeTargetStore"
+ class="org.hisp.dhis.detarget.hibernate.HibernateDeTargetStore">
+ <property name="sessionFactory" ref="sessionFactory"/>
+ <property name="deTargetDataValueService"
+ ref="org.hisp.dhis.detargetdatavalue.DeTargetDataValueService"/>
+ </bean>
+ <!--
+ <bean id="org.hisp.dhis.surveydatavalue.SurveyDataValueStore"
+ class="org.hisp.dhis.surveydatavalue.hibernate.HibernateSurveyDataValueStore">
+ <property name="sessionFactory" ref="sessionFactory"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.target.DeTargetMappingStore"
+ class="org.hisp.dhis.target.HibernateDeTargetMappingStore">
+ <property name="sessionFactory" ref="sessionFactory"/>
+ </bean>
+-->
+
</beans>
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget'
=== added directory 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate'
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTarget.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTarget.hbm.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTarget.hbm.xml 2011-01-13 07:06:44 +0000
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+ <class name="org.hisp.dhis.detarget.DeTarget" table="detarget">
+ <id name="id" column="detargetid">
+ <generator class="native"/>
+ </id>
+
+ <property name="name" not-null="true" unique="true" length="160"/>
+
+ <property name="shortName" column="shortname" unique="true" length="60"/>
+ <!--
+ <set name="dataelements" table="detargetmembers">
+ <key column="detargetid"/>
+ <many-to-many class="org.hisp.dhis.dataelement.DataElement"
+ column="dataelementid" foreign-key="fk_detarget_dataelementid"/>
+ <key column="detargetid"/>
+ <many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
+ column="dataelementoptioncombo" foreign-key="fk_detarget_categoryoptioncomboid"/>
+
+ </set>
+ -->
+ <set name="sources" table="detargetsource">
+ <key column="detargetid"/>
+ <many-to-many column="sourceid"
+ class="org.hisp.dhis.source.Source" foreign-key="fk_detarget_sourceid"/>
+ </set>
+
+ <property name="description" type="text"/>
+
+ <property name="url" length = "160"/>
+
+ </class>
+
+</hibernate-mapping>
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetDataValue.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetDataValue.hbm.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetDataValue.hbm.xml 2011-01-13 07:06:44 +0000
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+ <class name="org.hisp.dhis.detargetdatavalue.DeTargetDataValue" table="detargetdatavalue">
+ <composite-id>
+ <key-many-to-one name="deTarget" class="org.hisp.dhis.detarget.DeTarget"
+ column="detargetid" foreign-key="fk_detargetdatavalue_detargetid"/>
+ <key-many-to-one name="dataelement" class="org.hisp.dhis.dataelement.DataElement"
+ column="dataelementid" foreign-key="fk_detargetdatavalue_dataelementid"/>
+ <key-many-to-one name="decategoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
+ column="categoryoptioncomboid" foreign-key="fk_detargetdatavalue_categoryoptioncomboid"/>
+ <!--
+ The source relationship is made not lazy so that Hibernate won't put a
+ proxy on the reference which cannot be casted to the desired subclass.
+ -->
+ <key-many-to-one name="source" class="org.hisp.dhis.source.Source" lazy="false"
+ column="sourceid" foreign-key="fk_detargetdatavalue_sourceid"/>
+ <key-many-to-one name="period" class="org.hisp.dhis.period.Period"
+ column="periodid" foreign-key="fk_detargetdatavalue_periodid"/>
+
+ </composite-id>
+ <property name="value"/>
+ <property name="storedBy" column="storedby" length="50"/>
+ <property name="timestamp" column="lastupdated" type="date"/>
+
+ </class>
+</hibernate-mapping>
\ No newline at end of file
=== added file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetMember.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetMember.hbm.xml 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/org/hisp/dhis/detarget/hibernate/DeTargetMember.hbm.xml 2011-01-13 07:06:44 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+ <class name="org.hisp.dhis.detarget.DeTargetMember" table="detargetmember">
+ <composite-id>
+ <key-many-to-one name="detarget" class="org.hisp.dhis.detarget.DeTarget"
+ column="detargetid" foreign-key="fk_detargetmember_detargetid"/>
+ <key-many-to-one name="dataelements" class="org.hisp.dhis.dataelement.DataElement"
+ column="dataelementid" foreign-key="fk_detargetmember_dataelementid"/>
+ <!--
+ The source relationship is made not lazy so that Hibernate won't put a
+ proxy on the reference which cannot be casted to the desired subclass.
+ -->
+ <key-many-to-one name="decategoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
+ column="categoryoptioncomboid" foreign-key="fk_detargetmember_categoryoptioncomboid"/>
+
+ </composite-id>
+
+ </class>
+
+</hibernate-mapping>