diff --git a/vcell-api/src/main/java/org/vcell/rest/server/BiomodelsServerResource.java b/vcell-api/src/main/java/org/vcell/rest/server/BiomodelsServerResource.java index 92a73ecc78..0af6897f57 100644 --- a/vcell-api/src/main/java/org/vcell/rest/server/BiomodelsServerResource.java +++ b/vcell-api/src/main/java/org/vcell/rest/server/BiomodelsServerResource.java @@ -1,6 +1,7 @@ package org.vcell.rest.server; import java.sql.SQLException; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -103,7 +104,14 @@ public BiomodelRepresentation[] get_json() { VCellApiApplication application = ((VCellApiApplication)getApplication()); User vcellUser = application.getVCellUser(getChallengeResponse(),AuthenticationPolicy.prohibitInvalidCredentials); - return getBiomodelRepresentations(vcellUser); + BiomodelRepresentation[] bmReps = new BiomodelRepresentation[0]; + try { + getBiomodelRepresentations(vcellUser); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return bmReps; } @Override @@ -111,7 +119,15 @@ public Representation get_html() { VCellApiApplication application = ((VCellApiApplication)getApplication()); User vcellUser = application.getVCellUser(getChallengeResponse(),AuthenticationPolicy.ignoreInvalidCredentials); - BiomodelRepresentation[] biomodels = getBiomodelRepresentations(vcellUser); + BiomodelRepresentation[] biomodels = new BiomodelRepresentation[0]; + boolean bFormatErr = false; + try { + biomodels = getBiomodelRepresentations(vcellUser); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + bFormatErr = true; + } Map dataModel = new HashMap(); dataModel.put("loginurl", "/"+VCellApiApplication.LOGINFORM); // +"?"+VCellApiApplication.REDIRECTURL_FORMNAME+"="+getRequest().getResourceRef().toUrl()); @@ -123,8 +139,8 @@ public Representation get_html() { dataModel.put("userId", getAttribute(PARAM_USER)); dataModel.put("bmName", getQueryValue(PARAM_BM_NAME)); dataModel.put("bmId", getQueryValue(PARAM_BM_ID)); - dataModel.put("savedLow", getLongQueryValue(PARAM_SAVED_LOW)); - dataModel.put("savedHigh", getLongQueryValue(PARAM_SAVED_HIGH)); + dataModel.put("savedLow", (bFormatErr?"Error":getQueryValue(PARAM_SAVED_LOW))); + dataModel.put("savedHigh", (bFormatErr?"Error":getQueryValue(PARAM_SAVED_HIGH))); dataModel.put("ownerName", getQueryValue(PARAM_BM_OWNER)); dataModel.put("category", getQueryValue(PARAM_CATEGORY)); dataModel.put("orderBy", getQueryValue(PARAM_ORDERBY)); @@ -155,7 +171,7 @@ public Representation get_html() { } - private BiomodelRepresentation[] getBiomodelRepresentations(User vcellUser) { + private BiomodelRepresentation[] getBiomodelRepresentations(User vcellUser) throws ParseException{ // if (!application.authenticate(getRequest(), getResponse())){ // // not authenticated // return new SimulationTaskRepresentation[0]; diff --git a/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java b/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java index 8d05aa39f5..cecd77121d 100644 --- a/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java +++ b/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java @@ -2,10 +2,13 @@ import java.beans.PropertyVetoException; import java.sql.SQLException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Random; import java.util.TreeMap; @@ -281,14 +284,14 @@ public DataSetTimeSeries getDataSetTimeSeries(SimDataValuesServerResource resour } } - public BioModelRep[] query(BiomodelsServerResource resource, User vcellUser) throws SQLException, DataAccessException { + public BioModelRep[] query(BiomodelsServerResource resource, User vcellUser) throws SQLException, DataAccessException, ParseException { if (vcellUser==null){ vcellUser = VCellApiApplication.DUMMY_USER; } String bioModelName = resource.getQueryValue(BiomodelsServerResource.PARAM_BM_NAME); Long bioModelID = resource.getLongQueryValue(BiomodelsServerResource.PARAM_BM_ID); - Long savedLow = resource.getLongQueryValue(BiomodelsServerResource.PARAM_SAVED_LOW); - Long savedHigh = resource.getLongQueryValue(BiomodelsServerResource.PARAM_SAVED_HIGH); + String savedLow = resource.getQueryValue(BiomodelsServerResource.PARAM_SAVED_LOW); + String savedHigh = resource.getQueryValue(BiomodelsServerResource.PARAM_SAVED_HIGH); Long startRowParam = resource.getLongQueryValue(BiomodelsServerResource.PARAM_START_ROW); Long maxRowsParam = resource.getLongQueryValue(BiomodelsServerResource.PARAM_MAX_ROWS); String categoryParam = resource.getQueryValue(BiomodelsServerResource.PARAM_CATEGORY); // it is ok if the category is null; @@ -304,13 +307,16 @@ public BioModelRep[] query(BiomodelsServerResource resource, User vcellUser) thr } ArrayList conditions = new ArrayList(); - java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss", java.util.Locale.US); + //java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss", java.util.Locale.US); + SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd",Locale.US); - if (savedLow != null){ - conditions.add("(" + BioModelTable.table.versionDate.getQualifiedColName() + " >= to_date('" + df.format(new Date(savedLow)) + "', 'mm/dd/yyyy HH24:MI:SS'))"); + if (savedLow != null && savedLow.length()>0){ + df.parse(savedLow); + conditions.add("(" + BioModelTable.table.versionDate.getQualifiedColName() + " >= to_date('" + savedLow + "', 'yyyy/mm/dd'))"); } - if (savedHigh != null){ - conditions.add("(" + BioModelTable.table.versionDate.getQualifiedColName() + " <= to_date('" + df.format(new Date(savedHigh)) + "', 'mm/dd/yyyy HH24:MI:SS'))"); + if (savedHigh != null && savedHigh.length()>0){ + df.parse(savedHigh); + conditions.add("(" + BioModelTable.table.versionDate.getQualifiedColName() + " <= to_date('" + savedHigh + "', 'yyyy/mm/dd'))"); } if (bioModelName != null && bioModelName.trim().length()>0){ String pattern = bioModelName.trim(); diff --git a/vcell-api/src/main/resources/biomodels.ftl b/vcell-api/src/main/resources/biomodels.ftl index 1c0d22d574..6b1617de66 100644 --- a/vcell-api/src/main/resources/biomodels.ftl +++ b/vcell-api/src/main/resources/biomodels.ftl @@ -21,8 +21,8 @@ checked=on>educational Owner - Begin Time - End Timestamp + Begin Date (yyyy/mm/dd) + End Date (yyyy/mm/dd) start row max num rows Order By