← Back to team overview

slub.team team mailing list archive

[Merge] lp:~slub.team/goobi-production/bug-1032182 into lp:goobi-production

 

Henning Gerhardt has proposed merging lp:~slub.team/goobi-production/bug-1032182 into lp:goobi-production.

Requested reviews:
  Ralf Claussnitzer (ralf-claussnitzer)
  zeutschel (zeutschel)
Related bugs:
  Bug #1032182 in Goobi.Production: "webapi doesn’t show items that don’t use ppn as identifier"
  https://bugs.launchpad.net/goobi-production/+bug/1032182

For more details, see:
https://code.launchpad.net/~slub.team/goobi-production/bug-1032182/+merge/117916
-- 
https://code.launchpad.net/~slub.team/goobi-production/bug-1032182/+merge/117916
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== removed file 'src/org/goobi/webapi/beans/IdentifierPPN.java'
--- src/org/goobi/webapi/beans/IdentifierPPN.java	2012-07-27 17:07:00 +0000
+++ src/org/goobi/webapi/beans/IdentifierPPN.java	1970-01-01 00:00:00 +0000
@@ -1,61 +0,0 @@
-/*
- * This file is part of the Goobi Application - a Workflow tool for the support of
- * mass digitization.
- *
- * Visit the websites for more information.
- *     - http://gdz.sub.uni-goettingen.de
- *     - http://www.goobi.org
- *     - http://launchpad.net/goobi-production
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-package org.goobi.webapi.beans;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class IdentifierPPN {
-
-    private String ppn;
-
-    public IdentifierPPN(String ppn) {
-        if (!isValid(ppn)) {
-            throw new IllegalArgumentException("Given string is not a valid PPN identifier.");
-        }
-        this.ppn = ppn;
-    }
-
-    public static boolean isValid(String identifier) {
-        Boolean result;
-        int flags = Pattern.CASE_INSENSITIVE;
-        Pattern pattern;
-        Matcher matcher;
-
-        if ((identifier == null) || (identifier.length() == 0)) {
-            result = false;
-        } else {
-            pattern = Pattern.compile("^[0-9]{8}[0-9LXYZ]{1}$", flags);
-            matcher = pattern.matcher(identifier);
-            result = matcher.matches();
-        }
-
-        return result;
-    }
-
-    public String toString() {
-        return ppn;
-    }
-
-
-}

=== modified file 'src/org/goobi/webapi/dao/GoobiProcessDAO.java'
--- src/org/goobi/webapi/dao/GoobiProcessDAO.java	2012-07-30 14:03:15 +0000
+++ src/org/goobi/webapi/dao/GoobiProcessDAO.java	2012-08-02 15:02:21 +0000
@@ -28,7 +28,6 @@
 import org.apache.log4j.Logger;
 import org.goobi.webapi.beans.GoobiProcess;
 import org.goobi.webapi.beans.GoobiProcessStep;
-import org.goobi.webapi.beans.IdentifierPPN;
 import org.hibernate.Criteria;
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
@@ -44,7 +43,7 @@
 
     private static final Logger myLogger = Logger.getLogger(GoobiProcessDAO.class);
 
-    public static GoobiProcess getProcessByPPN(IdentifierPPN PPN) {
+    public static GoobiProcess getProcessByIdentifier(String identifier) {
         Session session;
         GoobiProcess result = null;
 
@@ -58,14 +57,15 @@
                     .createAlias("vorlagen.eigenschaften", "ve")
                     .createAlias("werkstuecke", "w")
                     .createAlias("werkstuecke.eigenschaften", "we")
+					// key PPN digital a/f-Satz could contain any string value
                     .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
                     .add(Restrictions.eq("ve.titel", "Titel"))
-                    .add(Restrictions.eq("we.wert", PPN.toString()))
+                    .add(Restrictions.eq("we.wert", identifier))
                     .addOrder(Order.asc("we.wert"))
                     .setProjection(Projections.projectionList()
-                            .add(Projections.property("we.wert"), "identifier")
-                            .add(Projections.property("ve.wert"), "title")
-                    )
+							.add(Projections.property("we.wert"), "identifier")
+							.add(Projections.property("ve.wert"), "title")
+					)
                     .setResultTransformer(Transformers.aliasToBean(GoobiProcess.class));
 
             result = (GoobiProcess) criteria.uniqueResult();
@@ -92,6 +92,7 @@
                     .createAlias("vorlagen.eigenschaften", "ve")
                     .createAlias("werkstuecke", "w")
                     .createAlias("werkstuecke.eigenschaften", "we")
+					// key PPN digital a/f-Satz could contain any string value
                     .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
                     .add(Restrictions.eq("ve.titel", "Titel"))
                     .addOrder(Order.asc("we.wert"))
@@ -114,7 +115,7 @@
         return result;
     }
 
-    public static List<GoobiProcessStep> getAllProcessSteps(IdentifierPPN PPN) {
+    public static List<GoobiProcessStep> getAllProcessSteps(String identifier) {
         List<GoobiProcessStep> result;
         Session session;
 
@@ -128,14 +129,15 @@
                     .createAlias("prozess", "p")
                     .createAlias("prozess.werkstuecke", "w")
                     .createAlias("prozess.werkstuecke.eigenschaften", "we")
+					// key "PPN digital a/f-Satz" could contain any string value
                     .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
-                    .add(Restrictions.eq("we.wert", PPN.toString()))
+                    .add(Restrictions.eq("we.wert", identifier))
                     .addOrder(Order.asc("reihenfolge"))
                     .setProjection(Projections.projectionList()
-                            .add(Projections.property("reihenfolge"), "sequence")
-                            .add(Projections.property("bearbeitungsstatus"), "state")
-                            .add(Projections.property("titel"), "title")
-                    )
+							.add(Projections.property("reihenfolge"), "sequence")
+							.add(Projections.property("bearbeitungsstatus"), "state")
+							.add(Projections.property("titel"), "title")
+					)
                     .setResultTransformer(Transformers.aliasToBean(GoobiProcessStep.class));
 
             @SuppressWarnings(value = "unchecked")

=== modified file 'src/org/goobi/webapi/resources/Processes.java'
--- src/org/goobi/webapi/resources/Processes.java	2012-07-30 14:01:10 +0000
+++ src/org/goobi/webapi/resources/Processes.java	2012-08-02 15:02:21 +0000
@@ -25,7 +25,6 @@
 import com.sun.jersey.api.NotFoundException;
 import org.goobi.webapi.beans.GoobiProcess;
 import org.goobi.webapi.beans.GoobiProcessStep;
-import org.goobi.webapi.beans.IdentifierPPN;
 import org.goobi.webapi.dao.GoobiProcessDAO;
 
 import javax.ws.rs.GET;
@@ -51,9 +50,9 @@
 
     @GET
     @Path("{ppnIdentifier}")
-    public GoobiProcess getProcess(@PathParam("ppnIdentifier") IdentifierPPN ippn) {
+    public GoobiProcess getProcess(@PathParam("ppnIdentifier") String identifier) {
 
-        GoobiProcess process = GoobiProcessDAO.getProcessByPPN(ippn);
+        GoobiProcess process = GoobiProcessDAO.getProcessByIdentifier(identifier);
 
         if (process == null) {
             throw new NotFoundException("No such process.");
@@ -64,9 +63,9 @@
 
     @GET
     @Path("{ppnIdentifier}/steps")
-    public List<GoobiProcessStep> getProcessSteps(@PathParam("ppnIdentifier") IdentifierPPN ippn) {
+    public List<GoobiProcessStep> getProcessSteps(@PathParam("ppnIdentifier") String identifier) {
 
-        List<GoobiProcessStep> resultList = GoobiProcessDAO.getAllProcessSteps(ippn);
+        List<GoobiProcessStep> resultList = GoobiProcessDAO.getAllProcessSteps(identifier);
 
         if (resultList.isEmpty()) {
             throw new NotFoundException("No such process.");

=== removed directory 'test/src/org/goobi/webapi'
=== removed directory 'test/src/org/goobi/webapi/beans'
=== removed file 'test/src/org/goobi/webapi/beans/IdentifierPPNTest.java'
--- test/src/org/goobi/webapi/beans/IdentifierPPNTest.java	2012-07-30 14:19:34 +0000
+++ test/src/org/goobi/webapi/beans/IdentifierPPNTest.java	1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
-/*
- * This file is part of the Goobi Application - a Workflow tool for the support of
- * mass digitization.
- *
- * Visit the websites for more information.
- *     - http://gdz.sub.uni-goettingen.de
- *     - http://www.goobi.org
- *     - http://launchpad.net/goobi-production
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-package org.goobi.webapi.beans;
-
-import junit.framework.Assert;
-import org.junit.Test;
-
-public class IdentifierPPNTest {
-
-	@Test
-	public void validPpnShouldValidateAsCorrect() {
-		String identifier = "32578597X";
-
-		Assert.assertTrue("Given PPN " + identifier + " should be correct.", IdentifierPPN.isValid(identifier));
-	}
-
-	@Test
-	public void lowerCaseValidPpnShouldBeCorrect() {
-		String identifier = "32578597x";
-
-		Assert.assertTrue("Given lowercase PPN " + identifier + " should be correct.", IdentifierPPN.isValid(identifier));
-
-	}
-
-	@Test
-	public void invalidPpnShouldBeFalse() {
-		String identifier = "32578597A";
-
-		Assert.assertFalse("Given PPN " + identifier + " should be invalid.", IdentifierPPN.isValid(identifier));
-	}
-
-	@Test
-	public void emptyStringValueShouldBeFalse() {
-		String identifier = "";
-
-		Assert.assertFalse("Empty string value should be invalid.", IdentifierPPN.isValid(identifier));
-	}
-
-	@Test
-	public void nullValueValidatedAsFalse() {
-		String identifier = null;
-
-		Assert.assertFalse("Null value should be invalid.", IdentifierPPN.isValid(identifier));
-	}
-
-	@Test
-	public void toShortPpnShouldNotBeCorrect() {
-		String identifier = "123";
-
-		Assert.assertFalse("To short PPN " + identifier + " should be invalid.", IdentifierPPN.isValid(identifier));
-	}
-
-	@Test
-	public void toLongPpnShouldNotBeCorrect() {
-		String identifier = "1234567890";
-
-		Assert.assertFalse("To long PPN " + identifier + " should be invalid.", IdentifierPPN.isValid(identifier));
-	}
-}


Follow ups