← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9772: remove uniqueness on name for document

 

------------------------------------------------------------
revno: 9772
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-08 12:10:24 +0700
message:
  remove uniqueness on name for document
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateDocumentAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm


--
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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java	2013-01-03 12:43:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java	2013-02-08 05:10:24 +0000
@@ -40,7 +40,7 @@
 /**
  * @author Lars Helge Overland
  */
-@JacksonXmlRootElement( localName = "document", namespace = Dxf2Namespace.NAMESPACE )
+@JacksonXmlRootElement(localName = "document", namespace = Dxf2Namespace.NAMESPACE)
 public class Document
     extends BaseIdentifiableObject
 {
@@ -63,12 +63,6 @@
     }
 
     @Override
-    public int hashCode()
-    {
-        return name.hashCode();
-    }
-
-    @Override
     public boolean equals( Object object )
     {
         if ( this == object )
@@ -92,8 +86,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
     public String getUrl()
     {
         return url;
@@ -105,8 +99,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
     public boolean isExternal()
     {
         return external;
@@ -118,8 +112,8 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    @JsonView({ DetailedView.class, ExportView.class })
+    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
     public String getContentType()
     {
         return contentType;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java	2013-02-08 05:10:24 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.Collection;
+import java.util.List;
 
 /**
  * @author Lars Helge Overland
@@ -37,10 +38,10 @@
 {
     String ID = DocumentService.class.getName();
     String DIR = "documents";
-    
+
     /**
      * Saves a Document.
-     * 
+     *
      * @param document the Document to save.
      * @return the generated identifier.
      */
@@ -64,32 +65,32 @@
 
     /**
      * Deletes a Document.
-     * 
+     *
      * @param document the Document to delete.
      */
     void deleteDocument( Document document );
 
     /**
      * Retrieves all Documents.
-     * 
+     *
      * @return a Collection of Documents.
      */
-    Collection<Document> getAllDocuments();
-    
+    List<Document> getAllDocuments();
+
     /**
      * Retrieves the Document with the given name.
-     * 
+     *
      * @param name the name of the Document.
      * @return the Document.
      */
-    Document getDocumentByName( String name );
-    
-    Collection<Document> getDocumentsBetween( int first, int max );
-    
-    Collection<Document> getDocumentsBetweenByName( String name, int first, int max );
-    
+    List<Document> getDocumentByName( String name );
+
+    List<Document> getDocumentsBetween( int first, int max );
+
+    List<Document> getDocumentsBetweenByName( String name, int first, int max );
+
     int getDocumentCount();
-    
+
     int getDocumentCountByName( String name );
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-02-08 04:20:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-02-08 05:10:24 +0000
@@ -519,6 +519,8 @@
         executeSql( "ALTER TABLE dataset DROP CONSTRAINT dataset_name_key" );
         executeSql( "ALTER TABLE dataset DROP CONSTRAINT dataset_shortname_key" );
 
+        executeSql( "ALTER TABLE document DROP CONSTRAINT document_name_key" );
+
         log.info( "Tables updated" );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2013-02-08 05:10:24 +0000
@@ -27,13 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collection;
+import java.util.List;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -77,14 +78,14 @@
         documentStore.delete( document );
     }
 
-    public Collection<Document> getAllDocuments()
+    public List<Document> getAllDocuments()
     {
         return documentStore.getAll();
     }
 
-    public Document getDocumentByName( String name )
+    public List<Document> getDocumentByName( String name )
     {
-        return documentStore.getByName( name );
+        return documentStore.getAllEqName( name );
     }
 
     public int getDocumentCount()
@@ -97,12 +98,12 @@
         return documentStore.getCountLikeName( name );
     }
 
-    public Collection<Document> getDocumentsBetween( int first, int max )
+    public List<Document> getDocumentsBetween( int first, int max )
     {
         return documentStore.getAllOrderedName( first, max );
     }
 
-    public Collection<Document> getDocumentsBetweenByName( String name, int first, int max )
+    public List<Document> getDocumentsBetweenByName( String name, int first, int max )
     {
         return documentStore.getAllLikeNameOrderedName( name, first, max );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml	2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml	2013-02-08 05:10:24 +0000
@@ -15,7 +15,7 @@
     </id>
     &identifiableProperties;
 
-    <property name="name" column="name" not-null="true" unique="true" length="230" />
+    <property name="name" column="name" not-null="true" unique="false" length="230" />
 
     <property name="url" not-null="true" type="text" />
 

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java	2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java	2013-02-08 05:10:24 +0000
@@ -107,6 +107,6 @@
         documentService.saveDocument( documentB );
         documentService.saveDocument( documentC );
 
-        assertEquals( documentA, documentService.getDocumentByName( "DocumentA" ) );
+        assertEquals( documentA, documentService.getDocumentByName( "DocumentA" ).get( 0 ) );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateDocumentAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateDocumentAction.java	2013-02-08 05:10:24 +0000
@@ -27,12 +27,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
 import org.hisp.dhis.i18n.I18n;
 
-import com.opensymphony.xwork2.Action;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -110,7 +109,8 @@
                 return INPUT;
             }
 
-            Document match = documentService.getDocumentByName( name );
+            // TODO compile fix, this should be removed
+            Document match = documentService.getDocumentByName( name ).get( 0 );
 
             if ( match != null && (id == null || match.getId() != id) )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm	2012-10-17 18:53:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm	2013-02-08 05:10:24 +0000
@@ -5,7 +5,7 @@
 		},function(){
 		});	
 	
-		checkValueIsExist( "name", "validateDocument.action", {id: "$!document.id"} );
+		// checkValueIsExist( "name", "validateDocument.action", {id: "$!document.id"} );
 	
 		toggleExternal();
 	});