Author: glandais Date: 2008-02-15 14:08:21 +0000 (Fri, 15 Feb 2008) New Revision: 989 Added: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/MetaDataModelFactory.java Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java Log: Display version in tables Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-15 13:15:27 UTC (rev 988) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-15 14:08:21 UTC (rev 989) @@ -78,7 +78,7 @@ try { if (query.equals("")) { result = RemoteStorageService.getStorageService() - .findApplicationsCount(token, false); + .findApplicationsCount(token, true); } else { result = RemoteStorageService.getStorageService() .findFullTextCount(token, query, false); @@ -123,7 +123,7 @@ try { if (query.equals("")) { entities = RemoteStorageService.getStorageService() - .findApplications(token, false, startIndex, + .findApplications(token, true, startIndex, 1 + endIndex - startIndex, dateOrder); } else { entities = RemoteStorageService.getStorageService() Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-15 13:15:27 UTC (rev 988) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementImport.java 2008-02-15 14:08:21 UTC (rev 989) @@ -49,6 +49,8 @@ * On success. * * @return the object + * + * @throws Exception the exception */ public Object onSuccess() throws Exception { MetaData mde = null; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java 2008-02-15 13:15:27 UTC (rev 988) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementList.java 2008-02-15 14:08:21 UTC (rev 989) @@ -17,8 +17,6 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.web.pages; -import java.util.ArrayList; -import java.util.List; import java.util.StringTokenizer; import org.apache.tapestry.ComponentResources; @@ -33,6 +31,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.ui.web.grid.ElementDataSource; import fr.cemagref.simexplorer.is.ui.web.pages.security.UserPage; +import fr.cemagref.simexplorer.is.ui.web.tools.MetaDataModelFactory; /** * The Class ElementList. @@ -67,23 +66,7 @@ * Page loaded. */ void pageLoaded() { - model = beanModelSource.create(MetaData.class, true, resources); - List<String> wantedProperties = new ArrayList<String>(); - wantedProperties.add("type"); - wantedProperties.add("uuid"); - wantedProperties.add("name"); - wantedProperties.add("description"); - wantedProperties.add("version"); - wantedProperties.add("creationDate"); - List<String> properties = model.getPropertyNames(); - for (String property : properties) { - if (!"creationDate".equals(property)) { - model.get(property).sortable(false); - } - if (!wantedProperties.contains(property)) { - model = model.remove(property); - } - } + model = MetaDataModelFactory.getMetaDataModel(beanModelSource, resources, true); elementDataSource = new ElementDataSource(getToken()); } @@ -99,8 +82,7 @@ /** * Search query. * - * @param query - * the query + * @param query the query */ public void searchQuery(String query) { if (query == null || query.equals("")) { @@ -134,8 +116,7 @@ /** * On action from detail element. * - * @param context - * the context + * @param context the context * * @return the object */ @@ -153,14 +134,10 @@ @Override public String getWindowTitle() { String title; - if (elementDataSource.getQuery() != null - && !elementDataSource.getQuery().equals("")) { - title = getMessages().format( - "simexplorer.ui.web.title.searchresults", - elementDataSource.getQuery()); + if (elementDataSource.getQuery() != null && !elementDataSource.getQuery().equals("")) { + title = getMessages().format("simexplorer.ui.web.title.searchresults", elementDataSource.getQuery()); } else { - title = getMessages().get( - "simexplorer.ui.web.title.applicationlist"); + title = getMessages().get("simexplorer.ui.web.title.applicationlist"); } return title; } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java 2008-02-15 13:15:27 UTC (rev 988) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/ElementMetadata.java 2008-02-15 14:08:21 UTC (rev 989) @@ -17,9 +17,6 @@ * ##% */ package fr.cemagref.simexplorer.is.ui.web.pages; -import java.util.ArrayList; -import java.util.List; - import org.apache.tapestry.ComponentResources; import org.apache.tapestry.annotations.Retain; import org.apache.tapestry.beaneditor.BeanModel; @@ -30,6 +27,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.service.SimExplorerServiceException; import fr.cemagref.simexplorer.is.ui.web.services.RemoteStorageService; +import fr.cemagref.simexplorer.is.ui.web.tools.MetaDataModelFactory; /** * The Class ElementMetadata. @@ -64,22 +62,7 @@ * Page loaded. */ void pageLoaded() { - model = beanModelSource.create(MetaData.class, false, resources); - List<String> wantedProperties = new ArrayList<String>(); - wantedProperties.add("type"); - wantedProperties.add("uuid"); - wantedProperties.add("name"); - wantedProperties.add("description"); - wantedProperties.add("version"); - wantedProperties.add("creationDate"); - List<String> properties = model.getPropertyNames(); - for (String property : properties) { - System.out.println(property); - model.get(property).sortable(false); - if (!wantedProperties.contains(property)) { - model = model.remove(property); - } - } + model = MetaDataModelFactory.getMetaDataModel(beanModelSource, resources, false); } /** Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java 2008-02-15 13:15:27 UTC (rev 988) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/AppModule.java 2008-02-15 14:08:21 UTC (rev 989) @@ -18,7 +18,6 @@ package fr.cemagref.simexplorer.is.ui.web.services; import java.io.IOException; -import java.math.BigDecimal; import org.apache.tapestry.ioc.Configuration; import org.apache.tapestry.ioc.MappedConfiguration; @@ -31,7 +30,6 @@ import org.apache.tapestry.services.RequestFilter; import org.apache.tapestry.services.RequestHandler; import org.apache.tapestry.services.Response; -import org.apache.tapestry.services.ValueEncoderFactory; import org.slf4j.Logger; import fr.cemagref.simexplorer.is.entities.metadata.Version; @@ -69,18 +67,12 @@ } /** - * Contribute value encoder source. + * Contribute default data type analyzer. * * @param configuration the configuration */ - @SuppressWarnings("unchecked") - public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration) { - /* - configuration.add(User.class, new GenericValueEncoderFactory<User>( - new UserValueEncoder())); - configuration.add(Group.class, new GenericValueEncoderFactory<Group>( - new GroupValueEncoder())); - */ + public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration<Class, String> configuration) { + configuration.add(Version.class, "text"); } /** Added: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/MetaDataModelFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/MetaDataModelFactory.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/MetaDataModelFactory.java 2008-02-15 14:08:21 UTC (rev 989) @@ -0,0 +1,74 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* 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 fr.cemagref.simexplorer.is.ui.web.tools; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tapestry.ComponentResources; +import org.apache.tapestry.beaneditor.BeanModel; +import org.apache.tapestry.services.BeanModelSource; + +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; + +/** + * A factory for creating MetaDataModel objects. + */ +public class MetaDataModelFactory { + + /** + * Instantiates a new meta data model factory. + */ + protected MetaDataModelFactory() { + // ssssh + } + + /** + * Gets the meta data model. + * + * @param beanModelSource the bean model source + * @param resources the resources + * @param dateSortable the date sortable + * + * @return the meta data model + */ + public static BeanModel getMetaDataModel(BeanModelSource beanModelSource, ComponentResources resources, + boolean dateSortable) { + BeanModel model = beanModelSource.create(MetaData.class, false, resources); + List<String> wantedProperties = new ArrayList<String>(); + wantedProperties.add("type"); + wantedProperties.add("uuid"); + wantedProperties.add("name"); + wantedProperties.add("description"); + wantedProperties.add("version"); + wantedProperties.add("creationDate"); + List<String> properties = model.getPropertyNames(); + for (String property : properties) { + if (!dateSortable || !property.equals("creationDate")) { + model.get(property).sortable(false); + } else { + model.get(property).sortable(true); + } + if (!wantedProperties.contains(property)) { + model = model.remove(property); + } + } + return model; + } + +}