Author: tchemit Date: 2011-04-11 23:54:18 +0200 (Mon, 11 Apr 2011) New Revision: 1 Url: http://chorem.org/repositories/revision/vradi/1 Log: create svn repository structure initial import of the project Added: branches/ tags/ trunk/ trunk/LICENSE.txt trunk/README.txt trunk/changelog.txt trunk/doc/ trunk/doc/REQUIRED trunk/pom.xml trunk/src/ trunk/src/announcement/ trunk/src/announcement/release-email-0.5.0.txt trunk/src/announcement/release-email-0.5.1.txt trunk/src/doc/ trunk/src/doc/REQUIRED trunk/src/doc/archiTechnique.dia trunk/src/doc/archiTechnique.png trunk/src/site/ trunk/src/site/resources/ trunk/src/site/resources/addField.png trunk/src/site/resources/clients.png trunk/src/site/resources/creationThesaurus.png trunk/src/site/resources/destsByForm.png trunk/src/site/resources/devel/ trunk/src/site/resources/devel/archi.svg trunk/src/site/resources/enregistrement.png trunk/src/site/resources/example-clients.csv trunk/src/site/resources/example-utilisateurs.csv trunk/src/site/resources/exportCSV.png trunk/src/site/resources/fieldsAssociation.png trunk/src/site/resources/flux.png trunk/src/site/resources/form.png trunk/src/site/resources/formType.png trunk/src/site/resources/formsByUser.png trunk/src/site/resources/generatePDF.png trunk/src/site/resources/groups.png trunk/src/site/resources/infogene.png trunk/src/site/resources/mailSession.png trunk/src/site/resources/model.png trunk/src/site/resources/pdfExample.png trunk/src/site/resources/quotesoOo.png trunk/src/site/resources/requetes.png trunk/src/site/resources/requetesModifiees.png trunk/src/site/resources/selectThesaurusNode.png trunk/src/site/resources/sendEmail.png trunk/src/site/resources/sendFormsAgain.png trunk/src/site/resources/thesaurus.png trunk/src/site/resources/thesaurusColor.png trunk/src/site/resources/utilisateurs.png trunk/src/site/rst/ trunk/src/site/rst/clients.rst trunk/src/site/rst/devel/ trunk/src/site/rst/devel/algosession.rst trunk/src/site/rst/devel/modificationmodele.rst trunk/src/site/rst/devel/openoffice.rst trunk/src/site/rst/devel/todomodel.rst trunk/src/site/rst/devel/xmlStream.rst trunk/src/site/rst/fluxXML.rst trunk/src/site/rst/formulaires.rst trunk/src/site/rst/generationPDF.rst trunk/src/site/rst/groups.rst trunk/src/site/rst/importExport.rst trunk/src/site/rst/index.rst trunk/src/site/rst/infogene.rst trunk/src/site/rst/lancement.rst trunk/src/site/rst/processForms.rst trunk/src/site/rst/requests.rst trunk/src/site/rst/roadmap.rst trunk/src/site/rst/sendEmails.rst trunk/src/site/rst/thesaurus.rst trunk/src/site/rst/todo.rst trunk/src/site/site_fr.xml trunk/vradi-entities/ trunk/vradi-entities/LICENSE.txt trunk/vradi-entities/README.txt trunk/vradi-entities/changelog.txt trunk/vradi-entities/pom.xml trunk/vradi-entities/src/ trunk/vradi-entities/src/license/ trunk/vradi-entities/src/license/THIRD-PARTY.properties trunk/vradi-entities/src/main/ trunk/vradi-entities/src/main/java/ trunk/vradi-entities/src/main/java/org/ trunk/vradi-entities/src/main/java/org/chorem/ trunk/vradi-entities/src/main/java/org/chorem/vradi/ trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/ trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FieldTypeEnum.java trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FormLinkTypeEnum.java trunk/vradi-entities/src/main/resources/ trunk/vradi-entities/src/main/resources/i18n/ trunk/vradi-entities/src/main/resources/i18n/vradi-entities_fr_FR.properties trunk/vradi-entities/src/main/xmi/ trunk/vradi-entities/src/main/xmi/vradi.properties trunk/vradi-entities/src/main/xmi/vradi.zargo trunk/vradi-entities/src/site/ trunk/vradi-entities/src/site/rst/ trunk/vradi-entities/src/site/rst/index.rst trunk/vradi-entities/src/site/site_fr.xml trunk/vradi-entities/src/test/ trunk/vradi-entities/src/test/java/ trunk/vradi-entities/src/test/resources/ trunk/vradi-services-web/ trunk/vradi-services-web/LICENSE.txt trunk/vradi-services-web/README.txt trunk/vradi-services-web/changelog.txt trunk/vradi-services-web/pom.xml trunk/vradi-services-web/src/ trunk/vradi-services-web/src/license/ trunk/vradi-services-web/src/license/THIRD-PARTY.properties trunk/vradi-services-web/src/main/ trunk/vradi-services-web/src/main/java/ trunk/vradi-services-web/src/main/java/org/ trunk/vradi-services-web/src/main/java/org/chorem/ trunk/vradi-services-web/src/main/java/org/chorem/vradi/ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/FileServlet.java trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java trunk/vradi-services-web/src/main/resources/ trunk/vradi-services-web/src/main/resources/jbossts-properties.xml trunk/vradi-services-web/src/main/resources/log4j.properties trunk/vradi-services-web/src/main/resources/solrconfig.xml trunk/vradi-services-web/src/main/webapp/ trunk/vradi-services-web/src/main/webapp/WEB-INF/ trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml trunk/vradi-services-web/src/main/webapp/favicon.png trunk/vradi-services-web/src/main/webapp/index.jsp trunk/vradi-services-web/src/site/ trunk/vradi-services-web/src/site/rst/ trunk/vradi-services-web/src/site/rst/index.rst trunk/vradi-services-web/src/site/site_fr.xml trunk/vradi-services-web/src/test/ trunk/vradi-services-web/src/test/java/ trunk/vradi-services-web/src/test/java/org/ trunk/vradi-services-web/src/test/java/org/chorem/ trunk/vradi-services-web/src/test/java/org/chorem/vradi/ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java trunk/vradi-services-web/src/test/resources/ trunk/vradi-services-web/src/test/resources/log4j.properties trunk/vradi-services-web/src/test/resources/vradi-services.properties trunk/vradi-services-web/src/test/resources/vradi_services_web.place_holder trunk/vradi-services-web/src/test/webapp/ trunk/vradi-services-web/src/test/webapp/WEB-INF/ trunk/vradi-services-web/src/test/webapp/WEB-INF/web.xml trunk/vradi-services/ trunk/vradi-services/LICENSE.txt trunk/vradi-services/README.txt trunk/vradi-services/changelog.txt trunk/vradi-services/pom.xml trunk/vradi-services/src/ trunk/vradi-services/src/license/ trunk/vradi-services/src/license/THIRD-PARTY.properties trunk/vradi-services/src/main/ trunk/vradi-services/src/main/assembly/ trunk/vradi-services/src/main/assembly/bin.xml trunk/vradi-services/src/main/java/ trunk/vradi-services/src/main/java/org/ trunk/vradi-services/src/main/java/org/chorem/ trunk/vradi-services/src/main/java/org/chorem/vradi/ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiConstants.java trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceMain.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryBean.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryParameters.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/SendingHelper.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/XmlStreamImportResult.java trunk/vradi-services/src/main/java/org/chorem/vradi/beans/package-info.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileService.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceImpl.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceProxy.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataService.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiException.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiPDFCleanerService.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/BindingManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ClientManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/DateParser.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormTypeManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ThesaurusManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapConnector.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapSocketConnector.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/OOoServer.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/SingletonOOo.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/CompareFilter.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/Filter.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterList.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterListQueryHandler.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/LuceneQueryParser.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/QueryHandler.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/RangeFilter.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/UnsupportedQueryException.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/VradiQueryParser.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/package-info.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ImportXmlStreamTasks.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ReceiveMailTasks.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/TasksManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/package-info.java trunk/vradi-services/src/main/java/org/chorem/vradi/util/ trunk/vradi-services/src/main/java/org/chorem/vradi/util/SSLUtils.java trunk/vradi-services/src/main/resources/ trunk/vradi-services/src/main/resources/i18n/ trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties trunk/vradi-services/src/main/resources/log4j.properties trunk/vradi-services/src/main/resources/vradi-services.properties trunk/vradi-services/src/main/resources/webHarvest/ trunk/vradi-services/src/main/resources/webHarvest/OuestFranceImmo.xml trunk/vradi-services/src/site/ trunk/vradi-services/src/site/rst/ trunk/vradi-services/src/site/rst/index.rst trunk/vradi-services/src/site/site_fr.xml trunk/vradi-services/src/test/ trunk/vradi-services/src/test/java/ trunk/vradi-services/src/test/java/org/ trunk/vradi-services/src/test/java/org/chorem/ trunk/vradi-services/src/test/java/org/chorem/vradi/ trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestConfiguration.java trunk/vradi-services/src/test/java/org/chorem/vradi/beans/ trunk/vradi-services/src/test/java/org/chorem/vradi/beans/QueryBeanTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/ trunk/vradi-services/src/test/java/org/chorem/vradi/services/MiscServicesTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiDataServiceTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiStorageServiceTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/BindingManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormTypeManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/MailingManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/SearchManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ThesaurusManagerTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/ trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/VradiQueryParserTest.java trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/ trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/TasksManagerTest.java trunk/vradi-services/src/test/resources/ trunk/vradi-services/src/test/resources/annonce.xml trunk/vradi-services/src/test/resources/csv/ trunk/vradi-services/src/test/resources/csv/clients.csv trunk/vradi-services/src/test/resources/csv/testimport.csv trunk/vradi-services/src/test/resources/csv/thesaurus.csv trunk/vradi-services/src/test/resources/csv/users.csv trunk/vradi-services/src/test/resources/dates.xml trunk/vradi-services/src/test/resources/file.xml trunk/vradi-services/src/test/resources/images/ trunk/vradi-services/src/test/resources/images/enregistrement.png trunk/vradi-services/src/test/resources/images/flux.gif trunk/vradi-services/src/test/resources/images/form.jpg trunk/vradi-services/src/test/resources/log4j.properties trunk/vradi-services/src/test/resources/ooo/ trunk/vradi-services/src/test/resources/ooo/modelePDF2.odt trunk/vradi-services/src/test/resources/ooo/test.ott trunk/vradi-services/src/test/resources/ooo/variousfieldtypes.odt trunk/vradi-services/src/test/resources/ooo/vradi_template.odt trunk/vradi-services/src/test/resources/vradi-services.properties trunk/vradi-swing/ trunk/vradi-swing/LICENSE.txt trunk/vradi-swing/README.txt trunk/vradi-swing/changelog.txt trunk/vradi-swing/pom.xml trunk/vradi-swing/src/ trunk/vradi-swing/src/license/ trunk/vradi-swing/src/license/THIRD-PARTY.properties trunk/vradi-swing/src/main/ trunk/vradi-swing/src/main/assembly/ trunk/vradi-swing/src/main/assembly/bin.xml trunk/vradi-swing/src/main/assembly/bin/ trunk/vradi-swing/src/main/assembly/bin/go.bat trunk/vradi-swing/src/main/assembly/bin/go.sh trunk/vradi-swing/src/main/java/ trunk/vradi-swing/src/main/java/org/ trunk/vradi-swing/src/main/java/org/chorem/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiAction.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiContext.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiEntitiesListener.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiExtensionsListener.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiMain.java trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiNotifier.java trunk/vradi-swing/src/main/java/org/chorem/vradi/services/ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java trunk/vradi-swing/src/main/java/org/chorem/vradi/services/package-info.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.css trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminContentUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavTreeFilter.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminPopupUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminClientUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminFormTypeUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminGroupUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminStatusUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminUserUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminXmlStreamUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestListUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestSelectUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/StatusEditionUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/XmlStreamConfigUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminBeanConstant.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ClientNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/FormTypeNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/GroupNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/XmlStreamNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientUsersNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsAndUsersNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/FormTypeNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupUsersNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupsNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/StreamNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/AdminTreeSelectionModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldSelectModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldTypeModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/TemplateFieldTableModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/XmlStreamFieldTableModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/AdminRequestUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/TemplateFieldBindingUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusConfirmDialogUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusEditUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusPathChooserUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCellEditor.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCheckCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ThesaurusChangesTreeTableModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/AdminCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/JListCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/AdminListSelectorHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/FieldSelectUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/GroupListSelectorHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/UserListSelectorHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailContentUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailPopupUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/FormViewUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/QueryMakerViewUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SendingViewUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SessionViewUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailBeanConstant.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailDataHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailNavigationTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/AbstractEmailNodeLoador.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailFormNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupUsersNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailUsersNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/EmailEntityModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/GroupEmailEntityModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/UserEmailEntityModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsHighlighter.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsListCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/AttachmentSessionFileHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ToolTipHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/UIHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/VradiComparators.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/XmlStreamHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/RegisterUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/EntityModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormMenu.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormTypeModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/RequestFieldMenu.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/CreateOfferDialogUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListColumnFactory.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferTable.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusCartographyUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/VradiTabHeader.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateTimeEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/JListCellEditor.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditorModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/OfferListTableModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/SimpleUrlValidator.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/AttachmentFileHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/EmbeddedFileHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/FormLinkCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/RelatedFormHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ReplaceFormHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/SelectFormUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ColorsMap.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/EntityRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/NumberListCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ThesaurusHighlighter.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/VradiI18nTableCellRenderer.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaField.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/MultipleSelectionEditor.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/PaginationUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchMultipleSelectionHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/AbstractProgressBarUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ProgressBarUI.jaxx trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/VradiTask.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ThesaurusDataProvider.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusDataHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusSelectionManager.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeTableHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusTreeTableNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusTreeTableNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ThesaurusTreeTableModel.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiDataProvider.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeNode.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeTableNode.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/VradiTreeHelper.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/AbstractVradiNodeLoadors.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionFileHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionHandler.java trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionPane.jaxx trunk/vradi-swing/src/main/jnlp/ trunk/vradi-swing/src/main/jnlp/vradi-server-jnlp.vm trunk/vradi-swing/src/main/resources/ trunk/vradi-swing/src/main/resources/changelog.txt trunk/vradi-swing/src/main/resources/i18n/ trunk/vradi-swing/src/main/resources/i18n/vradi-swing_fr_FR.properties trunk/vradi-swing/src/main/resources/icons/ trunk/vradi-swing/src/main/resources/icons/action-about.png trunk/vradi-swing/src/main/resources/icons/action-accept.png trunk/vradi-swing/src/main/resources/icons/action-add.png trunk/vradi-swing/src/main/resources/icons/action-arrowDown.png trunk/vradi-swing/src/main/resources/icons/action-arrowLeft.png trunk/vradi-swing/src/main/resources/icons/action-arrowRight.png trunk/vradi-swing/src/main/resources/icons/action-arrowUp.png trunk/vradi-swing/src/main/resources/icons/action-cancel.png trunk/vradi-swing/src/main/resources/icons/action-client_add.png trunk/vradi-swing/src/main/resources/icons/action-client_delete.png trunk/vradi-swing/src/main/resources/icons/action-close.png trunk/vradi-swing/src/main/resources/icons/action-closeTab.png trunk/vradi-swing/src/main/resources/icons/action-collapse.png trunk/vradi-swing/src/main/resources/icons/action-config.png trunk/vradi-swing/src/main/resources/icons/action-delete.png trunk/vradi-swing/src/main/resources/icons/action-detach.png trunk/vradi-swing/src/main/resources/icons/action-edit.png trunk/vradi-swing/src/main/resources/icons/action-exit.png trunk/vradi-swing/src/main/resources/icons/action-expand.png trunk/vradi-swing/src/main/resources/icons/action-export.png trunk/vradi-swing/src/main/resources/icons/action-feed_add.png trunk/vradi-swing/src/main/resources/icons/action-feed_delete.png trunk/vradi-swing/src/main/resources/icons/action-feed_magnify.png trunk/vradi-swing/src/main/resources/icons/action-fileChooser.png trunk/vradi-swing/src/main/resources/icons/action-fullscreen.png trunk/vradi-swing/src/main/resources/icons/action-group_add.png trunk/vradi-swing/src/main/resources/icons/action-group_delete.png trunk/vradi-swing/src/main/resources/icons/action-help.png trunk/vradi-swing/src/main/resources/icons/action-i18n-fr.png trunk/vradi-swing/src/main/resources/icons/action-i18n-uk.png trunk/vradi-swing/src/main/resources/icons/action-import.png trunk/vradi-swing/src/main/resources/icons/action-information.png trunk/vradi-swing/src/main/resources/icons/action-magnify.png trunk/vradi-swing/src/main/resources/icons/action-open.png trunk/vradi-swing/src/main/resources/icons/action-refresh.png trunk/vradi-swing/src/main/resources/icons/action-rename.png trunk/vradi-swing/src/main/resources/icons/action-revert.png trunk/vradi-swing/src/main/resources/icons/action-save.png trunk/vradi-swing/src/main/resources/icons/action-send.png trunk/vradi-swing/src/main/resources/icons/action-show-help.png trunk/vradi-swing/src/main/resources/icons/action-site.png trunk/vradi-swing/src/main/resources/icons/action-translate.png trunk/vradi-swing/src/main/resources/icons/action-zoom.png trunk/vradi-swing/src/main/resources/icons/application_get.png trunk/vradi-swing/src/main/resources/icons/time.png trunk/vradi-swing/src/main/resources/log4j.properties trunk/vradi-swing/src/main/resources/org/ trunk/vradi-swing/src/main/resources/org/chorem/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Client-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Group-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Status-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/User-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/VradiUser-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/WebHarvestStream-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/XmlStream-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/FieldSelectModel-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/DateEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/IdEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/NumEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/StringEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/TextEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-error-validation.xml trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-required-error-validation.xml trunk/vradi-swing/src/main/resources/validators.xml trunk/vradi-swing/src/main/resources/vradi.properties trunk/vradi-swing/src/site/ trunk/vradi-swing/src/site/rst/ trunk/vradi-swing/src/site/rst/index.rst trunk/vradi-swing/src/site/site_fr.xml trunk/vradi-swing/src/test/ trunk/vradi-swing/src/test/java/ trunk/vradi-swing/src/test/java/org/ trunk/vradi-swing/src/test/java/org/chorem/ trunk/vradi-swing/src/test/java/org/chorem/vradi/ trunk/vradi-swing/src/test/java/org/chorem/vradi/VradiHelperTest.java trunk/vradi-swing/src/test/java/org/chorem/vradi/services/ trunk/vradi-swing/src/test/java/org/chorem/vradi/services/FileServiceProxyTest.java trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ChangeLogUITest.java trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/ trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/XmlStreamHelperTest.java trunk/vradi-swing/src/test/resources/ trunk/vradi-swing/src/test/resources/rss/ trunk/vradi-swing/src/test/resources/rss/equipe_rss.xml Added: trunk/LICENSE.txt =================================================================== --- trunk/LICENSE.txt (rev 0) +++ trunk/LICENSE.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. Property changes on: trunk/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/changelog.txt =================================================================== --- trunk/changelog.txt (rev 0) +++ trunk/changelog.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,361 @@ + +---- 0.5.0 + +Bugs corrigés +============= + +Général +------- + +- Problème de lenteur + +Gestion des formulaires +----------------------- + +- Thésaurus créé en double +- Pièce jointe encapsulée non ajoutée au PDF +- Erreur à la génération PDF + +Gestion des flux XML +-------------------- + +- Aperçu vide + +Nouvelles fonctionalités +======================== + +Gestion des formulaires +----------------------- + +- Permettre la suppression des types de formulaires +- Multiples indexations +- Liens entre formualires +- Multi-sélection de flux dans les listes déroulantes + +---- 0.4.0 + +Bugs corrigés +============= + +Envoi de mail +------------- + +- Arbre non rafraichît à la supression de session +- Liste de formulaires non mise à jour après une suppression de formulaires +- Accusé de réception automatique ne fonctionne pas +- Ajouter des formulaires à un mail supprimé par annulation d'envoi d'un formulaire +- Modification possible d'un mail déjà envoyé +- Impossible d'associer les formulaires pour une nouvelle session + +Administration +-------------- + +- Rafraichissement de l'UI des utilisateurs/groupes +- Bug de case à cocher +- Bug de la couleur des thésaurus +- Impossible de supprimer un thésaurus nouvellement créé +- Problème affichage tooltip sur thésaurus +- Non modification des requêtes impactées +- Mauvaise proposition après la suppression de descripteurs +- Erreur à la suppression de thésaurus +- Impossible de supprimer un flux XML +- Champs du flux XML non vidés +- Possible de créer un statut vide + +Résultats de requêtes +--------------------- + +- Export CSV vide +- Refonte de la cartographie + +Traitement formulaire +--------------------- + +- Supression des erreurs de gestion des fichiers joints (encapsulés ou liés) +- Thésaurus ajouté au niveau des descripteurs + +Nouvelles fonctionnalités +========================= + +- Coloration syntaxique à la rédaction des requêtes +- Enregistrement de la disposition des fenêtres +- Ajout d'un menu contextuel sur le tooltip de résultat de recherche pour la copie + +---- 0.3.0 + +Bugs corrigés +============= + +- Erreurs de rafraichissements +- Impossible de fermer une session +- Résultats de recherche non rafraichis +- Lenteurs à l'affichage +- Association +- Recherche d'un thésaurus et de ses fils +- Tri des formulaires +- Problème de recherche sur un champ +- Cartographie - affichage-tri des noeuds + +Nouvelles fonctionalités +======================== + +- Possibilité d'enlever des destinataires/formulaires à la main depuis l'UI de mail +- Ajouter une fenêtre de recherche annexe +- Enregistrer des requêtes sans client +- Pouvoir jouer les requêtes des groupes +- Possibilité de voir les messages d'erreur d'envoi de mail +- Ajouter un menu contextuel pour ajouter les champs d'une requête +- Enlever un descripteur par double-clic +- Améliorer la documentation (requêtes et génération PDF) +- Envoi de mail si erreur de récupération automatique de flux +- Afficher et rayer les formulaires supprimés manuellement +- Afficher d'une manière différentes les formulaires ajoutés manuellement + +---- 0.2.0 + +Bugs corrigés +============= + +- Tous les flux importés à la même heure +- Gestion des arbres +- Ordre des descripteurs +- Formulaire non modifié lorsqu'il est changé +- Copie de thésaurus +- Import/Export de thésaurus +- Création de descripteur, limiter la taille du chemin +- Cartographie - prise en compte des critères de recherche cachés +- Multiples confirmations d'annulations +- Pas de désindexation des formulaires + +Nouvelles fonctionnalités +========================= + +- Copier/coller depuis n'importe quelle source +- Lien vers les formulaires depuis la cartographie +- Simplifier la copie de thésaurus depuis la recherche +- Retrouver simplement la dernière session ouverte +- Une seule génération PDF + +---- 0.1.0 + +Traitement de formulaire +======================== + +- Masques de saisie pour les champs de formulaires +- Validation du champ SourceURL +- Tout le thésaurus est parcouru à l'enregistrement d'un formulaire + +Flux xml +- Gestion des flux xml sur une adresse en https + +Thesaurus +- Possibilité d'avoir plusieurs thésaurus +- Possibilité de ne pas déplier l'arbre quand on sélectionne un noeud +- La checkbox 'Déplier les noeuds lors de la sélection' ne fonctionne pas +- Probleme de thésaurus quand rentré en majuscules +- Recherche d'un thesaurus et de ses fils + +Requêtes +- Pouvoir afficher le thésaurus lorsqu'on édite une requête +- Tableau traitement AO, manque des colones +- Mélange de 2 flux lors de l'utilisation des listes déroulantes +- Modifications de requêtes non sauvegardées +- Impossible de supprimer une requête + +Envoi de mails +- Rendre configurable l'e-mail d'envoi +- Problème de session lors de la suppression des destinataires +- Impossibilité de se connecter à Internet alors que le PC est connecté +- Ne rien rajouter à une session fermée +- Périodicité des requête pour un client existant +- Non-association des formulaires +- Utiliser le composant de liste utilisateur partout +- Pas de pièces jointes aux mails +- L'accusé de réception ne fonctionne pas +- Session créée le lendemain +- Corps de mail vide +- Bug de l'association formulaire - utilisateur + +Client, utilisateur, groupe, statut +----------------------------------- + +- Prise en compte de la date d'inscription des utilisateurs +- La suppression des status ne fonctionnent plus +- La modification du nom du groupe ne dégrise pas le bouton de sauvegarde +- Cocher ou décocher la case actif sur un client ne dégrise pas le bouton sauvegarder +- Le bouton supprimer ne fonctionne pas +- Erreur de l'import de base client + +Divers +------ + +- Migration vers la nouvelle API d'arbre de JAXX +- Achitecture client/serveur +- Utilisation du cache réparti +- Suppression des DTO +- Nouveau service de transfert de fichiers +- Mise au propre de la configuration basé sur ApplicationConfig +- Reindexation automatique si changement de version +- Impossibilité de faire l'association modèle PDF (nom de dossier avec caractère accentués) +- Augmenter la taille des tooltips +- Desélection des propositions + +---- 0.0.5 + +Traitement de formulaires +------------------------- + +- Propositions : montrer le chemin du noeud +- Pagination des résultats d'une recherche +- Ajout d'un champ tag sur l'infogène +- Déclenchement de la recherche de formulaires en arrière plan +- Gagner de la place en bas de l'écran de modification de formulaire +- Multi-sélection sans appuyer sur controle +- Bug : La zone de recherche ne fonctionne pas +- Bug : Impossible de voir tout le formulaire - redimmensionnement étrange +- Bug : Affichage des requetes/client/... retournant un formulaire +- Bug : Quand on sélectionne une proposition, elle n'est pas réaffichée dans les différents arbres du thésaurus +- Bug : Erreur au traitement des appel d'offre : choix du thesaurus +- Bug : Pas de récapitulatif des noeuds sélectionnés dans la première colonne de thésaurus +- Bug : Ajout d'une colonne de thésaurus non pris en compte +- Bug : La suppression d'une colonne de thésaurus est très longue +- Bug : L'ajout d'une colonne de thésaurus fait buger le thésaurus +- Bug : Pas de récapitulatif des noeuds sélectionnés dans la première colonne de thésaurus +- Bug : Mauvaises propositions de noeuds de thésaurus +- Bug : Problème de barre de défilement sur les colonnes du thésaurus + +Thésaurus +--------- + +- Ajout d'un numéro d'ordre +- Modification des requêtes associées lors d'une modification d'un descripteur +- Afficher les noeuds de premier niveau dans les colonnes du thésaurus +- Bug : Bug lors du changement de couleur d'une profondeur +- Bug : Doublons dans le thésaurus +- Bug : Erreur à l'enregistrement du thesaurus +- Bug : Mauvais thésaurus lors du déplacement d'un noeud +- Bug : Renommage de noeud de thésaurus non enregistré +- Bug : Duplication des noeuds de thésaurus après déplacement +- Bug : Impossibilité de remonter un noeud de thésaurus en fils du noeud root +- Bug : Erreur lors du déplacement d'un noeud de thésaurus +- Bug : Manque une scrollbar sur la liste des modifications de noeud de thésaurus +- Bug : Déplacement de noeud de thésaurus - proposer aucun changement +- Bug : Tri au runtime de l'admin thesaurus + +Requêtes +-------- + +- Support des plages de valeurs (FROM TO) +- Support des requêtes sur le dernier modifieur +- Possibilité de copier un noeud de thésaurus depuis l'administration et le coller dans une requête +- Ajout des '30 derniers jours' dans les champs pré-remplis de requête +- Visionner les résultats de recherche dans la cartographie du thésaurus +- Demander à l'utilisateur de confirmer l'annulation de l'édition des requêtes + +Envoi de mails +-------------- + +- Affichage d'une liste ordonnée des descripteurs associés à chaque formulaire +- Affichage du nombre de formulaires à envoyer à chaque client/utilisateur/groupe +- Ajout de la possibilité d'interrompre la procédure d'envoi de mail +- Ajout de la possibilité de réexpédier un message +- Confirmation quand un email est renvoyé +- Générer les PDFs non présents avant l'envoi des mails +- Afficher un message d'erreur quand pas de modèle PDF attaché +- Bug : Envoie uniquement les formulaires dont le statut est 'sélectionné' +- Bug : Message d'erreur 'bourrin' à l'envoi de mail +- Bug : Ajout de formulaires à une session envoyée +- Bug : Session envoyée alors qu'il y a des erreurs +- Bug : Mail envoyé avec un pdf alors que pas de modèle associé +- Bug : Le paragraphe de session n'est pas envoyé +- Bug : Les accusés de reception ne sont pas visible dans l'UI d'envoie de mail +- Bug : Erreur lors de la génération PDF (pendant l'envoi de mail) +- Bug : L'utilisateur reçoit 2 mails au lieu d'1 +- Bug : Un nouveau client ne doit pas recevoir tous les anciens formulaires +- Bug : Le bouton 'Envoyer les formulaires de la session' ne se grise pas une fois qu'elle a été envoyée +- Bug : Un utilisateur fils de tous les clients +- Bug : Erreur lorsque je supprime un Client ou un utilisateur de la liste des destinataires d'un formulaire + +Flux XML +-------- + +- Ajout de valeurs par defaut pour le mapping d'un flux XML +- Affichage du bilan de l'import de flux XML +- Prise en charge de l'url du flux après un copier coller dans le champ +- Bug : Impossible d'éditer le mapping d'un flux XML si hors-ligne +- Bug : Tooltip de description du flux vide +- Bug : L'ajout d'un nouveau flux dans l'admin n'apparait pas dans la combo du formulaire de recherche + +Client, utilisateur, groupe +--------------------------- + +- Import de base client depuis CSV +- Ajout de libellé et description pour les requêtes client/utilsateur +- Bug : Création des utilisateurs dans le bon client +- Bug : Suppressions d'utilisateurs et de clients +- Bug : Double sauvegarde pour l'administration client/utilisateur/groupe +- Bug : Bug d'affichage des clients quand plusieurs clients ont le même nom +- Bug : Il y a une ligne d'historique alors qu'aucune requête n'a été modifiée +- Bug : Pas de libellé et description pour les requêtes +- Bug : Il y a une ligne d'historique alors qu'aucune requête n'a été modifiée +- Bug : L'historique des requetes ne marche plus +- Bug : Tri des clients et utilisateurs par ordre alphabétique +- Bug : Préfixage des utilisateurs par le nom de leur client + +Statuts +------- + +- Bug : Ordre des statuts non conservés +- Bug : Les flèches de déplacement des statuts ne fonctionnent pas + +Types de formulaires +-------------------- + +- Bug : Le creation de type de formulaire ne fonctionne pas du tout + +Divers +------ + +- Faire fonctionner la reindexation +- Augmentation de la durée d'affichage des infos-bulles +- Ajout de barres de défilement dans la fenêtre de changelog +- La fenêtre d'admin ne doit pas être modale +- Bug : L'application demande si on veut sauver les modifications alors qu'on vient de cliquer sur le bouton supprimer +- Bug : Lors d'un clic sur supprimer, il n'y a pas de demande de confirmation + +---- 0.0.4 + +- Amélioration de l'ui d'administration des thésaurus (affichage des modifications apportées) +- Migration des données enregistrées avec la version précédente +- Ajout des statuts des formulaires +- Ajout de champs à l'infogène +- Amélioration de l'ergonomie +- Ajout des propositions de noeuds de thesaurus aux formulaires + +---- 0.0.3 + +- Amélioration de l'ui d'administration des thésaurus +- Ajout des tags sous la forme "a, b, c..." et ajout d'une description pour les thésaurus +- Export/import de la base de données +- Champ "name" remplacé par "objet" +- Changelog ajouté au menu d'aide +- Chaîne remplacé par ligne et text par paragraphe +- Prévisualisation du flux XML lors de la configuration +- Ajout d'un type de champ monétaire +- Chaque champ d'un formulaire a un nom cours et une description/nom long affichée en tooltip +- Une ligne par session et par client dans l'interface d'envoi d'e-mail +- Ajout d'une barre de progression lors des opérations longues +- Ajout de l'heure dans les dates +- Ajout des tags, séparés par une virgule et d'une description pour chaque noeud du thésaurus +- Ajout des champs source, initiateur et description dans l'infogène +- Possibilité de ne modifier que la date dans l'identifiant d'un formulaire. Identifiant de la forme date-id +- Ajouter un editeur en popup pour l'edition du paragraphe des emails a envoyer + +---- 0.0.2 + +- Client, utilisateur et groupe : création et mise à jour +- Création des types de formulaire +- Création du thésaurus +- Création manuelle de formulaires +- Création automatique de formulaires à partir de flux XMLs ou RSS +- Recherche de formulaires Property changes on: trunk/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/doc/REQUIRED =================================================================== --- trunk/doc/REQUIRED (rev 0) +++ trunk/doc/REQUIRED 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,209 @@ +REQUIS : +-------- + +58) Développement de l'application en client lourd, en utilisant la librairie graphique Swing (cf 4.2 p21). +59) L'application sera uniquement sur le serveur Jurismarchés (cf 4.3 p21). +60) Les technologies suivantes seront utilisées pour la réalisation de l'application (cf 4.4 p22) : + - Java (langage de programmation) + - Swing (librairie graphique) + - Jaxx (librairie de création d'interface graphique) + - Topia (librairie de génération et de persistance) + - Hibernate (librairie de gestion de la persistance) + - Lucene (moteur d'indexation et de recherche) + - PostgreSQL (base de données) + - JavaMail (librairie d'envoi de mails) + - Postfix (serveur d'email) + - Linux (Opérateur système du serveur) + - Samba (Utilisation des disques réseau) + - Apache (Serveur HTTP) + - Tomcat (Conteneur d'applications Java) + + +Lot 2 : Base d'information, thésaurus, requêteur, base client,... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Stockage des informations : +*************************** +49) Chaque modèle de formulaire est décrit via un fichier XML (cf 4.1.1 p19). +50) Un formulaire sera, comme les modèles de formulaire, lui aussi un fichier XML (cf 4.1.1 p19). +57) Les autres données seront stockées dans une base de données relationnelle via Hibernate (cf 4.1.4 p21). + +Structuration des informations : +******************************** +34) Création de types de formulaire correspondant à des types d'information (cf 2.3.8 p14). +48) Chaque formulaire est défini par un certain nombre de champs et de type différents. L'ordre des champs est déterminé par l'utilisateur (cf 4.1.1 p19). +51) A chaque modification ou création d'un fichier XML de formulaire, celui-ci sera envoyé au moteur d'indexation (cf 4.1.1 p19). +52) Lors de la modification d'un formulaire la version précédente du fichier est historisée avec un numéro de version (cf 4.1.1 p19). +53) Le moteur d'indexation utilisé sera Lucene (cf 4.1.1 p19). +54) L'infogène est compris dans un formulaire. Les champs date de création, identifiant, date de péremption sont ainsi présents dans tous les formulaires (cf 4.1.2 p20). +61) Le choix du type des champs des modèles de formulaires se fera via une liste déroulante proposant les types de champ disponibles (cf 5.2.1 p23). +62) Suivant le type de champ choisi l'utilisateur pourra définir des masques de saisie ou des valeurs par défaut (cf 5.2.1 p23). +63) Types de champ disponibles (cf 5.2.1.1 p23) : + - plein texte (plusieurs lignes) + - chaine de caractères (une seule ligne) + - date + - valeur numérique + - adresse email + - adresse web + +Récupération des informations : +******************************* +1) Les formulaires sont fournis sous forme de flux RSS (cf 2.2.1 p9). +12) Après le traitement des données, contrôle des données en s'aidant de la cartographie du thésaurus (cf 2.2.4 p11). +64) L'utilisateur pourra créer de nouveaux formulaires à partir d'un flux RSS (cf 5.2.2 p24). +65) Les nouveaux formulaires qui n'ont pas encore été vérifiés par un utilisateur seront marqués comme étant non traités (cf 5.2.2 p24). + +Enregistrement des informations : +********************************* +2) Chaque formulaire possède un infogène et peut être lié à d'autres infogènes (cf 2.2.1 p10 & 2.3.8 p14). +3) Les formulaires indexés sont disponibles pour tous les utilisateurs (cf 2.2.1 p10). +4) Ajout manuel de formulaires (cf 2.2.2 p10). +5) Les formulaires sont associés à un ou plusieurs descripteurs du thésaurus (cf 2.2.3 p10). +6) Un ou plusieurs descripteurs du thésaurus sont proposés à l'utilisateur en fonction du contenu de l'information extraites via des +mot clés ou groupe de mots associés au descripteurs (cf 2.2.3 p10). +7) Les mots clés doivent pouvoir être proposés avec une troncature, avec prise en charge des apostrophes, ou des groupe de mots (cf 2.2.3 p10). +8) L'utilisateur doit valider les descripteurs proposés afin qu'ils soient pris en compte. Il peut aussi choisir d'utiliser des descripteurs qui ne +lui sont pas proposés (cf 2.2.3 p10). +9) Les informations extraites automatiquement du formulaire sont complétées si besoin (cf 2.2.3 p10). +10) Les opérations de copier/coller depuis n'importe qu'elle source seront possibles sans problème d'encodage des caractères (cf 2.2.3 p10). + +La base client : +**************** +13) Les profils (requêtes sauvegardées) sont associées ou non à des clients et chaque client peut avoir un ou plusieurs destinataires (cf 2.2.5 p11). +66) Chaque société cliente a un ensemble de collaborateurs en relation avec Jurismarchés, chaque collaborateur est identifié dans la base client et associé à un ensemble de profils qui permettent de le caractériser (cf 5.2.3 p26). +67) Les collaborateurs appartiennent automatiquement au groupe de leur société, mais peuvent aussi appartenir à d'autres groupes (cf 5.2.3 p26). +68) Des interfaces de visualisation et de modification seront développées pour permettre l'administration de la base client (cf 5.2.3 p26). +69) A chaque client est associé une requête lui permettant de trier les appels d'offre qu'il doit recevoir (cf 5.2.3 p26). + +Le thésaurus : +************** +21) En cas de suppression d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le nœud supérieur du thésaurus doit être proposé, mais l'opération doit toujours être validée par l'utilisateur (cf 2.3.1 p12); +22) En cas de modification du nom d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le descripteur proposé est celui qui vient d'être renommé. La validation étant effectuée par l'utilisateur (cf 2.3.1 p12); +23) En cas de modification du nœud père d'un descripteur, les requêtes impactées doivent pouvoir être modifiées si jamais la nouvelle classification du descripteur ne convient plus (pas de proposition par défaut)(cf 2.3.1 p12). +55) Le stockage du thésaurus sera en XML (cf 4.1.3 p21). +56) A chaque descripteur du thésaurus, sera associé un ou plusieurs tags permettant de proposer des descripteur à l'utilisateur quand celuici traite un formulaire (cf 4.1.3 p21). +70) Une interface utilisateur permettra la consultation et la modification du thésaurus (cf 5.2.4 p26). +71) Les formulaires indexés via les entrées du thésaurus modifiées seront réindexés (cf 5.2.4 p27). +72) A chaque descripteur du formulaire sera associé un ou plusieurs tags (cf 5.2.4 p27). +72) L'interface permettra aussi d'ajouter/modifier supprimer les tags liés à un descripteur(cf 5.2.4 p27). + +Recherche dans la base d'informations : +*************************************** +24) Les nouvelles requêtes doivent être aisées à écrire et l'interface utilisateur doit proposer une aide à l'écriture de ces requêtes (cf 2.3.2 p12). +25) Les requêtes utilisent les opérateurs AND, OR et NOT et les descripteurs du thésaurus (cf 2.3.2 p12). +26) Lors de la création/modification de requêtes, il doit être possible de jouer les requêtes créées/modifiées sur un intervalle de temps donné et voir les résultats afin de valider ces dernières. Les résultats doivent présenter les formulaires associés(date à date) et les destinataires associés à ces formulaires (cf 2.3.2 p12). +41) Les recherches pourront être effectuées entre deux dates suivant les critères de localisation, émetteur, date limite de réponse et date d'envoi de Jurismarchés (cf 3.5 p15). +73) La recherche se fera directement sur le moteur d'indexation (cf 5.2.5 p28). +74) Chaque type d'information doit pouvoir faire l'objet d'une requête distincte ou mutualisée ou tous les types d'information ALL formulaires (cf 5.2.5 p28). +75) Une interface graphique permettra d'écrire des requêtes, de les sauver, de les rejouer (cf 5.2.5 p28). +76) La page de présentation des résultats permettra d'exporter tous les résultats de la requête sous un format CSV (cf 5.2.5 p28). +77) La page de présentation des résultats utilisera, de plus, la visualisation du thésaurus afin de visualiser rapidement la cartographie des résultats de la recherche (cf 5.2.5 p29). + +--NON CONFORME : +---------------- +52) Lors de la modification d'un formulaire la version précédente du fichier est historisée avec un numéro de version (cf 4.1.1 p19). +62) Suivant le type de champ choisi l'utilisateur pourra définir des masques de saisie ou des valeurs par défaut (cf 5.2.1 p23). +12) Après le traitement des données, contrôle des données en s'aidant de la cartographie du thésaurus (cf 2.2.4 p11). +2) Chaque formulaire possède un infogène et peut être lié à d'autres infogènes (cf 2.2.1 p10 & 2.3.8 p14). +21) En cas de suppression d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le nœud supérieur du thésaurus doit être proposé, mais l'opération doit toujours être validée par l'utilisateur (cf 2.3.1 p12); +22) En cas de modification du nom d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le descripteur proposé est celui qui vient d'être renommé. La validation étant effectuée par l'utilisateur (cf 2.3.1 p12); +23) En cas de modification du nœud père d'un descripteur, les requêtes impactées doivent pouvoir être modifiées si jamais la nouvelle classification du descripteur ne convient plus (pas de proposition par défaut)(cf 2.3.1 p12). +25) Les requêtes utilisent les opérateurs AND, OR et NOT et les descripteurs du thésaurus (cf 2.3.2 p12). +26) Lors de la création/modification de requêtes, il doit être possible de jouer les requêtes créées/modifiées sur un intervalle de temps donné et voir les résultats afin de valider ces dernières. Les résultats doivent présenter les formulaires associés(date à date) et les destinataires associés à ces formulaires (cf 2.3.2 p12). +77) La page de présentation des résultats utilisera, de plus, la visualisation du thésaurus afin de visualiser rapidement la cartographie des résultats de la recherche (cf 5.2.5 p29). +---------------- +-- DOUTE : +---------- +7) Les mots clés doivent pouvoir être proposés avec une troncature, avec prise en charge des apostrophes, ou des groupe de mots (cf 2.2.3 p10). +10) Les opérations de copier/coller depuis n'importe qu'elle source seront possibles sans problème d'encodage des caractères (cf 2.2.3 p10). +13) Les profils (requêtes sauvegardées) sont associées ou non à des clients et chaque client peut avoir un ou plusieurs destinataires (cf 2.2.5 p11). +67) Les collaborateurs appartiennent automatiquement au groupe de leur société, mais peuvent aussi appartenir à d'autres groupes (cf 5.2.3 p26). +69) A chaque client est associé une requête lui permettant de trier les appels d'offre qu'il doit recevoir (cf 5.2.3 p26). +---------- + +Sélection des formulaires à envoyer : +************************************* +78) Les requêtes seront toutes jouées afin d'associer les formulaires traités dans la journée et les clients. Le résultat est affichée dans deux interfaces (cf 5.2.6 p29) : + - clients par formulaire + - formulaires par clients +79) Pour ces interfaces, il sera possible de filtrer ce qui est visible à l'écran soit (cf 5.2.6 p31) : + - par type de formulaire + - par groupe de client + - par profil + - par client + - par ancienneté du client +80) Il est possible d'ajouter un client a un formulaire ou alors d'en enlever (cf 5.2.6 p29). +81) Il sera possible de visualiser l'ensemble des formulaires qui seront expédiés et qui sera leur destinataire, ou +bien visualiser l'ensemble des destinataires du jour et les formulaires qui leur sont associés, cette interface +permettra de sélectionner la date que l'on souhaite visualiser (cf 5.2.6 p29). +82) Tous les nouveaux clients qui n'ont pas encore reçu de mail, auront automatiquement un accusé de réception et cela jusqu'à ce qu'ils en valide au moins un ou qu'ils utilisent un des liens Web du mail envoyé (cf 5.2.6 p32). + +Modèle de génération des PDF : +****************************** +11) Le fichier PDF n'est généré que si quelqu'un souhaite le consulter et qu'il n'existe pas déjà (cf 2.2.3 p10). +27) Pour changer la génération PDF, Jurismarchés créera un patron de génération dans la suite bureautique OpenOffice.org en indiquant les champs du formulaire utilisés par les champs du patron (cf 2.3.3 p12). +28) Vérification de la cohérence de la génération PDF (cf 2.3.3 p13) : + - tous les champs du patron OpenOffice.org sont remplis par le formulaire. (erreur) + - tous les champs du formulaire sont présents dans le patron OpenOffice.org.(avertissement) + +Actualités : +************ +33) Création d'actualités ayant un infogène comme n'importe quel formulaire et associées à des descripteurs du thésaurus (cf 2.3.7 p13). +35) Actualités présentes sur toutes les pages de l'espace client (cf 3.2 p15). + + +Lot 3 : Envoi automatique de mails +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +15) Possibilité d'ajouter des informations à un mail (cf 2.2.5 p11). +16) Chaque client de Jurismarchés ne recevra qu'un mail par envoi, et ce quel que soit le nombre de formulaires à lui expédier (cf 2.2.5 p11). +17) Une fois les mails préparés, ils sont envoyés aux différents clients de Jurismarchés par un appui sur un bouton (cf 2.2.6 p11). +18) Une interface annonce le déroulement de l'opération (cf 2.2.6 p11). +19) Tant que les emails n'ont pas été envoyés, il est toujours possible d'interrompre la procédure d'envoi (cf 2.2.6 p11). +20) L'envoi des mails peut être différé (cf 2.2.6 p11). +83) L'interface permettant de visualiser l'ensemble des destinataires du jour permet aussi la visualisation de l'état d'expédition des mails (cf 5.3 p33) : + - à envoyer + - envoyé + - en attente de l'accusé de réception + - reçu + - erreur d'expédition +84) Dans le cas ou il y a eu une erreur d'expédition, il sera possible de voir le message d'erreur envoyé par le serveur de mail (cf 5.3 p33). +85) La plupart des mails correctement délivrés resteront dans l'état envoyé, il ne pourront passer dans l'état reçu que lorsque le client validera l'accusé de réception ou cliquera sur un des liens du mail pour télécharger un document attaché (cf 5.3 p33). +86) Cette interface permettra aussi de réexpédier un mail destiné à un client vers une autre adresse mail (cf 5.3 p33). + + +Lot 4 : Le portail client +~~~~~~~~~~~~~~~~~~~~~~~~~ +14) Les données sont présentées suivant plusieurs vues (cf 2.2.5 p11) : + - formulaires par requête; + - requête par formulaire; + - destinataires par formulaire; + - formulaires par destinataire; + - groupe par formulaire; + - formulaire par groupe. +36) Dans son interface, un client doit pouvoir visionner tous les formulaires qu'il a reçu (cf 3.3 p15). +37) L'interface client présentera par défaut les formulaires dont la date limite de réponse n'est pas dépassée (cf 3.3 p15). +38) Les autres formulaires resteront accessibles par une fonction de recherche et par date d'envoi de Jurismarchés sous forme de liste (cf 3.3 p15). +39) Les différents types de formulaires correspondent à des pages d'affichages et des rubriques différentes. Toutefois ils pourront être regroupés (cf 3.3 p15). +40) Tri des formulaires par type et date limite de réponse (cf 3.4 p15). +42) Un client doit toujours pouvoir télécharger la dernière version du fichier PDF générée par Jurismarchés (cf 3.6 p16). +43) S'il est autorisé par Jurismarchés, un client doit pouvoir télécharger les pièces jointes d'un formulaire, que ce soit depuis sa page d'accueil ou depuis les résultats de la recherche (cf 3.7 p16). +44) Un client doit pouvoir déterminer une adresse email qui recevra les appels d'offre pendant son absence (cf 3.8 p16). +45) Il pourra aussi décider de ne pas recevoir d'email pendant une période, mais continuer de recevoir les formulaires dans son portail client (cf 3.8 p16). +46) La liste des documents recus, présente sur la page d'accueil de l'interface client possèdera les champs suivants : Nom, Type et Date envoi (3.9.1 p17). +47) La liste des appels d'offre recus, présente sur la page de visionnage d'un type de formulaire de l'interface client possèdera les champs suivants : Nom, Date envoi, Demandeur, Date de soumission et Budget (3.9.2 p18). +87) Si le client n'a pas de compte, il pourra en créer un automatiquement grâce à son adresse mail (cf 5.4 p34). +88) Cette adresse lui servira de login. Un mot de passe généré aléatoirement lui sera envoyé par mail (cf 5.4 p34). +89) Si l'utilisateur oublie son mot de passe, il pourra demander à le recevoir de nouveau par mail (cf 5.4 p34). +90) Une fois connecté le client pourra voir l'ensemble des documents qu'il a reçu lors du mois en cours. Il pourra demander à filtrer les documents en fonction de la date d'envoi, du type de modèle de formulaire (cf 5.4 p34). +91) Le client pourra alors sélectionner un ensemble de formulaires et demander à voir leur contenu sous forme de tableau (cf 5.4 p34). +92) Il y aura un tableau par modèle de formulaire sur lequel le client pourra sélectionner certaines colonnes et demander leur export au format CSV (cf 5.4 p34). +93) Le client aura alors les mêmes fonctionnalités que sur la page d'accueil de son espace client (cf 5.4 p34). + + +Lot 5 : Le module de statistiques +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +29) Construction de requêtes statistiques dans lesquelles des descripteurs du thésaurus peuvent prendre toutes les valeurs de leurs fils (cf 2.3.4 p13). +30) Résultat de ces requêtes sous forme de tableau, exportable au format CSV (cf 2.3.4 p13). +31) Génération de la présentation des données sous formes de diagrammes, tout en permettant à Jurismarchés de rajouter des informations sous la forme de texte (cf 2.3.5 p13). +32) Envoi des résultats statistiques comme des formulaires aux clients (cf 2.3.6 p13). +94) Il est possible d'effectuer la génération de la représentation graphique des résultats à l'extérieur du système et l'importer pour générer les documents statistiques (cf 5.5 p34). + Property changes on: trunk/doc/REQUIRED ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/pom.xml =================================================================== --- trunk/pom.xml (rev 0) +++ trunk/pom.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,499 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>mavenpom4redmine</artifactId> + <version>2.5.3</version> + </parent> + + <groupId>org.chorem</groupId> + <artifactId>vradi</artifactId> + <version>0.6-SNAPSHOT</version> + + <modules> + <module>vradi-entities</module> + <module>vradi-services</module> + <module>vradi-services-web</module> + <module>vradi-swing</module> + </modules> + + <name>Vradi</name> + + <description>Projet Vradi</description> + <inceptionYear>2009</inceptionYear> + <url>http://maven-site.chorem.org/vradi</url> + + <licenses> + <license> + <name>GNU Affero General Public License version 3</name> + <url>http://www.gnu.org/licenses/agpl.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <developers> + + <developer> + <id>tchemit</id> + <name>Tony Chemit</name> + <email>chemit@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + + <developer> + <id>sletellier</id> + <name>Sylvain Letellier</name> + <email>letellier@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + + <developer> + <id>kmorin</id> + <name>Kevin Morin</name> + <email>morin@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + + <developer> + <id>jcouteau</id> + <name>Jean Couteau</name> + <email>couteau@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + + <developer> + <id>echatellier</id> + <name>Eric Chatellier</name> + <email>chatellier@codelutin.com</email> + <organization>CodeLutin</organization> + <roles> + <role>Développeur</role> + </roles> + <timezone>+2</timezone> + </developer> + </developers> + + <scm> + <connection>scm:svn:http://svn.chorem.org/svn/vradi/trunk</connection> + <developerConnection> + scm:svn:http://svn.chorem.org/svn/vradi/trunk + </developerConnection> + <url>http://www.chorem.org/repositories/browse/vradi/trunk</url> + </scm> + + <packaging>pom</packaging> + + + <properties> + <platform>chorem.org</platform> + <projectId>vradi</projectId> + + <!-- libraries version --> + <jaxxVersion>2.4</jaxxVersion> + <nuitonUtilsVersion>2.1.1</nuitonUtilsVersion> + <nuitonI18nVersion>2.3.2</nuitonI18nVersion> + <nuitonWidgetVersion>1.1</nuitonWidgetVersion> + <generatorPluginVersion>2.3.3</generatorPluginVersion> + <wikittyVersion>3.0.5</wikittyVersion> + <oooVersion>3.2.1</oooVersion> + <javamailVersion>1.4.3</javamailVersion> + <slf4jVersion>1.6.1</slf4jVersion> + + <!-- license header default copyright holder --> + <license.organizationName>Codelutin</license.organizationName> + + <!-- license to use --> + <license.licenseName>agpl_v3</license.licenseName> + + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>net.sourceforge.web-harvest</groupId> + <artifactId>web-harvest</artifactId> + <version>2.0-cl_20100531</version> + <exclusions> + <exclusion> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- librairie des nuiton-utils --> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + <version>${nuitonUtilsVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + <version>${nuitonI18nVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-widgets</artifactId> + <version>${nuitonWidgetVersion}</version> + <scope>compile</scope> + </dependency> + + <!-- librairie Jaxx --> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>javax.help</groupId> + <artifactId>javahelp</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-validator</artifactId> + <version>${jaxxVersion}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + <version>${jaxxVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + <version>${jaxxVersion}</version> + <scope>test</scope> + <classifier>tests</classifier> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>swingx-core</artifactId> + <version>1.6.2-2</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>jxlayer</artifactId> + <version>3.0.4</version> + </dependency> + + <dependency> + <groupId>com.fifesoft</groupId> + <artifactId>rsyntaxtextarea</artifactId> + <version>1.4.1</version> + </dependency> + + <!-- base h2 --> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <!-- Don't use < 1.1 or > 1.2.129 without testing migration + with old datas --> + <version>1.2.127</version> + <scope>runtime</scope> + </dependency> + + <!-- base postgres --> + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>8.4-701.jdbc4</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>xpp3</groupId> + <artifactId>xpp3</artifactId> + <version>1.1.4c</version> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + <version>${wikittyVersion}</version> + </dependency> + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-jdbc-impl</artifactId> + <version>${wikittyVersion}</version> + </dependency> + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-solr-impl</artifactId> + <version>${wikittyVersion}</version> + </dependency> + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-hessian-client</artifactId> + <version>${wikittyVersion}</version> + </dependency> + + <dependency> + <groupId>org.apache.lucene</groupId> + <artifactId>lucene-core</artifactId> + <version>2.9.3</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.tika</groupId> + <artifactId>tika-core</artifactId> + <version>0.8</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4jVersion}</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${slf4jVersion}</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.1</version> + </dependency> + + <!-- RSS dependencies --> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <version>1.0</version> + <!-- org.dom:jdom already included --> + <exclusions> + <exclusion> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>juh</artifactId> + <version>${oooVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>jurt</artifactId> + <version>${oooVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>ridl</artifactId> + <version>${oooVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>unoil</artifactId> + <version>${oooVersion}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + <version>${javamailVersion}</version> + </dependency> + + <dependency> + <groupId>com.caucho</groupId> + <artifactId>hessian</artifactId> + <version>4.0.6</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-fileupload</groupId> + <artifactId>commons-fileupload</artifactId> + <version>1.2.2</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-runner</artifactId> + <version>${jettyPluginVersion}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + <version>${jettyPluginVersion}</version> + <scope>provided</scope> + </dependency> + + <!-- Needed in runtime by solr (set provided where needed) --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> + <version>1.1</version> + </dependency> + + <dependency> + <groupId>net.sf.opencsv</groupId> + <artifactId>opencsv</artifactId> + <version>2.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + <version>1.0.1</version> + </dependency> + + <dependency> + <groupId>com.opensymphony</groupId> + <artifactId>xwork</artifactId> + <version>2.1.3</version> + </dependency> + + </dependencies> + </dependencyManagement> + + <build> + + <pluginManagement> + <plugins> + + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <version>${jaxxVersion}</version> + </plugin> + + <!-- eugene plugin --> + <plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>maven-eugene-plugin</artifactId> + <version>${generatorPluginVersion}</version> + <dependencies> + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-generators</artifactId> + <version>${wikittyVersion}</version> + </dependency> + </dependencies> + </plugin> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <version>${nuitonI18nVersion}</version> + <configuration> + <bundles>fr_FR</bundles> + </configuration> + </plugin> + + <!-- plugin site --> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.nuiton.jrst</groupId> + <artifactId>doxia-module-jrst</artifactId> + <version>${jrstPluginVersion}</version> + </dependency> + </dependencies> + </plugin> + + </plugins> + </pluginManagement> + + </build> + + <reporting> + <excludeDefaults>true</excludeDefaults> + </reporting> + + <repositories> + + <!-- depot des snapshots nuiton --> + <repository> + <id>nuiton.snapshot</id> + <name>NuitonSnapshotRepository</name> + <url>http://maven.nuiton.org/snapshot</url> + <snapshots> + <enabled>true</enabled> + <checksumPolicy>fail</checksumPolicy> + </snapshots> + <releases> + <enabled>false</enabled> + </releases> + </repository> + + </repositories> + + <pluginRepositories> + + <!-- depot des snapshots nuiton --> + <pluginRepository> + <id>nuiton.snapshot</id> + <name>NuitonSnapshotRepository</name> + <url>http://maven.nuiton.org/snapshot</url> + <snapshots> + <enabled>true</enabled> + <checksumPolicy>fail</checksumPolicy> + </snapshots> + <releases> + <enabled>false</enabled> + </releases> + </pluginRepository> + + </pluginRepositories> + +</project> Property changes on: trunk/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/announcement/release-email-0.5.0.txt =================================================================== --- trunk/src/announcement/release-email-0.5.0.txt (rev 0) +++ trunk/src/announcement/release-email-0.5.0.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,37 @@ +Toute l'équipe de VRADI est fière d'annoncer la version 0.5.0. + +Dans cette version : + +Bugs corrigés +============= + +Général +------- + +- Problème de lenteur + +Gestion des formulaires +----------------------- + +- Thésaurus créé en double +- Pièce jointe encapsulée non ajoutée au PDF +- Erreur à la génération PDF + +Gestion des flux XML +-------------------- + +- Aperçu vide + +Nouvelles fonctionalités +======================== + +Gestion des formulaires +----------------------- + +- Permettre la suppression des types de formulaires +- Multiples indexations +- Liens entre formualires +- Multi-sélection de flux dans les listes déroulantes + +Les fichiers peuvent être téléchargés à cette adresse : https://labs.libre-entreprise.org/frs/?group_id=146 +La documentation est disponible à l'adresse : http://vradi.labs.libre-entreprise.org/vradi \ No newline at end of file Property changes on: trunk/src/announcement/release-email-0.5.0.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/announcement/release-email-0.5.1.txt =================================================================== --- trunk/src/announcement/release-email-0.5.1.txt (rev 0) +++ trunk/src/announcement/release-email-0.5.1.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,14 @@ +Toute l'équipe de VRADI est fière d'annoncer la version 0.5.1. + +Dans cette version : + +Bugs corrigés +============= + +Général +------- + +- Problème d'import / export + +Les fichiers peuvent être téléchargés à cette adresse : https://labs.libre-entreprise.org/frs/?group_id=146 +La documentation est disponible à l'adresse : http://vradi.labs.libre-entreprise.org/vradi Property changes on: trunk/src/announcement/release-email-0.5.1.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/doc/REQUIRED =================================================================== --- trunk/src/doc/REQUIRED (rev 0) +++ trunk/src/doc/REQUIRED 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,187 @@ +REQUIS : +-------- + +58) Développement de l'application en client lourd, en utilisant la librairie graphique Swing (cf 4.2 p21). +59) L'application sera uniquement sur le serveur Jurismarchés (cf 4.3 p21). +60) Les technologies suivantes seront utilisées pour la réalisation de l'application (cf 4.4 p22) : + - Java (langage de programmation) + - Swing (librairie graphique) + - Jaxx (librairie de création d'interface graphique) + - Topia (librairie de génération et de persistance) + - Hibernate (librairie de gestion de la persistance) + - Lucene (moteur d'indexation et de recherche) + - PostgreSQL (base de données) + - JavaMail (librairie d'envoi de mails) + - Postfix (serveur d'email) + - Linux (Opérateur système du serveur) + - Samba (Utilisation des disques réseau) + - Apache (Serveur HTTP) + - Tomcat (Conteneur d'applications Java) + + +Lot 2 : Base d'information, thésaurus, requêteur, base client,... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Stockage des informations : +*************************** +49) Chaque modèle de formulaire est décrit via un fichier XML (cf 4.1.1 p19). +50) Un formulaire sera, comme les modèles de formulaire, lui aussi un fichier XML (cf 4.1.1 p19). +57) Les autres données seront stockées dans une base de données relationnelle via Hibernate (cf 4.1.4 p21). + +Structuration des informations : +******************************** +34) Création de types de formulaire correspondant à des types d'information (cf 2.3.8 p14). +48) Chaque formulaire est défini par un certain nombre de champs et de type différents. L'ordre des champs est déterminé par l'utilisateur (cf 4.1.1 p19). +51) A chaque modification ou création d'un fichier XML de formulaire, celui-ci sera envoyé au moteur d'indexation (cf 4.1.1 p19). +52) Lors de la modification d'un formulaire la version précédente du fichier est historisée avec un numéro de version (cf 4.1.1 p19). +53) Le moteur d'indexation utilisé sera Lucene (cf 4.1.1 p19). +54) L'infogène est compris dans un formulaire. Les champs date de création, identifiant, date de péremption sont ainsi présents dans tous les formulaires (cf 4.1.2 p20). +61) Le choix du type des champs des modèles de formulaires se fera via une liste déroulante proposant les types de champ disponibles (cf 5.2.1 p23). +62) Suivant le type de champ choisi l'utilisateur pourra définir des masques de saisie ou des valeurs par défaut (cf 5.2.1 p23). +63) Types de champ disponibles (cf 5.2.1.1 p23) : + - plein texte (plusieurs lignes) + - chaine de caractères (une seule ligne) + - date + - valeur numérique + - adresse email + - adresse web + +Récupération des informations : +******************************* +1) Les formulaires sont fournis sous forme de flux RSS (cf 2.2.1 p9). +12) Après le traitement des données, contrôle des données en s'aidant de la cartographie du thésaurus (cf 2.2.4 p11). +64) L'utilisateur pourra créer de nouveaux formulaires à partir d'un flux RSS (cf 5.2.2 p24). +65) Les nouveaux formulaires qui n'ont pas encore été vérifiés par un utilisateur seront marqués comme étant non traités (cf 5.2.2 p24). + +Enregistrement des informations : +********************************* +2) Chaque formulaire possède un infogène et peut être lié à d'autres infogènes (cf 2.2.1 p10 & 2.3.8 p14). +3) Les formulaires indexés sont disponibles pour tous les utilisateurs (cf 2.2.1 p10). +4) Ajout manuel de formulaires (cf 2.2.2 p10). +5) Les formulaires sont associés à un ou plusieurs descripteurs du thésaurus (cf 2.2.3 p10). +6) Un ou plusieurs descripteurs du thésaurus sont proposés à l'utilisateur en fonction du contenu de l'information extraites via des +mot clés ou groupe de mots associés au descripteurs (cf 2.2.3 p10). +7) Les mots clés doivent pouvoir être proposés avec une troncature, avec prise en charge des apostrophes, ou des groupe de mots (cf 2.2.3 p10). +8) L'utilisateur doit valider les descripteurs proposés afin qu'ils soient pris en compte. Il peut aussi choisir d'utiliser des descripteurs qui ne +lui sont pas proposés (cf 2.2.3 p10). +9) Les informations extraites automatiquement du formulaire sont complétées si besoin (cf 2.2.3 p10). +10) Les opérations de copier/coller depuis n'importe qu'elle source seront possibles sans problème d'encodage des caractères (cf 2.2.3 p10). + +La base client : +**************** +13) Les profils (requêtes sauvegardées) sont associées ou non à des clients et chaque client peut avoir un ou plusieurs destinataires (cf 2.2.5 p11). +66) Chaque société cliente a un ensemble de collaborateurs en relation avec Jurismarchés, chaque collaborateur est identifié dans la base client et associé à un ensemble de profils qui permettent de le caractériser (cf 5.2.3 p26). +67) Les collaborateurs appartiennent automatiquement au groupe de leur société, mais peuvent aussi appartenir à d'autres groupes (cf 5.2.3 p26). +68) Des interfaces de visualisation et de modification seront développées pour permettre l'administration de la base client (cf 5.2.3 p26). +69) A chaque client est associé une requête lui permettant de trier les appels d'offre qu'il doit recevoir (cf 5.2.3 p26). + +Le thésaurus : +************** +21) En cas de suppression d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le nœud supérieur du thésaurus doit être proposé, mais l'opération doit toujours être validée par l'utilisateur (cf 2.3.1 p12); +22) En cas de modification du nom d'un descripteur, il faut pouvoir modifier toutes les requêtes impactées. Par défaut, le descripteur proposé est celui qui vient d'être renommé. La validation étant effectuée par l'utilisateur (cf 2.3.1 p12); +23) En cas de modification du nœud père d'un descripteur, les requêtes impactées doivent pouvoir être modifiées si jamais la nouvelle classification du descripteur ne convient plus (pas de proposition par défaut)(cf 2.3.1 p12). +55) Le stockage du thésaurus sera en XML (cf 4.1.3 p21). +56) A chaque descripteur du thésaurus, sera associé un ou plusieurs tags permettant de proposer des descripteur à l'utilisateur quand celuici traite un formulaire (cf 4.1.3 p21). +70) Une interface utilisateur permettra la consultation et la modification du thésaurus (cf 5.2.4 p26). +71) Les formulaires indexés via les entrées du thésaurus modifiées seront réindexés (cf 5.2.4 p27). +72) A chaque descripteur du formulaire sera associé un ou plusieurs tags (cf 5.2.4 p27). +72) L'interface permettra aussi d'ajouter/modifier supprimer les tags liés à un descripteur(cf 5.2.4 p27). + +Recherche dans la base d'informations : +*************************************** +24) Les nouvelles requêtes doivent être aisées à écrire et l'interface utilisateur doit proposer une aide à l'écriture de ces requêtes (cf 2.3.2 p12). +25) Les requêtes utilisent les opérateurs AND, OR et NOT et les descripteurs du thésaurus (cf 2.3.2 p12). +26) Lors de la création/modification de requêtes, il doit être possible de jouer les requêtes créées/modifiées sur un intervalle de temps donné et voir les résultats afin de valider ces dernières. Les résultats doivent présenter les formulaires associés(date à date) et les destinataires associés à ces formulaires (cf 2.3.2 p12). +41) Les recherches pourront être effectuées entre deux dates suivant les critères de localisation, émetteur, date limite de réponse et date d'envoi de Jurismarchés (cf 3.5 p15). +73) La recherche se fera directement sur le moteur d'indexation (cf 5.2.5 p28). +74) Chaque type d'information doit pouvoir faire l'objet d'une requête distincte ou mutualisée ou tous les types d'information ALL formulaires (cf 5.2.5 p28). +75) Une interface graphique permettra d'écrire des requêtes, de les sauver, de les rejouer (cf 5.2.5 p28). +76) La page de présentation des résultats permettra d'exporter tous les résultats de la requête sous un format CSV (cf 5.2.5 p28). +77) La page de présentation des résultats utilisera, de plus, la visualisation du thésaurus afin de visualiser rapidement la cartographie des résultats de la recherche (cf 5.2.5 p29). + +Sélection des formulaires à envoyer : +************************************* +78) Les requêtes seront toutes jouées afin d'associer les formulaires traités dans la journée et les clients. Le résultat est affichée dans deux interfaces (cf 5.2.6 p29) : + - clients par formulaire + - formulaires par clients +79) Pour ces interfaces, il sera possible de filtrer ce qui est visible à l'écran soit (cf 5.2.6 p31) : + - par type de formulaire + - par groupe de client + - par profil + - par client + - par ancienneté du client +80) Il est possible d'ajouter un client a un formulaire ou alors d'en enlever (cf 5.2.6 p29). +81) Il sera possible de visualiser l'ensemble des formulaires qui seront expédiés et qui sera leur destinataire, ou +bien visualiser l'ensemble des destinataires du jour et les formulaires qui leur sont associés, cette interface +permettra de sélectionner la date que l'on souhaite visualiser (cf 5.2.6 p29). +82) Tous les nouveaux clients qui n'ont pas encore reçu de mail, auront automatiquement un accusé de réception et cela jusqu'à ce qu'ils en valide au moins un ou qu'ils utilisent un des liens Web du mail envoyé (cf 5.2.6 p32). + +Modèle de génération des PDF : +****************************** +11) Le fichier PDF n'est généré que si quelqu'un souhaite le consulter et qu'il n'existe pas déjà (cf 2.2.3 p10). +27) Pour changer la génération PDF, Jurismarchés créera un patron de génération dans la suite bureautique OpenOffice.org en indiquant les champs du formulaire utilisés par les champs du patron (cf 2.3.3 p12). +28) Vérification de la cohérence de la génération PDF (cf 2.3.3 p13) : + - tous les champs du patron OpenOffice.org sont remplis par le formulaire. (erreur) + - tous les champs du formulaire sont présents dans le patron OpenOffice.org.(avertissement) + +Actualités : +************ +33) Création d'actualités ayant un infogène comme n'importe quel formulaire et associées à des descripteurs du thésaurus (cf 2.3.7 p13). +35) Actualités présentes sur toutes les pages de l'espace client (cf 3.2 p15). + + +Lot 3 : Envoi automatique de mails +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +15) Possibilité d'ajouter des informations à un mail (cf 2.2.5 p11). +16) Chaque client de Jurismarchés ne recevra qu'un mail par envoi, et ce quel que soit le nombre de formulaires à lui expédier (cf 2.2.5 p11). +17) Une fois les mails préparés, ils sont envoyés aux différents clients de Jurismarchés par un appui sur un bouton (cf 2.2.6 p11). +18) Une interface annonce le déroulement de l'opération (cf 2.2.6 p11). +19) Tant que les emails n'ont pas été envoyés, il est toujours possible d'interrompre la procédure d'envoi (cf 2.2.6 p11). +20) L'envoi des mails peut être différé (cf 2.2.6 p11). +83) L'interface permettant de visualiser l'ensemble des destinataires du jour permet aussi la visualisation de l'état d'expédition des mails (cf 5.3 p33) : + - à envoyer + - envoyé + - en attente de l'accusé de réception + - reçu + - erreur d'expédition +84) Dans le cas ou il y a eu une erreur d'expédition, il sera possible de voir le message d'erreur envoyé par le serveur de mail (cf 5.3 p33). +85) La plupart des mails correctement délivrés resteront dans l'état envoyé, il ne pourront passer dans l'état reçu que lorsque le client validera l'accusé de réception ou cliquera sur un des liens du mail pour télécharger un document attaché (cf 5.3 p33). +86) Cette interface permettra aussi de réexpédier un mail destiné à un client vers une autre adresse mail (cf 5.3 p33). + + +Lot 4 : Le portail client +~~~~~~~~~~~~~~~~~~~~~~~~~ +14) Les données sont présentées suivant plusieurs vues (cf 2.2.5 p11) : + - formulaires par requête; + - requête par formulaire; + - destinataires par formulaire; + - formulaires par destinataire; + - groupe par formulaire; + - formulaire par groupe. +36) Dans son interface, un client doit pouvoir visionner tous les formulaires qu'il a reçu (cf 3.3 p15). +37) L'interface client présentera par défaut les formulaires dont la date limite de réponse n'est pas dépassée (cf 3.3 p15). +38) Les autres formulaires resteront accessibles par une fonction de recherche et par date d'envoi de Jurismarchés sous forme de liste (cf 3.3 p15). +39) Les différents types de formulaires correspondent à des pages d'affichages et des rubriques différentes. Toutefois ils pourront être regroupés (cf 3.3 p15). +40) Tri des formulaires par type et date limite de réponse (cf 3.4 p15). +42) Un client doit toujours pouvoir télécharger la dernière version du fichier PDF générée par Jurismarchés (cf 3.6 p16). +43) S'il est autorisé par Jurismarchés, un client doit pouvoir télécharger les pièces jointes d'un formulaire, que ce soit depuis sa page d'accueil ou depuis les résultats de la recherche (cf 3.7 p16). +44) Un client doit pouvoir déterminer une adresse email qui recevra les appels d'offre pendant son absence (cf 3.8 p16). +45) Il pourra aussi décider de ne pas recevoir d'email pendant une période, mais continuer de recevoir les formulaires dans son portail client (cf 3.8 p16). +46) La liste des documents recus, présente sur la page d'accueil de l'interface client possèdera les champs suivants : Nom, Type et Date envoi (3.9.1 p17). +47) La liste des appels d'offre recus, présente sur la page de visionnage d'un type de formulaire de l'interface client possèdera les champs suivants : Nom, Date envoi, Demandeur, Date de soumission et Budget (3.9.2 p18). +87) Si le client n'a pas de compte, il pourra en créer un automatiquement grâce à son adresse mail (cf 5.4 p34). +88) Cette adresse lui servira de login. Un mot de passe généré aléatoirement lui sera envoyé par mail (cf 5.4 p34). +89) Si l'utilisateur oublie son mot de passe, il pourra demander à le recevoir de nouveau par mail (cf 5.4 p34). +90) Une fois connecté le client pourra voir l'ensemble des documents qu'il a reçu lors du mois en cours. Il pourra demander à filtrer les documents en fonction de la date d'envoi, du type de modèle de formulaire (cf 5.4 p34). +91) Le client pourra alors sélectionner un ensemble de formulaires et demander à voir leur contenu sous forme de tableau (cf 5.4 p34). +92) Il y aura un tableau par modèle de formulaire sur lequel le client pourra sélectionner certaines colonnes et demander leur export au format CSV (cf 5.4 p34). +93) Le client aura alors les mêmes fonctionnalités que sur la page d'accueil de son espace client (cf 5.4 p34). + + +Lot 5 : Le module de statistiques +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +29) Construction de requêtes statistiques dans lesquelles des descripteurs du thésaurus peuvent prendre toutes les valeurs de leurs fils (cf 2.3.4 p13). +30) Résultat de ces requêtes sous forme de tableau, exportable au format CSV (cf 2.3.4 p13). +31) Génération de la présentation des données sous formes de diagrammes, tout en permettant à Jurismarchés de rajouter des informations sous la forme de texte (cf 2.3.5 p13). +32) Envoi des résultats statistiques comme des formulaires aux clients (cf 2.3.6 p13). +94) Il est possible d'effectuer la génération de la représentation graphique des résultats à l'extérieur du système et l'importer pour générer les documents statistiques (cf 5.5 p34). + Property changes on: trunk/src/doc/REQUIRED ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/doc/archiTechnique.dia =================================================================== (Binary files differ) Property changes on: trunk/src/doc/archiTechnique.dia ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/doc/archiTechnique.png =================================================================== (Binary files differ) Property changes on: trunk/src/doc/archiTechnique.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/addField.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/addField.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/clients.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/clients.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/creationThesaurus.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/creationThesaurus.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/destsByForm.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/destsByForm.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/devel/archi.svg =================================================================== --- trunk/src/site/resources/devel/archi.svg (rev 0) +++ trunk/src/site/resources/devel/archi.svg 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,681 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="297mm" + height="210mm" + id="svg2816" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="vradi.svg"> + <defs + id="defs2818"> + <marker + inkscape:stockid="Arrow1Lstart" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lstart" + style="overflow:visible"> + <path + id="path3872" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" + transform="scale(0.8) translate(12.5,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Mend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Mend" + style="overflow:visible;"> + <path + id="path3881" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.4) rotate(180) translate(10,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Lend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lend" + style="overflow:visible;"> + <path + id="path3875" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.8) rotate(180) translate(12.5,0)" /> + </marker> + <linearGradient + inkscape:collect="always" + id="linearGradient3693"> + <stop + style="stop-color:#ffb88b;stop-opacity:1;" + offset="0" + id="stop3695" /> + <stop + style="stop-color:#ffb88b;stop-opacity:0;" + offset="1" + id="stop3697" /> + </linearGradient> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 372.04724 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="1052.3622 : 372.04724 : 1" + inkscape:persp3d-origin="526.18109 : 248.03149 : 1" + id="perspective2825" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3693" + id="linearGradient3699" + x1="22.448979" + y1="399.97954" + x2="71.798546" + y2="399.97954" + gradientUnits="userSpaceOnUse" /> + <inkscape:perspective + id="perspective2836" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2836-3" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2836-7" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2904" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2985" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2985-2" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3804" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3804-0" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective6219" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective6457" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective6493" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + inkscape:document-units="mm" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.98" + inkscape:cx="427.14398" + inkscape:cy="370.35978" + inkscape:current-layer="layer1" + id="namedview2820" + showgrid="false" + inkscape:window-width="1680" + inkscape:window-height="973" + inkscape:window-x="-2" + inkscape:window-y="26" + inkscape:window-maximized="1" /> + <metadata + id="metadata2822"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 486.73469,18.584278 3.06123,711.224492" + id="path2848" + inkscape:connector-type="polyline" /> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="150" + y="45.114891" + id="text2850"><tspan + sodipodi:role="line" + id="tspan2852" + x="150" + y="45.114891">Client</tspan></text> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="650" + y="56.339378" + id="text2854"><tspan + sodipodi:role="line" + x="650" + y="56.339378" + id="tspan2858">Serveur</tspan></text> + <g + id="g2942" + transform="translate(-116.32653,262.2449)"> + <g + id="g3644"> + <rect + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3.67120075;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.34240138, 14.68480276;stroke-dashoffset:0" + id="rect2862" + width="151.36961" + height="37.0839" + x="141.15193" + y="84.226006" /> + <text + xml:space="preserve" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="158.16325" + y="107.35979" + id="text3636"><tspan + sodipodi:role="line" + x="158.16325" + y="107.35979" + id="tspan3640" + style="font-size:20px">WikittyProxy</tspan></text> + </g> + </g> + <g + id="g2937" + transform="translate(-20.408164,407.14286)"> + <path + transform="translate(-12.244898,19.387755)" + d="m 217.34694,165.01285 c 0,12.68 -37.23346,22.95918 -83.16327,22.95918 -45.929805,0 -83.163269,-10.27918 -83.163269,-22.95918 0,-12.68001 37.233464,-22.95918 83.163269,-22.95918 45.92981,0 83.16327,10.27917 83.16327,22.95918 z" + sodipodi:ry="22.959183" + sodipodi:rx="83.163269" + sodipodi:cy="165.01285" + sodipodi:cx="134.18367" + id="path3649" + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2868" + y="185.93123" + x="51.020409" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + id="tspan2872" + y="185.93123" + x="51.020409" + sodipodi:role="line">WikittyServiceNotifier</tspan></text> + </g> + <g + id="g2932" + transform="translate(-20.408163,235.71428)"> + <path + transform="translate(-14.285714,36.734694)" + d="m 222.44897,221.1353 c 0,11.55289 -38.60401,20.91837 -86.22448,20.91837 C 88.604018,242.05367 50,232.68819 50,221.1353 c 0,-11.5529 38.604018,-20.91837 86.22449,-20.91837 47.62047,0 86.22448,9.36547 86.22448,20.91837 z" + sodipodi:ry="20.918367" + sodipodi:rx="86.224487" + sodipodi:cy="221.1353" + sodipodi:cx="136.22449" + id="path3651" + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2876" + y="260.42102" + x="56.122452" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="260.42102" + x="56.122452" + id="tspan2878" + sodipodi:role="line">WikittyServiceCache</tspan></text> + </g> + <g + id="g3862" + transform="translate(-5.1020408,84.693878)"> + <path + transform="translate(-30.612244,325.5102)" + d="m 222.44897,279.80878 c 0,14.08889 -38.83244,25.5102 -86.73469,25.5102 -47.90225,0 -86.734696,-11.42131 -86.734696,-25.5102 0,-14.0889 38.832446,-25.51021 86.734696,-25.51021 47.90225,0 86.73469,11.42131 86.73469,25.51021 z" + sodipodi:ry="25.510204" + sodipodi:rx="86.734695" + sodipodi:cy="279.80878" + sodipodi:cx="135.71428" + id="path3653" + style="fill:#8dff8b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2880" + y="607.35974" + x="57.142857" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + id="tspan3858" + y="607.35974" + x="57.142857" + sodipodi:role="line">ProxyHessian</tspan></text> + </g> + <flowRoot + xml:space="preserve" + id="flowRoot2888" + style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:13"><flowRegion + id="flowRegion2890"><rect + id="rect2892" + width="321.42856" + height="229.59184" + x="356.12244" + y="179.80876" /></flowRegion><flowPara + id="flowPara2894"></flowPara></flowRoot> <g + id="g2960" + transform="translate(-19.387755,329.59184)"> + <path + transform="translate(510.71429,89.285717)" + d="m 217.34694,165.01285 c 0,12.68 -37.23346,22.95918 -83.16327,22.95918 -45.929805,0 -83.163269,-10.27918 -83.163269,-22.95918 0,-12.68001 37.233464,-22.95918 83.163269,-22.95918 45.92981,0 83.16327,10.27917 83.16327,22.95918 z" + sodipodi:ry="22.959183" + sodipodi:rx="83.163269" + sodipodi:cy="165.01285" + sodipodi:cx="134.18367" + id="path3649-4" + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2948" + y="255.31897" + x="576.53064" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="255.31897" + x="576.53064" + id="tspan2950" + sodipodi:role="line">WikittyServiceNotifier</tspan></text> + </g> + <g + id="g2965" + transform="translate(-19.387756,152.04082)"> + <path + transform="translate(509.69388,178.06123)" + d="m 217.34694,165.01285 c 0,12.68 -37.23346,22.95918 -83.16327,22.95918 -45.929805,0 -83.163269,-10.27918 -83.163269,-22.95918 0,-12.68001 37.233464,-22.95918 83.163269,-22.95918 45.92981,0 83.16327,10.27917 83.16327,22.95918 z" + sodipodi:ry="22.959183" + sodipodi:rx="83.163269" + sodipodi:cy="165.01285" + sodipodi:cx="134.18367" + id="path3649-0" + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2952" + y="347.15573" + x="579.59186" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="347.15573" + x="579.59186" + id="tspan2954" + sodipodi:role="line">WikittyServiceCache</tspan></text> + </g> + <g + id="g2970" + transform="translate(-20.408163,232.65306)"> + <path + transform="translate(511.7347,275)" + d="m 217.34694,165.01285 c 0,12.68 -37.23346,22.95918 -83.16327,22.95918 -45.929805,0 -83.163269,-10.27918 -83.163269,-22.95918 0,-12.68001 37.233464,-22.95918 83.163269,-22.95918 45.92981,0 83.16327,10.27917 83.16327,22.95918 z" + sodipodi:ry="22.959183" + sodipodi:rx="83.163269" + sodipodi:cy="165.01285" + sodipodi:cx="134.18367" + id="path3649-8" + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999981, 11.99999962;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text2956" + y="443.07407" + x="586.73468" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="443.07407" + x="586.73468" + id="tspan2958" + sodipodi:role="line">WikittyServiceImpl</tspan></text> + </g> + <g + id="g3835" + transform="translate(38.775515,241.83674)"> + <path + d="m 345.91836,119.60468 c 0,12.96179 -34.72078,23.46939 -77.55102,23.46939 -42.83024,0 -77.55102,-10.5076 -77.55102,-23.46939 0,-12.96178 34.72078,-23.469384 77.55102,-23.469384 42.83024,0 77.55102,10.507604 77.55102,23.469384 z" + sodipodi:ry="23.469387" + sodipodi:rx="77.551018" + sodipodi:cy="119.60468" + sodipodi:cx="268.36734" + id="path2975" + style="fill:#05b4ff;fill-opacity:1;stroke:#000000;stroke-width:3.00118113;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6.0023622, 12.00472441;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text3008" + y="120.6251" + x="210.20407" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + id="tspan3012" + y="120.6251" + x="210.20407" + sodipodi:role="line">VradiDataService</tspan></text> + </g> + <g + id="g3840" + transform="translate(61.224493,-98.979594)"> + <path + d="m 345.91836,119.60468 c 0,12.96179 -34.72078,23.46939 -77.55102,23.46939 -42.83024,0 -77.55102,-10.5076 -77.55102,-23.46939 0,-12.96178 34.72078,-23.469384 77.55102,-23.469384 42.83024,0 77.55102,10.507604 77.55102,23.469384 z" + sodipodi:ry="23.469387" + sodipodi:rx="77.551018" + sodipodi:cy="119.60468" + sodipodi:cx="268.36734" + id="path2975-25" + style="fill:#05b4ff;fill-opacity:1;stroke:#000000;stroke-width:3.00118113;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6.0023622, 12.00472441;stroke-dashoffset:0" + sodipodi:type="arc" + transform="translate(10.204088,84.693882)" /> + <text + id="text3827" + y="205.31897" + x="212.2449" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="205.31897" + x="212.2449" + id="tspan3829" + sodipodi:role="line">VradiStorageService</tspan></text> + </g> + <g + id="g3849" + transform="translate(55.10204,-87.755098)"> + <path + d="m 345.91836,119.60468 c 0,12.96179 -34.72078,23.46939 -77.55102,23.46939 -42.83024,0 -77.55102,-10.5076 -77.55102,-23.46939 0,-12.96178 34.72078,-23.469384 77.55102,-23.469384 42.83024,0 77.55102,10.507604 77.55102,23.469384 z" + sodipodi:ry="23.469387" + sodipodi:rx="77.551018" + sodipodi:cy="119.60468" + sodipodi:cx="268.36734" + id="path2975-8" + style="fill:#05b4ff;fill-opacity:1;stroke:#000000;stroke-width:3.00118113;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6.0023622, 12.00472441;stroke-dashoffset:0" + sodipodi:type="arc" + transform="translate(17.346942,174.4898)" /> + <g + transform="translate(-8.1632653,-1.0204082)" + id="g3845"> + <text + xml:space="preserve" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="238.77551" + y="297.1557" + id="text3831"><tspan + sodipodi:role="line" + id="tspan3833" + x="238.77551" + y="297.1557">VradiFileService</tspan></text> + </g> + </g> + <path + style="fill:none;stroke:#000000;stroke-width:0.85127294;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1Lend)" + d="M 183.5995,679.88273 550.07397,510.34704" + id="path3867" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.92937213px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 96.938776,499.16121 0,66.39715" + id="path4317" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.85905838px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="M 101.15284,614.43192 99.995772,662.5323" + id="path4319" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 97.959184,375.72714 0,101.0204" + id="path4321" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.84397047999999997px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 228.64944,359.32259 -51.17643,3.21725" + id="path4323" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.91719735px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 618.32594,516.50206 8.75063,37.83791" + id="path4325" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.77727692999999998px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 623.35802,609.28924 1.24315,34.91661" + id="path4327" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.92249483;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:0.92249487, 1.84498973;stroke-dashoffset:0;marker-start:url(#Arrow1Lstart);marker-mid:none;marker-end:url(#Arrow1Lend)" + d="m 184.65512,587.98956 353.13873,-6.15751" + id="path4329" + inkscape:connector-type="polyline" /> + <text + xml:space="preserve" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="287.7551" + y="578.78833" + id="text5267"><tspan + sodipodi:role="line" + id="tspan5269" + x="287.7551" + y="578.78833" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans">JGroups</tspan></text> + <g + id="g2942-9" + transform="translate(405.61224,260.71428)"> + <g + id="g3644-6"> + <rect + style="fill:#ffb88b;fill-opacity:1;stroke:#000000;stroke-width:3.67120075;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.34240138, 14.68480276;stroke-dashoffset:0" + id="rect2862-4" + width="151.36961" + height="37.0839" + x="141.15193" + y="84.226006" /> + <text + xml:space="preserve" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="158.16325" + y="107.35979" + id="text3636-6"><tspan + sodipodi:role="line" + x="158.16325" + y="107.35979" + id="tspan3640-4" + style="font-size:20px">WikittyProxy</tspan></text> + </g> + </g> + <path + style="fill:none;stroke:#000000;stroke-width:0.94297135px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 618.36105,384.88229 1.02769,91.89376" + id="path6245" + inkscape:connector-type="polyline" /> + <g + id="g6516" + transform="translate(46.938776,0)"> + <path + transform="matrix(1.36149,0,0,0.99670193,-183.78588,-8.8144496)" + d="m 677.55105,111.95162 c 0,13.80712 -36.54819,25 -81.63265,25 -45.08447,0 -81.63266,-11.19288 -81.63266,-25 0,-13.807117 36.54819,-24.999998 81.63266,-24.999998 45.08446,0 81.63265,11.192881 81.63265,24.999998 z" + sodipodi:ry="25" + sodipodi:rx="81.632652" + sodipodi:cy="111.95162" + sodipodi:cx="595.9184" + id="path6435" + style="fill:#8dfffd;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 2;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text6437" + y="106.33938" + x="539.7959" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="106.33938" + x="539.7959" + id="tspan6439" + sodipodi:role="line">VradiStorageServiceImpl</tspan></text> + </g> + <g + id="g6471" + transform="translate(-21.428571,-1.0204082)"> + <rect + y="270.37863" + x="391.59027" + height="29.064327" + width="89.268402" + id="rect6441" + style="fill:#8dc3c0;fill-opacity:1;stroke:#000000;stroke-width:0.50709957;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:0.50709955, 1.01419911;stroke-dashoffset:0" /> + <text + id="text6445" + y="287.97205" + x="401.02042" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="287.97205" + x="401.02042" + id="tspan6447" + sodipodi:role="line">HTTP Proxy</tspan></text> + </g> + <g + id="g6480" + transform="translate(13.265306,-2.0408163)"> + <rect + y="271.39905" + x="510.46783" + height="29.064327" + width="89.268402" + id="rect6441-6" + style="fill:#8dc3c0;fill-opacity:1;stroke:#000000;stroke-width:0.50709957;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:0.50709955, 1.01419911;stroke-dashoffset:0" /> + <text + id="text6476" + y="286.95166" + x="527.55103" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="286.95166" + x="527.55103" + id="tspan6478" + sodipodi:role="line">Servlet</tspan></text> + </g> + <g + id="g6511" + transform="translate(48.979592,-1.0204081)"> + <path + transform="matrix(1.36149,0,0,0.99670193,-185.82673,97.818207)" + d="m 677.55105,111.95162 c 0,13.80712 -36.54819,25 -81.63265,25 -45.08447,0 -81.63266,-11.19288 -81.63266,-25 0,-13.807117 36.54819,-24.999998 81.63266,-24.999998 45.08446,0 81.63265,11.192881 81.63265,24.999998 z" + sodipodi:ry="25" + sodipodi:rx="81.632652" + sodipodi:cy="111.95162" + sodipodi:cx="595.9184" + id="path6435-0" + style="fill:#8dfffd;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1, 2;stroke-dashoffset:0" + sodipodi:type="arc" /> + <text + id="text6507" + y="212.46184" + x="553.06122" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="212.46184" + x="553.06122" + id="tspan6509" + sodipodi:role="line">VradiFileServiceImpl</tspan></text> + </g> + <path + style="fill:none;stroke:#000000;stroke-width:0.72283465;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Lend)" + d="m 377.41193,227.62885 30.89044,41.09452" + id="path6521" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.88991659999999995px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 463.21027,279.86381 58.27335,-2.1509" + id="path6523" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.69387483999999999px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" + d="m 604.94898,270.77816 17.65306,-42.14287" + id="path6525" + inkscape:connector-type="polyline" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.88019168;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:0.88019168,0.88019168;stroke-dashoffset:0" + d="m 419.2717,105.31897 143.08924,0" + id="path6527" + inkscape:connector-type="polyline" /> + <text + xml:space="preserve" + style="font-size:13px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="455.10202" + y="97.155708" + id="text7845"><tspan + sodipodi:role="line" + id="tspan7847" + x="455.10202" + y="97.155708">Hessian</tspan></text> + </g> +</svg> Property changes on: trunk/src/site/resources/devel/archi.svg ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/resources/enregistrement.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/enregistrement.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/example-clients.csv =================================================================== --- trunk/src/site/resources/example-clients.csv (rev 0) +++ trunk/src/site/resources/example-clients.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,2 @@ +"Client.name","Client.contact","Client.address","Client.phone" +"Code Lutin","Benjamin Poussin","44 bld des pas enchant�s, 44230 Saint S�bastien sur Loire","02 40 50 29 28" Property changes on: trunk/src/site/resources/example-clients.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/resources/example-utilisateurs.csv =================================================================== --- trunk/src/site/resources/example-utilisateurs.csv (rev 0) +++ trunk/src/site/resources/example-utilisateurs.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,2 @@ +"User.name","User.client","User.email","User.phone","User.service","User.address" +"Couteau Jean","Client.name=""Code Lutin""","couteau@codelutin.com","02 40 50 29 28","Direction","44 bld des pas enchant�s, 44230 Saint S�bastien sur Loire" Property changes on: trunk/src/site/resources/example-utilisateurs.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/resources/exportCSV.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/exportCSV.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/fieldsAssociation.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/fieldsAssociation.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/flux.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/flux.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/form.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/form.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/formType.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/formType.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/formsByUser.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/formsByUser.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/generatePDF.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/generatePDF.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/groups.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/groups.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/infogene.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/infogene.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/mailSession.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/mailSession.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/model.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/model.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/pdfExample.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/pdfExample.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/quotesoOo.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/quotesoOo.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/requetes.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/requetes.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/requetesModifiees.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/requetesModifiees.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/selectThesaurusNode.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/selectThesaurusNode.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/sendEmail.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/sendEmail.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/sendFormsAgain.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/sendFormsAgain.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/thesaurus.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/thesaurus.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/thesaurusColor.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/thesaurusColor.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/resources/utilisateurs.png =================================================================== (Binary files differ) Property changes on: trunk/src/site/resources/utilisateurs.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/site/rst/clients.rst =================================================================== --- trunk/src/site/rst/clients.rst (rev 0) +++ trunk/src/site/rst/clients.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,170 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Créer/Gérer la base clients +--------------------------- + +.. contents:: Table des matières + +La base client est composée de sociétés et d'utilisateurs faisant partie de ces +sociétés. + +Ouvrez l'administration de la base client en cliquant sur le menu +Administration -> Gestion des clients. Vous arrivez sur la fenêtre +d'administration, directement sur l'onglet de gestion des clients. + +Les clients +=========== + +Pour créer une nouvelle société (ou client), Sélectionnez le noeud 'Clients' et +cliquez sur le bouton 'Créer un client'. Cela crée un nouveau client nommé +'Nouveau client' vide. Vous pouvez rentrer son adresse, numéro de +téléphone, ... + +.. image:: clients.png + :width: 800px + +Les champs disponibles pour un client sont : + +- Nom : Le nom du client. +- Adresse : L'adresse postale du client. Le bouton en bout de ligne permet de + situer géographiquement le client en ouvrant un navigateur sur le site Google + Maps à l'adresse du client. +- Téléphone : Le numéro de téléphone du client. +- Contact : Le contact du client, ça peut être le nom d'une personne, une + adresse mail, ... Cela permet d'identifier la personne à contacter chez le + client. + +Pour supprimer un client, sélectionnez le dans l'arbre et cliquez sur le bouton +suppression (un personnage avec un symbole moins) en haut à droite. + +Les utilisateurs +================ + +Un utilisateur correspond à une adresse mail ou une personne physique d'un +client. Il est possible de lui associer des groupes ou profils d'utilisateur. + +Pour créer un nouvel utilisateur d'une société cliente, sélectionnez la société +que vous souhaitez modifier ou son nom 'Utilisateurs' de la société que vous +souhaitez modifier. Ajoutez un utilisateur en cliquant sur le bouton 'Créer un +utilisateur'. Cela crée un nouvel utilisateur nommé 'Nouvel utilisateur' vide. +Vous pouvez le modifier, rentrer son adresse, ... + +.. image:: utilisateurs.png + :width: 800px + +Les champs disponibles pour un utilisateur sont : + +- Nom : Le nom de l'utilisateur +- Service : Le service de l'utilisateur (ex: Direction, Achats, ...) +- Adresse : L'adresse postale de l'utilisateur. Cette dernière peut être + différente de l'adresse du client (organisations décentralisées, agence, ...). + Le bouton en bout de ligne permet de situer géographiquement l'utilisateur en + ouvrant un navigateur sur le site Google Maps à l'adresse de l'utilisateur. +- Téléphone : Le numéro de téléphone de l'utilisateur. +- Email : L'adresse email de l'utilisateur. C'est à cette adresse qu'il recevra + les formulaires. +- Date d'inscription : La date d'inscription de l'utilisateur au service d'envoi + de formulaire. L'utilisateur ne recevra aucun formulaire publié avant cette + date. +- Actif : Si la case est cochée, l'utilisateur ne recevra pas de formulaires. + A utiliser pour les personnes contact des organisations clientes par exemple. +- Groupes : Les groupes (ou profils utilisateurs) dont l'utilisateur fait partie. + +Pour associer un groupe à un utilisateur, il faut le sélectionner dans la liste +déroulante et cliquer sur le bouton '+'. La liste des groupes dont l'utilisateur +fait partie est située sous la liste déroulante. Pour supprimer l'utilisateur +d'un groupe, il faut le sélectionner et cliquer sur '-'. +Les formulaires qui seront retournés pas une requête d'un groupe dont +l'utilisateur fait partie lui seront envoyées. + +Pour supprimer un utilisateur, sélectionnez le dans l'arbre et cliquez sur le +bouton suppression (une poubelle) en haut à droite. + +Importer la base clients +======================== + +Il est possible d'importer la base client depuis plusieurs fichier CSV. L'import +doit être réalisé en utilisant deux fichiers. Il faut obligatoirement importer +les clients avant les utilisateurs. L'import se fait depuis le bouton 'Import' +situé sous la liste des clients et utilisateurs. + +Contenu des fichier CSV +~~~~~~~~~~~~~~~~~~~~~~~ + +Chaque champ doit être enregistré entre quotes ("). Exemple : "mon champ". + +Fichier clients +,,,,,,,,,,,,,,, + +Dans ce fichier, chaque ligne représente un client. + +Les entêtes de colonne doivent être : + +* Client.name : le nom du client +* Client.contact : le nom du contact chez le client +* Client.address : l'adresse postale du client +* Client.phone : le numéro de téléphone du client + +`Exemple de fichier CSV clients`_ + +.. _Exemple de fichier CSV clients: example-clients.csv + +Fichier utilisateurs +,,,,,,,,,,,,,,,,,,,, + +* User.name : le nom de l'utilisateur +* User.email : l'adresse email de l'utilisateur +* User.address : l'adresse postale de l'utilisateur +* User.service : le service de l'utilisateur +* User.client : l'identifiant du client dont l'utilisateur fait partie + +Pour faire un lien entre un client et un utilisateur, il faut mettre, dans le +champ User.client de l'utilisateur une requête Client.name="nom du client". +Exemple : :: + + Client.name="Code Lutin" + +`Exemple de fichier CSV utilisateurs`_ + +.. _Exemple de fichier CSV utilisateurs: example-utilisateurs.csv + +Rédiger simplement le fichier depuis le tableur openOffice +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pour écrire plus facilement un fichier CSV, il est conseillé de l'éditer +dans un tableur (comme celui d'openOffice) et d'enregistrer le fichier au format +CSV en utilisant l'encoding UTF-8, la virgule comme délimiteur de champ et les +quotes (") comme délimiteur de texte. + +.. image::exportCSV.png + +Attention, pour les requêtes, il faut bien mettre des quotes (") et non des +guillemets. Si des guillemets s'affichent dans open office, vous pouvez +désactiver le remplacement automatique des quotes par les guillemets dans +Outils>Options d'autocorrection et désactiver le remplacement des double quotes +dans l'onglet 'Custom quotes' + +.. image::quotesoOo.png + Property changes on: trunk/src/site/rst/clients.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/devel/algosession.rst =================================================================== --- trunk/src/site/rst/devel/algosession.rst (rev 0) +++ trunk/src/site/rst/devel/algosession.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,33 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Algorithmes utilisés lors de l'envoi des mails +============================================== + +Un mail est envoyé a un utilisateur si : + - l'utilisateur n'est pas inactif + - s'il appartient à un groupe dont les requette renvoi des formulaires + - les formulaires ont été publié après sa date d'inscription + - les formulaires n'ont pas été associé à une précedente session d'envoie + pour l'utilisateur \ No newline at end of file Property changes on: trunk/src/site/rst/devel/algosession.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/devel/modificationmodele.rst =================================================================== --- trunk/src/site/rst/devel/modificationmodele.rst (rev 0) +++ trunk/src/site/rst/devel/modificationmodele.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,65 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Modifications apportées au modèle +--------------------------------- + +03/10/2010 +- FormLink[1.0] Creating FormLink class + +24/10/2010 +- Sending[8.0] Add association class GroupForms to keep concerned group, that replace fields : addedGroupsConcerned, forms, groupsConcerned, addedForms + +22/10/2010 +- Sending[7.0] Add association with group named 'addedGroupsConcerned' + +22/10/2010 +- Sending[6.0] Add association with group named 'groupsConcerned' + +21/10/2010 +- Sending[5.0] Add association with forms named 'addedForms' + +18/10/2010 +- Rename TreeNode to WikittyTreeNode + +12/10/2010 : +- Session[4.0] : Ajout du champs sessionLogs + +28/09/2010 : +- XmlStream[5.0] : Suppression du champ importLastItem +- Form[7.0] : Add importContentHash field + +27/09/2010 : +- User[7.0] : Rename inscriptionDate to beginSearchDate + +22/09/2010 : +- Client[4.0] : Suppression de l'heritage QueryMaker +- User[6.0] : Suppression de l'heritage QueryMaker +- Group[3.0] : Suppression du lien Goup>User +- Sending[4.0] : Le lien Sending>QueryMaker remplacé par le lien Sending>User +- XmlStream[4.0] : Ajout des champs "importTime" et "importLastItem" + +21/09/2010 : +- Form[5.0] : retrait de champs xmlStream et thesaurus +- XmlStream[3.0] : changement du sens de la relation Form>XmlStream \ No newline at end of file Property changes on: trunk/src/site/rst/devel/modificationmodele.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/devel/openoffice.rst =================================================================== --- trunk/src/site/rst/devel/openoffice.rst (rev 0) +++ trunk/src/site/rst/devel/openoffice.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,44 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Resources OpenOffice.org +======================== + +Divers liens et resources pour l'utilisation de l'API java de openoffice. + +Forums +------ + +Publipostage : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=17839 +Images : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=6357&p=31958 + +Tutorials +--------- + +http://www.lerjen.com/site/docs/OpenOffice/OOo_API_Java.pdf + +Maven +----- + +Dépendances : http://repo1.maven.org/maven2/org/openoffice/ Property changes on: trunk/src/site/rst/devel/openoffice.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/devel/todomodel.rst =================================================================== --- trunk/src/site/rst/devel/todomodel.rst (rev 0) +++ trunk/src/site/rst/devel/todomodel.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,32 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +TODO model +========== + +Model: + - heritage multiples "ModificationTag" + - heritage query maker + - lien xml stream form ? + - champs form#thesaurus ? \ No newline at end of file Property changes on: trunk/src/site/rst/devel/todomodel.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/devel/xmlStream.rst =================================================================== --- trunk/src/site/rst/devel/xmlStream.rst (rev 0) +++ trunk/src/site/rst/devel/xmlStream.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,137 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Construire un flux XML pour VRADI +================================= + +Il existe 2 moyens de créer des flux pour VRADI. La méthode dite 'classique' qui +consiste à générer à la main le flux XML et la méthode WebHarvest qui consiste à +créer un flux XML à partir d'un site web en utilisant la librairie WebHarvest. + +Flux XML 'classiques' +~~~~~~~~~~~~~~~~~~~~~ + +VRADI accepte trois types de flux XMLs basés sur la norme RSS. Dans tous les +cas, le nom du tag root du flux n'est pas imposé. Il est par contre bon de +prendre une convention pour tous les flux générés. Dans cette documentation, +nous prendrons comme noeud root, le nom root. + +Tags autorisés par entrée +------------------------- + +Dans VRADI, tous les noms de tags sont autorisés pour une entrée. Du moment +qu'ils sont les mêmes pour chaque entrée et qu'ils respectent les règles XML. +Par exemple, il est possible de mettre un tag <price></price> pour des +informations de prix, ... + +Type de flux 1 +-------------- + +Dans le premier type de flux, tous les items sont des fils directs du noeud +<root>. + +Exemple :: + + <root> + + <item> + <name>Nom de mon item</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item</content> + </item> + + <item> + <name>Nom de mon item 2</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item 2</content> + </item> + + </root> + +Type de flux 2 +-------------- + +Dans le deuxième type de flux accepté, tous les items sont des fils direct d'un +noeud <channel> lui même fils direct du noeud <root>. + +Exemple :: + + <root> + + <channel> + + <item> + <name>Nom de mon item</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item</content> + </item> + + <item> + <name>Nom de mon item 2</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item 2</content> + </item> + + </channel> + + </root> + +Type de flux 3 +-------------- + +Dans le troisième type de flux, tous les items sont nommés <entry> et sont fils +direct du noeud <root>. + +Exemple :: + + <root> + + <entry> + <name>Nom de mon item</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item</content> + </entry> + + <entry> + <name>Nom de mon item 2</name> + <publicationDate>24/06/2010</publicationDate> + <content>Le contenu de mon item 2</content> + </entry> + + </root> + +Flux XML 'WebHarvest' +~~~~~~~~~~~~~~~~~~~~~ + +Il est possible de créer des flux XML WebHarvest. WebHarvest navigue dans un +site web pour en extraire le contenu et le fournir sous format XML choisi par +le développeur. Il suffit pour cela de créer un fichier de configuration par +site parcouru. Il est préférable de se référer à la documentation de WebHarvest +pour la création du fichier de configuration : +http://web-harvest.sourceforge.net/index.php . Il est possible de trouver un +exemple de fichier de configuration dans les sources de VRADI : +https://labs.libre-entreprise.org/scm/viewvc.php/vradi/trunk/vradi-services/... + +Dans tous les cas, le fichier XML généré doit être conforme à ceux attendus par +VRADI (cf Flux XML 'classiques') \ No newline at end of file Property changes on: trunk/src/site/rst/devel/xmlStream.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/fluxXML.rst =================================================================== --- trunk/src/site/rst/fluxXML.rst (rev 0) +++ trunk/src/site/rst/fluxXML.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,79 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Créer/Gérer les flux XML +------------------------ + +.. contents:: Table des matières + +Tous les formulaires de VRADI sont importés depuis des flux XML ou créés à la +main. Pour créer de nouveaux flux ou modifier ceux qui existent, allez sur +'Administration -> Gestion des flux XML'. Vous arrivez sur l'écran +d'administration sur l'onglet de gestion des flux XML. + +.. image:: flux.png + :width: 800px + +Création +======== + +Pour créer un nouveau flux XML, sélectionnez le noeud 'Flux XML' et cliquez sur +le bouton 'Créer un flux'. Un nouveau flux XMl nommé 'Nouveau flux' est créé. +Choisissez son nom, remplissez son addresse et le type de formulaire associé. +Validez en cliquant sur le bouton 'Valider'. Cela va télécharger le flux afin de +pouvoir le configurer. Le tableau des champs du flux va se remplir. Vous pouvez +visionner le premier élément du flux en survolant l'icone RSS situé à la droite +de l'addresse du flux. + +Paramétrage +=========== + +Une fois le flux validé, vous avez la liste des champs du formulaire, en +regard, la liste des champs du flux, puis une valeur par défaut. Pour chaque +champ du formulaire, il faut choisir le/les champs du flux XML associés puis une +valeur par défaut si besoin. + +La valeur par défaut sert en cas de champ vide dans le flux ou non rempli par le +flux. Si une valeur est présente dans le flux, elle sera utilisée pour remplir +le formulaire, sinon ce sera la valeur par défaut. + +Une fois le paramétrage effectué, vous pouvez enregistrer le flux XML en +utilisant le bouton 'Sauvegarder'. + +Paramétrer l'import automatique du flux XML +=========================================== + +L'import des flux XML peut se faire automatiquement. Pour configurer l'import +automatique des flux XML, cliquez sur le bouton 'Configurer les flux XML'. +Vous pouvez choisir la fréquence d'import des flux : entre tous les 30 jours et +tous les quarts d'heure. Choisissez la fréquence souhaitée dans les trois listes +à votre disposition et validez. L'application doit être démarrée à l'heure où +l'alarme se déclenche pour que l'import s'effectue. + +Forcer l'import d'un flux XML +============================= + +L'import du flux XML est automatique, cependant vous pouvez forcer l'import des +flux XML en cliquant sur le bouton 'Forcer l'import du flux' dans l'interface +d'administration de chaque flux XML. \ No newline at end of file Property changes on: trunk/src/site/rst/fluxXML.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/formulaires.rst =================================================================== --- trunk/src/site/rst/formulaires.rst (rev 0) +++ trunk/src/site/rst/formulaires.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,109 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Créer/Gérer les types de formulaires +------------------------------------ + +.. contents:: Table des matières + +Tous les formualires de VRADI sont configurables/paramétrables. Pour en créer de +nouveaux ou modifier les formulaires existants, allez sur +'Administration -> Gérer les types de formulaires'. Vous arrivez sur l'écran +d'administration sur l'onglet de gestion des types de formulaire. + +Notez bien qu'il n'est pas possible de supprimer un type de formulaire une fois +qu'il est utilisé. Il faut donc bien créer uniquement les types de formulaires +dont vous avez besoin. + +Pour créer un nouveau type de formulaire, cliquez sur 'Créer un type de +formulaire'. Renseignez son nom. Un type de formulaire comprenant uniquement +l'infogène est créé. Par défaut, l'infogène est caché. + +.. image::formType.png + :width: 800px + +Vous pouvez ajouter des champs à l'infogène en cliquant sur +'Ajouter'. Un nouveau champ est créé. Renseignez son nom (uniquement des +caractères alphanumériques), son label (un nom plus explicite qui sera affiché +au traitement du formulaire), une description qui apparaitra au survol du nom du +champ quand vous traiterez un formulaire, et un type. + +Pour afficher/cacher l'infogène, il faut cliquer sur 'Cacher l'infogène' / +'Afficher l'infogène' + +.. image::infogene.png + :width: 800px + +Les types de champs +=================== + +- Ligne : Une ligne est un texte libre de taille illimité, mais limité à une + seule ligne. +- Paragraphe : Un paragraphe est un texte libre de taille illimité et pouvant + être sur plusieurs lignes. +- Date : Une date +- Date-Heure : Une date et une heure +- Email : Une addresse e-mail +- URL : Une addresse internet (site) +- Nombre : Un nombre +- Montant : Un nombre et une monnaie (euro, livre sterling, dollar). + +Un type de champs doit être sélectionné. Si ce n'est pas le cas, vous verrez un +point d'exclamation apparaitre sur la liste déroulante, indiquant qu'il faut +sélectionner un type de formulaire. + +Organisation des champs +======================= + +Vous pouvez organiser l'ordre des champs en cliquant sur les flèches situées sur +la droite de l'écran. Vous pouvez supprimer un champ an cliquant sur la poubelle +située à droite de ce champ. + +Assigner un modèle de PDF a un type de formulaire +================================================= + +Dans l'interface d'administration des formulaires, vous pouvez ajouter un +modèle de PDF en cliquant sur le bouton 'Ajouter'. Ensuite vous associez les +champs du modèle avec les champs du formulaire. Vous pouvez ensuite voir un +exemple en cliquant sur le bouton 'voir un exemple' après avoir sauvegardé. +Notez que si aucun formulaire de ce type n'existe, il ne sera pas possible de +voir d'exemple. + +.. image::fieldsAssociation.png + :width: 400px + +.. image::pdfExample.png + :width: 800px + +Vous pouvez choisir parmis les modèles déjà ajoutés dans la liste déroulante, +télécharger le modèle utilisé en cliquant sur 'Télécharger' ou alors +recommencer l'association en cliquant sur 'Associer les champs'. + +Lorsque vous validez l'association, un message apparait si soit des champs du +formulaire ne sont pas repris dans le PDF, soit des champs du PDF ne sont pas +remplis par des champs du formulaire. + +Plus d'information sur la génération PDF dans la `documentation specifique`_ + +.. _documentation specifique: generationPDF.html \ No newline at end of file Property changes on: trunk/src/site/rst/formulaires.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/generationPDF.rst =================================================================== --- trunk/src/site/rst/generationPDF.rst (rev 0) +++ trunk/src/site/rst/generationPDF.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,69 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Generation PDF +============== + +Il est possible de générer un fichier PDF à partir des formulaires. + +Creation du modèle de PDF +------------------------- + +Pour créer un modèle, vous pouvez partir d'un document vierge et rédiger votre +document. A chaque fois que vous souhaitez intégrer un champ du formulaire, il +suffit de créer un champ utilisateur dédié en utilisant le menu Insertion > +Champs > Autres. Le type de champ doit être 'champ utilisateur' et le format +doit être 'Texte'. Si il n'est pas présent, vous pouvez l'ajouter à l'aide du +bouton 'Autres formats...'. Sélectionnez le champ choisi dans la liste et +cliquez sur 'Insérer'. + +.. image::addField.png + :width: 400px + +'Nom' correspond au nom du champ, celui que vous retrouverez dans VRADI +pour faire l'association entre les champs du formulaire et les champs du PDF. Il +ne doit pas obligatoirement être nommé de la même manière que le champ du +formulaire correspondant. + +'Valeur' correspond à la valeur par défaut prise par le champ si il n'est pas +rempli. Vous pouvez mettre par example 'N.D.' à cet endroit. C'est également +cette valeur que vous verrez dans le modèle. + +Un simple modèle peut ressembler à ceci : + +.. image::model.png + :width: 800px + +Vous pouvez alors changer la mise en page, la police, la couleur... + +Fonctionnement de la génération PDF +----------------------------------- + +Pour chaque type de formulaire, on associe un modèle de document créé dans +OpenOffice. Ce modèle de document doit comporter des champs utilisateurs. On +associe ensuite les champs du type de formulaire et les champs du modèle. + +A chaque fois que l'on souhaite obtenir le PDF d'un formulaire, chaque champ du +modèle est remplacé par le champ du formulaire associé et le modèle est +transformé en PDF. \ No newline at end of file Property changes on: trunk/src/site/rst/generationPDF.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/groups.rst =================================================================== --- trunk/src/site/rst/groups.rst (rev 0) +++ trunk/src/site/rst/groups.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,73 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Gérer les groupes ou profils d'utilisateurs +=========================================== + +.. contents:: Table des matières + +Les groupes ou profils d'utilisateurs sont un ensemble de requêtes auquels ont +peut associer des utilisateurs. Ces utilisateurs recevront les formulaires +retournés par les requêtes des groupes associés. + +Ouvrez l'administration de la base client en cliquant sur le menu +Administration -> Gestion des groupes. Vous arrivez sur la fenêtre +d'administration, directement sur l'onglet de gestion des groupes. + +Créer un groupe/profil utilisateur +---------------------------------- + +Vous pouvez créer un groupe en sélectionnant le noeud Groupes et en cliquant sur +le bouton 'Créer un groupe'. Cela crée un nouveau groupe nommé 'Nouveau groupe' +vide. Vous pouvez lui ajouter ou enlever des utilisateurs ou gérer ses requêtes. + +.. image:: groups.png + :width: 800px + +Gérer les utilisateurs d'un groupe +---------------------------------- + +Pour associer un utilisateur à un groupe, il faut le sélectionner dans la liste +déroulante et cliquer sur le bouton '+'. La liste des utilisateur associés au +groupe est située sous la liste déroulante. Pour supprimer l'utilisateur +d'un groupe, il faut le sélectionner et cliquer sur '-'. +Les formulaires qui seront retournés pas une requête du groupe seront envoyés +aux utilisateurs de ce groupe. + +Gérer les requêtes d'un groupe +------------------------------ + +Vous pouvez ajouter une requête à un groupe en cliquant sur le bouton 'Nouvelle +requête'. Vous pouvez donner un nom et une description à cette requête et la +rédiger en cliquant sur le bouton éditer (pour l'éditer c'est la même chose). +Cela va ouvrir une interface permettant d'éditer et tester la requête. Pour plus +d'informations sur la rédaction des requêtes, référez-vous à la `documentation +specifique`_ . Si vous voulez supprimer la/les requêtes, cliquez sur la poubelle +située à côté de cette/ces dernière(s). + +.. _documentation specifique: requests.html + +Vous pouvez visualiser l'historique des requêtes d'un groupe en cliquant sur +le bouton 'Voir l'historique des requêtes'. Cela crée un flux RSS qui est +visualisé dans votre navigateur préféré. Property changes on: trunk/src/site/rst/groups.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/importExport.rst =================================================================== --- trunk/src/site/rst/importExport.rst (rev 0) +++ trunk/src/site/rst/importExport.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,35 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Import/Export des données +========================= + +Dans VRADI il esxiste une fonction d'import/export permettant d'effectuer une +sauvegarde des données de l'application. +Ces fonctionnalités sont accessibles depuis le menu "Import/Export". + +Pour l'import vous devez spécifier le fichier de destination (ex: +export-100121.xml). + +Pour l'export, sélectionnez le fichier à importer et validez. \ No newline at end of file Property changes on: trunk/src/site/rst/importExport.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/index.rst =================================================================== --- trunk/src/site/rst/index.rst (rev 0) +++ trunk/src/site/rst/index.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,47 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI +===== + +VRADI est une application de traitement de flux XMLs (flux RSS ou flux +spécifiques). + +VRADI sert à récupérer le contenu des flux, le trier et le renvoyer par e-mail à +différents utilisateurs. + +Vous pouvez lancer VRADI depuis la page suivante_ + +.. _suivante::vradi-swing/jnlp-report.html + +Fonctionnalités +--------------- + +- Import automatique de formulaire à partir de flux XML (RSS,...) +- Gestion de base utilisateurs avec requêtes par groupes +- Traitement de formulaires (assignation de descripteurs, ...) +- Multiples indexations de formulaires +- Gestion de la base de descripteurs +- Envoi semi-automatique de mail aux utilisateurs +- Génération de PDFs avec le contenu des formulaires \ No newline at end of file Property changes on: trunk/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/infogene.rst =================================================================== --- trunk/src/site/rst/infogene.rst (rev 0) +++ trunk/src/site/rst/infogene.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,58 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Infogène +-------- + +L'infogène est la partie commune à tous les formulaires. Il est composé de +plusieurs champs : + +objet +===== + +id +== + +datePub +======= + + +datePeremption +============== + + +statut +====== + + +source +====== + + +description +=========== + + +initiateur +========== \ No newline at end of file Property changes on: trunk/src/site/rst/infogene.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/lancement.rst =================================================================== --- trunk/src/site/rst/lancement.rst (rev 0) +++ trunk/src/site/rst/lancement.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,32 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Premier lancement +----------------- + +Au lancement, un login/mot de passe est demandé. Si vous n'en possédez pas, +cliquez sur le bouton enregistrement. Vous pourrez choisir un nom d'utilisateur +et un mot de passe et démarrer l'application avec plus tard avec. + +.. image:: enregistrement.png \ No newline at end of file Property changes on: trunk/src/site/rst/lancement.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/processForms.rst =================================================================== --- trunk/src/site/rst/processForms.rst (rev 0) +++ trunk/src/site/rst/processForms.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,154 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +======================= +Traiter les formulaires +======================= + +.. contents:: Table des matières + +Traitement par formulaire +------------------------- + +Pour traiter un formulaire, il faut l'ouvrir en double-cliquant dans l'interface +des résultats de recherche. Le formulaire est ensuite ouvert. + +.. image::form.png + :width: 800px + + +Editer les informations +,,,,,,,,,,,,,,,,,,,,,,, + +Les informations sont pré-remplies lors de l'import des formulaires, cependant +il peut s'avérer que les informations importées soient inexactes. Vous pouvez +modifier toutes les informations du formulaire afin qu'elles soient présentées +correctement au client. + +Indexer le formulaire dans le thesaurus +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +Plusieures indextations possibles peuvent vous être proposées. Vous devez les +sélectionner pour les valider Vous pouvez aussi choisir dans le thésaurus +d'autres indexations pertinentes. Pour sélectionner un noeud de thésaurus, il +suffit de cliquer dessus, pour le désélectionner, il suffit de recliquer dessus. + +Pour avoir une meilleure vision du thésaurus, il est possible de changer son +affichage afin de ne conserver à l'écran que les parties du thésaurus les plus +utilisées. Cet affichage est conservé dans tout les formulaires et après le +redémarrage de VRADI. + +Pour afficher une partie du thésaurus dans une nouvelle colonne, il suffit de +faire un clic-droit sur un noeud et de sélectionner 'Afficher le noeud en +colonne de thésaurus'. Une nouvelle colonne apparaitra avec ce noeud en racine. + +Attacher des pièces jointes +,,,,,,,,,,,,,,,,,,,,,,,,,,, + +Il existe deux types de pièces jointes qui peuvent être attachées à un +formulaire. Les fichiers encapsulés qui seront ajoutés dans le PDF envoyé au +client, et les pièces jointes qui pourront être téléchargées par le client +depuis l'interface web. + +Pour ajouter un fichier encapsulé ou une pièce jointe, il suffit de cliquer sur +le bouton '+' correspondant et de choisir le fichier. Pour supprimer un fichier, +il suffit de le sélectionner et de cliquer sur le bouton '-' correspondant. + +Visionner le PDF +,,,,,,,,,,,,,,,, + +Il est possible de visionner le fichier PDF qui sera envoyé au client en +cliquant sur le bouton 'Voir en PDF'. Le fichier s'affiche dans votre +logiciel de visualisation PDF. + +Visionner les requêtes retournant le formulaire +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +En cliquant sur le bouton 'Requête ?' vous pouvez voir toutes les requêtes +retournant le formulaire que vous êtes en train d'éditer. Vous pouvez voir +toutes les requêtes ou les requêtes classées par client/utilisateur/groupe. + +.. image::requetes.png + :width: 500px + +Enregistrer, changer le statut +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +Une fois les modifications terminées, vous devez enregistrer en choisissant le +statut du formulaire après votre traitement. Le statut actuel est représenté par +un bouton de couleur bleu. + +Traitement de masse +------------------- + +Il est possible de traiter les formulaires en masse pour, par example, ne pas +sélectionner tous les formulaires inintéressants. + +Pour traiter les formulaires en masse, sélectionnez les dans l'interface des +résultats de recherche (vous pouvez utiliser les touches Ctrl et Shift pour la +multi-sélection). Avec un clic droit vous pouvez changer le statut des +formulaires. Attention, si vous n'avez pas assigné de noeud de thésaurus et que +vous passez des formulaires dans le statut 'Sélectionné', ils ne seront pas +envoyés (il y a de très fortes chances qu'ils ne ressortent dans aucunne requête +client). + +Formulaires liés et autres indexations +-------------------------------------- + +Formulaires liés +,,,,,,,,,,,,,,,, + +Il est possible de lier des formulaires entre eux (Par exemple des +modifications, différents formulaires sur un même sujet,...). Pour cela, il +suffit, au traitement du formulaire, de cliquer sur le bouton '+' dans la partie +'Formulaires liés'. Vous devez alors choisir le nom que vous allez donner au +lien, par exemple 'ancienne version'. Ensuite, une fenêtre de recherche s'ouvre, +recherchez le fomulaire à lier, sélectionnez le et cliquez sur 'Sélectionner'. + +Le formulaire apparait maintenant dans la liste des formulaires liés. Vous +pouvez ouvrir le formulaire lié en double-cliquant sur son nom. + +Autres indexations +,,,,,,,,,,,,,,,,,, + +Il est possible de créer différentes indexations pour un formulaire (plusieures +informations différentes dans un même formulaire par exemple). Pour créer une +nouvelle indexation, cliquez sur le bouton '+' dans la section 'Autres +indexations'. Vous devez alors choisir le nom que vous allez donner à la +nouvelle indexation (par exemple 'Deuxième indexation'). Un nouveau formulaire +avec les mêmes informations et non modifiable s'ouvre, c'est votre nouvelle +indexation. Vous pouvez alors choisir vos descripteurs et sélectionner (ou non) +votre autre indexation. + +Vous pourrez alors trouver votre nouvelle indexation par des requêtes. +Pour ouvrir le formulaire principal, cliquez sur le bouton 'Autre indexation du +formulaire : '#identifiant'' + +Note : Les champs, pièces jointes, ... de la nouvelle indexation ne sont pas +modifiables. Pour modifier les informations, il faut donc modifier le formulaire +principal. + +Même si un utilisateur doit recevoir un formulaire par plusieurs indexations +différentes, il ne le recevra qu'une fois, le contenu du PDF généré étant le +même. Property changes on: trunk/src/site/rst/processForms.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/requests.rst =================================================================== --- trunk/src/site/rst/requests.rst (rev 0) +++ trunk/src/site/rst/requests.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,167 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +================================= +Syntaxe des recherches textuelles +================================= + +.. contents:: Table des matières + +La recherche dans Vradi est basée sur le moteur de recherche libre Apache +Lucene_ . + +.. _Lucene: http://lucene.apache.org/ + +Voici les caractéristiques principales supportées par Vradi : + +Termes +------ +Une requête est décomposée en termes et opérateurs. Il existe deux types de +termes : les termes simples et les phrases. + +- Un seul terme est un mot unique tel que «air» ou «qualité». +- Une phrase est un groupe de mots entre guillemets comme "qualité de l'air". +- Plusieurs termes peuvent être combinés avec des opérateurs booléens pour former une requête plus complexe. + +Exemples: + - La recherche de *``air``* se traduit par 35 résultats (documents contenant + le mot air) + - La recherche de *``qualité``* retourne 123 résultats (documents contenant le + mot qualité) + - La recherche de *``qualité OR air``* donnera 148 résultats (documents + contenant les mots air ou qualité ou les deux) + - La recherche de *``qualité AND air``* donnera 10 résultats (documents + contenant les deux mots) + - La recherche de *``"qualité de l'air"``* (avec les guillemets) donnera 4 + résultats (documents contenant exactement la phrase "qualité de l'air") + - La recherche de *``objet:air``* donnera 5 résultats (documents contenant le + mot "air" dans l'objet) + - La recherche de *``objet:qualité``* donnera 14 résultats (documents + contenant le mot "qualité" dans l'objet) + +Recherche sur un champ +---------------------- + +Par défaut, la recherche est une recherche plein-texte, recherchant sur tout le +contenu des formulaires. Il est possible aussi de restreindre la recherche +a un champ particulier en tapant le nom court de ce champ suivi de deux points +":" et ensuite le terme sur lequel porte la recherche. + +Les champs supportés sont : + - ``id`` : l'identifiant du formulaire + - ``objet`` : l'objet du formulaire. Ex : ``objet:livraison`` + - ``creationDate`` : la date d'entrée dans la base au format jj/mm/aaaa. Ex : + ``creationDate:22/09/2010`` pour tous les formulaires entrés dans la base le + 22 septembre 2010. + - ``datePub`` : la date de publication. Ex : ``datePub:22/09/2010`` pour tous les + formulaires publiés le 22 septembre 2010. + - ``datePeremption`` : la date de péremption du formulaire (ou date de fin de + validité). Ex : ``datePeremption:22/09/2010`` pour tous les formulaires + périmant le 22 septembre 2010. + - ``sourceURL`` : l'adresse URL de la source. Ex : ``sourceURL:"https://www.achatpublic.com"`` + - ``sourceText`` : le texte de la source. Ex : ``sourceText:"Edi-tender"`` + - ``entity`` : l'entité émettrice du formulaire. Ex : ``entity:Versailles`` + - ``country`` : le pays. Ex : ``country:France`` + - ``department`` : le département. Ex : ``department:44`` + - ``description`` : la description. Ex : ``description:informatique`` + - ``xmlStreamURL`` : l'adresse du flux XML ayant généré le formulaire. Ex : + ``xmlStreamURL:www.lequipe.fr`` + - ``modificateur`` : le login de la dernière personne à avoir modifié le + formulaire. Ex : ``modificateur : eric`` + - ``modificateur.status`` : le login de la dernière personne à avoir changé le + statut du formulaire. Ex : ``modificateur.status : eric`` + +Notes: + - Les champs de type date: la date doit être formattée comme ceci: + ``DD/MM/YYYY`` + - Le champ est uniquement valable pour le terme qu'il précède + directement, donc la requête: *``objet:qualité de l'air``* sera transformée + en *``objet:qualité AND de AND air``* et seul le terme *``qualité``* sera + recherché sur le descripteur *``objet``*. + +Recherche dans un thésaurus +--------------------------- + +Pour effectuer une recherche dans un thésaurus, il faut utiliser comme mot clé, +le nom de ce thésaurus. Si j'ai, par exemple, un thésaurus nommé testThesaurus +et que je veux rechercher un descripteur dedans, je dois rechercher +toto ``testThesaurus:"descripteur"``. Les guillemets sont obligatoires si le nom du +descripteur contient un espace. + +Recherche générique +------------------- +Les recherches génériques sont supportées au sein de mots simples (pas dans les +phrases). + +- Pour effectuer une recherche générique portant sur un seul caractère, utilisez + le symbole "``?``". + Par exemple, pour chercher "``text``" ou "``test``", vous pouvez utiliser la + recherche: *``te?t``* +- Pour effectuer une recherche générique portant sur plusieurs caractères, + utilisez le symbole "``*``". + Par exemple, pour chercher les termes "``test``", "``tests``" ou + "``testeur``", vous pouvez utiliser la recherche: *``test*``* + +Opérateurs booléens +------------------- + +Les opérateurs booléens permettent de combiner les termes de recherche. + +- L'opérateur ``AND`` recherche les documents où les deux termes existent. Cela + équivaut à une intersection en utilisant des ensembles. Le symbole ``&&`` peut + être utilisée à la place du mot ``AND``. + L'opérateur ``AND`` est l'opérateur par defaut, cela signifie que si aucun + opérateur n'existe entre deux termes l'opérateur ``AND`` est utilisé. +- L'opérateur ``OR`` recherche les documents où l'un ou l'autre des deux termes + existent. Cela est équivalent à une union en utilisant des ensembles. Le + symbole ``||`` peut être utilisé à la place du mot OR. +- L'opérateur ``NOT`` exclut les documents contenant le terme. Ceci est + équivalent à une différence en utilisant des ensembles. + Note: L'opérateur ``NOT`` ne peut pas être utilisé s'il n'y a qu'un seul + terme. + +Groupement +---------- + +Le groupement de termes s'effectue en utilisant des parenthèses. Cela est utile +pour contrôler la logique booléenne d'une requête. Par exemple, la recherche: +*``(air OR eau) AND qualité``* trouvera les documents contenant les mots +*``air``* et *``qualité``* ou les mots *``eau``* et *``qualité``* ou les deux. + +L'utilisation de parenthèses avec un descripteur permet de regrouper des clauses +multiples pour un seul descripteur. Par exemple, la recherche: +*``objet:(air OR eau)``* trouvera tous les documents dont l'objet contient les +mots *``air``* ou *``eau``*. + +Caractères spéciaux +------------------- + +Tous les caractères suivant sont des caractères spéciaux: +``+ - && || ! ( ) { } [ ] ^ " ~ * ? : \`` + +Les caractères spéciaux doivent être échappés en utilisant un anti-slash (\) ou +en plaçant le terme de la recherche entre guillemets. Par exemple, pour chercher +``(1+1):2`` utiliser l'une ou l'autre requête : + - ``\(1\+1\)\:2`` + - ``"(1+1):2"`` \ No newline at end of file Property changes on: trunk/src/site/rst/requests.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/roadmap.rst =================================================================== --- trunk/src/site/rst/roadmap.rst (rev 0) +++ trunk/src/site/rst/roadmap.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,98 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +ROADMAP +####### + +Lot 2 : Base d'information, thésaurus, requêteur, base client +************************************************************* +Reste à faire : + +- pagination des résultats des requêtes (1j) ~~~~~~~> reste à faire le tri des résultats : impossible pour l'instant car Solr ne permet pas le tri sur des champs de type "text" +- ajouter l'aide (1j) +- ajouter les validateurs (1j) ~~~~~~~> à améliorer +- visualisation cartographique des résultats des requêtes (2j) +- modification des mails (1j) +- modification des pièces jointes (1j) +- modèle de génération des PDFs (5j) + +Total : 17j + +Lot 3 : Envoi automatique de mails +********************************** +Reste à faire : + +- Gestion des accusés de réception (1j) +- Gestions des erreurs (3j) +- Gestion des renvois (1j) +- Gestion des documents vus (3j) +- Envoi (2j) +- Génération des PDF (3j) +- Génération des mails (2j) + +Total : 15j + +Lot 4 : Le portail client +************************* +Reste à faire : + +- Compte utilisateur (2j) +- Recherche/filtre (2j) +- Présentation (2j) +- Formulaire en tableau (2j) +- Export (2j) +- Style/CSS (2j) + +Total : 12j + +Lot 5 : Le module de statistiques +********************************* +Reste à faire : + +- Ajout de la possibilité de faire des requêtes statistiques (3j) +- UI de statistique (3j) +- Génération de Diagrammes (2j) + + +Total : 8j + + +Total de jours restant : 52j +---------------------------- + +Échéances +######### + +16/12/09 +******** +Lot 2 +----- +terminé ! + +Lot 3 +----- + +- Gestion des accusés de réception (1j) +- Envoi (2j) +- Génération des mails (2j) Property changes on: trunk/src/site/rst/roadmap.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/sendEmails.rst =================================================================== --- trunk/src/site/rst/sendEmails.rst (rev 0) +++ trunk/src/site/rst/sendEmails.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,167 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +Envoyer les emails +================== + +.. contents:: Table des matières + +Une fois que vous avez traité les formulaires, vous pouvez envoyer ces derniers +aux clients associés. Pour afficher l'interface de traitement des emails, dans +le menu, cliquez sur 'Emails'>'Administration des Emails'. + +Session d'envoi journalière +--------------------------- + +Une session d'envoi regroupe l'association des formulaires à envoyer avec les +destinataires. + +Créer une nouvelle session d'envoi +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pour créer une nouvelle session d'envoi, il suffit de cliquer sur le bouton +'Créer une nouvelle session'. Une seule session peut être ouverte à la fois. Si +une session est déjà ouverte, un message vous l'indiquera ainsi que sa date afin +de pouvoir la resélectionner. + +Associer les clients et les formulaires +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +L'association des clients et des formulaires pouvant être longue, elle doit être +lancée à la main par un clic sur le bouton 'Associer les formulaires aux +utilisateurs' une fois la session active sélectionnée. +Cela associera les formulaires aux utilisateurs si : + +- Le formulaire est retourné par une requête d'un groupe dont l'utilisateur fait + partie +- Le formulaire est dans le statut sélectionné +- L'utilisateur est actif +- La date de dernière modification est après la date de début de recherche + (d'inscription) de l'utilisateur +- La date de péremption est vide (ou nulle) ou n'est pas dépassée +- Le formulaire n'a pas déjà été reçu par l'utilisateur. + +.. image:: mailSession.png + :width:800px + +Voir les formulaires par destinataire +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pour voir les formulaires par type de destinataire, il suffit de choisir le +filtre 'par type de destinataire' (ex: 'par client') et de cliquer sur la loupe. + +Vous avez alors, pour chaque utilisateur le nombre de formulaire qui va lui être +envoyé, la liste des formulaires à envoyer, et la gestion de l'email. + +.. image:: formsByUser.png + :width:800px + +Pour chaque utilisateur, vous pouvez définir si l'email à envoyer +doit avoir un accusé de réception ou non et ajouter un paragraphe spécifique +pour l'utilisateur qui sera affiché en plus du paragraphe de la session. + +Voir les destinataires par formulaire +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pour voir les destinataires par formulaire, il suffit de choisir le +filtre 'par formulaire' et de cliquer sur la loupe. + +Vous avez alors, pour chaque formulaire, les destinataires, rangés par type. +Vous pouvez alors choisir d'enlever ou d'ajouter des destinataires. + +.. image:: destsByForm.png + :width:800px + +Ajouter ou enlever des destinataires d'un formulaire +____________________________________________________ + +Une fois un formulaire sélectionné dans l'interface de visualisation par +formulaire : + +- Pour ajouter un destinataire à un formulaire, il faut le sélectionner dans la + liste déroulante, puis cliquer sur le bouton '+'. + +- Pour enlever le destinataire d'un formulaire, il faut le sélectionner dans la + liste et cliquer sur le bouton '-'. + +Envoyer les mails +~~~~~~~~~~~~~~~~~ + +Une fois que tous les emails ont été préparés et vérifier, vous pouvez envoyer +les emails en cliquant sur le bouton 'Envoyer les formulaires de la session' + +Les PDFs vont être générés si besoin puis envoyés. Vous pouvez annuler l'envoi a +tout moment et le reprendre par la suite en recliquant sur le bouton d'envoi. + +.. image::generatePDF.png + +.. image::sendEmail.png + +Modifier le contenu du mail +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Vous pouvez modifier le contenu du mail envoyé en sélectionnant la session et +modifiant le paragraphe de la session. + +Vous pouvez également rajouter un paragraphe par utilisateur en le sélectionant +et en éditant le champ 'Paragraphe' + +Ajouter des pièces jointes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Vous pouvez ajouter des pièces jointes à un mail. Pour cela, sélectionnez la +session. Cliquez sur le bouton '+' puis sélectionner le fichier à joindre. + +Vous pouvez également enlever des ficheirs en les sélectionnant puis en +cliquant sur '-'. + +Tous les utilisateurs devant recevoir un email recevront également les fichiers +joints. + +Travailler sur une ancienne session +----------------------------------- + +Une ancienne session ne pourra pas être modifiée. Vous pourrez la consulter et +réenvoyer les mails de la session au cas par cas. + +Chercher une ancienne session +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Il est possible de chercher une session par date d'envoi. Rentrez la date +d'envoi dans le champ approprié ou sélectionnez une date dans le calendrier +(disponible à l'aide du bouton 'flèche'). + +Vous avez alors toutes les sessions d'envoi de la journée. + +Réenvoyer un email +~~~~~~~~~~~~~~~~~~ + +Lorsqu'une session a déjà été envoyée, il est toujours possible de réenvoyer un +email. Sélectionnez alors l'utilisateur à qui vous souhaitez réenvoyer un mail +et cliquez sur le bouton 'Réenvoyer les formulaires'. Un email sera alors +réenvoyé à l'utilisateur en question. + +.. image::sendFormsAgain.png + :width:800px + Property changes on: trunk/src/site/rst/sendEmails.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/thesaurus.rst =================================================================== --- trunk/src/site/rst/thesaurus.rst (rev 0) +++ trunk/src/site/rst/thesaurus.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,144 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - + +Créer et gérer le thésaurus +=========================== + +.. contents:: Table des matières + +Pour arriver à l'écran d'administration des thésaurus, utilisez le menu +'Administration -> Gestion des thésaurus'. Vous arrivez sur l'écran +d'administration des thésaurus qui représente les thésaurus sous forme d'arbre. +A partir de cette interface, vous pouvez effectuer toutes les opérations sur les +thésaurus : créer de nouveaux thésaurus, créer des nouveaux noeuds, déplacer des +noeuds/branches, ajouter des tags à un noeud (pour les propositions lors du +traitement des formulaires), modifier des noeuds,... + +.. image:: thesaurus.png + :width: 700px + +Créer un thésaurus +------------------ + +Vous pouvez créer un thésaurus depuis n'importe quel niveau de n'importe quel +autre thésaurus en cliquant sur le bouton 'Créer un thésaurus'. Vous devez +choisir un nom pour ce thésaurus. Ce nom servant de base aux requêtes, il est +préférable qu'il soit court. Il doit, dans tous les cas, ne comporter que des +caractères alphanumériques (aucun espace, caractères spéciaux ou accentués). +Validez et le nouveau thésaurus est créé. + +Créer un noeud/descripteur +-------------------------- + +Pour créer un noeud, vous pouvez soit utiliser les boutons situés au dessus du +thésaurus, soit utiliser le menu contextuel (clic droit), après avoir +sélectionné le noeud père du noeud à créer. + +Vous arrivez sur l'interface de création/édition d'un noeud. + +.. image:: creationThesaurus.png + :width: 400px + +Vous pouvez ici modifier et/ou visualiser plusieurs informations : + +- Ordre : Permet de mettre une relation d'ordre dans les noeuds d'un niveau de + thésaurus. Dans un même niveau, les noeuds sont classés suivant leur niveau + d'ordre (on commence par 1 et on continu, le niveau 0 correspond à la fin) + puis l'ordre alphabétique. +- Nom : Le nom du noeud/descripteur +- Chemin : Le chemin permettant d'arriver au descripteur. +- Tags : Les tags associés au descripteur. Si un tag est présent dans un + formulaire, ce descripteur sera proposé lors du traitement. Pour ajouter + plusieurs tags, il faut les séparer par des virgules. Exemple : sport, + Ligue 1, football. Vous pouvez entrer les tags en plusieurs mots normalement + (ex : Ligue 1). Les tags ne sont pas sensibles à la casse. Les espaces avant + et après les virgules ne sont pas pris en compte. +- Commentaire : Un commentaire permettant d'identifier plus précisément un + descripteur. Par exemple, préciser son utilisation. + +Modifier un descripteur +----------------------- +Pour modifier un descripteur, sélectionnez le et cliquez sur 'Editer'. Vous +pouvez changer les informations et valider. Vous pouvez alors visualiser les +formulaires impactés par cette modification. Si vous validez, vous pouvez +modifier toutes les requêtes impactées. + +.. image:: requetesModifiees.png + :width: 600px + +Vous pouvez visualiser l'ancienne requête, la nouvelle requête (une requête +modifiée est proposée par défaut), et utiliser la checkbox en fin de ligne si +vous ne souhaitez pas voir la requête modifiée. Si la requête proposée ne vous +satisfait pas, double-cliquez sur cette dernière, vous arrivez sur l'écran +d'édition de requête. + + +Déplacer un noeud/descripteur ou une branche +-------------------------------------------- + +Pour déplacer un descripteur, éditez le et cliquez sur le bouton +'Déplacer' choisissez le noeud père de destination et cliquez sur sélectionner. + +.. image:: selectThesaurusNode.png + :width: 600px + +Comme pour les modifications de descripteur, vous pouvez modifier les +requêtes impactées. + +Supprimer un descripteur +------------------------ + +Pour supprimer un descripteur, il vous suffit de le sélectionner et de cliquer +sur 'Supprimer'. + +Comme pour les modifications de descripteur, vous pouvez modifier les +requêtes impactées. + +Changer la couleur d'un niveau de thesaurus +------------------------------------------- + +Tous les noeuds d'un même niveau du thésaurus sont affichés d'une même couleur. + +Pour changer la couleur d'un niveau de thésaurus, sélectionnez un noeud de ce +niveau et sélectionnez 'Changer la couleur pour cette profondeur' dans le menu +contextuel (clic-droit). Choisissez la couleur souhaitée et validez. + +.. image:: thesaurusColor.png + :width: 300px + +Le menu contextuel +------------------ + +Le menu contextuel que l'on obtient en faisant un clic droit sur un noeud +permet de simplifier l'accès à de nombreuses actions comme : + +- Créer un thésaurus +- Créer un descripteur +- Editer le descripteur +- Supprimer le descripteur +- Déplacer le descripteur +- Changer la couleur du descripteur +- Copier le descripteur (pour le coller dans une requête par exemple). + Property changes on: trunk/src/site/rst/thesaurus.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/rst/todo.rst =================================================================== --- trunk/src/site/rst/todo.rst (rev 0) +++ trunk/src/site/rst/todo.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,157 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI +##### + +TODO : +****** + - Pouvoir rajouter l'heure limite de réponse (si vide : 24h). Voir Si on met Date+heure ou 2 champs séparés + - Possibilité de faire une recherche par utilisateur ->Gestion des droits + - Gestion des droits : utilisateur peut être admin ou pas, les onglets de l'interface d'admin peuvent s'afficher ou non suivant si l'utilisateur est admin ou pas. + - Affichage du nombre de résultats : +En bas de la recherche, mettre une barre avec Nombre total, page précédente, page suivante, nombre/statut. + - Requête peut-être active en test ou non active, si non active, resultats calculés uniquement à la demande, en test, montrés dans l'interface d'envoi de mail mais non envoyés, actif, envoyés. + - quand on crée un descripteur il faut pouvoir signifier si c'est un descripteur supérieur, inférieur ou de même niveau +- Menu pour forcer la recréation de l'index solr + +Interface admin flux XML +------------------------ + +- Problème de conversion String -> num +- Si le flux xml est mal formé il y a une fenêtre d'erreur, il faudrait afficher un message plus explicite + +Envoi d'e-mail +-------------- + +- il faut pouvoir sélectionner le type d'e-mail (prévoir l'admin des types d'e-mail) (mail client, mail de test, mail de voeux, mail bon anniversaire,...) +- possibilité d'envoyer un message à tous les clients de la session (genre demain on travaille pas l'aprem pour cause de formation,...) +- possibilité de réouvrir le formulaire (pour se rappeler ce que c'est). + +Requêtes +-------- + +Il faut pouvoir voir les requêtes par utilisateur et les utilisateurs par requêtes + +Edition des formulaires +----------------------- + +- Possibilité de pouvoir ajouter des destinataires directement dans cette interface. +- Avoir le pourquoi la proposition est proposée (pour pouvoir juger de la pertinence). + +Qualite du code +--------------- + +- les classes, enumeration, interface doivent avoir une javadoc en entete + en respectant les standards codelutin (author, date, ...) et + leurs methodes/champs doivent etre aussi documentees +- se remettre pour le core wikitty sur le developpement fait dans wikengo, ne + plus utiliser le fork qui a ete fait. (par contre pour les templates de + generation continue a utilise les notres +- a-t-on vraiment besoin de org.sharengo.exceptions (il me semble qu'on utilise + pas leur template de generation) +- isVersionNewer ne devrait pas etre dans vradi, mais dans nuiton-utils (il me + semble qu'en plus elle y est deja) + +Done : +****** + +- Possibilité d'avoir 2 chaines d'indexation +- Infogène : Pas très clair encore ce qu'il faut mettre dedans mais déjà +- L'utilisateur doit pouvoir ne pas recevoir les formulaires de sa société (case à cocher dans l'interface admin utilisateur). +- Pourquoi pas une couleur par niveau (genre 5-10 couleurs qui se répètent) +- pour l'interface, il faudrait plutôt un truc en accordéon qui permet de gagner de la place et permet de se focaliser sur chaque client (3/4 des clients, ils regardent même pas les formulaires qui sont envoyés, car ils maitrisent le domaine et savent qu'il y a pas d'erreur), du coup ils passent que sur les domaines moins bien maitrisés, les clients chiants,... +- Bug sur le nom du client, si un utilisateur doit recevoir des formulaires, il est affiché sous le nom client (sa société), il faudrait mettre nom client - nom utilisateur +- utiliser ApplicationConfig de nuiton-utils (pour les services) +- pourquoi y a-t-il un cache dans FormTypeManager ? n'est pas le role de wikitty + de faire le cache si necessaire ? +- Il faut aider la lisibilité avec des traits (comme dans un explorateur de fichier) (Sylvain) +- Afficher les tags du noeud (Sylvain) +- ajouter la roadmap au début du changelog (kevin) +- pourquoi dans VradiStorageServiceImpl.updateEntity incremente-t-on le major + Revision ? c'est wikitty qui le fait normalement, donc du coup il est fait 2 + fois :( +- Si il n'y a pas de connexion réseau ou si le fichier est gros, l'ui reste bloqué lorsque l'on renseigne l'url, ajout d'un timout et un veuillez patienter ? +- Il faut pouvoir ajouter, enlever des colonnes (parmi les champs de l'infogène, hormis le champ description, cf partie infogène) +- A chaque sauvegarde, il faut pouvoir visualiser les modifications et les impactes sur les requêtes +- Bug d'actualisation +- name a remplacer par objet (c'est déjà fait dans le tableau, mais il faut aussi dans le nom du champ) +- Édition de l'AO disponible partout (Edition de requêtes, Email...) +- ajouter un bouton par statut dans l'edition des formulaires +- faire une partie admin des statuts +- Possibilité de rajouter des statuts et de modifier les statuts existants ->Remplacer le bouton valider par n boutons, 1 par statut +- Pour déplacer un nœud, on clique droit sur le nœud -> Déplacer ce nœud -> ouvre l'arbre du thésaurus, on choisit le nœud de destination et on valide (Sylvain) +- Chaque niveau doit être classé par ordre alphabétique, en commençant par les chiffres +- il est tres derangeant dans FieldTypeModel de voir un copyright Sun + (proprietary/confidential) en meme dans qu'un declaration d'une licence GPL + mise par nous :( (supprimé, Stephane) +- Pourquoi y a-t-il un QueryParserTest dans les sources ? (supprimé, Stephane) +- pourquoi refaire un parser QueryParser ? n'est pas le role de SolR ? (utilisation du QueryParser de lucene, Stephane) +- a quoi ca sert d'avoir un package avec une seule classe dedans :( (vrai pour + tous les managers (Stephane) +- il ne faut pas trouver des choses dans le code comme :: (Tony) + /* + * //TODO configurer l'ide + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +- pouvoir déplacer les nœuds du thesaurus (Sylvain) +- Corriger le bug de cancel (Sylvain) +- supprimer tous les 'Created by IntelliJ IDEA.' ca n'a rien a faire dans le code +- faire une demande au projet Jaxx pour renommer Util en JaxxUtil +- ni avait-il pas une meilleur solution pour les DTO ? generation ? + Pourquoi certain DTO n'herite pas d'une classe generee ? + + Il y a que VradiThesaurusDTO qui n'hérite par de l'entité (TreeNode) car l'on souhaite avoir un comportement completement différent. + +- il faut la licence en haut de chaque fichier avec le bon copyrigth +- Pouvez-vous remplacer "name" par "objet" +- ajouter le changelog au menu d'aide (à propos de Vradi) -- Kevin le 09/12/09 +- Pour les types de champs, remplacer chaine par ligne et texte par paragraphe -- Kevin le 10/12/09 +- Prévisualiser le XML : mettre en exemple le contenu du premier item en tooltip par exemple -- Kevin le 10/12/09 +- Ajouter un type monétaire en type de champ (en fait 2 champ : nombre et 1 monnaie) -- Kevin le 11/12/09 +- Formulaire : chaque champ a un nom cours et une description/nom long affichée en tooltip -- Kevin le 11/12/09 +- modifier la visualisation des emails à envoyer : + une ligne par session et par client -- Kevin le 17/12/09 +- l'id généré devrait commencer par la date (sans le time), et ce devrait être la seul chose qu'ils aient le droit de modifier, l'id technique sera affiché mais pas modifiable. -- Kevin le 17/12/09 +- source de type ligne a rajouter -- Kevin le 17/12/09 +- initiateur (nom peut être amené à changer) de type ligne -- Kevin le 17/12/09 +- description de type paragraphe a rajouter -- Kevin le 17/12/09 +- ajouter un editeur en popup pour l'edition du paragraphe des emails a envoyer -- Kevin le 18/12/09 +- Ajout d'une barre de progression lors de "forcer la création des AO". -- Kevin le 18/12/09 +- rajouter un bouton d'envoi d'email à cote des champs emails -- Kevin le 21/12/09 +- Ajout de l'heure dans les dates -- Kevin le 22/12/09 +- Mettre en place un export / import (ou autre...?) car il ne veulent pas avoir a réinsérer les données a chaque fois que la base change (ex : thésaurus) -- Kevin le 23/12/09 +- UI pas très claire au niveau des ajouts notamment -- Sylvain le 30/12/09 +- Ajout des tags sous la forme "a, b, c..." et ajout d'une description lors de la création -- Sylvain le 31/12/09 +- Renommer le menu "Ajout d'un thésaurus" en "Afficher le nœud en colonne de thésaurus" -- Jean le 31/12/09 +- Quand il y a un l' par example dans le texte, ça recherche pas ce qu'il y a après. ex : aude ne renvoi pas conseil général de l'aude :( -- Kevin le 05/01/10 +- Nombre de formulaires associés à un noeud du thésaurus -- Sylvain + Kevin le 05/01/10 +- Bug sur le AND et le OR et potentiellement les parenthèses pour les priorités -- Kevin le 05/01/10 +- Lorsque les critères des recherches sont caché, la recherche ne doit pas les prendre en compte (c'était fait mais ça ne marche plus). -- Kevin le 06/01/10 +- Faire en sorte que la description de l'infogène (cf partie infogène) soit visible en tooltip au survol de la ligne dans la liste. Il serait bien (car ça arrive :() que par défaut ce soit en html. -- Kevin le 06/01/10 +*- dans l'admin des flux xml, sortir de l'edition des listes quand on clique sur valider -- Kevin le 11/01/10 +*- Message de confirmation quand on annule -- Kevin le 11/01/10 +- Possibilité de traitement de masse des AO : sélection multiple ->menu contextuel -> passer au statut n. Confirmation si plusieurs statuts différents à l'origine. -- Kevin le 10/02/10 +- Possibilité de rechercher par statut(s) (1 ou n statuts), à touver un moyen de rendre ça bien -- Kevin le 10/02/10 Property changes on: trunk/src/site/rst/todo.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/site/site_fr.xml =================================================================== --- trunk/src/site/site_fr.xml (rev 0) +++ trunk/src/site/site_fr.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <!--src>${site.home.url}/jaxx.png</src--> + <href>index.html</href> + </bannerLeft> + + <poweredBy> + <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/> + <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/> + <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" + img="${project.url}/images/restructuredtext-logo.png"/> + </poweredBy> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="${project.url}"/> + </breadcrumbs> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + <item name="Lancement" href="lancement.html"/> + <item name="Gérer les clients" href="clients.html"/> + <item name="Gérer les groupes/profils" href="groups.html"/> + <item name="Gérer les types de formulaire" href="formulaires.html"/> + <item name="Gérer les flux XML" href="fluxXML.html"/> + <item name="Gérer le thésaurus" href="thesaurus.html"/> + <item name="Traiter les formulaires" href="processForms.html"/> + <item name="Envoyer les formulaires" href="sendEmails.html"/> + <!--item name="Import/export" href="importExport.html"/--> + </menu> + + <menu name="Points généraux"> + <item name="Les requêtes" href="requests.html"/> + <item name="La génération PDF" href="generationPDF.html"/> + </menu> + + <menu name="Développeur"> + <item name="Flux XMLs" href="devel/xmlStream.html"/> + <item name="Roadmap" href="roadmap.html"/> + </menu> + + <menu ref="modules"/> + + <menu ref="reports"/> + </body> +</project> Property changes on: trunk/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/LICENSE.txt =================================================================== --- trunk/vradi-entities/LICENSE.txt (rev 0) +++ trunk/vradi-entities/LICENSE.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. Property changes on: trunk/vradi-entities/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-entities/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-entities/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/pom.xml =================================================================== --- trunk/vradi-entities/pom.xml (rev 0) +++ trunk/vradi-entities/pom.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>vradi</artifactId> + <version>0.6-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.vradi</groupId> + <artifactId>vradi-entities</artifactId> + + <name>Vradi :: Entities</name> + <description>Vradi entities module</description> + + <dependencies> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + </dependency> + </dependencies> + + <build> + + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>maven-eugene-plugin</artifactId> + <executions> + <execution> + <id>api generator</id> + <phase>generate-sources</phase> + <configuration> + <inputs> + <input>zargo</input> + <input>classpath:model:/:wikitty.objectmodel</input> + </inputs> + <fullPackagePath>org.chorem.vradi</fullPackagePath> + <defaultPackage>org.chorem.vradi</defaultPackage> + <extractedPackages>org.chorem.vradi.entities,org.nuiton.wikitty</extractedPackages> + <generatedPackages>org.chorem.vradi.entities</generatedPackages> + <templates>org.nuiton.wikitty.generator.WikittyMetaGenerator</templates> + </configuration> + <goals> + <goal>smart-generate</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + + </build> + +</project> Property changes on: trunk/vradi-entities/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/license/THIRD-PARTY.properties =================================================================== --- trunk/vradi-entities/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/vradi-entities/src/license/THIRD-PARTY.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,25 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache 2 +# - Apache Software License, Version 2.0 +# - Apache Software License, version 1.1 +# - BSD License +# - BSD style +# - Indiana University Extreme! Lab Software License +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - Java Transaction API (JTA) License +# - LGPL 2.1 +# - Lesser General Public License (LGPL) v 3.0 +# - Public Domain +# - Public domain +# - The Apache Software License, Version 2.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 23 16:48:32 CET 2010 +commons-primitives--commons-primitives--1.0--jar=Apache Software License, Version 2.0 +concurrent--concurrent--1.0--jar=TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +javax.transaction--jta--1.1--jar=Java Transaction API (JTA) License +xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme\! Lab Software License Property changes on: trunk/vradi-entities/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FieldTypeEnum.java =================================================================== --- trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FieldTypeEnum.java (rev 0) +++ trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FieldTypeEnum.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,105 @@ +package org.chorem.vradi.entities; + +import org.nuiton.wikitty.entities.FieldType; + +import static org.nuiton.i18n.I18n.n_; + +/** @author letellier */ +public enum FieldTypeEnum { + STRING(FieldType.TYPE.STRING, n_("vradi.fieldTypeEnum.string"), 0, 1), + TEXT(FieldType.TYPE.STRING, n_("vradi.fieldTypeEnum.text"), 0, 1), + DATE(FieldType.TYPE.DATE, n_("vradi.fieldTypeEnum.date"), 1, 1), + DATE_TIME(FieldType.TYPE.DATE, n_("vradi.fieldTypeEnum.dateTime"), 1, 1), + EMAIL(FieldType.TYPE.STRING, n_("vradi.fieldTypeEnum.email"), 0, 1), + URL(FieldType.TYPE.STRING, n_("vradi.fieldTypeEnum.url"), 0, 1), + NUMERIC(FieldType.TYPE.NUMERIC, n_("vradi.fieldTypeEnum.numeric"), 1, 1), + CURRENCY(FieldType.TYPE.STRING, n_("vradi.fieldTypeEnum.currency"), 0, 1); + + public static final String CURRENCY_TAG_VALUE = "currency"; + + protected String TAG_VALUE = "use"; + + protected String tagValue; + + protected FieldType type; + + FieldTypeEnum(FieldType.TYPE type, String tagValue, int min, int max) { + this.tagValue = tagValue; + this.type = new FieldType(type, min, max); + this.type.addTagValue(TAG_VALUE, tagValue); + } + + public String getTagValue() { + return tagValue; + } + + public FieldType getFieldType() { + FieldType result = new FieldType(type.getType(), type.getLowerBound(), type.getUpperBound()); + result.addTagValue(TAG_VALUE, tagValue); + + return result; + } + + public boolean isType(FieldType type) { + return tagValue.equals(type.getTagValue(TAG_VALUE)); + } + + @Override + public String toString() { + return getTagValue(); + } + + public static FieldTypeEnum valueOf(FieldType type) { + if (type == null) { + return null; + } + FieldTypeEnum e; + if (FieldTypeEnum.DATE_TIME.isType(type)) { + e = FieldTypeEnum.DATE_TIME; + } else if (FieldTypeEnum.DATE.isType(type) || FieldType.TYPE.DATE.equals(type.getType())) { + e = FieldTypeEnum.DATE; + } else if (FieldTypeEnum.EMAIL.isType(type)) { + e = FieldTypeEnum.EMAIL; + } else if (FieldTypeEnum.CURRENCY.isType(type)) { + e = FieldTypeEnum.CURRENCY; + } else if (FieldTypeEnum.NUMERIC.isType(type) || FieldType.TYPE.NUMERIC.equals(type.getType())) { + e = FieldTypeEnum.NUMERIC; + } else if (FieldTypeEnum.TEXT.isType(type)) { + e = FieldTypeEnum.TEXT; + } else if (FieldTypeEnum.URL.isType(type)) { + e = FieldTypeEnum.URL; + } else { + e = FieldTypeEnum.STRING; + } + return e; + } + + static public Currency getCurrency(String value) { + if ("vradi.currency.euro".equals(value)) { + return Currency.EUR; + } else if ("vradi.currency.usd".equals(value)) { + return Currency.USD; + } else if ("vradi.currency.gbp".equals(value)) { + return Currency.GBP; + } + return null; + } + + public enum Currency { + EUR("vradi.currency.euro"), + USD("vradi.currency.usd"), + GBP("vradi.currency.gbp"); + + private String name; + + Currency(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + } + +} Property changes on: trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FieldTypeEnum.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FormLinkTypeEnum.java =================================================================== --- trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FormLinkTypeEnum.java (rev 0) +++ trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FormLinkTypeEnum.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,16 @@ +package org.chorem.vradi.entities; + +/** @author letellier */ +public enum FormLinkTypeEnum { + RELATED, + REPLACE; + + public int getValue() { + return ordinal(); + } + + public String getValueAsString() { + return String.valueOf(getValue()); + } +} + Property changes on: trunk/vradi-entities/src/main/java/org/chorem/vradi/entities/FormLinkTypeEnum.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/main/resources/i18n/vradi-entities_fr_FR.properties =================================================================== --- trunk/vradi-entities/src/main/resources/i18n/vradi-entities_fr_FR.properties (rev 0) +++ trunk/vradi-entities/src/main/resources/i18n/vradi-entities_fr_FR.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,8 @@ +vradi.fieldTypeEnum.currency=Montant +vradi.fieldTypeEnum.date=Date +vradi.fieldTypeEnum.dateTime=Date, Heure +vradi.fieldTypeEnum.email=Email +vradi.fieldTypeEnum.numeric=Nombre +vradi.fieldTypeEnum.string=Ligne +vradi.fieldTypeEnum.text=Paragraphe +vradi.fieldTypeEnum.url=URL Property changes on: trunk/vradi-entities/src/main/resources/i18n/vradi-entities_fr_FR.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/main/xmi/vradi.properties =================================================================== --- trunk/vradi-entities/src/main/xmi/vradi.properties (rev 0) +++ trunk/vradi-entities/src/main/xmi/vradi.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,30 @@ +### +# #%L +# Vradi :: Entities +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +model.tagvalue.i18n=vradi.common. +model.tagvalue.notGenerateToString=true +model.tagvalue.generateOperatorForDAOHelper=true +model.tagvalue.generatePropertyChangeListener=true +model.tagvalue.dataType-List=java.util.List +model.tagvalue.dataType-Integer=int Property changes on: trunk/vradi-entities/src/main/xmi/vradi.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/main/xmi/vradi.zargo =================================================================== (Binary files differ) Property changes on: trunk/vradi-entities/src/main/xmi/vradi.zargo ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-entities/src/site/rst/index.rst =================================================================== --- trunk/vradi-entities/src/site/rst/index.rst (rev 0) +++ trunk/vradi-entities/src/site/rst/index.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI :: Module services +======================== + +Ce module contient les entités et le modèle de VRADI. \ No newline at end of file Property changes on: trunk/vradi-entities/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-entities/src/site/site_fr.xml =================================================================== --- trunk/vradi-entities/src/site/site_fr.xml (rev 0) +++ trunk/vradi-entities/src/site/site_fr.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <menu ref="parent"/> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> \ No newline at end of file Property changes on: trunk/vradi-entities/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/LICENSE.txt =================================================================== --- trunk/vradi-services/LICENSE.txt (rev 0) +++ trunk/vradi-services/LICENSE.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. Property changes on: trunk/vradi-services/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-services/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-services/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/pom.xml =================================================================== --- trunk/vradi-services/pom.xml (rev 0) +++ trunk/vradi-services/pom.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,301 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>vradi</artifactId> + <version>0.6-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.vradi</groupId> + <artifactId>vradi-services</artifactId> + + <name>Vradi :: Services</name> + <description>Vradi services module</description> + + <properties> + + <!--Vradi service Main Class in JAR --> + <maven.jar.main.class> + org.chorem.vradi.VradiServiceMain + </maven.jar.main.class> + + </properties> + + <dependencies> + <!-- sibling dependencies --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-entities</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- RSS dependencies --> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + </dependency> + + <!-- databases dependencies --> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + </dependency> + + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.tika</groupId> + <artifactId>tika-core</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-jdbc-impl</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-solr-impl</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.lucene</groupId> + <artifactId>lucene-core</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + </dependency> + + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>juh</artifactId> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>jurt</artifactId> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>ridl</artifactId> + </dependency> + <dependency> + <groupId>org.openoffice</groupId> + <artifactId>unoil</artifactId> + </dependency> + + <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </dependency> + + <dependency> + <groupId>net.sourceforge.web-harvest</groupId> + <artifactId>web-harvest</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>net.sf.opencsv</groupId> + <artifactId>opencsv</artifactId> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + + <dependency> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> + </dependency> + + <!--dependency> + <groupId>net.sf.saxon</groupId> + <artifactId>saxon-dom</artifactId> + </dependency--> + + </dependencies> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>*.properties</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>*.properties</exclude> + </excludes> + </resource> + </resources> + <testResources> + <testResource> + <directory>src/test/resources</directory> + <filtering>true</filtering> + <includes> + <include>*.properties</include> + </includes> + </testResource> + <testResource> + <directory>src/test/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>*.properties</exclude> + </excludes> + </testResource> + </testResources> + <plugins> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>attach-test</id> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>target/lib</outputDirectory> + <silent>true</silent> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + + <pluginManagement> + <plugins> + + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>./lib/</classpathPrefix> + <useUniqueVersions>false</useUniqueVersions> + </manifest> + </archive> + </configuration> + </plugin> + + </plugins> + </pluginManagement> + </build> + + <profiles> + <profile> + <id>assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>verify</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/bin.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> + Property changes on: trunk/vradi-services/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/license/THIRD-PARTY.properties =================================================================== --- trunk/vradi-services/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/vradi-services/src/license/THIRD-PARTY.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,47 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache 2 +# - Apache License +# - Apache Software License, Version 2.0 +# - Apache Software License, version 1.1 +# - BSD License +# - BSD style +# - CDDL +# - Common Development and Distribution License (CDDL) v1.0 +# - Common Public License Version 1.0 +# - GNU LESSER GENERAL PUBLIC LICENSE +# - GNU Lesser General Public License, Version 3 +# - GPLv2+CE +# - General Public License (GPL) v 3.0 +# - Indiana University Extreme! Lab Software License +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - JDom license +# - Java Transaction API (JTA) License +# - LGPL 2.1 +# - Lesser General Public License (LGPL) v 3.0 +# - MIT License +# - Mozilla Public License +# - Mozilla Public License Version 1.0 +# - Public Domain +# - Public domain +# - TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +# - The Apache Software License, Version 2.0 +# - The H2 License, Version 1.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 23 18:05:55 CET 2010 +commons-cli--commons-cli--1.2--jar=Apache Software License, Version 2.0 +commons-primitives--commons-primitives--1.0--jar=Apache Software License, Version 2.0 +concurrent--concurrent--1.0--jar=TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +groovy--groovy-all--1.0-jsr-06--jar=Apache Software License, Version 2.0 +javax.servlet--servlet-api--2.5--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +javax.transaction--jta--1.1--jar=Java Transaction API (JTA) License +jboss--jnet--3.2.1--jar=GNU Lesser General Public License, Version 3 +org.apache.commons--commons-email--1.2--jar=Apache Software License, Version 2.0 +org.jdom--jdom--1.1--jar=JDom license +rome--rome--1.0--jar=Apache Software License, Version 2.0 +woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / The Apache Software License - Version 2.0 +xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme\! Lab Software License Property changes on: trunk/vradi-services/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/assembly/bin.xml =================================================================== --- trunk/vradi-services/src/main/assembly/bin.xml (rev 0) +++ trunk/vradi-services/src/main/assembly/bin.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> + <id>bin</id> + <formats> + <format>zip</format> + </formats> + <!-- <dependencySets> + <dependencySet> + <outputDirectory>lib</outputDirectory> + <scope>runtime</scope> + </dependencySet> + </dependencySets> --> + + <fileSets> + + <fileSet> + <directory>target/lib</directory> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>${project.build.finalName}.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>target/classes</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>THIRD-PARTY.txt</include> + </includes> + </fileSet> + <fileSet> + <outputDirectory>/</outputDirectory> + <includes> + <include>README*</include> + <include>LICENSE*</include> + </includes> + </fileSet> + </fileSets> +</assembly> \ No newline at end of file Property changes on: trunk/vradi-services/src/main/assembly/bin.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiConstants.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiConstants.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiConstants.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,292 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; + +import java.text.SimpleDateFormat; +import java.util.UUID; +import java.util.regex.Pattern; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * Vradi application constants. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 2 mars 2010 15:37:19 + */ +public class VradiConstants { + + /** + * Pattern de l'heure d'import des flux xml. + * <p/> + * Autorisé : + * 2:13 + */ + public static final Pattern XML_STREAM_IMPORT_TIME = Pattern.compile("^(\\d{1,2})\\:(\\d{1,2})$"); + + // names of feed elements + public static final String CHANNEL = "channel"; + + public static final String ENTRY = "entry"; + + public static final String ITEM = "item"; + + // Name of context to get client user decorator + public static final String USER_ONLY_DECORATOR = "userOnly"; + + /** + * La taille d'un uuid. + * Utilisé pour decouper les Infogene.ID dans l'edition de formulaire. + */ + public static final int UUID_LENGTH = UUID.randomUUID().toString().length(); + + /** Form Id date format. */ + public static final SimpleDateFormat FORM_ID_DATE_FORMAT = + new SimpleDateFormat("yyyy-MM-dd"); + + /** default value of the sending paragraph. */ + public static final String DEFAULT_SENDING_PARAGRAPH = ""; + + /** default value of the sending status. */ + public static final int DEFAULT_SENDING_STATUS = 0; + + /** Forms Status. */ + public enum FormStatus { + NON_TRAITE(n_("vradi.status.nontraite.name"), n_("vradi.status.nontraite.description")), + NON_SELECTIONNE(n_("vradi.status.nonselectionne.name"), n_("vradi.status.nonselectionne.description")), + PRESELECTIONNE(n_("vradi.status.preselectionne.name"), n_("vradi.status.preselectionne.description")), + SELECTIONNE(n_("vradi.status.selectionne.name"), n_("vradi.status.selectionne.description")); + + private String name; + + private String description; + + private FormStatus(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public int getValue() { + return ordinal(); + } + } + + /** Sending Status. */ + public enum SendingStatus { + DELETED(_("vradi.email.status.deleted")), + TO_SEND(_("vradi.email.status.toSend")), + SENT(_("vradi.email.status.sent")), + WAITING_RECEPTION_PROOF(_("vradi.email.status.waitingReceptionProof")), + RECEIVED(_("vradi.email.status.received")), + ERROR(_("vradi.email.status.error")); + + private final String description; + + private SendingStatus(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public int getValue() { + // Deleted must return -1 + return ordinal() - 1; + } + + public static SendingStatus getStatus(int i) { + for (SendingStatus status : values()) { + if (status.getValue() == i) { + return status; + } + } + return null; + } + + // Status methods utility for sending + public static boolean isSent(Sending sending) { + int status = sending.getStatus(); + return status == SENT.getValue() || + status == WAITING_RECEPTION_PROOF.getValue() || + status == RECEIVED.getValue(); + } + + public static boolean isDeleted(Sending sending) { + int status = sending.getStatus(); + return status == DELETED.getValue(); + } + + public static boolean isToSend(Sending sending) { + int status = sending.getStatus(); + return status == TO_SEND.getValue() || + status == ERROR.getValue(); + } + + public static boolean isWaitingReceptionProof(Sending sending) { + int status = sending.getStatus(); + return status == WAITING_RECEPTION_PROOF.getValue(); + } + + public static boolean isInError(Sending sending) { + int status = sending.getStatus(); + return status == ERROR.getValue(); + } + + public static boolean isClosed(Sending sending) { + return isDeleted(sending) || isSent(sending); + } + } + + /** Session status. */ + public enum SessionStatus { + ACTIVE(_("vradi.sessionStatus.active")), + STOPPED(_("vradi.sessionStatus.stopped")), + SENT(_("vradi.sessionStatus.sent")), + ERROR(_("vradi.sessionStatus.error")); + + protected final String description; + + private SessionStatus(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public static SessionStatus getStatus(int i) { + SessionStatus result = null; + for (SessionStatus status : values()) { + if (status.ordinal() == i) { + result = status; + } + } + return result; + } + + public int getValue() { + return ordinal(); + } + + // Status methods utility for session + public static boolean isActive(Session session) { + if (session == null) { + return false; + } + int status = session.getStatus(); + return status == ACTIVE.getValue(); + } + + public static boolean isSent(Session session) { + int status = session.getStatus(); + return status == SENT.getValue(); + } + + public static boolean isStopped(Session session) { + int status = session.getStatus(); + return status == STOPPED.getValue(); + } + + public static boolean isToRestart(Session session) { + int status = session.getStatus(); + return status == STOPPED.getValue() || + status == ERROR.getValue(); + } + + public static boolean isToSend(Session session) { + int status = session.getStatus(); + return status == ACTIVE.getValue() || + status == STOPPED.getValue() || + status == ERROR.getValue(); + } + } + + /** Form type enum used to xml file markup list. */ + public enum FormTypeTemplateEnum { + FIELDS_ELEMENT("fields"), + FIELD_ELEMENT("field"), + FIELD_TEMPLATE_ATTRIBUTE("template"), + FIELD_EXTENSION_ATTRIBUTE("extension"); + + private final String value; + + private FormTypeTemplateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + /** All file type managed by vradi. */ + public enum FileType { + /** Template files (ott, odt). */ + TEMPLATE, + /** Files embedded into generated PDF. */ + EMBEDDED_FORM_FILES, + /** Files attached to sended mails. */ + ATTACHMENTS_FORM_FILES, + /** Fils attached to session. */ + ATTACHMENTS_SESSION_FILES, + /** Generated pdf files. */ + PDF("application/pdf"), + /** Web harvest script files. */ + WEB_HARVEST, + /** Request history files. */ + QUERY_HISTORY("application/rss+xml"), + /** Temp files */ + TEMP_FILE; + + private final String mineType; + + + private FileType() { + this("application/octet-stream"); + } + + private FileType(String mineType) { + this.mineType = mineType; + } + + public String getMineType() { + return mineType; + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiConstants.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,334 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.ServiceFactory; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiStorageService; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.StringUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.WikittyTreeNode; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This class reference all action run by Vradi Service : + * <p/> + * -- reIndexSolr : reindex solr index + * + * @author sletellier <letellier@codelutin.com> + */ +public class VradiServiceAction { + + /** log. */ + private static final Log log = LogFactory.getLog(VradiServiceAction.class); + + /** Display help and exit action. */ + public void help() { + System.out.println("Usage: vradi-services [-h]"); + System.out.println("Options (set with --option <key> <value>) :"); + for (VradiServiceConfiguration.VradiServiceOption o : VradiServiceConfiguration.VradiServiceOption.values()) { + System.out.println("\t" + o.key + "(" + o.defaultValue + ") : " + o.description); + } + + System.out.println("Actions:"); + for (VradiServiceConfiguration.VradiServiceActionDef a : VradiServiceConfiguration.VradiServiceActionDef.values()) { + System.out.println("\t" + Arrays.toString(a.getAliases()) + "(" + a.getAction() + ") : " + a.getDescription()); + } + System.exit(0); + } + + /** Reload solr index. */ + public static void reIndexSolr() { + + if (log.isInfoEnabled()) { + log.info("Starting reIndex solr"); + } + + long startingTime = System.nanoTime(); + + ServiceFactory.getWikittyProxy().syncSearchEngine(); + + if (log.isInfoEnabled()) { + log.info("ReIndex solr is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + } + System.exit(0); + } + + /** Delete obselete thesaurus. */ + public static void deleteObseleteThesaurus() { + log.info("Starting deleting obselete thesaurus"); + + long startingTime = System.nanoTime(); + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS).criteria(); + + WikittyProxy proxy = ServiceFactory.getWikittyProxy(); + List<Thesaurus> thesauruses = proxy.findAllByCriteria(Thesaurus.class, criteria).getAll(); + + for (Thesaurus thesaurus : thesauruses) { + String parentId = thesaurus.getParent(); + if (parentId == null) { + proxy.delete(thesaurus.getWikittyId()); + + log.info("Found thesaurus '" + thesaurus.getName() + "' has no parentId, deleting this"); + } else { + Thesaurus parent = proxy.restore(Thesaurus.class, parentId); + if (parent == null) { + proxy.delete(thesaurus.getWikittyId()); + log.info("Found thesaurus '" + thesaurus.getName() + "' has no parent with id '" + parentId + ", deleting this"); + } + } + } + + log.info("Deleting obselete thesaurus is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Delete obselete status. */ + public static void reinitStatus() { + log.info("Starting reinit status"); + + long startingTime = System.nanoTime(); + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Status.EXT_STATUS).criteria(); + + WikittyProxy proxy = ServiceFactory.getWikittyProxy(); + List<Status> statuses = proxy.findAllByCriteria(Status.class, criteria).getAll(); + List<String> statusesIds = new ArrayList<String>(); + + for (Status status : statuses) { + statusesIds.add(status.getWikittyId()); + log.info("Deleting status " + status.getName()); + } + + proxy.delete(statusesIds); + + try { + ServiceFactory.getVradiStorageService().createDefaultStatuses(); + } catch (VradiException eee) { + log.error(eee); + } + + log.info("reinit status is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Force all old user to enable. */ + public static void forceAllOldUserEnable() { + log.info("Starting forcing all user enabled"); + + long startingTime = System.nanoTime(); + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER).criteria(); + + WikittyProxy proxy = ServiceFactory.getWikittyProxy(); + List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll(); + + for (User user : users) { + if (user == null) { + break; + } + Object field = user.getField(User.EXT_USER, User.FIELD_USER_ENABLE); + + if (field == null) { + log.info("Found user '" + user.getName() + "' with no enable"); + + // FIXME EC20100910 remove direct access to wikitty + user.setField(User.EXT_USER, User.FIELD_USER_ENABLE, true); + proxy.store(user); + } + } + + log.info("Forcing all user enabled is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Delete all user with no client attached. */ + public static void deleteObseleteUsers() { + log.info("Starting obselete user deletion"); + + long startingTime = System.nanoTime(); + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER).criteria(); + + WikittyProxy proxy = ServiceFactory.getWikittyProxy(); + List<User> users = proxy.findAllByCriteria(User.class, criteria).getAll(); + + for (User user : users) { + if (user == null) { + break; + } + String clientId = user.getClient(); + + if (clientId == null) { + log.info("Deleting user " + user.getName() + " with no client attached"); + proxy.delete(user.getWikittyId()); + } else { + Client client = proxy.restore(Client.class, clientId); + if (client == null) { + log.info("Deleting user " + user.getName() + " with no client attached"); + proxy.delete(user.getWikittyId()); + } + } + } + + log.info("Forcing all user enabled is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Import files contains in {@link VradiServiceConfigurationHelper#getImportCSVDir} with name end by .csv */ + public static void importFiles() { + log.info("Starting import files"); + + long startingTime = System.nanoTime(); + + File importCSVDir = VradiServiceConfigurationHelper.getImportCSVDir(getConfig()); + + if (importCSVDir == null) { + log.error("No import csv dir found, abording"); + System.exit(0); + } + + FilenameFilter filter = new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.matches(".+\\.csv"); + } + }; + File[] files = importCSVDir.listFiles(filter); + + for (File f : files) { + + // import from file on server + String uri = f.toURI().toString(); + try { + log.info("Start import file " + uri); + ServiceFactory.getVradiStorageService().importAsCSV(uri); + } catch (VradiException eee) { + log.error("failled to import file : " + uri, eee); + } + } + log.info("Import files is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Export users */ + public static void exportClients() { + log.info("Starting export clients"); + + long startingTime = System.nanoTime(); + + File exportCSVDir = VradiServiceConfigurationHelper.getExportCSVDir(getConfig()); + + if (exportCSVDir == null) { + log.error("No export csv dir found, abording"); + System.exit(0); + } + + // export + VradiStorageService vradiStorageService = ServiceFactory.getVradiStorageService(); + String vscContent = null; + try { + vscContent = vradiStorageService.exportClientDB(); + } catch (VradiException eee) { + log.error("failled to export clients", eee); + System.exit(0); + } + + String fileName = "exportClient" + startingTime + ".csv"; + + // write content into file + try { + FileUtils.writeStringToFile(new File(exportCSVDir, fileName), vscContent); + } catch (IOException eee) { + log.error("failled to write file : " + fileName, eee); + } + + log.info("Export clients is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + /** Export thesaurus */ + public static void exportThesaurus() { + log.info("Starting export thesaurus"); + + long startingTime = System.nanoTime(); + + File exportCSVDir = VradiServiceConfigurationHelper.getExportCSVDir(getConfig()); + + if (exportCSVDir == null) { + log.error("No export csv dir found, abording"); + System.exit(0); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, + WikittyTreeNode.EXT_WIKITTYTREENODE); + Criteria criteria = search.criteria(); + + // export + VradiStorageService vradiStorageService = ServiceFactory.getVradiStorageService(); + String vscContent = null; + try { + vscContent = vradiStorageService.exportAsCSV(criteria); + } catch (VradiException eee) { + log.error("failled to export thesaurus", eee); + System.exit(0); + } + + String fileName = "exportThesaurus" + startingTime + ".csv"; + + // write content into file + try { + FileUtils.writeStringToFile(new File(exportCSVDir, fileName), vscContent); + } catch (IOException eee) { + log.error("failled to write file : " + fileName, eee); + } + + log.info("Export thesaurus is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + System.exit(0); + } + + protected static ApplicationConfig getConfig() { + return VradiServiceConfiguration.getInstance(); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,450 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import org.apache.commons.lang.UnhandledException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyConfig; + +import java.io.File; +import java.util.Locale; + +import static org.nuiton.i18n.I18n._; + +/** + * Configuration. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 26 mars 2010 21:18:08 + */ +public class VradiServiceConfiguration extends ApplicationConfig { + + /** log. */ + private static final Log log = LogFactory.getLog(VradiServiceConfiguration.class); + + /** After init step. */ + public static final int STEP_AFTER_INIT = 0; + + /** Singleton instance. */ + protected static VradiServiceConfiguration instance = null; + + public static final String DATA_DEFAULT_DIR = "${user.home}" + File.separator + ".vradi" + + File.separator + "vradi-${application.version}"; + + public static final String ATTACHEMENTS_DEFAULT_DIR_NAME = "attachments"; + + public static final String SESSION_ATTACHEMENTS_DEFAULT_DIR_NAME = "sessionAttachments"; + + public static final String EMBEDDED_DEFAULT_DIR_NAME = "embeddedFiles"; + + public static final String QUERY_HISTORY_DEFAULT_DIR_NAME = "queryHistory"; + + public static final String TEMPLATE_DEFAULT_DIR_NAME = "templates"; + + public static final String PDF_DEFAULT_DIR_NAME = "pdf"; + + public static final String TEMP_DEFAULT_DIR_NAME = "temp"; + + public static final String EXPORT_CSV_DEFAULT_DIR_NAME = "exportCSV"; + + public static final String IMPORT_CSV_DEFAULT_DIR_NAME = "importCSV"; + + public static final String WEB_HARVERT_SCRIPT_DEFAULT_DIR_NAME = "WebHarvestScript"; + + public static final String WEB_HARVERT_SCRIPT_PREVIEW_DEFAULT_DIR_NAME = "WebHarvestPreview"; + + protected VradiServiceConfiguration() { + // Load defaults wikitty options + loadDefaultOptions(WikittyConfig.WikittyOption.class); + + // Load defaults vradi options + loadDefaultOptions(VradiServiceOption.class); + + // Load actions + loadActions(VradiServiceActionDef.class); + } + + /** + * Set {@code solr} and {@code jms} system configuration. + * <p/> + * This is the "only" way to configure embedded solr. + */ + protected void setSystemDefaultProps() { + String[] datadirs = new String[]{"solr.data.dir", "wikitty.searchengine.solr.directory.data", "vradi.objectStore.dir"}; + + for (String datadir : datadirs) { + String value = System.getProperty(datadir, null); + if (value == null) { + value = getOption(datadir); + if (log.isInfoEnabled()) { + log.info("Setting system property " + datadir + " : " + value); + } + if (value != null) { + System.setProperty(datadir, value); + env.put(datadir, value); + } + } + } + } + + public static synchronized VradiServiceConfiguration getInstance(String... args) { + if (instance == null) { + try { + instance = new VradiServiceConfiguration(); + instance.parse(args); + instance.setSystemDefaultProps(); + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't intitialize configuration", ex); + } + throw new UnhandledException(ex); + } + } + return instance; + } + + /** Vradi option definition. */ + public static enum VradiServiceOption implements OptionDef { + + CONFIG_FILE( + CONFIG_FILE_NAME, + _("vradi.service.config.configFileName.description"), + "vradi-services.properties", + String.class, true, true), + + APPLICATION_VERSION( + "application.version", + _("vradi.service.config.application.version.description"), + null, String.class, false, false), + + SERVICE_VERSION( + "vradi.service.version", + _("vradi.service.config.version.description"), + null, String.class, false, false), + + DATA_DIR( + "vradi.data.dir", + _("vradi.service.config.data.dir.description"), + DATA_DEFAULT_DIR, + String.class, false, false), + + LOCALE( + "vradi.service.locale", + _("vradi.service.config.ui.locale.description"), + Locale.FRANCE.toString(), Locale.class, false, false), + + MAIL_ADMIN( + "vradi.mail.admin", + _("vradi.service.config.mail.admin.description"), + null, String.class, false, false), + + OOO_DIR( + "oOo.exec.folder", + _("vradi.service.config.oOo.exec.folder.description"), + "${user.home}/.vradi/vradi-${application.version}", + String.class, false, false), + + MAIL_DEBUG( + "vradi.mail.debug", + _("vradi.service.config.mail.debug.description"), + Boolean.FALSE.toString(), Boolean.class, false, false), + + SMTP_HOST( + "vradi.smtp.host", + _("vradi.service.config.smtp.host.description"), + null, String.class, false, false), + + SMTP_PORT( + "vradi.smtp.port", + _("vradi.service.config.smtp.port.description"), + null, Integer.class, false, false), + + IMAP_HOST( + "vradi.imap.host", + _("vradi.service.config.imap.host.description"), + null, Integer.class, false, false), + + IMAP_PORT( + "vradi.imap.port", + _("vradi.service.config.imap.port.description"), + null, Integer.class, false, false), + + MAIL_USER( + "vradi.mail.user", + _("vradi.service.config.mail.user.description"), + null, String.class, false, false), + + MAIL_FROM( + "vradi.mail.from", + _("vradi.service.config.mail.from.description"), + null, String.class, false, false), + + MAIL_FROM_NAME( + "vradi.mail.fromname", + _("vradi.service.config.mail.fromname.description"), + null, String.class, false, false), + + MAIL_PASSWORD( + "vradi.mail.password", + _("vradi.service.config.mail.password.description"), + null, String.class, false, false), + + MAIL_OFFER_SUBJECT( + "vradi.mail.offer.subject", + _("vradi.service.config.mail.offer.subject.description"), + null, String.class, false, false), + + SESSION_DEFAULT_PARAGRAPH( + "vradi.session.defaultParagraph", + _("vradi.service.config.session.defaultParagraph.description"), + null, String.class, false, false), + + SKIP_MIGRATION( + "vradi.migration.skip", + _("vradi.service.config.migration.skip.description"), + Boolean.FALSE.toString(), Boolean.class, false, false), + + ATTACHEMENTS_DIR( + "vradi.attachments.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(ATTACHEMENTS_DEFAULT_DIR_NAME), + String.class, false, false), + + SESSION_ATTACHEMENTS_DIR( + "vradi.session.attachments.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(SESSION_ATTACHEMENTS_DEFAULT_DIR_NAME), + String.class, false, false), + + EMBEDDED_DIR( + "vradi.embeddedFiles.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(EMBEDDED_DEFAULT_DIR_NAME), + String.class, false, false), + + QUERY_HISTORY_DIR( + "vradi.queryHistory.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(QUERY_HISTORY_DEFAULT_DIR_NAME), + String.class, false, false), + + TEMPLATE_DIR( + "vradi.templates.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(TEMPLATE_DEFAULT_DIR_NAME), + String.class, false, false), + + PDF_DIR( + "vradi.pdf.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(PDF_DEFAULT_DIR_NAME), + String.class, false, false), + + TEMP_DIR( + "vradi.temp.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(TEMPLATE_DEFAULT_DIR_NAME), + String.class, false, false), + + EXPORT_CSV_DIR( + "vradi.exportCSV.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(EXPORT_CSV_DEFAULT_DIR_NAME), + String.class, false, false), + + IMPORT_CSV_DIR( + "vradi.importCSV.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(IMPORT_CSV_DEFAULT_DIR_NAME), + String.class, false, false), + + WEB_HARVERT_SCRIPT_DIR( + "vradi.WebHarvestScript.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(WEB_HARVERT_SCRIPT_DEFAULT_DIR_NAME), + String.class, false, false), + + WEB_HARVERT_SCRIPT_PREVIEW_DIR( + "vradi.WebHarvestPreview.dir", + _("vradi.service.config.migration.skip.description"), + getDefaultDir(WEB_HARVERT_SCRIPT_PREVIEW_DEFAULT_DIR_NAME), + String.class, false, false); + + public String key; + + public String description; + + public String defaultValue; + + public Class<?> type; + + public boolean isTransient; + + public boolean isFinal; + + private VradiServiceOption(String key, String description, String defaultValue, + Class<?> type, boolean isTransient, boolean isFinal) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + this.isFinal = isFinal; + this.isTransient = isTransient; + } + + @Override + public String getKey() { + return key; + } + + @Override + public Class<?> getType() { + return type; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public boolean isTransient() { + return isTransient; + } + + @Override + public boolean isFinal() { + return isFinal; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public void setTransient(boolean isTransient) { + this.isTransient = isTransient; + } + + @Override + public void setFinal(boolean isFinal) { + this.isFinal = isFinal; + } + + private static String getDefaultDir(String dirName) { + String defaultDir = "${" + DATA_DIR.key + "}" + File.separator + dirName; + return defaultDir; + } + } + + /** + * Actions can be called in command line + * + * @author sletellier <letellier@codelutin.com> + */ + public enum VradiServiceActionDef implements ActionDef { + + HELP( + VradiServiceAction.class.getName() + "#help", + _("vradi.service.config.help.description"), + "-h", "--help"), + + REINDEX_SOLR( + VradiServiceAction.class.getName() + "#reIndexSolr", + _("vradi.service.config.reIndexSolr.description"), + "--reIndexSolr"), + + DELETE_OBSELETE_THESAURUS( + VradiServiceAction.class.getName() + "#deleteObseleteThesaurus", + _("vradi.service.config.deleteObseleteThesaurus.description"), + "--deleteObseleteThesaurus"), + + REINIT_STATUS( + VradiServiceAction.class.getName() + "#reinitStatus", + _("vradi.service.config.reinitStatus.description"), + "--reinitStatus"), + + FORCE_ALL_OLD_USER_ENABLE( + VradiServiceAction.class.getName() + "#forceAllOldUserEnable", + _("vradi.service.config.forceAllOldUserEnable.description"), + "--forceAllOldUserEnable"), + + DELETE_OBSELETE_USERS( + VradiServiceAction.class.getName() + "#deleteObseleteUsers", + _("vradi.service.config.deleteObseleteUsers.description"), + "--deleteObseleteUsers"), + + IMPORT_FILES( + VradiServiceAction.class.getName() + "#importFiles", + _("vradi.service.config.importFiles.description"), + "--importFiles"), + + EXPORT_CLIENTS( + VradiServiceAction.class.getName() + "#exportClients", + _("vradi.service.config.exportClients.description"), + "--exportClients"), + + EXPORT_THESAURUS( + VradiServiceAction.class.getName() + "#exportThesaurus", + _("vradi.service.config.exportThesaurus.description"), + "--exportThesaurus"); + + protected String action; + + protected String description; + + protected String[] aliases; + + private VradiServiceActionDef(String action, String description, String... aliases) { + this.action = action; + this.description = description; + this.aliases = aliases; + } + + @Override + public String getAction() { + return action; + } + + public String getDescription() { + return action; + } + + @Override + public String[] getAliases() { + return aliases; + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfiguration.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,238 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.StringUtil; +import org.nuiton.wikitty.WikittyConfig; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import static org.chorem.vradi.VradiServiceConfiguration.VradiServiceOption; + +/** @author sletellier */ +public class VradiServiceConfigurationHelper { + + /** + * Get current application version as string. + * + * @param config vradi service configuration + * @return version + */ + public static String getApplicationVersion(ApplicationConfig config) { + return config.getOption(VradiServiceOption.APPLICATION_VERSION.key); + } + + /** + * Get last saved version as string (last launch). + * + * @param config vradi service configuration + * @return version + */ + public static String getServiceVersion(ApplicationConfig config) { + return config.getOption(VradiServiceOption.SERVICE_VERSION.key); + } + + /** + * Set service version. + * + * @param config vradi service configuration + * @param version version to set + */ + public static void setServiceVersion(ApplicationConfig config, String version) { + config.setOption(VradiServiceOption.SERVICE_VERSION.key, version); + } + + public static String getDataDir(ApplicationConfig config) { + String option = config.getOption(VradiServiceOption.DATA_DIR.key); + return option; + } + + public static File getDataDirAsFile(ApplicationConfig config) { + File option = config.getOptionAsFile(VradiServiceOption.DATA_DIR.key); + return option; + } + + public static Locale getLocale(ApplicationConfig config) { + Locale result = config.getOption(Locale.class, VradiServiceOption.LOCALE.key); + return result; + } + + public static void setLocale(ApplicationConfig config, Locale locale) { + config.setOption(VradiServiceOption.LOCALE.key, locale.toString()); + } + + public static File getAttachmentsDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.ATTACHEMENTS_DIR.key); + } + + public static File getSessionAttachmentsDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.SESSION_ATTACHEMENTS_DIR.key); + } + + public static File getEmbeddedFilesDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.EMBEDDED_DIR.key); + } + + public static File getQueryHistoryDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.QUERY_HISTORY_DIR.key); + } + + public static File getTemplatesDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.TEMPLATE_DIR.key); + } + + public static File getPdfDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.PDF_DIR.key); + } + + public static File getTempDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.TEMP_DIR.key); + } + + public static File getExportCSVDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.EXPORT_CSV_DIR.key); + } + + public static File getImportCSVDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.IMPORT_CSV_DIR.key); + } + + public static File getWebHarvestPreviewDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.WEB_HARVERT_SCRIPT_PREVIEW_DIR.key); + } + + public static File getWebHarvestScriptDir(ApplicationConfig config) { + return config.getOptionAsFile(VradiServiceOption.WEB_HARVERT_SCRIPT_DIR.key); + } + + public static String getOpenOfficeExecDir(ApplicationConfig config) { + return config.getOption(VradiServiceOption.OOO_DIR.key); + } + + public static String getSmtpHost(ApplicationConfig config) { + return config.getOption(VradiServiceOption.SMTP_HOST.key); + } + + public static int getSmtpPort(ApplicationConfig config) { + return config.getOptionAsInt(VradiServiceOption.SMTP_PORT.key); + } + + public static String getImapHost(ApplicationConfig config) { + return config.getOption(VradiServiceOption.IMAP_HOST.key); + } + + public static int getImapPort(ApplicationConfig config) { + return config.getOptionAsInt(VradiServiceOption.IMAP_PORT.key); + } + + public static String getMailUser(ApplicationConfig config) { + return config.getOption(VradiServiceOption.MAIL_USER.key); + } + + public static String getMailFrom(ApplicationConfig config) { + return config.getOption(VradiServiceOption.MAIL_FROM.key); + } + + public static String getMailFromName(ApplicationConfig config) { + return config.getOption(VradiServiceOption.MAIL_FROM_NAME.key); + } + + public static String getMailPassword(ApplicationConfig config) { + return config.getOption(VradiServiceOption.MAIL_PASSWORD.key); + } + + public static String getOfferMailSubject(ApplicationConfig config) { + String result = config.getOption(VradiServiceOption.MAIL_OFFER_SUBJECT.key); + return result; + } + + public static boolean isMailDebug(ApplicationConfig config) { + return config.getOptionAsBoolean(VradiServiceOption.MAIL_DEBUG.key); + } + + public static List<String> getMailAdmin(ApplicationConfig config) { + return getOptionAsList(config, VradiServiceOption.MAIL_ADMIN.key); + } + + public static void addMailAdmin(ApplicationConfig config, String email) { + addOptionAsList(config, VradiServiceOption.MAIL_ADMIN.key, email); + } + + public static String getSessionDefaultParagraph(ApplicationConfig config) { + return config.getOption(VradiServiceOption.SESSION_DEFAULT_PARAGRAPH.key); + } + + public static boolean skipMigration(ApplicationConfig config) { + return config.getOptionAsBoolean(VradiServiceOption.SKIP_MIGRATION.key); + } + + public static List<String> getOptionAsList(ApplicationConfig config, String key) { + + List<String> result = new ArrayList<String>(); + String admins = config.getOption(key); + if (admins != null && !admins.isEmpty()) { + if (admins.contains(", ")) { + String[] strings = admins.split(", "); + result = Arrays.asList(strings); + } else { + result.add(admins); + } + } + return result; + } + + protected static void addOptionAsList(ApplicationConfig config, String key, String value) { + List<String> list = getOptionAsList(config, key); + list.add(value); + + String values = StringUtil.join(list, ", ", false); + + config.setOption(key, values); + } + + /* + * TODO sletellier 22/11/10 : Move this in wikitty + */ + public static void setWikittyEventPropagate(ApplicationConfig config, boolean b) { + config.setOption(WikittyConfig.WikittyOption.WIKITTY_EVENT_PROPAGATE.key, String.valueOf(b)); + } + + public static Boolean getWikittyEventPropagate(ApplicationConfig config) { + return config.getOptionAsBoolean(WikittyConfig.WikittyOption.WIKITTY_EVENT_PROPAGATE.key); + } + + public static String getWikittyEventTransporterXMPPServer(ApplicationConfig config) { + return config.getOption(WikittyConfig.WikittyOption.WIKITTY_EVENT_TRANSPORTER_XMPP_SERVER.key); + } + + public static String getWikittyEventTransporterXMPPRoom(ApplicationConfig config) { + return config.getOption(WikittyConfig.WikittyOption.WIKITTY_EVENT_TRANSPORTER_XMPP_ROOM.key); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceConfigurationHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceMain.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceMain.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceMain.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,59 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; + +/** + * This module do nothing except with options : + * <p/> + * -- reIndexSolr + * + * @author sletellier <letellier@codelutin.com> + */ +public class VradiServiceMain { + + /** log. */ + private static final Log log = LogFactory.getLog(VradiServiceMain.class); + + public static void main(String[] args) { + + // Initialise config + VradiServiceConfiguration config = VradiServiceConfiguration.getInstance(args); + I18n.setDefaultLocale(VradiServiceConfigurationHelper.getLocale(config)); + + try { + // Launch actions + config.doAction(VradiServiceConfiguration.STEP_AFTER_INIT); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't run actions ", eee); + } + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/VradiServiceMain.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,183 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.beans; + +import org.chorem.vradi.entities.Form; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Contient en meme tps les parametres de recherches et les resultats and + * les parametres en résultats. + * + * @author morin + * Date: 4 déc. 2009 + * Time: 09:43:37 + */ +public class FormPagedResult implements Serializable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + protected transient PropertyChangeSupport propertyChange = new PropertyChangeSupport(this); + + public static final String FORMS_TO_SHOW_PROPERTY = "formsToShow"; + + public static final String TOTAL_FOUND_FORM_NB_PROPERTY = "totalFoundFormNb"; + + public static final String PAGE_TO_SHOW_PROPERTY = "pageToShow"; + + public static final String NB_FORMS_TO_SHOW_PROPERTY = "nbFormsToShow"; + + public static final String FIELD_TO_SORT_PROPERTY = "fieldToSort"; + + public static final String ASCENDING_PROPERTY = "ascending"; + + /** Result forms. */ + protected List<String> formsIdsToShow; + + /** Total result count. */ + protected int totalFoundFormNb = 0; + + /** Current page index. */ + protected int pageToShow = 0; + + /** Total page count. */ + protected int nbFormsToShow = 0; + + /** Field name to sort (wikitty fqName). */ + protected String fieldToSort = null; + + /** Sort order. */ + protected boolean ascending = true; + + public FormPagedResult() { + formsIdsToShow = new ArrayList<String>(); + } + + public FormPagedResult(List<Form> formsToShow) { + this(formsToShow, formsToShow.size(), 0, formsToShow.size()); + } + + public FormPagedResult(List<Form> formsToShow, int totalFoundFormNb, int pageToShow, int nbFormsToShow) { + this(); + formsIdsToShow = extractIds(formsToShow); + this.totalFoundFormNb = totalFoundFormNb; + this.pageToShow = pageToShow; + this.nbFormsToShow = nbFormsToShow; + } + + protected List<String> extractIds(List<Form> formsToShow) { + List<String> formsIds = new ArrayList<String>(); + if (formsToShow != null) { + for (Form form : formsToShow) { + if (form != null) { + formsIds.add(form.getWikittyId()); + } + } + } + return formsIds; + } + + public List<String> getFormsIdsToShow() { + return formsIdsToShow; + } + + public void setFormsToShow(List<String> formsIdsToShow) { + List<String> oldValue = this.formsIdsToShow; + this.formsIdsToShow = formsIdsToShow; + propertyChange.firePropertyChange(FORMS_TO_SHOW_PROPERTY, oldValue, formsIdsToShow); + } + + public int getTotalFoundFormNb() { + return totalFoundFormNb; + } + + public void setTotalFoundFormNb(int totalFoundFormNb) { + int oldValue = this.totalFoundFormNb; + this.totalFoundFormNb = totalFoundFormNb; + propertyChange.firePropertyChange(TOTAL_FOUND_FORM_NB_PROPERTY, oldValue, totalFoundFormNb); + } + + public int getPageToShow() { + return pageToShow; + } + + public void setPageToShow(int pageToShow) { + int oldValue = this.pageToShow; + this.pageToShow = pageToShow; + propertyChange.firePropertyChange(PAGE_TO_SHOW_PROPERTY, oldValue, pageToShow); + } + + public int getNbFormsToShow() { + return nbFormsToShow; + } + + public void setNbFormsToShow(int nbFormsToShow) { + int oldValue = this.nbFormsToShow; + this.nbFormsToShow = nbFormsToShow; + propertyChange.firePropertyChange(NB_FORMS_TO_SHOW_PROPERTY, oldValue, nbFormsToShow); + } + + public String getFieldToSort() { + return fieldToSort; + } + + public void setFieldToSort(String fieldToSort) { + String oldValue = this.fieldToSort; + this.fieldToSort = fieldToSort; + propertyChange.firePropertyChange(FIELD_TO_SORT_PROPERTY, oldValue, fieldToSort); + } + + public boolean isAscending() { + return ascending; + } + + public void setAscending(boolean ascending) { + boolean oldValue = this.ascending; + this.ascending = ascending; + propertyChange.firePropertyChange(ASCENDING_PROPERTY, oldValue, ascending); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + propertyChange.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + propertyChange.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + propertyChange.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + propertyChange.removePropertyChangeListener(propertyName, listener); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/FormPagedResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryBean.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryBean.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryBean.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,218 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.beans; + +import au.com.bytecode.opencsv.CSVParser; +import au.com.bytecode.opencsv.CSVWriter; + +import java.io.IOException; +import java.io.Serializable; +import java.io.StringWriter; + +/** + * Query bean. + * <p/> + * Used to manipulate User, Group, Client queries, parse from CSV ad encode to CSV. + * + * @author schorlet + * @version $Revision$ $Date$ + * @see CSVWriter + * @see CSVParser + * @since 16 mars 2010 14:25:12 + */ +public final class QueryBean implements Serializable { + + private static final long serialVersionUID = 2L; + + protected final String queryLine; + + protected final String[] queryArray; + + protected final String id; + + public QueryBean() { + id = null; + queryLine = ""; + queryArray = new String[3]; + } + + /** + * Decode the specified <code>queryLine</code>. The queryLine must be CSV formatted. + * + * @param queryLine the formatted query. + * @throws IOException if <code>queryLine</code> is badly formatted. + */ + public QueryBean(String queryLine) throws IOException { + this(queryLine, null); + } + + public QueryBean(String queryLine, String id) throws IOException { + this.id = id; + this.queryLine = queryLine; + queryArray = decode(queryLine, 3); + } + + /** + * Creates a CSV formatted query from the specified <code>queryArray</code>. + * + * @param queryArray the string composing the query + */ + private QueryBean(String[] queryArray, String id) { + if (queryArray.length < 3) { + throw new IllegalArgumentException("queryArray length is less than 3"); + } + + this.id = id; + this.queryArray = queryArray.clone(); + queryLine = encode(queryArray); + } + + public String getQueryLine() { + return queryLine; + } + + public String getQuery() { + return queryArray[0]; + } + + public String getName() { + return queryArray[1]; + } + + public String getDescription() { + return queryArray[2]; + } + + public String getCSVQuery() { + return queryLine; + } + + public String[] toArray() { + return queryArray; + } + + public QueryBean setQuery(String value) { + return create(value, 0); + } + + public QueryBean setName(String value) { + return create(value, 1); + } + + public QueryBean setDescription(String value) { + return create(value, 2); + } + + private QueryBean create(String value, int pos) { + String[] newArray = queryArray.clone(); + newArray[pos] = value; + return new QueryBean(newArray, id); + } + + /** + * Parse the specified line and returns a string array of the specified size. + * + * @param line the string to parse + * @return the comma-tokenized list of elements + * @throws IOException + */ + static String[] decode(String line, int size) throws IOException { + CSVParser csvParser = new CSVParser(); + String[] parseLine = csvParser.parseLine(line); + + String[] result = new String[size]; + for (int i = 0; i < parseLine.length; i++) { + result[i] = parseLine[i]; + } + + return result; + } + + /** + * Escape each columns of the specified array and return a valid CSV line. + * + * @param columns columns composing the CVS string + * @return a CSV formatted string + */ + static String encode(String[] columns) { + StringWriter writer = new StringWriter(); + // creates a CSVWriter with all default options but with no line end + CSVWriter csvwriter = new CSVWriter(writer, CSVWriter.DEFAULT_SEPARATOR, + CSVWriter.DEFAULT_QUOTE_CHARACTER, CSVWriter.DEFAULT_ESCAPE_CHARACTER, ""); + csvwriter.writeNext(columns); + return writer.toString(); + } + + /** + * Additionnal attribute. It does not belongs to the query definition. + * + * @return query id + */ + public String getId() { + return id; + } + + @Override + public int hashCode() { + int prime = 31; + int result = 1; + result = prime * result + (id == null ? 0 : id.hashCode()); + result = prime * result + + (queryLine == null ? 0 : queryLine.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + QueryBean other = (QueryBean) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + + if (queryLine == null) { + if (other.queryLine != null) { + return false; + } + } else if (!queryLine.equals(other.queryLine)) { + return false; + } + + return true; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryBean.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryParameters.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryParameters.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryParameters.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,155 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.beans; + +import org.chorem.vradi.entities.Thesaurus; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Query parameters. + * <p/> + * The {@link #beginDate} and {@link #endDate} specifies a + * date range filter which is applied on {@link #dateFieldName} field. + * The date range filter is applied only if the three parameters are not null. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class QueryParameters implements Serializable { + + /** serialVersionUID */ + private static final long serialVersionUID = 1L; + + protected String query; + + protected Date beginDate; + + protected Date endDate; + + protected WikittyExtension extension; + + protected String dateFieldName; + + protected List<String> statusIds; + + protected List<Thesaurus> thesaurus; + + protected List<String> streamIds; + + public QueryParameters() { + + } + + public QueryParameters(String query) { + this(); + this.query = query; + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Date getBeginDate() { + return beginDate; + } + + public void setBeginDate(Date beginDate) { + this.beginDate = beginDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public WikittyExtension getExtension() { + return extension; + } + + public void setExtension(WikittyExtension extension) { + this.extension = extension; + } + + public String getDateFieldName() { + return dateFieldName; + } + + public void setDateFieldName(String dateFieldName) { + this.dateFieldName = dateFieldName; + } + + public List<String> getStatusIds() { + return statusIds; + } + + public void setStatusIds(List<String> statusIds) { + this.statusIds = statusIds; + } + + public List<Thesaurus> getThesaurus() { + return thesaurus; + } + + public void setThesaurus(List<Thesaurus> thesaurus) { + this.thesaurus = thesaurus; + } + + public void addThesaurus(Thesaurus thesaurus) { + if (this.thesaurus == null) { + this.thesaurus = new ArrayList<Thesaurus>(); + } + this.thesaurus.add(thesaurus); + } + + public void clearThesaurus() { + if (thesaurus != null) { + thesaurus.clear(); + } + } + + public List<String> getStreamIds() { + return streamIds; + } + + public void setStreamIds(List<String> streamIds) { + this.streamIds = streamIds; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/QueryParameters.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/SendingHelper.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/SendingHelper.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/SendingHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,116 @@ +/* + * #%L + * Vradi :: Services + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.beans; + +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.GroupFormsImpl; +import org.chorem.vradi.entities.Sending; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Search; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** @author letellier */ +public class SendingHelper { + + public static GroupForms createGroupForms(Group group, String formId) { + Set<String> forms = new HashSet<String>(); + forms.add(formId); + return createGroupForms(group, forms); + } + + public static GroupForms createGroupForms(Group group, Set<Form> forms) { + Set<String> formIds = new HashSet<String>(); + for (Form f : forms) { + formIds.add(f.getWikittyId()); + } + return createGroupForms(group, formIds); + } + + public static GroupForms createGroupForms(Group group, Collection<String> formsId) { + return createGroupForms(group == null ? null : group.getWikittyId(), formsId); + } + + public static GroupForms createGroupForms(String groupId, Collection<String> formsId) { + + GroupForms groupFormCreated = new GroupFormsImpl(); + + if (groupId != null) { + groupFormCreated.setGroup(groupId); + } + + if (formsId != null) { + for (String formId : formsId) { + groupFormCreated.addForm(formId); + } + } + return groupFormCreated; + } + + public static Set<String> extractForms(WikittyProxy wikittyProxy, Collection<String> groupFormIds) { + Set<String> result = new HashSet<String>(); + + if (groupFormIds != null) { + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormIds)); + for (GroupForms groupForm : groupForms) { + result.addAll(extractForms(groupForm)); + } + } + return result; + } + + public static Set<String> extractForms(WikittyProxy wikittyProxy, String groupFormId) { + + GroupForms groupForms = wikittyProxy.restore(GroupForms.class, groupFormId); + return extractForms(groupForms); + } + + public static Set<String> extractForms(GroupForms groupForm) { + Set<String> result = new HashSet<String>(); + + if (groupForm != null) { + Set<String> idsSet = groupForm.getForm(); + if (idsSet != null) { + result.addAll(idsSet); + } + } + return result; + } + + public static Sending findSendingCorrespondingGroupForm(WikittyProxy wikittyProxy, String wikittyId) { + + Search searchOr = Search.query().or(); + searchOr.contains(Sending.FQ_FIELD_SENDING_GROUPFORMS, wikittyId); + searchOr.contains(Sending.FQ_FIELD_SENDING_DELETEDGROUPFORMS, wikittyId); + + return wikittyProxy.findByCriteria(Sending.class, searchOr.criteria()); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/SendingHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/XmlStreamImportResult.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/XmlStreamImportResult.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/XmlStreamImportResult.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,89 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.beans; + +import java.io.Serializable; + +/** + * Import xml stream results. + * <p/> + * Contains : + * - the number of created forms + * - the number of already existing forms (non created) + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class XmlStreamImportResult implements Serializable { + + /** serialVersionUID. */ + private static final long serialVersionUID = -7378576743532050958L; + + protected int createdFormCount; + + protected int alreadyExistsFormCount; + + protected int dateParsingError; + + protected int numberParsingError; + + public int getCreatedFormCount() { + return createdFormCount; + } + + public void setCreatedFormCount(int createdFormCount) { + this.createdFormCount = createdFormCount; + } + + public int getAlreadyExistsFormCount() { + return alreadyExistsFormCount; + } + + public void setAlreadyExistsFormCount(int alreadyExistsFormCount) { + this.alreadyExistsFormCount = alreadyExistsFormCount; + } + + public int getDateParsingError() { + return dateParsingError; + } + + public void setDateParsingError(int dateParsingError) { + this.dateParsingError = dateParsingError; + } + + public int getNumberParsingError() { + return numberParsingError; + } + + public void setNumberParsingError(int numberParsingError) { + this.numberParsingError = numberParsingError; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/XmlStreamImportResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/package-info.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/beans/package-info.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/beans/package-info.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +/** + * Vradi beans objects (service methods return types : multiples results). + */ +package org.chorem.vradi.beans; Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/beans/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileService.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileService.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,320 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import java.io.File; + +/** + * File management service. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public interface FileService { + + /** + * Upload a template on server. + * + * @param file file to upload + * @param extensionName extension name to put file into + * @return file uri to reference file + * @throws VradiException throw VradiException if exception is occured + */ + String uploadTemplate(File file, String extensionName) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param extensionName extension name + * @param templateName template name + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadTemplate(String extensionName, String templateName) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param extensionName extension name + * @param templateName template name + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadTemplate(boolean convertUrl, String extensionName, String templateName) throws VradiException; + + /** + * Upload a web harvest script on server. + * + * @param file file to upload + * @return file uri to reference file + * @throws VradiException throw VradiException if exception is occured + */ + String uploadWebHarvestScript(File file) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadWebHarvestScript(String uri) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadWebHarvestScript(boolean convertUrl, String uri) throws VradiException; + + /** + * Download pdf file. + * <p/> + * File may be temporary. + * + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadPDF(String uri) throws VradiException; + + /** + * Download pdf file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadPDF(boolean convertUrl, String uri) throws VradiException; + + /** + * Download pdf file. + * + * @param uri corresponding to history + * @return url to go to file + * @throws VradiException throw VradiException if exception is occured + */ + String getPDFUrl(String uri) throws VradiException; + + /** + * Upload a temporary file (for example for export). + * + * @param file The file to upload + * @return an absolute URI on server file system + * @throws VradiException if an exception occurred + */ + String uploadTempFile(File file) throws VradiException; + + /** + * Upload a form attachment. + * + * @param file file to upload + * @param formId form id + * @return file uri to reference file + * @throws VradiException if an exception occurred + */ + String uploadFormAttachment(File file, String formId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormAttachment(String uri) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param fileName to download + * @param formId form id + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormAttachment(boolean convertUrl, String fileName, String formId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param fileName to download + * @param formId concerned + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormAttachment(String fileName, String formId) throws VradiException; + + /** + * Upload a session attachment. + * + * @param file file to upload + * @param sessionId session id + * @return file uri to reference file + * @throws VradiException if an exception occurred + */ + String uploadSessionAttachment(File file, String sessionId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadSessionAttachment(String uri) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param fileName to download + * @param sessionId session id + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadSessionAttachment(boolean convertUrl, String fileName, String sessionId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param fileName to download + * @param sessionId concerned + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadSessionAttachment(String fileName, String sessionId) throws VradiException; + + /** + * Upload a form attachement. + * + * @param file file to upload + * @param formId form id + * @return file uri to reference file + * @throws VradiException throw VradiException if exception is occured + */ + String uploadFormEmbeddedFile(File file, String formId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param uri file uri to download + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormEmbeddedFile(String uri) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param fileName to download + * @param formId form id + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormEmbeddedFile(String fileName, String formId) throws VradiException; + + /** + * Download file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param fileName to download + * @param formId form id + * @return locally downloaded file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadFormEmbeddedFile(boolean convertUrl, String fileName, String formId) throws VradiException; + + String getFormEmbeddedUrl(String fileName, String formId) throws VradiException; + + /** + * Download request histiory file. + * <p/> + * File may be temporary. + * + * @param uri corresponding to history + * @return url to go to file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadRequestHistory(String uri) throws VradiException; + + /** + * Download request history file. + * <p/> + * File may be temporary. + * + * @param convertUrl if convertion url is necessary + * @param uri corresponding to history + * @return url to go to file + * @throws VradiException throw VradiException if exception is occured + */ + File downloadRequestHistory(boolean convertUrl, String uri) throws VradiException; + + /** + * Get the url of request history. + * + * @param uri corresponding to history + * @return url to go to file + * @throws VradiException throw VradiException if exception is occured + */ + String getRequestHistoryURL(String uri) throws VradiException; +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceImpl.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceImpl.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceImpl.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,296 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.io.FileUtils; +import org.chorem.vradi.VradiServiceConfiguration; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.nuiton.util.ApplicationConfig; + +import java.io.File; +import java.io.IOException; + +/** + * File service impl. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FileServiceImpl implements FileService { + + protected ApplicationConfig config; + + public FileServiceImpl() { + this(VradiServiceConfiguration.getInstance()); + } + + public FileServiceImpl(ApplicationConfig config) { + this.config = config; + } + + @Override + public String uploadTemplate(File file, String extensionName) throws VradiException { + + String fileuri; + + try { + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File templateDir = new File(templatesDir, extensionName); + templateDir.mkdirs(); + + File copyOfTemplate = new File(templateDir, file.getName()); + FileUtils.copyFile(file, copyOfTemplate); + fileuri = copyOfTemplate.getName(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileuri; + } + + @Override + public File downloadTemplate(String extensionName, String templateName) { + File templateFile = null; + if (templateName != null) { + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File templateDir = new File(templatesDir, extensionName); + templateFile = new File(templateDir, templateName); + } + return templateFile; + } + + @Override + public File downloadTemplate(boolean convertUrl, String extensionName, String templateName) throws VradiException { + return downloadTemplate(extensionName, templateName); + } + + @Override + public String uploadWebHarvestScript(File file) throws VradiException { + + String fileuri; + + try { + File scriptsDir = VradiServiceConfigurationHelper.getWebHarvestScriptDir(config); + File scriptFile = new File(scriptsDir, file.getName()); + FileUtils.copyFile(file, scriptFile); + fileuri = scriptFile.getName(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileuri; + } + + @Override + public File downloadWebHarvestScript(String uri) { + File scriptsDir = VradiServiceConfigurationHelper.getWebHarvestScriptDir(config); + File scriptFile = new File(scriptsDir, uri); + return scriptFile; + } + + @Override + public File downloadWebHarvestScript(boolean convertUrl, String uri) { + return downloadWebHarvestScript(uri); + } + + @Override + public File downloadPDF(String uri) { + File pdfDir = VradiServiceConfigurationHelper.getPdfDir(config); + File pdfFile = new File(pdfDir, uri); + return pdfFile; + } + + @Override + public File downloadPDF(boolean convertUrl, String uri) { + return downloadPDF(uri); + } + + @Override + public String getPDFUrl(String uri) throws VradiException { + File pdfDir = VradiServiceConfigurationHelper.getPdfDir(config); + File pdfFile = new File(pdfDir, uri); + return pdfFile.toURI().toString(); + } + + @Override + public String uploadTempFile(File file) throws VradiException { + + String fileURI; + + try { + File tempDir = VradiServiceConfigurationHelper.getTempDir(config); + tempDir.mkdirs(); + + File copyOfTempFile = new File(tempDir, file.getName()); + FileUtils.copyFile(file, copyOfTempFile); + fileURI = "file://" + copyOfTempFile.getAbsolutePath(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileURI; + } + + @Override + public String uploadFormAttachment(File file, String formId) throws VradiException { + + String fileuri; + + try { + File attachementsDir = VradiServiceConfigurationHelper.getAttachmentsDir(config); + File attachementDir = new File(attachementsDir, formId); + attachementDir.mkdirs(); + + File copyOfFormAttachement = new File(attachementDir, file.getName()); + FileUtils.copyFile(file, copyOfFormAttachement); + fileuri = copyOfFormAttachement.getName(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileuri; + } + + @Override + public File downloadFormAttachment(String uri) { + File attachmentDir = VradiServiceConfigurationHelper.getAttachmentsDir(config); + File attachmentFile = new File(attachmentDir, uri); + return attachmentFile; + } + + @Override + public File downloadFormAttachment(String fileName, String formId) { + return downloadFormAttachment(formId + File.separator + fileName); + } + + @Override + public File downloadFormAttachment(boolean convertUrl, String fileName, String formId) { + return downloadFormAttachment(fileName, formId); + } + + @Override + public String uploadSessionAttachment(File file, String sessionId) throws VradiException { + + String fileuri; + + try { + File attachementsDir = VradiServiceConfigurationHelper.getSessionAttachmentsDir(config); + File attachementDir = new File(attachementsDir, sessionId); + attachementDir.mkdirs(); + + File copyOfFormAttachement = new File(attachementDir, file.getName()); + FileUtils.copyFile(file, copyOfFormAttachement); + fileuri = copyOfFormAttachement.getName(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileuri; + } + + @Override + public File downloadSessionAttachment(String uri) { + File attachmentDir = VradiServiceConfigurationHelper.getSessionAttachmentsDir(config); + File attachmentFile = new File(attachmentDir, uri); + return attachmentFile; + } + + @Override + public File downloadSessionAttachment(String fileName, String sessionId) { + return downloadSessionAttachment(sessionId + File.separator + fileName); + } + + @Override + public File downloadSessionAttachment(boolean convertUrl, String fileName, String sessionId) { + return downloadSessionAttachment(fileName, sessionId); + } + + @Override + public String uploadFormEmbeddedFile(File file, String formId) throws VradiException { + + String fileuri; + + try { + File embeddedsDir = VradiServiceConfigurationHelper.getEmbeddedFilesDir(config); + File embeddedDir = new File(embeddedsDir, formId); + embeddedDir.mkdirs(); + + File copyOfEmbeddedFile = new File(embeddedDir, file.getName()); + FileUtils.copyFile(file, copyOfEmbeddedFile); + fileuri = copyOfEmbeddedFile.getName(); + } catch (IOException ex) { + throw new VradiException("Can't copy file", ex); + } + + return fileuri; + } + + @Override + public File downloadFormEmbeddedFile(String uri) { + File parentDir = VradiServiceConfigurationHelper.getEmbeddedFilesDir(config); + File toDownloadFile = new File(parentDir, uri); + return toDownloadFile; + } + + @Override + public File downloadFormEmbeddedFile(String fileName, String formId) { + return downloadFormEmbeddedFile(formId + File.separator + fileName); + } + + @Override + public File downloadFormEmbeddedFile(boolean convertUrl, String fileName, String formId) { + return downloadFormEmbeddedFile(fileName, formId); + } + + @Override + public String getFormEmbeddedUrl(String fileName, String formId) throws VradiException { + File parentDir = VradiServiceConfigurationHelper.getEmbeddedFilesDir(config); + File toDownloadFile = new File(parentDir, formId + File.separator + fileName); + return toDownloadFile.toURI().toString(); + } + + @Override + public File downloadRequestHistory(String uri) throws VradiException { + File parentDir = VradiServiceConfigurationHelper.getQueryHistoryDir(config); + File toDownloadFile = new File(parentDir, uri); + return toDownloadFile; + } + + @Override + public File downloadRequestHistory(boolean convertUrl, String uri) throws VradiException { + return downloadRequestHistory(uri); + } + + @Override + public String getRequestHistoryURL(String uri) throws VradiException { + File parentDir = VradiServiceConfigurationHelper.getQueryHistoryDir(config); + File toDownloadFile = new File(parentDir, uri); + return toDownloadFile.toURI().toString(); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceProxy.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceProxy.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceProxy.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,417 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.multipart.FilePart; +import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; +import org.apache.commons.httpclient.methods.multipart.Part; +import org.apache.commons.httpclient.params.HttpClientParams; +import org.apache.commons.httpclient.util.EncodingUtil; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLDecoder; +import java.net.URLEncoder; + +import static org.nuiton.i18n.I18n._; + +/** + * This proxy can handle i/o API and manage file upload on servlet. + * <p/> + * FileService -> FileServiceProxy -> FileServlet -> FileServiceImpl. + * <p/> + * Based on commons http client. + * <p/> + * Principe: + * <ul> + * <li>Post : upload file + * <li>Get : download file + * </ul> + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FileServiceProxy implements FileService { + + /** log. */ + private static final Log log = LogFactory.getLog(FileServiceProxy.class); + + /** Remote service endpoint. Endpoint is http://xxx/vradi/file */ + protected String serviceEndpoint; + + /** + * Constructor with remote service endpoint. + * + * @param serviceEndpoint remote service endpoint + */ + public FileServiceProxy(String serviceEndpoint) { + if (log.isDebugEnabled()) { + log.debug("Using " + FileServiceProxy.class.getSimpleName() + " to manage file upload"); + } + this.serviceEndpoint = serviceEndpoint; + } + + @Override + public String uploadTemplate(File file, String extensionName) + throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.TEMPLATE.toString(), extensionName); + return uploadFile(file, postUrl); + } + + @Override + public String uploadWebHarvestScript(File file) + throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.WEB_HARVEST.toString(), file.getName()); + return uploadFile(file, postUrl); + } + + @Override + public String uploadFormAttachment(File file, String formId) + throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.ATTACHMENTS_FORM_FILES.toString(), + formId, file.getName()); + return uploadFile(file, postUrl); + } + + @Override + public String uploadSessionAttachment(File file, String sessionId) + throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.ATTACHMENTS_SESSION_FILES.toString(), + sessionId, file.getName()); + return uploadFile(file, postUrl); + } + + @Override + public String uploadTempFile(File file) throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.TEMP_FILE.toString(), file.getName()); + return uploadFile(file, postUrl); + } + + @Override + public String uploadFormEmbeddedFile(File file, String formId) + throws VradiException { + String postUrl = buildUrl(serviceEndpoint, true, + VradiConstants.FileType.EMBEDDED_FORM_FILES.toString(), formId, + file.getName()); + return uploadFile(file, postUrl); + } + + /** + * Build post url. + * + * @param endpoint endpoint + * @param convertUrl if url must be encode + * @param additionalParams parameters to be added to the url + * @return the built url + * @throws VradiException if url error + */ + protected String buildUrl(String endpoint, boolean convertUrl, String... additionalParams) + throws VradiException { + + StringBuilder url = new StringBuilder(endpoint); + if (url.lastIndexOf("/") == url.length() - 1) { + url = url.delete(url.length() - 1, url.length()); + } + + for (String additionalParam : additionalParams) { + url.append("/"); + + if (convertUrl) { + try { + additionalParam = URLEncoder.encode(additionalParam, "UTF-8"); + } catch (UnsupportedEncodingException eee) { + throw new VradiException("Cant parse param '" + additionalParam + "'", eee); + } + } + url.append(additionalParam); + } + String urlAsString = url.toString(); + return urlAsString; + } + + protected String uploadFile(final File file, String postUrl) + throws VradiException { + + String uri; + + try { + // create client and timeout + HttpClientParams params = new HttpClientParams(); + params.setConnectionManagerTimeout(8000); + HttpClient client = new HttpClient(params); + + // send file via post + PostMethod postMethod = new PostMethod(postUrl); + + final String filename = file.getName(); + + // multipart version + // sletellier : hack to keep file name encoding + Part[] parts = {new FilePart(filename, file) { + + /** + * Write the disposition header to the output stream + * @param out The output stream + * @throws IOException If an IO problem occurs + * @see Part#sendDispositionHeader(OutputStream) + */ + @Override + protected void sendDispositionHeader(OutputStream out) + throws IOException { + + super.sendDispositionHeader(out); + if (filename != null) { + out.write(EncodingUtil.getBytes(FILE_NAME, "UTF-8")); + out.write(EncodingUtil.getBytes(QUOTE, "UTF-8")); + out.write(EncodingUtil.getBytes(filename, "UTF-8")); + out.write(EncodingUtil.getBytes(QUOTE, "UTF-8")); + } + } + }}; + RequestEntity requestEntity = new MultipartRequestEntity(parts, + postMethod.getParams()); + + postMethod.setRequestEntity(requestEntity); + int response = client.executeMethod(postMethod); + + // 200 = http OK + if (response != 200) { + if (log.isDebugEnabled()) { + log.debug("File upload servlet response : " + response); + } + throw new VradiException(_("File upload failed : server response %d", response)); + } + + Header header = postMethod.getResponseHeader("fileuri"); + if (header == null || StringUtils.isEmpty(header.getValue())) { + if (header != null && log.isErrorEnabled()) { + log.error("Can't read upload response as valid file uri : " + header.getValue()); + } + throw new VradiException(_("File upload failed : invalid response")); + } else { + uri = header.getValue(); + } + + // get uploaded file uri + postMethod.releaseConnection(); + } catch (FileNotFoundException ex) { + throw new VradiException("Can't upload file", ex); + } catch (HttpException ex) { + throw new VradiException("Can't upload file", ex); + } catch (IOException ex) { + throw new VradiException("Can't upload file", ex); + } + return uri; + + } + + protected File downloadFile(String fileUrl) throws VradiException { + + String[] splited = fileUrl.split("/"); + + // Get last + String fullFileName = splited[splited.length - 1]; + + // Convert name + try { + fullFileName = URLDecoder.decode(fullFileName, "UTF-8"); + } catch (UnsupportedEncodingException eee) { + throw new VradiException("Failled to decode " + fullFileName, eee); + } + + // Extract file and ext + int posPoint = fullFileName.lastIndexOf('.'); + String fileName = fullFileName.substring(0, posPoint - 1); + String fileExt = fullFileName.substring(posPoint); + + // FIXME chatellier 20110217 fileName can too small for method File.createTempFile + + File resultFile; + try { + // temp downloaded file + resultFile = File.createTempFile(fileName, fileExt); + resultFile.deleteOnExit(); + + // download + URL url = new URL(fileUrl); + FileUtils.copyURLToFile(url, resultFile); + + if (log.isDebugEnabled()) { + log.debug("File downloaded to " + resultFile); + } + + } catch (IOException ex) { + throw new VradiException("Can't download file", ex); + } + + return resultFile; + } + + @Override + public File downloadWebHarvestScript(String uri) throws VradiException { + return downloadWebHarvestScript(true, uri); + } + + @Override + public File downloadWebHarvestScript(boolean convertUrl, String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.WEB_HARVEST.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadTemplate(String extensionName, String templateName) throws VradiException { + return downloadTemplate(true, extensionName, templateName); + } + + @Override + public File downloadTemplate(boolean convertUrl, String extensionName, String templateName) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.TEMPLATE.toString(), extensionName, templateName); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadPDF(String uri) throws VradiException { + return downloadPDF(true, uri); + } + + @Override + public File downloadPDF(boolean convertUrl, String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.PDF.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public String getPDFUrl(String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, true, VradiConstants.FileType.PDF.toString(), uri); + return fileUrl; + } + + @Override + public File downloadFormAttachment(String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, true, VradiConstants.FileType.ATTACHMENTS_FORM_FILES.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadFormAttachment(String fileName, String formId) throws VradiException { + return downloadFormAttachment(true, fileName, formId); + } + + @Override + public File downloadFormAttachment(boolean convertUrl, String fileName, String formId) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.ATTACHMENTS_FORM_FILES.toString(), formId, fileName); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadSessionAttachment(String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, true, VradiConstants.FileType.ATTACHMENTS_SESSION_FILES.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadSessionAttachment(String fileName, String sessionId) throws VradiException { + return downloadSessionAttachment(true, fileName, sessionId); + } + + @Override + public File downloadSessionAttachment(boolean convertUrl, String fileName, String sessionId) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.ATTACHMENTS_SESSION_FILES.toString(), sessionId, fileName); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadFormEmbeddedFile(String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, false, VradiConstants.FileType.EMBEDDED_FORM_FILES.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public File downloadFormEmbeddedFile(String fileName, String formId) throws VradiException { + return downloadFormEmbeddedFile(true, fileName, formId); + } + + @Override + public File downloadFormEmbeddedFile(boolean convertUrl, String fileName, String formId) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convertUrl, VradiConstants.FileType.EMBEDDED_FORM_FILES.toString(), formId, fileName); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public String getFormEmbeddedUrl(String fileName, String formId) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, true, VradiConstants.FileType.EMBEDDED_FORM_FILES.toString(), formId, fileName); + return fileUrl; + } + + @Override + public File downloadRequestHistory(String uri) throws VradiException { + return downloadRequestHistory(true, uri); + } + + @Override + public File downloadRequestHistory(boolean convretUrl, String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, convretUrl, VradiConstants.FileType.QUERY_HISTORY.toString(), uri); + File file = downloadFile(fileUrl); + return file; + } + + @Override + public String getRequestHistoryURL(String uri) throws VradiException { + String fileUrl = buildUrl(serviceEndpoint, true, VradiConstants.FileType.QUERY_HISTORY.toString(), uri); + return fileUrl; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/FileServiceProxy.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,245 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfiguration; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.GroupFormsImpl; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.InfogeneImpl; +import org.chorem.vradi.entities.ModificationTagImpl; +import org.chorem.vradi.entities.QueryMakerImpl; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.SendingImpl; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.StatusImpl; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.entities.UserImpl; +import org.chorem.vradi.entities.VradiUserImpl; +import org.chorem.vradi.entities.WebHarvestStreamImpl; +import org.chorem.vradi.entities.XmlFieldBindingImpl; +import org.chorem.vradi.entities.XmlStreamImpl; +import org.nuiton.i18n.I18n; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.converter.ConverterUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyServiceFactory; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyTreeNodeImpl; +import org.nuiton.wikitty.entities.WikittyUserImpl; + +import java.util.Arrays; +import java.util.List; + +/** + * ServiceFactory. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 24 févr. 2010 22:18:17 + */ +public class ServiceFactory { + + /** Log. */ + private static final Log log = LogFactory.getLog(ServiceFactory.class); + + /** Wikitty service (cached version) for remote access. */ + protected static WikittyService vradiWikittyService; + + /** Single instance of storage service. */ + protected static VradiStorageService vradiStorageService; + + /** Single instance of wikitty proxy. */ + protected static WikittyProxy wikittyProxy; + + protected static VradiServiceConfiguration config; + + + static { + // Dans un block static pour definition des variables + // d'environnement solr et jbossts + // A voir pourquoi, les converters s'initialise mal durant les tests + try { + + ConverterUtil.initConverters(); + config = VradiServiceConfiguration.getInstance(); + I18n.setDefaultLocale(VradiServiceConfigurationHelper.getLocale(config)); + } catch (Exception eee) { + log.error("Cant initialize Service factory : ", eee); + } + } + + public static synchronized VradiStorageService getVradiStorageService() { + if (vradiStorageService == null) { + vradiStorageService = new VradiStorageServiceImpl(); + } + return vradiStorageService; + } + + /** + * Creates wikitty service (cached). + * <p/> + * Getter for service, with default service configuration. + * + * @return a unique instance of WikittyService + */ + public static synchronized WikittyService getWikittyService() { + if (vradiWikittyService == null) { + getWikittyService(config); + } + + return vradiWikittyService; + } + + /** + * Creates wikitty service (cached). + * <p/> + * Constructor added for UI embedded mode, with custom configuration. + * + * @param config configuration of vradi service + * @return a unique instance of WikittyService + */ + public static synchronized WikittyService getWikittyService(ApplicationConfig config) { + if (vradiWikittyService == null) { + + vradiWikittyService = WikittyServiceFactory.buildWikittyService(config); + } + + return vradiWikittyService; + } + + /** + * Creates wikitty proxy. + * + * @return a unique instance of WikittyProxy. + */ + public static synchronized WikittyProxy getWikittyProxy() { + if (wikittyProxy == null) { + WikittyService wikittyService = getWikittyService(); + + // init proxy on cached service + wikittyProxy = new WikittyProxy(wikittyService); + + // post operation : register extensions + updateExtensions(wikittyProxy); + + // post operation : reindex data if necessary + reindexData(wikittyProxy); + } + + return wikittyProxy; + } + + /** + * Register all extensions. + * <p/> + * Already existing extensions with same version are skipped, + * new extension are created and stored. + * + * @param localWikittyProxy wikitty proxy + */ + static void updateExtensions(WikittyProxy localWikittyProxy) { + + // easier if ordered + // TODO EC20100616 don't work with required extensions :( + List<WikittyExtension> extensions = Arrays.asList( + ClientImpl.extensionClient, + FormImpl.extensionForm, + GroupImpl.extensionGroup, + InfogeneImpl.extensionInfogene, + ModificationTagImpl.extensionModificationTag, + QueryMakerImpl.extensionQueryMaker, + RootThesaurusImpl.extensionRootThesaurus, + SendingImpl.extensionSending, + SessionImpl.extensionSession, + StatusImpl.extensionStatus, + ThesaurusImpl.extensionThesaurus, + WikittyTreeNodeImpl.extensionWikittyTreeNode, + UserImpl.extensionUser, + VradiUserImpl.extensionVradiUser, + WebHarvestStreamImpl.extensionWebHarvestStream, + WikittyUserImpl.extensionWikittyUser, + XmlFieldBindingImpl.extensionXmlFieldBinding, + XmlStreamImpl.extensionXmlStream, + GroupFormsImpl.extensionGroupForms); + + localWikittyProxy.storeExtension(extensions); + } + + /** + * Check if version has changed and launch wikitty service reindex. + * + * @param localWikittyProxy local proxy + */ + protected static void reindexData(WikittyProxy localWikittyProxy) { + try { + + String currentVersion = VradiServiceConfigurationHelper.getApplicationVersion(config); + String lastVersion = VradiServiceConfigurationHelper.getServiceVersion(config); + + // different is enougth to reindex + // currentVersion is never null, lastVersion could be + if (!currentVersion.equals(lastVersion)) { + + // do version change migration + ServiceMigration.versionChangeMigration(lastVersion, currentVersion, localWikittyProxy); + + // Dont reindex data on version change +// if (log.isInfoEnabled()) { +// log.info(_("Version change detected : %s. Reindexing data...", lastVersion)); +// } +// long timeBefore = System.currentTimeMillis(); +// +// // call syncEngin +// localWikittyProxy.syncEngin(); +// +// long timeAfter = System.currentTimeMillis(); +// +// if (log.isInfoEnabled()) { +// log.info("Reindexing completed in " + (timeAfter - timeBefore) + " ms"); +// } + + // save new version + VradiServiceConfigurationHelper.setServiceVersion(config, currentVersion); + config.saveForUser(); + } else { + if (log.isInfoEnabled()) { + log.info("No version change, skipping reindexing."); + } + } + + // post operation : register migration classes + ServiceMigration.configureMigration(); + + } catch (Exception eee) { + log.error("Failled to reindex data : ", eee); + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,487 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.GroupFormsImpl; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyImpl; +import org.nuiton.wikitty.entities.WikittyTreeNode; +import org.nuiton.wikitty.entities.WikittyTreeNodeImpl; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.nuiton.wikitty.services.WikittyExtensionMigration; +import org.nuiton.wikitty.services.WikittyExtensionMigrationRename; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Configure wikitty migration. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ServiceMigration { + + /** Log. */ + private static final Log log = LogFactory.getLog(ServiceMigration.class); + + /** Install all migration. */ + public static void configureMigration() { + configureMigration010(); + configureMigration021(); + } + + /** Configure migration from 0.0.5 to 0.1.0. */ + protected static void configureMigration010() { + + // extension VradiUser renamed to WikittyUser + WikittyExtensionMigration.migrationRegistry.put(VradiUser.EXT_VRADIUSER, new MigrationVradiUser()); + WikittyExtensionMigration.migrationRegistry.put(User.EXT_USER, new MigrationUser()); + WikittyExtensionMigration.migrationRegistry.put(Sending.EXT_SENDING, new MigrationSending()); + + } + + /** Configure migration from 0.1.0 to 0.2.1. */ + protected static void configureMigration021() { + WikittyExtensionMigration.migrationRegistry.put(Sending.EXT_SENDING, new MigrationSendingV8()); + } + + static class MigrationVradiUser extends WikittyExtensionMigrationRename { + + /** + * Some field names has also changed. + * <p/> + * Migration 1.0 > 2.0: + * "VradiUser.name" to VradiUser.FQ_FIELD_LOGIN + * "VradiUser.password" to VradiUser.FQ_FIELD_PASSWORD + */ + @Override + public Wikitty migrate(WikittyService service, Wikitty wikitty, WikittyExtension oldExt, WikittyExtension newExt) { + + String wikittyId = wikitty.getId(); + String wikittyVersion = wikitty.getVersion(); + + Wikitty result = new WikittyImpl(wikittyId); + result.setVersion(wikittyVersion); + + // Add all extension and replace old by the new + for (WikittyExtension extension : wikitty.getExtensions()) { + // add one by one to manage require + + // during loop add new when old one is found + if (extension.equals(oldExt)) { + addExtension(service, result, newExt); + } else { + addExtension(service, result, extension); + } + } + + // Pas sur de la method de migration + // les champs VradiUser.name, VradiUser.password + // existait en 1.0, pas après + if (oldExt.getVersion().equals("1.0")) { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + if (fieldName.equals("VradiUser.name")) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(VradiUser.FQ_FIELD_WIKITTYUSER_LOGIN, value); + } else if (fieldName.equals("VradiUser.password")) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(VradiUser.FQ_FIELD_WIKITTYUSER_PASSWORD, value); + } else { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + } else { + + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + return result; + } + } + + static class MigrationUser extends WikittyExtensionMigrationRename { + + /** + * Some field names has also changed. + * <p/> + * Migration 6.0 > 7.0: + * "User.inscriptionDate" to {@link User#FQ_FIELD_USER_BEGINSEARCHDATE} + */ + @Override + public Wikitty migrate(WikittyService service, Wikitty wikitty, WikittyExtension oldExt, WikittyExtension newExt) { + + String wikittyId = wikitty.getId(); + String wikittyVersion = wikitty.getVersion(); + + Wikitty result = new WikittyImpl(wikittyId); + result.setVersion(wikittyVersion); + + // Add all extension and replace old by the new + for (WikittyExtension extension : wikitty.getExtensions()) { + // add one by one to manage require + + // during loop add new when old one is found + if (extension.equals(oldExt)) { + addExtension(service, result, newExt); + } else { + addExtension(service, result, extension); + } + } + + // Pas sur de la method de migration + // les champs User.inscriptionDate + // existait en 6.0, pas après + if (oldExt.getVersion().equals("6.0")) { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + if (fieldName.equals("User.inscriptionDate")) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(User.FQ_FIELD_USER_BEGINSEARCHDATE, value); + } else { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + } else { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + return result; + } + } + + static class MigrationSending extends WikittyExtensionMigrationRename { + + /** + * Some field names has also changed. + * <p/> + * Migration 3.0 > 4.0: + * "Sending.queryMaker" to Sending.FQ_FIELD_SENDING_USER + */ + @Override + public Wikitty migrate(WikittyService service, Wikitty wikitty, + WikittyExtension oldExt, WikittyExtension newExt) { + + String wikittyId = wikitty.getId(); + String wikittyVersion = wikitty.getVersion(); + + Wikitty result = new WikittyImpl(wikittyId); + result.setVersion(wikittyVersion); + + // Add all extension and replace old by the new + for (WikittyExtension extension : wikitty.getExtensions()) { + // add one by one to manage require + + // during loop add new when old one is found + if (extension.equals(oldExt)) { + addExtension(service, result, newExt); + } else { + addExtension(service, result, extension); + } + } + + // Pas sur de la method de migration + // les champs Sending.queryMaker + // existait en 3.0, pas après + if (oldExt.getVersion().equals("3.0")) { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + if (fieldName.equals("Sending.queryMaker")) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(Sending.FQ_FIELD_SENDING_USER, value); + } else { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + } else { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + return result; + } + } + + static class MigrationSendingV8 extends WikittyExtensionMigrationRename { + + /** + * Some field names has also changed. + * <p/> + * Migration 7.0 > 8.0: + * "Sending.queryMaker" to Sending.FQ_FIELD_SENDING_USER + */ + @Override + public Wikitty migrate(WikittyService service, Wikitty wikitty, WikittyExtension oldExt, WikittyExtension newExt) { + + if (log.isDebugEnabled()) { + log.debug("migrate, old " + oldExt + " new " + newExt); + } + + String wikittyId = wikitty.getId(); + String wikittyVersion = wikitty.getVersion(); + + Wikitty result = new WikittyImpl(wikittyId); + result.setVersion(wikittyVersion); + + // Add all extension and replace old by the new + for (WikittyExtension extension : wikitty.getExtensions()) { + // add one by one to manage require + + // during loop add new when old one is found + if (extension.equals(oldExt)) { + addExtension(service, result, newExt); + } else { + addExtension(service, result, extension); + } + } + + // Pas sur de la method de migration + // les champs Sending.queryMaker + // existait en 3.0, pas après + if (oldExt.getVersion().equals("4.0") || + oldExt.getVersion().equals("5.0") || + oldExt.getVersion().equals("6.0") || + oldExt.getVersion().equals("7.0")) { + + // Migrate + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + if (!fieldName.equals("Sending.form") && + !fieldName.equals("Sending.deletedForms") && + !fieldName.equals("Sending.addedForms") && + !fieldName.equals("Sending.groupsConcerned")) { + + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + } else { + // Copy other values + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + Object value = wikitty.getFqField(fieldName); + result.setFqField(fieldName, value); + } + } + return result; + } + + protected void addExtentions(WikittyService service, Wikitty groupFormsWikitty) { + + for (WikittyExtension extension : groupFormsWikitty.getExtensions()) { + addExtension(service, groupFormsWikitty, extension); + } + } + } + + /** + * Do migration that wikitty extension migration can't handle. + * <p/> + * They are done only at version change time, because, can take + * some times to perform... + * + * @param lastVersionAsString last launch version + * @param currentVersionAsString current application version + * @param localWikittyProxy local wikitty proxy + */ + public static void versionChangeMigration(String lastVersionAsString, + String currentVersionAsString, WikittyProxy localWikittyProxy) { + + if (log.isDebugEnabled()) { + log.debug("versionChangeMigration, old " + lastVersionAsString + " current " + currentVersionAsString); + } + + // Remove snapshot if exist + currentVersionAsString = VersionUtil.removeSnapshot(currentVersionAsString); + + if (lastVersionAsString != null) { + lastVersionAsString = VersionUtil.removeSnapshot(lastVersionAsString); + } + + // Create comparable version object + Version currentVersion = VersionUtil.valueOf(currentVersionAsString); + Version lastVersion = VersionUtil.valueOf(lastVersionAsString); + + // last version < 0.1.0 <= Current version : add extension RootThesaurus on "Thesaurus" node + Version thesaurusMigrationVersion = VersionUtil.valueOf("0.1.0"); + if (isConcernedByMigration(lastVersion, currentVersion, thesaurusMigrationVersion)) { + + // modification du noeud root + if (log.isInfoEnabled()) { + log.info("Migration root Thesaurus node : add RootThesaurus extension"); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, WikittyTreeNode.EXT_WIKITTYTREENODE) + .eq(WikittyTreeNode.FQ_FIELD_WIKITTYTREENODE_NAME, "Thesaurus"); + Criteria criteria = search.criteria(); + WikittyTreeNodeImpl rootThesaurus = localWikittyProxy.findByCriteria(WikittyTreeNodeImpl.class, criteria); + if (rootThesaurus != null) { + if (!rootThesaurus.getWikitty().hasExtension(RootThesaurusImpl.EXT_ROOTTHESAURUS)) { + rootThesaurus.getWikitty().addExtension(RootThesaurusImpl.extensionRootThesaurus); + // WARNING, fake modification to force wikitty version increments + rootThesaurus.setName("Thesaurus"); + localWikittyProxy.store(rootThesaurus); + } + + // referencement du noeud root pour tous les noeud existants + if (log.isInfoEnabled()) { + log.info("Set rootThesaurus id to all existing thesaurus"); + } + search = Search.query().eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS); + criteria = search.criteria(); + List<Thesaurus> thesauruses = localWikittyProxy.findAllByCriteria(Thesaurus.class, criteria).getAll(); + for (Thesaurus thesaurus : thesauruses) { + thesaurus.setRootThesaurus(rootThesaurus.getWikittyId()); + } + localWikittyProxy.store(thesauruses); + } + + // migration des status + Criteria criteriaStatus = Search.query().eq(Element.ELT_EXTENSION, Status.EXT_STATUS).criteria(); + List<Status> statuses = localWikittyProxy.findAllByCriteria(Status.class, criteriaStatus).getAll(); + List<String> statusesIds = new ArrayList<String>(); + for (Status status : statuses) { + statusesIds.add(status.getWikittyId()); + if (log.isInfoEnabled()) { + log.info("Deleting status " + status.getName()); + } + } + localWikittyProxy.delete(statusesIds); + // les status sont normalement créer tout seul + } + + // last version < 0.3 <= Current version : migre sending + Version sendingMigrationVersion = VersionUtil.valueOf("0.3"); + if (isConcernedByMigration(lastVersion, currentVersion, sendingMigrationVersion)) { + + // modification du noeud root + if (log.isInfoEnabled()) { + log.info("Sendings migration"); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, Sending.EXT_SENDING); + Criteria criteria = search.criteria(); + List<Sending> sendings = localWikittyProxy.findAllByCriteria(Sending.class, criteria).getAll(); + for (Sending sending : sendings) { + if (sending != null) { + + Wikitty wikitty = localWikittyProxy.getWikitty(sending); + + // Migrate + Set<String> fqFieldNames = wikitty.fieldNames(); + for (String fieldName : fqFieldNames) { + if (fieldName.equals("Sending.form")) { + Object value = wikitty.getFqField(fieldName); + + GroupFormsImpl groupFormCreated = new GroupFormsImpl(); + Wikitty groupFormsWikitty = groupFormCreated.getWikitty(); + groupFormsWikitty.setFqField(GroupForms.FQ_FIELD_GROUPFORMS_FORM, value); + + localWikittyProxy.store(groupFormCreated); + + sending.addGroupForms(groupFormCreated.getWikittyId()); + + } else if (fieldName.equals("Sending.deletedForms")) { + Object value = wikitty.getFqField(fieldName); + + GroupFormsImpl groupFormCreated = new GroupFormsImpl(); + Wikitty groupFormsWikitty = groupFormCreated.getWikitty(); + groupFormsWikitty.setFqField(GroupForms.FQ_FIELD_GROUPFORMS_FORM, value); + + localWikittyProxy.store(groupFormCreated); + + sending.addDeletedGroupForms(groupFormCreated.getWikittyId()); + + } + } + localWikittyProxy.store(sending); + } + } + } + } + + /** + * Return true if : + * <p/> + * lastVersion < migrationVersion <= currentVersion + * + * @param lastVersion last version installed of vradi + * @param currentVersion curent version of vradi + * @param migrationVersion concerned version to apply migration + * @return if is concerned + */ + protected static boolean isConcernedByMigration(Version lastVersion, + Version currentVersion, + Version migrationVersion) { + + if (lastVersion.equals(currentVersion)) { + // If version not chaged, do nothing + return false; + } + + return lastVersion.before(migrationVersion) && + (currentVersion.equals(migrationVersion) + || currentVersion.after(migrationVersion)); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ServiceMigration.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataService.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataService.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,556 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * This service contains business code to do on data before calling + * {@link WikittyProxy}. + * <p/> + * It's intended to be used on a local {@link WikittyProxy}. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public interface VradiDataService { + + /** + * Find all clients ordered by client name. + * + * @return all clients + */ + List<Client> findAllClients(); + + /** + * Delete client, users associated and user groups association + * + * @param clientId to delete + */ + void deleteClient(String clientId) throws VradiException; + + /** + * Find all users ordered by user name. + * + * @return all users + */ + List<User> findAllUsers(); + + /** + * Find all users for a client ordered by user name. + * + * @param clientId client wikitty id + * @return all users for client + */ + List<User> findClientUsers(String clientId); + + /** + * Delete users, and groups association + * + * @param userId to delete + */ + void deleteUser(String userId) throws VradiException; + + /** + * Find user group. + * + * @param userId user wikitty id + * @return all groups for user + */ + List<Group> findUserGroups(String userId); + + /** + * Find all groups ordered by group name. + * + * @return all groups + */ + List<Group> findAllGroups(); + + /** + * Get all the groups a user is in. + * + * @param userId the user we want the groups of + * @return the group for our user + * @throws VradiException + */ + List<Group> getGroupsForUser(String userId) throws VradiException; + + /** + * Delete group + * + * @param groupId to delete + */ + void deleteGroup(String groupId) throws VradiException; + + /** + * Find all xml streams ordered by stream name. + * + * @return all xml streams + */ + List<XmlStream> findAllXmlStreams(); + + /** + * Find all webHarvest stream ordered by stream name. + * + * @return all stream webHarvest + */ + List<WebHarvestStream> findAllWebHarvest(); + + /** + * Delete group + * + * @param groupId to delete + */ + void deleteXmlStream(String id) throws VradiException; + + /** + * Find all status ordered by status name. + * + * @return all status + */ + List<Status> findAllStatus(); + + /** + * Create all default status. + * + * @return all status + * @throws VradiException + */ + List<Status> createDefaultStatuses() throws VradiException; + + /** + * Get the status passed in parameter. Init status if it have not been done + * already + * + * @param statusName the status + * @return the Status object + * @throws VradiException if an error occur during statuses initialisation + */ + Status getStatus(String statusName) throws VradiException; + + /** + * Delete status if no form is use this + * + * @param statusIds to delete + * @return false if not deleted (is in use) + * @throws VradiException is occured if status deletion is aborded + */ + boolean deleteStatus(List<String> statusIds) throws VradiException; + + /** + * Retrieves the form type whose name is the parameter 'name' + * + * @param name the name of the form type we want to retrieve + * @return the form type whose name is the parameter + * @throws VradiException + */ + WikittyExtension getFormType(String name) throws VradiException; + + /** + * Finds fields of a form type. + * + * @param name the name of the form type + * @return a map containing the names of the fields and their type + */ + Map<String, FieldType> getFormTypeFields(String name) throws VradiException; + + /** + * Creates or Update a form type. + * + * @param extension the extension designing the form type + * @return a <code>WikittyExtension</code> + * @throws VradiException + */ + WikittyExtension updateFormType(WikittyExtension extension) throws VradiException; + + /** + * Creates or Update a form type. + * + * @param extension the extension designing the form type + * @param template name + * @return a <code>WikittyExtension</code> + * @throws VradiException + */ + WikittyExtension updateFormType(WikittyExtension extension, String templateName) throws VradiException; + + /** + * Creates or Update a form type. + * + * @param name the name of the form type + * @param fields the fields of the form type + * @param requires the extension required by the extension to update + * @param tagValues the map containing the tags and their values + * @return a <code>WikittyExtension</code> + * @throws VradiException + */ + WikittyExtension updateFormType(String name, Map<String, FieldType> fields, String requires, Map<String, String> tagValues) throws VradiException; + + /** + * Retourne l'ensemble des thesaurus qui sont attachés a un formulaire. + * + * @param form form dont on veut les thesaurus + * @return thesaurus attachés au formulaire + */ + List<Thesaurus> getThesaurusAttachedToForm(Form form) throws VradiException; + + /** + * Searches for forms with the specified filters. + * <p/> + * The <code>beginDate</code> and <code>endDate</code> specifies a + * date range filter which is applied on <code>dateType</code> field. + * The date range filter is applied only if the three parameters are not null. + * + * @param queryParameters query parameters + * @return FormPagedResult + * @throws UnsupportedQueryException + * @throws VradiException + */ + FormPagedResult findForms(QueryParameters queryParameters, FormPagedResult formPagedResult) + throws VradiException, UnsupportedQueryException; + + /* +* Computes the number of forms associated with every thesaurus node. +* +* @param query the query filter +* @param extension the extension filter +* @param dateType the date field. Must be fully qualified (extension.field) +* @param beginDate the begin date filter +* @param endDate the end date filter +* @param streamId id of stream +* @param thesaurus the thesaurus filter +* @param statusIds the ids of the status filters +* @return a <code>VradiCartographyDTO</code> containing forms result and a map of form count indexed by thesaurus nodes +* @throws VradiException +* @throws UnsupportedQueryException +* +ThesaurusCartography getThesaurusCartography(String query, + WikittyExtension extension, String dateType, Date beginDate, + Date endDate, String streamId, java.util.List<String> thesaurus, String[] statusIds) + throws VradiException, UnsupportedQueryException;*/ + + /** + * Computes the number of forms associated with every thesaurus node. + * + * @param thesaurusId thesaurusId + * @param queryParameters query parameters + * @return a map with children thesaurus and associated form count + * @throws VradiException + * @throws UnsupportedQueryException + */ + Map<Thesaurus, Integer> getChildrenCartography(String thesaurusId, QueryParameters queryParameters) + throws VradiException, UnsupportedQueryException; + + /** + * Computes a list of queries returning the specified <code>Form</code>. + * + * @param formId id of the form which match queries + * @return a list of queries + */ + Map<Group, List<QueryBean>> findQueriesReturningForm(String formId) throws VradiException; + + /** + * Computes a list of queries returning the specified <code>Form</code> and <code>groups</code>. + * + * @param formId id of the form which match queries + * @param groups concerned + * @return a list of queries + */ + Map<Group, List<QueryBean>> findQueriesReturningForm(List<Group> groups, String formId) throws VradiException; + + /** + * Update a list of <code>XmlFieldBinding</code>. + * + * @param bindings the list of XmlFieldBinding to update + * @return the list of updated XmlFieldBinding + * @throws VradiException + */ + List<XmlFieldBinding> updateXmlFieldBindings(List<XmlFieldBinding> bindings) throws VradiException; + + /** + * Retrieves all the form types + * + * @return a list containing all the form types + * @throws VradiException + */ + List<WikittyExtension> getAllFormTypes() throws VradiException; + + /** + * Check if a form type name already exists. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + boolean isFormTypeExists(String formTypeName) throws VradiException; + + /** + * Create new form type. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + WikittyExtension createFormType(String formTypeName) throws VradiException; + + /** + * Get web harvest preview url from script + * + * @param stream + * @return url of preview file + */ + String getWebHarvestPreviewURL(WebHarvestStream stream) throws VradiException; + + /** + * Get all WebHarvest script name in server's WebHarvest directory. + * <p/> + * All filename doesn't contains "/". + * + * @return script file names + */ + List<String> getAllWebHarvestScripts(); + + /** + * Gets the query makers whose queries are potentially to modify + * after a thesaurus node modification + * + * @param rootThesaurusName the modified root thesaurus name node + * @param thesaurusName the modified thesaurus name node + * @return a map containing the query makers and their queries which contains + * the thesaurus node name + */ + Map<Group, List<QueryBean>> getQueriesToModifyAfterThesaurusModification( + String rootThesaurusName, String thesaurusName); + + /** + * Return root thesaurus ids (ie thesaurus nodes without parent) sorted + * by root thesaurus name. + * + * @return a {@link RootThesaurus} collection + * @throws VradiException + */ + List<RootThesaurus> getRootThesaurus() throws VradiException; + + /** + * Returns all children of the specified {@code thesaurusId} sorted by name. + * + * @param thesaurusId thesaurus wikitty id + * @return all list of <code>TreeNodeImpl</code> + * @throws VradiException + */ + List<Thesaurus> getChildrenThesaurus(String thesaurusId) throws VradiException; + + /** + * Computes the number of forms associated with the specified {@code thesaurusId}. + * + * @param thesaurusId thesaurus id + * @return the number of forms associated + * @throws VradiException + */ + int getNbFormsForThesaurus(String thesaurusId) throws VradiException; + + /** + * Create new thesaurus. + * + * @param rootThesaurusName root thesaurus name (must contains only alphnum characters) + * @return new created thesaurus + * @throws VradiException if name is not valid + */ + RootThesaurus createRootThesaurus(String rootThesaurusName) throws VradiException; + + /** + * Delete all thesaurus and sub thesaurus. + * + * @param thesaurusId thesaurusId to delete + * @throws VradiException + */ + Collection<String> deleteThesaurus(String thesaurusId) throws VradiException; + + /** + * Return true if thesaurusName exists in rootThesaurus children. + * + * @param rootThesaurus root thesaurus + * @param thesaurusName thesaurus name to test + * @return true if thesaurusName exists in rootThesaurus children + */ + boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName); + + /** + * Check if name of thesaurus is existing in rootThesaurus. + * + * @param rootThesaurus to check + * @param thesaurusName name to check + * @param exceptedThesaurusId in case of rename, exclude exceptedThesaurusId from check + * @return true if thesaurus already exist + */ + boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName, String exceptedThesaurusId); + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @return true if rootThesaurusName already exists + */ + boolean isRootThesaurusNameExists(String rootThesaurusName); + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @param exceptedRootThesaurusId in case of rename, exclude exceptedRootThesaurusId from check + * @return true if rootThesaurusName already exists + */ + boolean isRootThesaurusNameExists(String rootThesaurusName, String exceptedRootThesaurusId); + + /** + * Propose thesaurus nodes that might be in relation with a specified form + * + * @param formId the <code>Form</code> id containing the information needed + * to search the thesaurus nodes + * @return a list of <code>Thesaurus</code> + * @throws VradiException + */ + List<Thesaurus> proposeThesaurus(String formId) throws VradiException; + + /** + * Delete all thesauruses recursively. + * + * @throws VradiException if an error occur + */ + void deleteAllThesaurus() throws VradiException; + + /** + * Check if user have email non empyt + * + * @param sending to check + * @return false if no valid email found + */ + boolean checkUserEmail(Sending sending); + + /** + * Return session corresponding of sending id in param + * + * @param sendingId corresponding to session to find + * @return session found + */ + Session getSessionBySending(String sendingId); + + /** + * Get all session by date + * + * @param sessionDate Date concerned + * @return a list of VradiSessionDTO + * @throws VradiException + */ + List<Session> getSessions(Date sessionDate) throws VradiException; + + /** + * Get session contain sending + * + * @param sendingId concerned + * @return session found + * @throws VradiException if an error occur + */ + Session getSessionOfSending(String sendingId) throws VradiException; + + /** + * Get last closed session + * + * @return last opened session + * @throws VradiException if an error occur + */ + Session getLastCloseSession() throws VradiException; + + /** + * Get last opened session + * + * @return last opened session + * @throws VradiException if an error occur + */ + Session getLastOpenSession() throws VradiException; + + /** + * Get all related forms ids of form in param + * + * @param formId concerned + * @return related forms links ids + * @throws VradiException if an error occur + */ + List<String> getRelatedFormsLinkIds(String formId) throws VradiException; + + /** + * Get all replace forms ids of form in param + * + * @param formId concerned + * @return replace forms links ids + * @throws VradiException if an error occur + */ + List<String> getReplaceFormsLinkIds(String formId) throws VradiException; + + /** + * Return true if form is a replace form + * + * @param formId concerned + * @return true if form is a replace form + */ + boolean isReplaceForm(String formId); + + /** + * Return formId of previous replace form + * + * @param formId concerned + * @return formId of previous replace form + */ + String getPreviousReplaceForm(String formId); + + /** Get form type template name */ + String getFormTypeTemplateName(WikittyExtension extension); +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,767 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfiguration; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.managers.BindingManager; +import org.chorem.vradi.services.managers.ClientManager; +import org.chorem.vradi.services.managers.FormManager; +import org.chorem.vradi.services.managers.FormTypeManager; +import org.chorem.vradi.services.managers.SearchManager; +import org.chorem.vradi.services.managers.ThesaurusManager; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Vradi data service implementation (on a local wikiity proxy). + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiDataServiceImpl implements VradiDataService { + + /** Log. */ + private static final Log log = LogFactory.getLog(VradiDataServiceImpl.class); + + protected ApplicationConfig config; + + /** Wikiity proxy. */ + protected WikittyProxy wikittyProxy; + + protected ThesaurusManager thesaurusManager; + + protected SearchManager searchManager; + + protected FormManager formManager; + + protected FormTypeManager formTypeManager; + + protected BindingManager bindingManager; + + protected ClientManager clientManager; + + /** + * Constructor with a wikitty proxy. + * <p/> + * Make sure that wikitty proxy doesn't access remote service. + * + * @param wikittyProxy wikitty proxy + */ + public VradiDataServiceImpl(WikittyProxy wikittyProxy) { + this(VradiServiceConfiguration.getInstance(), wikittyProxy); + } + + /** + * Constructor with a wikitty proxy. + * <p/> + * Make sure that wikitty proxy doesn't access remote service. + * + * @param config vradi configuration + * @param wikittyProxy wikitty proxy + */ + public VradiDataServiceImpl(ApplicationConfig config, WikittyProxy wikittyProxy) { + this.config = config; + this.wikittyProxy = wikittyProxy; + initManagers(); + } + + /** Init managers. */ + protected void initManagers() { + + thesaurusManager = new ThesaurusManager(wikittyProxy); + searchManager = new SearchManager(wikittyProxy, thesaurusManager); + formManager = new FormManager(config, wikittyProxy, thesaurusManager, searchManager); + formTypeManager = new FormTypeManager(config, wikittyProxy); + clientManager = new ClientManager(config, wikittyProxy); + bindingManager = new BindingManager(config, wikittyProxy, formTypeManager, formManager); + } + + /** + * Do a find all by applying a criteria to WikittyProxy. + * <p/> + * Example : + * List<Client> client = VradiServiceHelper.findAllByExtension(Client.class, Client.EXT_CLIENT) + * + * @param type type to search + * @param extension extension to search + * @param sortFields sort fields (ascending to sort on) + * @param <T> type of result + * @return all of entities with extension + */ + protected <T extends BusinessEntity> List<T> findAllByExtension(Class<T> type, String extension, String... sortFields) { + + Search search = Search.query().eq(Element.ELT_EXTENSION, extension); + Criteria criteria = search.criteria(); + + // set sort order + for (String sortField : sortFields) { + criteria.addSortAscending(sortField); + } + + PagedResult<T> findAllByCriteria = wikittyProxy.findAllByCriteria(type, criteria); + List<T> results = findAllByCriteria.getAll(); + + return new ArrayList<T>(results); + } + + /** + * Find all clients. + * + * @return all clients + */ + @Override + public List<Client> findAllClients() { + return findAllByExtension(Client.class, Client.EXT_CLIENT, Client.FQ_FIELD_CLIENT_NAME); + } + + /** + * Find all users. + * + * @return all users + */ + @Override + public List<User> findAllUsers() { + + //FIXME JC 25/08/2010 Should also not return user that have id of a non existing client + + //Create query to return only User that have clients. Users with no + //clients should not exist and are corrupted. + Search search = Search.query().eq(User.FQ_FIELD_USER_CLIENT, "*"); + Criteria criteria = search.criteria(); + + PagedResult<User> users = wikittyProxy.findAllByCriteria(User.class, + criteria); + + return new ArrayList<User>(users.getAll()); + } + + /** + * Find all groups. + * + * @return all groups + */ + @Override + public List<Group> findAllGroups() { + return findAllByExtension(Group.class, Group.EXT_GROUP, Group.FQ_FIELD_GROUP_NAME); + } + + /** + * Find all status. + * + * @return all status + */ + @Override + public List<Status> findAllStatus() { + return findAllByExtension(Status.class, Status.EXT_STATUS, Status.FQ_FIELD_STATUS_NAME); + } + + @Override + public List<Group> getGroupsForUser(String userId) throws VradiException { + Search search = Search.query().eq(Group.FQ_FIELD_GROUP_USER, userId); + PagedResult<Group> groups = wikittyProxy.findAllByCriteria(Group.class, search.criteria()); + return groups.getAll(); + } + + @Override + public boolean deleteStatus(List<String> statusIds) throws VradiException { + return formManager.deleteStatuses(statusIds); + } + + /** + * Get the status passed in parameter. Init status if it have not been done + * already + * + * @param statusName the status name + * @return the Status object + * @throws VradiException if an error occur during statuses initialisation + */ + @Override + public Status getStatus(String statusName) throws VradiException { + + List<Status> statuses = createDefaultStatuses(); + + for (Status status : statuses) { + if (status.getName().equals(statusName)) { + return status; + } + } + return null; + } + + @Override + public Session getSessionOfSending(String sendingId) throws VradiException { + return formManager.getSessionOfSending(sendingId); + } + + @Override + public void deleteClient(String clientId) throws VradiException { + clientManager.deleteClient(clientId); + } + + @Override + public void deleteUser(String userId) throws VradiException { + clientManager.deleteUser(userId); + } + + @Override + public void deleteGroup(String groupId) throws VradiException { + clientManager.deleteGroup(groupId); + } + + @Override + public void deleteXmlStream(String id) throws VradiException { + wikittyProxy.delete(id); + } + + @Override + public Map<Group, List<QueryBean>> findQueriesReturningForm(String formId) + throws VradiException { + return searchManager.findQueriesReturningForm(formId); + } + + @Override + public Map<Group, List<QueryBean>> findQueriesReturningForm(List<Group> groups, String formId) + throws VradiException { + return searchManager.findQueriesReturningForm(groups, formId); + } + + @Override + public Map<String, FieldType> getFormTypeFields(String name) throws VradiException { + return formTypeManager.getFormTypeFields(name); + } + + /** + * Create all default status. + * + * @return all status created + */ + @Override + public List<Status> createDefaultStatuses() throws VradiException { + return formManager.createDefaultStatuses(); + } + + /** + * Find all webHarvest stream. + * + * @return all stream webHarvest + */ + @Override + public List<WebHarvestStream> findAllWebHarvest() { + return findAllByExtension(WebHarvestStream.class, WebHarvestStream.EXT_WEBHARVESTSTREAM, WebHarvestStream.FQ_FIELD_XMLSTREAM_NAME); + } + + /** + * Find all xml streams. + * + * @return all xml streams + */ + @Override + public List<XmlStream> findAllXmlStreams() { + return findAllByExtension(XmlStream.class, XmlStream.EXT_XMLSTREAM, XmlStream.FQ_FIELD_XMLSTREAM_NAME); + } + + /** + * Find all users for a client. + * + * @param clientId client wikitty id + * @return all users for client + */ + @Override + public List<User> findClientUsers(String clientId) { + + // Get user of client + Search search = Search.query().eq(User.FQ_FIELD_USER_CLIENT, clientId); + Criteria criteria = search.criteria(); + criteria.addSortAscending(User.FQ_FIELD_USER_NAME); + + PagedResult<User> usersResult = wikittyProxy.findAllByCriteria(User.class, criteria); + List<User> users = usersResult.getAll(); + return users; + } + + /** + * Find all groups for a user. + * + * @param userId user wikitty id + * @return groups for a user + */ + @Override + public List<Group> findUserGroups(String userId) { + + // Get user of client + Search search = Search.query().eq(Group.FQ_FIELD_GROUP_USER, userId); + Criteria criteria = search.criteria(); + + PagedResult<Group> groupsResult = wikittyProxy.findAllByCriteria(Group.class, criteria); + List<Group> groups = groupsResult.getAll(); + + if (log.isDebugEnabled()) { + log.debug(groups.size() + " groups found for user " + userId); + } + + return groups; + } + + /** + * Retrieves the form type whose name is the parameter 'name' + * + * @param name the name of the form type we want to retrieve + * @return the form type whose name is the parameter + * @throws VradiException + */ + @Override + public WikittyExtension getFormType(String name) throws VradiException { + + return formTypeManager.getFormType(name); + } + + /** + * Updates the form type whose name is 'name'. + * + * @param name the name of the form type to update + * @param fields the new fields of the form type + * @param requires the new requires of the form type + * @param tagValues the new tag values of the form type + * @return the form type up to date + */ + @Override + public WikittyExtension updateFormType(String name, Map<String, FieldType> fields, + String requires, Map<String, String> tagValues) throws VradiException { + + return formTypeManager.updateFormType(name, fields, requires, tagValues); + } + + /** + * Update the form type given in parameter + * + * @param extension the form type to update + * @return the form type up to date + */ + @Override + public WikittyExtension updateFormType(WikittyExtension extension) throws VradiException { + return formTypeManager.updateFormType(extension, null); + } + + /** + * Update the form type given in parameter + * + * @param extension the form type to update + * @return the form type up to date + */ + public WikittyExtension updateFormType(WikittyExtension extension, String templateName) throws VradiException { + + return formTypeManager.updateFormType(extension, templateName); + } + + @Override + public FormPagedResult findForms(QueryParameters queryParameters, + FormPagedResult formPagedResult) throws UnsupportedQueryException, VradiException { + + FormPagedResult result = searchManager.findForms(queryParameters, formPagedResult); + return result; + } + + @Override + public Map<Thesaurus, Integer> getChildrenCartography(String thesaurusId, QueryParameters queryParameters) + throws VradiException, UnsupportedQueryException { + + Map<Thesaurus, Integer> thesaurusCartography = searchManager.getChildrenCartography( + thesaurusId, queryParameters); + + return thesaurusCartography; + } + + @Override + public Map<Group, List<QueryBean>> getQueriesToModifyAfterThesaurusModification( + String rootThesaurusName, String thesaurusName) { + return thesaurusManager.getQueriesToModifyAfterThesaurusModification(rootThesaurusName, thesaurusName); + } + + /** + * Updates the xml field bindings given in parameters. + * + * @param bindings the list of the xml field bindings to update + * @return the list of the xml field bindings up to date + */ + @Override + public List<XmlFieldBinding> updateXmlFieldBindings(List<XmlFieldBinding> bindings) + throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateXmlFieldBindings(bindings)"); + } + + try { + List<XmlFieldBinding> list = new ArrayList<XmlFieldBinding>(); + + if (bindings != null) { + bindings = wikittyProxy.store(bindings); + list.addAll(bindings); + } + + return list; + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't update xml field bindings", eee); + } + throw new VradiException("Can't update xml field bindings", eee); + } + } + + /** + * Retrieves all the form types + * + * @return a list containing all the form types + */ + @Override + public List<WikittyExtension> getAllFormTypes() throws VradiException { + + List<WikittyExtension> extensions = new ArrayList<WikittyExtension>(); + + List<String> allExtensionIds = wikittyProxy.getAllExtensionsRequires(Form.EXT_FORM); + Map<String, WikittyExtension> lastVersions = + new HashMap<String, WikittyExtension>(); + + for (String extensionId : allExtensionIds) { + String extensionName = WikittyExtension.computeName(extensionId); + if (lastVersions.get(extensionName) == null) { + WikittyExtension extension = wikittyProxy.restoreExtensionLastVersion(extensionName); + extension = computeExtension(extension); + lastVersions.put(extensionName, extension); + } + } + extensions.addAll(lastVersions.values()); + + return extensions; + } + + /** + * Compute the specified extension and return a new one with ordered fields. + * Fields order is specified by their tag values. + * + * @param extension specified + * @return extention ordered + */ + protected WikittyExtension computeExtension(WikittyExtension extension) { + + Collection<String> fieldNames = extension.getFieldNames(); + List<String> fieldOrder = new ArrayList<String>(); + List<String> orderlessFields = new ArrayList<String>(); + + for (String fieldName : fieldNames) { + FieldType fieldType = extension.getFieldType(fieldName); + + try { + Integer.valueOf(fieldType.getTagValue("rank")); + fieldOrder.add(fieldName); + + } catch (Exception eee) { + orderlessFields.add(fieldName); + } + } + + LinkedHashMap<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + + for (String key : fieldOrder) { + fields.put(key, extension.getFieldType(key)); + } + + for (String key : orderlessFields) { + fields.put(key, extension.getFieldType(key)); + } + + WikittyExtension fieldOrderedExtension = + new WikittyExtension(extension.getName(), + extension.getVersion(), + extension.getRequires(), + fields); + fieldOrderedExtension.setTagValues(extension.getTagValues()); + + return fieldOrderedExtension; + } + + @Override + public List<Thesaurus> proposeThesaurus(String formId) throws VradiException { + return thesaurusManager.proposeThesaurus(formId); + } + + /** + * Return root thesaurus ids (ie thesaurus nodes without parent) sorted + * by root thesaurus name. + * + * @return a {@link RootThesaurus} collection + * @throws VradiException + */ + @Override + public List<RootThesaurus> getRootThesaurus() throws VradiException { + return thesaurusManager.getRootThesaurus(); + } + + @Override + public int getNbFormsForThesaurus(String thesaurusId) + throws VradiException { + return thesaurusManager.getNbFormsForThesaurus(thesaurusId); + } + + /** + * Retourne l'ensemble des thesaurus qui sont attachés a un formulaire. + * + * @param form form dont on veut les thesaurus + * @return thesaurus attachés au formulaire + */ + public List<Thesaurus> getThesaurusAttachedToForm(Form form) { + return thesaurusManager.getThesaurusAttachedToForm(form); + } + + /** + * Returns all children of the specified {@code thesaurusId} sorted by name. + * + * @param thesaurusId thesaurus wikitty id + * @return all list of <code>TreeNodeImpl</code> + * @throws VradiException + */ + @Override + public List<Thesaurus> getChildrenThesaurus(String thesaurusId) throws VradiException { + return thesaurusManager.getChildrenThesaurus(thesaurusId); + } + + @Override + public RootThesaurus createRootThesaurus(String rootThesaurusName) throws VradiException { + return thesaurusManager.createRootThesaurus(rootThesaurusName); + } + + /** + * Delete all thesaurus and sub thesaurus. + * + * @param thesaurusId thesaurusId to delete + * @throws VradiException + */ + public Collection<String> deleteThesaurus(String thesaurusId) throws VradiException { + return thesaurusManager.deleteThesaurus(thesaurusId); + } + + /** + * Delete all thesauruses recursively. + * + * @throws VradiException + */ + public void deleteAllThesaurus() throws VradiException { + thesaurusManager.deleteAllThesaurus(); + } + + /** + * Return true if thesaurusName exists in rootThesaurus children. + * + * @param rootThesaurus root thesaurus + * @param thesaurusName thesaurus name to test + * @return true if thesaurusName exists in rootThesaurus children + */ + public boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName) { + return thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, thesaurusName); + } + + /** + * Check if name of thesaurus is existing in rootThesaurus. + * + * @param rootThesaurus to check + * @param thesaurusName name to check + * @param exceptedThesaurusId in case of rename, exclude exceptedThesaurusId from check + * @return true if thesaurus already exist + */ + public boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName, String exceptedThesaurusId) { + return thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, thesaurusName, exceptedThesaurusId); + } + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @return true if rootThesaurusName already exists + */ + public boolean isRootThesaurusNameExists(String rootThesaurusName) { + return thesaurusManager.isRootThesaurusNameExists(rootThesaurusName); + } + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @param exceptedRootThesaurusId in case of rename, exclude exceptedRootThesaurusId from check + * @return true if rootThesaurusName already exists + */ + public boolean isRootThesaurusNameExists(String rootThesaurusName, String exceptedRootThesaurusId) { + return thesaurusManager.isRootThesaurusNameExists(rootThesaurusName, exceptedRootThesaurusId); + } + + /** + * Check if a form type name already exists. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + public boolean isFormTypeExists(String formTypeName) throws VradiException { + return formTypeManager.isFormTypeExists(formTypeName); + } + + /** + * Create new form type. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + public WikittyExtension createFormType(String formTypeName) throws VradiException { + return formTypeManager.createFormType(formTypeName); + } + + @Override + public boolean checkUserEmail(Sending sending) { + + // Check users email + String userId = sending.getUser(); + + User user = wikittyProxy.restore(User.class, userId); + if (user != null) { + String emailUser = user.getEmail(); + if (StringUtils.isBlank(emailUser)) { + return true; + } + } + return false; + } + + @Override + public Session getSessionBySending(String sendingId) { + + Search query = Search.query(); + query.eq(Element.ELT_EXTENSION, Session.EXT_SESSION); + + query.contains(Session.FQ_FIELD_SESSION_SENDING, sendingId); + + Criteria criteria = query.criteria(); + Session session = wikittyProxy.findByCriteria(Session.class, criteria); + return session; + } + + @Override + public List<Session> getSessions(Date sessionDate) throws VradiException { + return formManager.getSessions(sessionDate); + } + + @Override + public Session getLastCloseSession() throws VradiException { + return formManager.getLastCloseSession(); + } + + @Override + public Session getLastOpenSession() throws VradiException { + return formManager.getLastOpenSession(); + } + + @Override + public List<String> getRelatedFormsLinkIds(String formId) throws VradiException { + return formManager.getRelatedFormsLinkIds(formId); + } + + @Override + public List<String> getReplaceFormsLinkIds(String formId) throws VradiException { + return formManager.getReplaceFormsLinkIds(formId); + } + + @Override + public boolean isReplaceForm(String formId) { + return formManager.isReplaceForm(formId); + } + + @Override + public String getPreviousReplaceForm(String formId) { + return formManager.getPreviousReplaceForm(formId); + } + + @Override + public List<String> getAllWebHarvestScripts() { + File scriptDir = VradiServiceConfigurationHelper.getWebHarvestScriptDir(config); + + List<String> files = new ArrayList<String>(); + for (File file : scriptDir.listFiles()) { + if (file.isFile()) { + files.add(file.getName()); + } + } + + return files; + } + + @Override + public String getWebHarvestPreviewURL(WebHarvestStream stream) throws VradiException { + return bindingManager.getWebHarvestPreviewUrlAsString(stream); + } + + @Override + public String getFormTypeTemplateName(WikittyExtension extension) { + return formTypeManager.getFormTypeTemplateName(extension); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiDataServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiException.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiException.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiException.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,56 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +/** + * Generic vradi service exception. + * + * @author morin + * @since 0.0.4 + */ +public class VradiException extends Exception { + + /** serialVersionUID. */ + private static final long serialVersionUID = -150304295847654675L; + + /** + * Constructs a new exception with the specified detail message. + * + * @param message message + */ + public VradiException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * + * @param message + * @param cause + */ + public VradiException(String message, Throwable cause) { + super(message, cause); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiPDFCleanerService.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiPDFCleanerService.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiPDFCleanerService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,136 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.entities.Form; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.FileUtil; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.nuiton.wikitty.services.WikittyEvent; +import org.nuiton.wikitty.services.WikittyServiceDelegator; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.regex.Pattern; + +/** + * Wikitty service that clean generated pdf files when an extension is + * stored (updated). + * <p/> + * If template is modified, new generation don't work because pdf file + * already exists. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiPDFCleanerService extends WikittyServiceDelegator { + + /** Log. */ + private static final Log log = LogFactory.getLog(VradiPDFCleanerService.class); + + protected ApplicationConfig config; + + public VradiPDFCleanerService(WikittyService delegate, ApplicationConfig config) { + super(delegate); + this.config = config; + } + + /** + * Return generated pdf file path containing form wikitty id and form version. + * + * @param form form + * @param config config + * @return generated pdf file + * <p/> + * TODO echatellier 20110218 move this to a better place + */ + public static File getGeneratedPdfFile(Form form, ApplicationConfig config) { + String filename = form.getWikittyId() + "-" + form.getWikittyVersion() + ".pdf"; + File pdfDir = VradiServiceConfigurationHelper.getPdfDir(config); + File result = new File(pdfDir, filename); + return result; + } + + @Override + public WikittyEvent storeExtension(String securityToken, + Collection<WikittyExtension> exts) { + WikittyEvent event = super.storeExtension(securityToken, exts); + + // + for (WikittyExtension ext : exts) { + + // only extension that require Form + if (Form.EXT_FORM.equals(ext.getRequires())) { + + if (log.isInfoEnabled()) { + log.info("Removing generated pdf for extension " + ext.getName()); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, ext.getName()); + Criteria criteria = search.criteria(); + List<PagedResult<String>> allFormId = findAllByCriteria( + securityToken, + Arrays.asList(criteria) + ); + + if (CollectionUtils.isNotEmpty(allFormId)) { + for (String formId : allFormId.get(0).getAll()) { + if (log.isDebugEnabled()) { + log.debug("Delete all pdf files for form " + formId); + } + + // remove all files named formid*.pdf + File generatedPdfDir = VradiServiceConfigurationHelper.getPdfDir(config); + String filePattern = Pattern.quote(formId) + ".*\\.pdf"; + List<File> pdfFiles = FileUtil.find(generatedPdfDir, filePattern, false); + for (File pdfFile : pdfFiles) { + if (log.isDebugEnabled()) { + log.debug("Delete pdf file " + pdfFile); + } + pdfFile.delete(); + } + } + } + } + } + + return event; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiPDFCleanerService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,396 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.QueryMaker; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlStream; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.search.Criteria; + +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * Vradi storage service. + * <p/> + * This service is intended to be used in remote mode. + * <p/> + * Typical usage is code that can be run only on server : + * <ul> + * <li>Openoffice template generation + * <li>Mail sending + * </ul> + * + * @author morin + * @version $Revision$ $Date$ + */ +public interface VradiStorageService { + + + /** + * Create all default status. + * + * @return all status + * @throws VradiException + */ + List<Status> createDefaultStatuses() throws VradiException; + + /** + * Binds all queryMaker with the forms found by their queries + * and not already sent. + */ + Session bindForms(Session session) throws VradiException; + + /** + * Create new Sending + * + * @param session + * @param group + * @param formsIdsToBind + * @return + * @throws VradiException + */ + List<Sending> createAllSending(String sessionId, Group group, List<String> formsIdsToBind) throws VradiException; + + /** + * Create new Sending + * + * @param session + * @param user + * @param formsIdsToBind + * @return + * @throws VradiException + */ + Sending createSending(String sessionId, User user, List<String> formsIdsToBind) throws VradiException; + + Session createNewSession() throws VradiException; + + /** + * Creates and store forms from an {@code WebHarvestXmlStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param webHarvestStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + XmlStreamImportResult importFormsFromWebHarvestStream(WebHarvestStream webHarvestStream) throws VradiException; + + /** + * Get association between template fields and extension fields. + * + * @param extensionName + * @param templateName + * @return association map or {@code null} is there is no association yet + * @throws VradiException + */ + Map<String, String> getAssociatedFields(String extensionName, + String templateName) throws VradiException; + + /** + * Lists the template filename (simple name) associated with the specified + * extension. + * <p/> + * This need to be called by a WS because an {@link WikittyExtension} + * doesn't have a files fields. + * + * @param extension + * @return + */ + Collection<String> getTemplateFilenames(WikittyExtension extension); + + /** + * Creates and store forms from an {@code XmlStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param xmlStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + XmlStreamImportResult importFormsFromXmlStream(XmlStream xmlStream) throws VradiException; + + /** + * Create a {@code VradiUser}. + * + * @param user the user to create + * @return the vradiUser updated or {@code null} if user can't be created (already exists) + * @throws VradiException + */ + VradiUser createUser(VradiUser user) throws VradiException; + + /** + * Checks if {@code userName} and {@code userPassword} matches a valid {@code VradiUser}. + * + * @param login the login of a WikittyUser + * @param md5Password the password of a WikittyUser (md5 encoded) + * @return a {@code WikittyUser} or null if either userName or userPassword don't match + * @throws VradiException + */ + VradiUser loginUser(String login, String md5Password) throws VradiException; + + /* + * Import data from an XML file. + * + * @param file the XML file containing datas + * @throws VradiException + * + void importData(File file) throws VradiException; + + /* + * Export the datas into an XML format. + * + * @return the datas as an XML String + * @throws VradiException + * + String exportData() throws VradiException;*/ + + /* + * Create or Update a list of <code>Forms</code>. + * + * @param forms the list of forms to insert or update + * @return an updated list of <code>Form</code> + * + List<Form> updateForms(List<Form> forms) throws VradiException;*/ + + /** + * Import all data as CSV. + * <p/> + * FIXME EC-20100415 will not work in remote mode (or uri maybe be + * valid for remote server too) + * + * @param uri uri used to read input stream + * @throws VradiException if any error happen during import + */ + void importAsCSV(String uri) throws VradiException; + + /** + * Get csv export. + * + * @param criteria export criteria + * @return csv export + * @throws VradiException if any error happen during export + */ + String exportAsCSV(Criteria criteria) throws VradiException; + + /** + * Export thesaurus as csv + * + * @return thesaurus csv export + * @throws VradiException if any error happen during export + */ + String exportThesaurusAsCSV() throws VradiException; + + /** Reindex the datas. */ + void reindexData() throws VradiException; + + /** + * Archives the queries of a user, client or group in a RSS file. + * + * @param queryMaker the query maker whose queries are archived + * @throws VradiException + */ + void archiveQueries(QueryMaker queryMaker) throws VradiException; + + /** + * Save association between template fields and extensions fields. + * + * @param extensionName + * @param templateName + * @param fieldMap + * @throws VradiException + */ + void setAssociatedFields(String extensionName, String templateName, + Map<String, String> fieldMap) throws VradiException; + + /** + * Generate pdf file for specified form. + * + * @param formId form id to generate pdf + * @param force force regeneration + * @return uri to download file + */ + String generatePDF(String formId, boolean force) throws VradiException; + + /** + * Remove all sending corresponding with form and group from session + * + * @param session concerned + * @param formsIds concerned + * @param queryMaker concerned + * @return List of sending after deletion + */ + List<Sending> removeAllSending(String sessionId, List<String> formsIds, Group group) throws VradiException; + + /** + * Remove sending corresponding with form and user from session + * + * @param session concerned + * @param formsIds concerned + * @param queryMaker concerned + * @return sending after deletion + */ + Sending removeSending(String sessionId, List<String> formsIds, User user) throws VradiException; + + /** + * Get template document fields names. + * + * @param extension extension + * @param templateName template name + * @return field names + * @throws VradiException + */ + List<String> getDocumentFields(WikittyExtension extension, String templateName) throws VradiException; + + /** + * Send session pass in param + * + * @param sessionId session id concerned + * @return Logged messages + * @throws VradiException exception is occured + */ + String sendMessages(String sessionId) throws VradiException; + + /** + * Send sending pass in param to sending user email + * + * @param sendingId sending id concerned + * @param sessionParagraph paragraph to send + * @param fileToAttach file to attache + * @return Logged messages + * @throws VradiException exception is occured + */ + String sendMessage(String sendingId, String sessionParagraph, Collection<File> fileToAttach) throws VradiException; + + /** + * Send sending pass in param to specific email + * + * @param sendingId sending id concerned + * @param sessionParagraph paragraph to send + * @param email specific + * @param fileToAttach file to attach + * @return Logged messages + * @throws VradiException exception is occured + */ + String sendMessage(String sendingId, String sessionParagraph, String email, Collection<File> fileToAttach) throws VradiException; + + void receiveMessages() throws VradiException; + + Session stopSentMail(Session session) throws VradiException; + + /** + * Generate all the PDFs needed to send a session. + * + * @param sessionId the session wikitty id + * @throws VradiException + */ + void generatePDFForSession(String sessionId) throws VradiException; + + /** + * Export all the clients, users and groups in database + * + * @return the csv export as a String + * @throws VradiException if any error happen during export + */ + String exportClientDB() throws VradiException; + + /** + * Delete session and sending associated + * This method return a {@link VradiException} if session to delete is not active + * + * @param sessionId to delete + * @throws VradiException if an error occur during session deletion + */ + void deleteSession(String sessionId) throws VradiException; + + /** + * Check if template file form extension name in param + * + * @param extensionName to check + * @return true if file exist + * @throws VradiException if an error occur during checking template + */ + boolean checkTemplateExist(String extensionName) throws VradiException; + + /** + * Check if template file form extension name in param + * + * @param formsIds to update + * @return false if no session opened found + * @throws VradiException if an error occur during checking template + */ + boolean removeFormsFromSession(String session, List<String> formsIds) throws VradiException; + + /** + * Method call to revert froms deleted in sending + * + * @param sendingId to update + * @param formsIdsToUpdate deleted to revert + * @return updated sending + */ + Sending revertDeletion(String sendingId, List<String> formsIdsToUpdate); + + /** + * Revert forms deleted for user + * + * @param sessionId session concerned + * @param userId user concerned + * @param formId form to revert + * @return sending impacted + */ + Sending revertUserDeletion(String sessionId, String userId, String formId); + + + /** + * Revert forms deleted for group + * + * @param sessionId session concerned + * @param groupId user concerned + * @param formId form to revert + * @return sending impacted + */ + List<Sending> revertGroupDeletion(String sessionId, String groupId, String formId); + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,914 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiServiceConfiguration; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.QueryMaker; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.managers.BindingManager; +import org.chorem.vradi.services.managers.ClientManager; +import org.chorem.vradi.services.managers.FormManager; +import org.chorem.vradi.services.managers.FormTypeManager; +import org.chorem.vradi.services.managers.MailingManager; +import org.chorem.vradi.services.managers.SearchManager; +import org.chorem.vradi.services.managers.TemplateManager; +import org.chorem.vradi.services.managers.ThesaurusManager; +import org.chorem.vradi.services.tasks.TasksManager; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.DateUtil; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.addons.WikittyImportExportService; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyTreeNode; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.chorem.vradi.VradiConstants.SendingStatus; +import static org.chorem.vradi.VradiConstants.SessionStatus; +import static org.nuiton.i18n.I18n._; + +/** + * Vradi storage implementation. + * + * @author morin + * @author chatellier + */ +public class VradiStorageServiceImpl implements VradiStorageService { + + static private final Log log = LogFactory.getLog(VradiStorageServiceImpl.class); + + protected ApplicationConfig config; + + /** Proxy to store and retrieve data. */ + protected WikittyProxy wikittyProxy; + + protected WikittyImportExportService importExportService; + + protected ThesaurusManager thesaurusManager; + + protected BindingManager bindingManager; + + protected FormManager formManager; + + protected FormTypeManager formTypeManager; + + protected ClientManager clientManager; + + protected SearchManager searchManager; + + protected MailingManager mailingManager; + + protected TasksManager tasksManager; + + protected FileService fileService; + + /** Remote instantiation and empty constructor for hessian. */ + public VradiStorageServiceImpl() { + this(VradiServiceConfiguration.getInstance(), ServiceFactory.getWikittyProxy()); + } + + /** + * This constructor exists for local wikittyProxy instanciation. + * + * @param config vradi config + * @param wikittyProxy custom wikitty proxy + */ + protected VradiStorageServiceImpl(ApplicationConfig config, WikittyProxy wikittyProxy) { + this.wikittyProxy = wikittyProxy; + this.config = config; + + thesaurusManager = new ThesaurusManager(wikittyProxy); + clientManager = new ClientManager(config, wikittyProxy); + formTypeManager = new FormTypeManager(config, wikittyProxy); + mailingManager = new MailingManager(config, wikittyProxy); + + fileService = new FileServiceImpl(config); + searchManager = new SearchManager(wikittyProxy, thesaurusManager); + formManager = new FormManager(config, wikittyProxy, thesaurusManager, searchManager); + bindingManager = new BindingManager(config, wikittyProxy, formTypeManager, formManager); + tasksManager = new TasksManager(config, wikittyProxy, mailingManager, bindingManager); + + // init cron tasks + tasksManager.initTasks(); + wikittyProxy.getWikittyService().addWikittyServiceListener(tasksManager, WikittyService.ServiceListenerType.ALL); + } + + /** + * Get {@link WikittyImportExportService} singl instance. + * + * @return WikittyImportExportService singleton + */ + protected WikittyImportExportService getImportExportService() { + if (importExportService == null) { + VradiServiceConfiguration config = VradiServiceConfiguration.getInstance(); + + importExportService = new WikittyImportExportService( + config, + wikittyProxy.getSecurityToken(), + wikittyProxy.getWikittyService()); + + } + return importExportService; + } + + /** + * Create all default status. + * + * @return all status created + */ + @Override + public List<Status> createDefaultStatuses() throws VradiException { + return formManager.createDefaultStatuses(); + } + + @Override + public Session createNewSession() throws VradiException { + return formManager.createNewSession(); + } + + @Override + public Session bindForms(Session session) throws VradiException { + return formManager.bindForms(session); + } + + @Override + public List<Sending> createAllSending(String sessionId, Group group, List<String> formsIdsToBind) throws VradiException { + return formManager.createAllSending(sessionId, group, formsIdsToBind); + } + + @Override + public Sending createSending(String sessionId, User user, List<String> formsIdsToBind) throws VradiException { + return formManager.createUserSending(sessionId, user, formsIdsToBind); + } + + @Override + public List<Sending> removeAllSending(String sessionId, List<String> formsIds, Group group) + throws VradiException { + return formManager.removeAllSending(sessionId, formsIds, group); + } + + @Override + public Sending removeSending(String sessionId, List<String> formsIds, User user) + throws VradiException { + return formManager.removeSending(sessionId, formsIds, user); + } + + /** + * Creates and store forms from an {@code WebHarvestStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param webHarvestStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + @Override + public XmlStreamImportResult importFormsFromWebHarvestStream(WebHarvestStream webHarvestStream) + throws VradiException { + return bindingManager.importFormsFromWebHarvestStream(webHarvestStream); + } + + /** + * Creates and store forms from an {@code XmlStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param xmlStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + @Override + public XmlStreamImportResult importFormsFromXmlStream(XmlStream xmlStream) + throws VradiException { + return bindingManager.importFormsFromXmlStream(xmlStream); + } + + @Override + public VradiUser createUser(VradiUser user) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateVradiUser(" + user.getLogin() + ")"); + } + + Search search = Search.query().eq(VradiUser.FIELD_WIKITTYUSER_LOGIN, user.getLogin()); + Criteria criteria = search.criteria(); + criteria.setEndIndex(1); // one is enought + + PagedResult<VradiUser> users = wikittyProxy.findAllByCriteria(VradiUser.class, criteria); + + if (users.getNumFound() > 0) { + if (log.isDebugEnabled()) { + log.debug("User " + user.getLogin() + " already exists"); + } + return null; + + } else { + return wikittyProxy.store(user); + } + } + + @Override + public VradiUser loginUser(String login, String mp5password) { + if (log.isDebugEnabled()) { + log.debug("logVradiUser(" + login + ", " + mp5password + ")"); + } + + Criteria criteria = Search.query() + .eq(VradiUser.FQ_FIELD_WIKITTYUSER_LOGIN, login) + .eq(VradiUser.FQ_FIELD_WIKITTYUSER_PASSWORD, mp5password) + .criteria(); + criteria.setEndIndex(1); // max 1 + + VradiUser vradiUser = wikittyProxy.findByCriteria(VradiUser.class, criteria); + return vradiUser; + } + + /*@Override + public void importData(File file) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("importData(file)"); + } + + // TODO: create an archive of vradi.home directory before + + try { + String toURI = file.toURI().toString(); + log.info("importing file: " + toURI); + + WikittyImportExportService importExportService = getImportExportService(); + importExportService.syncImportFromUri(WikittyImportExportService.FORMAT.CSV, toURI); + + log.info("import done"); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't import data", e); + } + throw new VradiException("Can't import data", e); + } + } + + @Override + public String exportData() throws VradiException { + if (log.isDebugEnabled()) { + log.debug("exportData()"); + } + + try { + Search search = Search.query().keyword("*"); + Criteria criteria = search.criteria(); + + WikittyImportExportService importExportService = getImportExportService(); + String export = importExportService.syncExportAllByCriteria(WikittyImportExportService.FORMAT.CSV, criteria); + log.info("export done"); + return export; + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't export data", e); + } + throw new VradiException("Can't export data", e); + } + }*/ + + @Override + public void importAsCSV(String uri) throws VradiException { + + if (log.isDebugEnabled()) { + log.debug("Importing data as CSV with url = " + uri); + } + + try { + WikittyImportExportService ieService = getImportExportService(); + ieService.syncImportFromUri(WikittyImportExportService.FORMAT.CSV, uri); + } catch (WikittyException eee) { + if (log.isErrorEnabled()) { + log.error("Can't import data", eee); + } + throw new VradiException("Can't import data", eee); + } + } + + @Override + public String exportAsCSV(Criteria criteria) throws VradiException { + + //FIXME JC 01/09/2010 Should create a file and make him downloadable through FileService. + + if (log.isDebugEnabled()) { + log.debug("Exporting data as CSV with criteria " + criteria); + } + + String result = null; + try { + WikittyImportExportService ieService = getImportExportService(); + result = ieService.syncExportAllByCriteria(WikittyImportExportService.FORMAT.CSV, criteria); + } catch (WikittyException eee) { + if (log.isErrorEnabled()) { + log.error("Can't export data", eee); + } + } + return result; + } + + @Override + public String exportThesaurusAsCSV() throws VradiException { + // creation du criteria wikitty + // (export de tous les wikitty avec extension "thesaurus" + Search search = Search.query().eq(Element.ELT_EXTENSION, + WikittyTreeNode.EXT_WIKITTYTREENODE); + Criteria criteria = search.criteria(); + return exportAsCSV(criteria); + } + + @Override + public void reindexData() { + if (log.isDebugEnabled()) { + log.debug("reindexData()"); + } + + wikittyProxy.getWikittyService().syncSearchEngine(null); + } + + @Override + public void archiveQueries(QueryMaker queryMaker) + throws VradiException { + clientManager.archiveQueries(queryMaker); + } + + @Override + public void setAssociatedFields(String extensionName, + String templateName, + Map<String, String> fieldMap) + throws VradiException { + + formTypeManager.setAssociatedFields(extensionName, templateName, fieldMap); + + } + + @Override + public String generatePDF(String formId, boolean force) throws VradiException { + + String uri = null; + + String extensionName = null; + Form form = wikittyProxy.restore(Form.class, formId); + for (String ext : form.getExtensionNames()) { + if (!ext.equals(Infogene.EXT_INFOGENE) + && !ext.equals(Form.EXT_FORM)) { + extensionName = ext; + break; + } + + } + WikittyExtension extension = formTypeManager.getFormType(extensionName); + // VradiHelper.getFormTypeTemplate(extension); + String template = extension.getTagValue(VradiConstants.FormTypeTemplateEnum.FIELD_TEMPLATE_ATTRIBUTE.getValue()); + File templateFile = formTypeManager.getTemplate(extensionName, template); + Map<String, String> fieldMap = getAssociatedFields(extension.getName(), template); + + if (log.isDebugEnabled()) { + log.debug("Generating PDF file for form " + form.getWikittyId() + + " (template = " + template + ")"); + } + + try { + // but only those associated with current templates ! + List<Form> currentForms = Collections.singletonList(form); + List<File> filesToAdd = generateFilledDocumentInPDF( + templateFile, currentForms, fieldMap, force); + + if (filesToAdd != null && !filesToAdd.isEmpty()) { + uri = filesToAdd.get(0).getName(); + } + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't generate pdf", ex); + } + throw new VradiException("Can't generate pdf", ex); + } + + return uri; + } + + + @Override + public Collection<String> getTemplateFilenames(WikittyExtension extension) { + return formTypeManager.getTemplateFilenames(extension); + } + + @Override + public Map<String, String> getAssociatedFields(String extensionName, + String templateName) + throws VradiException { + return formTypeManager.getAssociatedFields(extensionName, templateName); + } + + @Override + public List<String> getDocumentFields(WikittyExtension extension, String templateName) throws VradiException { + + List<String> documentsFields; + + try { + File templateDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File extensionTemplate = new File(templateDir, extension.getName()); + File templateFile = new File(extensionTemplate, templateName); + + TemplateManager templateManager = new TemplateManager(config, templateFile); + documentsFields = templateManager.getDocumentFields(); + } catch (VradiException ex) { + if (log.isErrorEnabled()) { + log.error("Can't get documents fields", ex); + } + throw ex; + } + return documentsFields; + } + + /** + * Generate offer PDF form given forms with specified template. + * + * @param template template to use to generate PDF + * @param forms to to generate + * @param fieldBindings map between template field name and form fields names + * @param replace replace already existing generated forms + * @return generated pdf files + * @throws VradiException for various possible errors + */ + protected List<File> generateFilledDocumentInPDF(File template, List<Form> forms, + Map<String, String> fieldBindings, + boolean replace) + throws VradiException { + + List<File> generatedPDFList = null; + + if (template == null) { + if (log.isWarnEnabled()) { + log.warn("Try to generate form pdf without template"); + } + } else if (fieldBindings == null) { + if (log.isWarnEnabled()) { + log.warn("No association field found, abording"); + } + } else { + TemplateManager templateManager = new TemplateManager(config, template); + + // split fqn form field name in an array + // composed of extension name, and extension field + // TODO EC20100510 set in commun with same function in + // {@link generateFilledDocumentInPDF(TemplateManager, Form form, Map<String, String[]>, boolean) + Map<String, String[]> map = new HashMap<String, String[]>(); + for (Map.Entry<String, String> binding : fieldBindings.entrySet()) { + String fieldFQName = binding.getValue(); + if (fieldFQName != null && fieldFQName.indexOf(".") > 0) { + int dot = fieldFQName.indexOf("."); + String[] fqField = new String[2]; + fqField[0] = fieldFQName.substring(0, dot); + fqField[1] = fieldFQName.substring(dot + 1); + map.put(binding.getKey(), fqField); + } + } + + generatedPDFList = new ArrayList<File>(); + for (Form form : forms) { + File f = generateFilledDocumentInPDF(templateManager, form, map, replace); + generatedPDFList.add(f); + } + } + + return generatedPDFList; + } + + /** + * Generate a single pdf file for specified form. + * + * @param templateManager pdf template manager + * @param form form to get pdf + * @param fieldBindings association between field name and form fields (couple extension name, extension field) + * @param replace replace already existing pdf + * @return the pdf file associated with pdf + * @throws VradiException for various possible errors + */ + protected File generateFilledDocumentInPDF(TemplateManager templateManager, + Form form, Map<String, String[]> fieldBindings, + boolean replace) throws VradiException { + + // generated pdf are cached + File result = mailingManager.getGeneratedPdfFile(form); + if (!replace && result.exists()) { + return result; + } + + Map<String, Object> fieldValues = new HashMap<String, Object>(); + for (Map.Entry<String, String[]> binding : fieldBindings.entrySet()) { + String[] fqField = binding.getValue(); + Object value = form.getField(fqField[0], fqField[1]); + fieldValues.put(binding.getKey(), + value != null ? value.toString() : null); + } + + // Extract files + List<String> formUrls = new ArrayList<String>(); + if (form.getFiles() != null) { + for (String file : form.getFiles()) { + String formUrl = fileService.getFormEmbeddedUrl(file, form.getWikittyId()); + formUrls.add(formUrl); + } + } + + templateManager.generateDoc(result.getPath(), fieldValues, + formUrls.toArray(new String[formUrls.size()])); + + return result; + } + + @Override + public String sendMessages(String sessionId) throws VradiException { + + Session session = wikittyProxy.restore(Session.class, sessionId); + + if (SessionStatus.isSent(session)) { + return StringUtils.EMPTY; + } + + // Pass to active for session in error or stopped + if (SessionStatus.isToRestart(session)) { + + log.info("Session was stopped or in error, resume sending"); + + session.setStatus(SessionStatus.ACTIVE.getValue()); + session.setSessionLogs(StringUtils.EMPTY); + session = wikittyProxy.store(session); + } + + // Get all files to attach + Set<String> filesNames = session.getFiles(); + List<File> files = new ArrayList<File>(); + if (filesNames != null) { + for (String fileName : filesNames) { + File file = fileService.downloadSessionAttachment(fileName, sessionId); + files.add(file); + log.info("Files founds for session : " + session.getSessionDate() + " : " + (file == null ? "not found" : file.getName())); + } + } + + // Init logger to keep exception + List<String> sessionLogger = new ArrayList<String>(); + + Set<String> sendingIds = session.getSending(); + if (sendingIds != null) { + + for (String sendingId : sendingIds) { + + // Flag to detect if it's canceled by user + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + if (SessionStatus.isStopped(session)) { + log.warn("Sending stopped by user"); + sessionLogger.add(_("vradi.error.session.stopped", session.getNum(), + DateUtil.formatDate(session.getSessionDate(), DateUtil.DEFAULT_PATTERN))); + } + + Sending sending = wikittyProxy.restore(Sending.class, sendingId); + if (sending != null) { + if (SendingStatus.isSent(sending)) { + if (log.isDebugEnabled()) { + log.debug("Sending " + sendingId + " already sent, skip"); + } + } else if (SendingStatus.isToSend(sending)) { + + // Send + String log = sendMessage(sendingId, session.getParagraph(), files); + if (log != null) { + sessionLogger.add(log); + } + } + } + } + } + + // Get logs + String formatedLogs = formatSessionLog(sessionLogger); + + // Set session to sent or error + if (sessionLogger.isEmpty()) { + session.setStatus(SessionStatus.SENT.getValue()); + session.setSessionLogs(StringUtils.EMPTY); + } else { + session.setStatus(SessionStatus.ERROR.getValue()); + session.setSessionLogs(formatedLogs); + } + session.setSessionDate(new Date()); + wikittyProxy.store(session); + + return formatedLogs; + } + + @Override + public String sendMessage(String sendingId, String sessionParagraph, Collection<File> filesToAttach) throws VradiException { + return sendMessage(sendingId, sessionParagraph, null, false, filesToAttach); + } + + @Override + public String sendMessage(String sendingId, String sessionParagraph, String email, Collection<File> filesToAttach) throws VradiException { + return sendMessage(sendingId, sessionParagraph, email, true, filesToAttach); + } + + public String sendMessage(String sendingId, String sessionParagraph, String email, boolean reSend, Collection<File> filesToAttach) throws VradiException { + + Sending sending = wikittyProxy.restore(Sending.class, sendingId); + User user = clientManager.getUser(sending.getUser()); + + // Will resend sending already sent + if (!reSend) { + // Do nothing + if (!SendingStatus.isToSend(sending)) { + return null; + } + } + + // If its client or group sending : do nothing + // Never append +// if (sending.getUser() == null) { +// sending.setStatus(VradiConstants.SendingStatus.SENT.getValue()); +// return wikittyProxy.store(sending); +// } + + Set<String> formsIds = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + // If no forms founds + if (formsIds.isEmpty()) { + + // Set session in error + sending.setStatus(SendingStatus.DELETED.getValue()); + wikittyProxy.store(sending); + + // Do nothing + return null; + } + + // Get email address + // si aucune n'est specifiée, on utilise celle du client + if (StringUtils.isBlank(email)) { + email = user.getEmail(); + + // il peut arriver qu'un user n'est pas d'email et que l'admin + // souhaite quand meme faire l'envoie d'une session. + // dans ce cas on ne traite pas l'envoi de mail courant. + if (StringUtils.isBlank(email)) { + + if (log.isWarnEnabled()) { + log.warn("User " + user.getName() + " has not valid email (skip current mail sending)"); + } + // Set session in error + sending.setStatus(SendingStatus.ERROR.getValue()); + wikittyProxy.store(sending); + + return _("vradi.error.sending.emailIsBlank", user.getName()); + } + } + + if (log.isDebugEnabled()) { + log.debug("Sending message to " + email); + } + + String subject = VradiServiceConfigurationHelper.getOfferMailSubject(config); + + // Set message + String message = sessionParagraph + "\n\n" + sending.getParagraph(); + + List<Form> forms = wikittyProxy.restore(Form.class, new ArrayList<String>(formsIds)); + + boolean receptionProof = sending.getReceptionProof(); + + // Post mail and save msg id + String messageId; + try { + messageId = mailingManager.postMail( + email, subject, message, forms, receptionProof, filesToAttach); + + } catch (VradiException eee) { + + log.error("Failed to send sending for email : " + email, eee); + + // Set sending in error + sending.setStatus(SendingStatus.ERROR.getValue()); + wikittyProxy.store(sending); + + return _("vradi.error.sending.failedToSend", user.getName(), eee.getMessage()); + } + sending.setMessageId(messageId); + + // Set sending status + sending.setStatus(receptionProof ? + SendingStatus.WAITING_RECEPTION_PROOF.getValue() : + SendingStatus.SENT.getValue()); + + // Update sending + wikittyProxy.store(sending); + + return null; + } + + protected String formatSessionLog(List<String> logs) { + return StringUtils.join(logs, ",\n"); + } + + @Override + public void receiveMessages() throws VradiException { + mailingManager.receiveMails(); + } + + @Override + public Session stopSentMail(Session session) throws VradiException { + + // Flag status to stop traitement + session.setStatus(SessionStatus.STOPPED.getValue()); + + // Update + session = wikittyProxy.store(session); + + return session; + } + + /** + * Generate all the PDFs needed to send a session. + * + * @param sessionId the session wikitty id + */ + @Override + public void generatePDFForSession(String sessionId) throws VradiException { + List<String> formsIdsToGenerate = new ArrayList<String>(); + + Session session = wikittyProxy.restore(Session.class, sessionId); + + Set<String> sendingIds = session.getSending(); + + if (sendingIds == null) { + return; + } + + for (String id : sendingIds) { + Sending sending = wikittyProxy.restore(Sending.class, id); + + if (sending != null) { + Set<String> formsIds = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + if (formsIds != null) { + for (String formId : formsIds) { + + if (!formsIdsToGenerate.contains(formId)) { + formsIdsToGenerate.add(formId); + } + } + } + } + } + + for (String formId : formsIdsToGenerate) { + try { + generatePDF(formId, true); + } catch (VradiException eee) { + throw new VradiException("An error occurred while generating PDF file for " + + "form : " + formId, eee); + } + } + } + + /** + * Get all the groups a user is in. + * + * @param userId the user we want the groups of + * @return the group for our user + * @throws VradiException for various possible errors + */ + public List<Group> getGroupsForUser(String userId) throws VradiException { + return clientManager.getGroupsForUser(userId); + } + + @Override + public String exportClientDB() throws VradiException { + + // creation du criteria wikitty + // (export de tous les wikitty avec extension "client" + // "groupement" ou "user" + Search restriction = Search.query().or(); //definit un "groupement" qui se fera en "or" + restriction.eq(Element.ELT_EXTENSION, Group.EXT_GROUP); + restriction.eq(Element.ELT_EXTENSION, Client.EXT_CLIENT); + restriction.eq(Element.ELT_EXTENSION, User.EXT_USER); + Criteria criteria = restriction.criteria(); + + // export + String vscContent = exportAsCSV(criteria); + + return vscContent; + } + + @Override + public void deleteSession(String sessionId) throws VradiException { + formManager.deleteSession(sessionId); + } + + @Override + public boolean checkTemplateExist(String extensionName) throws VradiException { + boolean fileExists; + + try { + WikittyExtension extension = formTypeManager.getFormType(extensionName); + + String templateName = formTypeManager.getFormTypeTemplateName(extension); + + if (templateName == null) { + return false; + } + + // just verify file existence + // File file = storageService.getTemplate(extensionName, template); + File template = formTypeManager.getTemplate(extensionName, templateName); + + fileExists = template != null && template.exists(); + } catch (Exception eee) { + throw new VradiException("Can't check if template existe : ", eee); + } + return fileExists; + } + + @Override + public boolean removeFormsFromSession(String sessionId, List<String> formsIds) throws VradiException { + return formManager.removeFormsFromSession(sessionId, formsIds); + } + + @Override + public Sending revertDeletion(String sendingId, List<String> formsIdsToUpdate) { + return formManager.revertDeletion(sendingId, formsIdsToUpdate); + } + + @Override + public Sending revertUserDeletion(String sessionId, String userId, String formId) { + return formManager.revertUserDeletion(sessionId, userId, formId); + } + + @Override + public List<Sending> revertGroupDeletion(String sessionId, String groupId, String formId) { + return formManager.revertGroupDeletion(sessionId, groupId, formId); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/VradiStorageServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/BindingManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/BindingManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/BindingManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,648 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.util.SSLUtils; +import org.jdom.Document; +import org.jdom.Namespace; +import org.jdom.input.SAXBuilder; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.StringUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.webharvest.definition.ScraperConfiguration; +import org.webharvest.runtime.Scraper; +import org.webharvest.runtime.variables.Variable; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; + +/** + * Class containing the methods to manage the binding of the xml streams fields + * with the form fields : + * - xml field bindings creation, update and retrieving + * - xml streams retrieving + * - form creation with the data from an xml stream + * + * @author schorlet + * @version $Revision$ $Date$ + * @date 2010-01-22 20:18:29 + */ +public class BindingManager { + private static final Log log = LogFactory.getLog(BindingManager.class); + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + protected FormTypeManager formTypeManager; + + protected FormManager formManager; + + protected Timer timer; + + protected TimerTask xmlStreamTask; + + static { + // used for xml stream on https/ssl + SSLUtils.intallCertificateTruster(); + } + + public BindingManager(ApplicationConfig config, + WikittyProxy wikittyProxy, + FormTypeManager formTypeManager, + FormManager formManager) { + + this.config = config; + this.wikittyProxy = wikittyProxy; + this.formTypeManager = formTypeManager; + this.formManager = formManager; + } + + /** + * Retrieves the xml field bindings whose xml stream is xmlStream + * + * @param xmlStream the xml stream associated with the xml field bindings + * we want to retrieve + * @return a list containing the xml field bindings associated with + * the xml stream xmlStream + */ + public List<XmlFieldBinding> getXmlFieldBindings(XmlStream xmlStream) { + List<XmlFieldBinding> list = new ArrayList<XmlFieldBinding>(); + + if (xmlStream != null && xmlStream.getXmlFieldBinding() != null) { + if (log.isDebugEnabled()) { + log.debug("getXmlFieldBindings(" + xmlStream.getName() + ")"); + log.debug(xmlStream.getXmlFieldBinding()); + } + + List<String> bindings = new ArrayList<String>(); + bindings.addAll(xmlStream.getXmlFieldBinding()); + + List<XmlFieldBinding> restore = wikittyProxy.restore(XmlFieldBinding.class, bindings); + list.addAll(restore); + } + + return list; + } + + /** + * Retrieves the xml field binding whose id is xmlFieldBindingId + * + * @param xmlFieldBindingId the id of the xml field binding we want to retrieve + * @return the xml field binding whose id is xmlFieldBindingId + */ + public XmlFieldBinding getXmlFieldBinding(String xmlFieldBindingId) { + if (log.isDebugEnabled()) { + log.debug("getXmlFieldBinding(" + xmlFieldBindingId + ")"); + } + + XmlFieldBinding xmlFieldBinding = wikittyProxy.restore(XmlFieldBinding.class, xmlFieldBindingId); + return xmlFieldBinding; + } + + /** Retourne toutes les instance de stream avec leur réelle entité. */ + public List<XmlStream> getAllXmlStreams() { + if (log.isDebugEnabled()) { + log.debug("getAllXmlStreams()"); + } + + List<XmlStream> result = new ArrayList<XmlStream>(); + + // XmlStream + Criteria criteriaXmlStream = Search.query() + .eq(Element.ELT_EXTENSION, XmlStream.EXT_XMLSTREAM) + .neq(Element.ELT_EXTENSION, WebHarvestStream.EXT_WEBHARVESTSTREAM) + .criteria(); + + PagedResult<XmlStream> xmlStreams = wikittyProxy.findAllByCriteria(XmlStream.class, criteriaXmlStream); + result.addAll(xmlStreams.getAll()); + + // XmlStream + Criteria criteriaWebHarvestStream = Search.query() + .eq(Element.ELT_EXTENSION, XmlStream.EXT_XMLSTREAM) + .eq(Element.ELT_EXTENSION, WebHarvestStream.EXT_WEBHARVESTSTREAM) + .criteria(); + + PagedResult<WebHarvestStream> xmlWebHarvestStream = wikittyProxy.findAllByCriteria(WebHarvestStream.class, criteriaWebHarvestStream); + result.addAll(xmlWebHarvestStream.getAll()); + + return result; + } + + public List<WebHarvestStream> getAllWebHarvestStreams() { + if (log.isDebugEnabled()) { + log.debug("getAllWebHarvestStreams()"); + } + + Criteria criteria = Search.query() + .eq(Element.ELT_EXTENSION, WebHarvestStream.EXT_WEBHARVESTSTREAM) + .criteria(); + + PagedResult<WebHarvestStream> xmlStreams = wikittyProxy.findAllByCriteria(WebHarvestStream.class, criteria); + List<WebHarvestStream> all = xmlStreams.getAll(); + + List<WebHarvestStream> list = new ArrayList<WebHarvestStream>(); + list.addAll(all); + + return list; + } + + public URI getWebHarvestPreviewUrl(WebHarvestStream stream) throws VradiException { + String path = getWebHarvestPreviewPath(stream); + File previewFile = new File(path); + + // If doesnt exist, creating one + if (!previewFile.exists()) { + if (log.isDebugEnabled()) { + log.debug("Preview file doesnt exist, creating one for script path : " + path); + } + previewFile = createPreviewFile(stream); + } + + URI uri = previewFile.toURI(); + return uri; + } + + public String getWebHarvestPreviewUrlAsString(WebHarvestStream stream) throws VradiException { + String uri = getWebHarvestPreviewUrl(stream).toString(); + + if (log.isDebugEnabled()) { + log.debug("Previews url is : " + uri); + } + + return uri; + } + + public String getWebHarvestPreviewPath(WebHarvestStream stream) { + File scriptFile = new File(VradiServiceConfigurationHelper.getWebHarvestScriptDir(config) + + File.separator + stream.getScriptUrl()); + + String previewPath = VradiServiceConfigurationHelper.getWebHarvestPreviewDir(config) + + File.separator + + "Preview" + + scriptFile.getName(); + + if (log.isDebugEnabled()) { + log.debug("Previews path is : " + previewPath); + } + + return previewPath; + } + + public XmlStream getXmlStream(String xmlStreamId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getXmlStream(" + xmlStreamId + ")"); + } + + XmlStream xmlStream = wikittyProxy.restore(XmlStream.class, xmlStreamId); + return xmlStream; + } + + private static class BindingContext { + int dateParsingError = 0; + + int numberParsingError = 0; + + int nbCreated = 0; + } + + /** + * Create from from feed element. + * + * @param formType + * @param bindings + * @param feed + * @param namespace namespace for getting correct field with fieldnames + * @param bindingContext + * @return + */ + protected FormImpl createForm(WikittyExtension formType, List<XmlFieldBinding> bindings, + org.jdom.Element feed, Namespace namespace, BindingContext bindingContext) throws VradiException { + FormImpl form = new FormImpl(); + Wikitty wikitty = form.getWikitty(); + wikitty.addExtension(formType); + + for (XmlFieldBinding binding : bindings) { + String fqFormField = binding.getFormField(); + FieldType fieldType; + try { + fieldType = wikitty.getFieldType(fqFormField); + } catch (Exception e) { + continue; + } + + fillFormField(wikitty, fieldType, binding, feed, namespace, bindingContext); + } + + return form; + } + + /** + * Fill form with feed element. + * + * @param wikitty + * @param fieldType + * @param binding + * @param feed + * @param namespace namespace to get field from feed element + * @param bindingContext + */ + protected void fillFormField(Wikitty wikitty, FieldType fieldType, XmlFieldBinding binding, + org.jdom.Element feed, Namespace namespace, BindingContext bindingContext) throws VradiException { + + String fqFormField = binding.getFormField(); + Set<String> xmlFields = binding.getXmlField(); + + if (xmlFields == null || xmlFields.isEmpty()) { + // no mapping + String defaultValue = binding.getDefaultValue(); + fillFormField2(wikitty, fieldType, fqFormField, defaultValue, bindingContext); + return; + } + + for (String xmlField : xmlFields) { + org.jdom.Element child = feed.getChild(xmlField, namespace); + String feedValue = null; + + // get feed field text + if (child != null) { + feedValue = child.getTextTrim(); + } + + // get default value + if (feedValue == null || feedValue.isEmpty()) { + feedValue = binding.getDefaultValue(); + } + + fillFormField2(wikitty, fieldType, fqFormField, feedValue, bindingContext); + } + } + + private void fillFormField2(Wikitty wikitty, FieldType fieldType, String fqFormField, + String feedValue, BindingContext bindingContext) throws VradiException { + // if no value then return + if (feedValue == null || feedValue.isEmpty()) { + return; + } + + switch (fieldType.getType()) { + case DATE: + Date date = DateParser.parse(feedValue); + if (date != null) { + try { + wikitty.setFqField(fqFormField, WikittyUtil.formatDate(date)); + } catch (ParseException eee) { + throw new VradiException("Cant parse date " + date, eee); + } + } else { + bindingContext.dateParsingError++; + } + break; + + case NUMERIC: + if (NumberUtils.isNumber(feedValue)) { + Double value = Double.valueOf(feedValue); + wikitty.setFqField(fqFormField, value); + } else { + bindingContext.numberParsingError++; + } + break; + + default: + Object fieldValue = wikitty.getFqField(fqFormField); + String newValue = null; + + if (fieldValue != null) { + newValue = fieldValue + "\n" + feedValue; + } else { + newValue = feedValue; + } + + wikitty.setFqField(fqFormField, newValue); + } + } + + /** + * Creates and store forms from an {@code WebHarvestStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param webHarvestStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + public XmlStreamImportResult importFormsFromWebHarvestStream(WebHarvestStream webHarvestStream) throws VradiException { + + log.info("getFormsFromWebHarvestStream for " + webHarvestStream.getName()); + + // Create file + File previewFile = createPreviewFile(webHarvestStream, true); + + Document document = null; + try { + SAXBuilder sxb = new SAXBuilder(); + document = sxb.build(previewFile); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't read xml stream", e); + } + throw new VradiException("Can't read xml stream : ", e); + } + return getFormsFromStream(webHarvestStream, document); + } + + /** + * Creates file result of webharvest scrip + * + * @param webHarvestStream + * @return Preview file + * @throws VradiException for various possible errors + */ + public File createPreviewFile(WebHarvestStream webHarvestStream) throws VradiException { + return createPreviewFile(webHarvestStream, false); + } + + // Create file if necessary + protected File createPreviewFile(WebHarvestStream webHarvestStream, boolean override) throws VradiException { + String path = webHarvestStream.getScriptUrl(); + if (path == null) { + return null; + } + + // Get script path + path = VradiServiceConfigurationHelper.getWebHarvestPreviewDir(config) + + File.separator + + path; + + File scriptFile = new File(path); + + if (!override && scriptFile.exists()) { + return scriptFile; + } + + // Init webharvest + ScraperConfiguration scrapperConfig; + try { + scrapperConfig = new ScraperConfiguration(scriptFile); + } catch (FileNotFoundException eee) { + throw new VradiException("Cant open script " + webHarvestStream.getScriptUrl(), eee); + } + Scraper scraper = new Scraper(scrapperConfig, VradiServiceConfigurationHelper.getDataDir(config)); + + scraper.setDebug(log.isDebugEnabled()); + + scraper.addVariableToContext("url", webHarvestStream.getUrl()); + + long startTime = System.currentTimeMillis(); + scraper.execute(); + log.info("Script execution time elapsed: " + (System.currentTimeMillis() - startTime)); + + // takes variable created during execution + Variable resultVar = (Variable) scraper.getContext().get("result"); + String result = resultVar.toString(); + + result = result.replaceAll("&", "&"); + + File previewFile = new File(path); + + try { + FileUtils.writeStringToFile(previewFile, result); + log.info("Store preview for script " + scriptFile.getPath()); + } catch (IOException eee) { + log.error("Failed to write preview for script " + scriptFile.getName(), eee); + } + + return previewFile; + } + + /** + * Creates and store forms from an {@code XmlStream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param xmlStream stream to import + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + public XmlStreamImportResult importFormsFromXmlStream(XmlStream xmlStream) throws VradiException { + Document document; + try { + + // rome : but not done with rome :( + //SyndFeedInput input = new SyndFeedInput(); + //URL rssUrl = new URL(xmlStream.getUrl()); + //SyndFeed feed = input.build(new XmlReader(rssUrl)); + + SAXBuilder sxb = new SAXBuilder(false); + + // this prevent xerces to look for external dtd + sxb.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + + URL rssUrl = new URL(xmlStream.getUrl()); + log.info("Reading xmlStream url from: " + rssUrl); + document = sxb.build(rssUrl); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't read xml stream", e); + } + throw new VradiException("Can't read xml stream : ", e); + } + return getFormsFromStream(xmlStream, document); + } + + /** + * Creates and store forms from an {@code stream} by using the XmlStreamBinding + * to link xml stream field values with form fields. + * <p/> + * Input xmlStream is modified by this method (wikitty obselete). + * + * @param <E> xml stream type ({@link XmlStream} or {@link WebHarvestStream}). + * @param stream stream to import + * @param document of rss + * @return a structure containing : + * - the number of created forms + * - the number of already existing forms + * - the number of forms created with date parsing error + * - the number of forms created with number parsing error + * @throws VradiException for various possible errors + */ + public <E extends XmlStream> XmlStreamImportResult getFormsFromStream(E stream, Document document) throws VradiException { + + XmlStreamImportResult result = new XmlStreamImportResult(); + + if (log.isDebugEnabled()) { + log.debug("getFormsFromStream(" + stream.getName()); + } + + if (stream.getFormTypeName() == null) { + throw new VradiException("xmlStream.formTypeName is null"); + } + + WikittyExtension formType = formTypeManager.getFormType( + stream.getFormTypeName()); + if (formType == null) { + throw new VradiException("Extension of name xmlStream.formTypeName does not exists"); + } + + org.jdom.Element racine = document.getRootElement(); + // namespace should be used, otherwize, getChild(String) return + // nothing in some feeds: + // ex : http://www.gentoo.org/rdf/en/gentoo-news.rdf + // https://labs.libre-entreprise.org/export/rss_sfnews.php + Namespace namespace = racine.getNamespace(""); + List<org.jdom.Element> elements = null; + + // must start with ITEM : + // some feed have both channel and item + // http://www.gentoo.org/rdf/en/gentoo-news.rdf + if (racine.getChild(VradiConstants.ITEM, namespace) != null) { + elements = racine.getChildren(VradiConstants.ITEM, namespace); + } else if (racine.getChild(VradiConstants.CHANNEL, namespace) != null) { + org.jdom.Element channel = racine.getChild(VradiConstants.CHANNEL, namespace); + elements = channel.getChildren(VradiConstants.ITEM, namespace); + } else if (racine.getChild(VradiConstants.ENTRY, namespace) != null) { + elements = racine.getChildren(VradiConstants.ENTRY, namespace); + } + + if (elements == null) { + if (log.isWarnEnabled()) { + log.warn("Enable to find items or entries in stream"); + } + return result; + } + + List<Form> forms = new ArrayList<Form>(); + List<String> xmlFieldBindingIds = new ArrayList<String>(stream.getXmlFieldBinding()); + List<XmlFieldBinding> bindings = wikittyProxy.restore(XmlFieldBinding.class, xmlFieldBindingIds); + String formDateId = VradiConstants.FORM_ID_DATE_FORMAT.format(new Date()); + String toTreatId = formManager.getNonTraiteStatus().getWikittyId(); + BindingContext bindingContext = new BindingContext(); + + for (int index = 0; index < elements.size(); index++) { + org.jdom.Element feedElement = elements.get(index); + + // calculate element content sha1 sum + StringBuffer sb = new StringBuffer(); + List<org.jdom.Element> fields = feedElement.getChildren(); + for (org.jdom.Element field : fields) { + sb.append(field.getText()); + } + String contentSHA1Hash = StringUtil.encodeSHA1(sb.toString()); + + // check if one element with this hash already exists + Criteria criteria = Search.query().eq(Form.FQ_FIELD_FORM_IMPORTCONTENTHASH, contentSHA1Hash).criteria(); + criteria.setEndIndex(0); + PagedResult<Form> pagesResult = wikittyProxy.findAllByCriteria(Form.class, criteria); + if (pagesResult.getNumFound() > 0) { + // TODO EC20100928 sha1 collision found + // check form field to detect proper content collision + if (log.isWarnEnabled()) { + log.warn("SHA1 content collision detected"); + } + + // for now, just break + break; + } + + // create the form with the info from the xml stream + FormImpl form = createForm(formType, bindings, feedElement, namespace, bindingContext); + bindingContext.nbCreated++; + + form.setId(formDateId + form.getWikittyId()); + form.setXmlStream(stream.getWikittyId()); + form.setStatus(toTreatId); + form.setImportContentHash(contentSHA1Hash); + forms.add(form); + + if (forms.size() > 100) { + formManager.updateForms(forms, null); + forms.clear(); + } + } + + if (!forms.isEmpty()) { + formManager.updateForms(forms, null); + } + + result.setCreatedFormCount(bindingContext.nbCreated); + result.setDateParsingError(bindingContext.dateParsingError); + result.setNumberParsingError(bindingContext.numberParsingError); + + // equals to : elements.size() - result.getCreatedFormCount() + int alreadyExists = elements.size() - result.getCreatedFormCount(); + result.setAlreadyExistsFormCount(alreadyExists); + + // TODO EC-20100428 : redirect log output into file + if (log.isInfoEnabled()) { + log.info("Form import from stream, created = " + result.getCreatedFormCount()); + log.info("Form import from stream, already existing = " + result.getAlreadyExistsFormCount()); + log.info("Form import from stream, dateParsingError = " + result.getDateParsingError()); + log.info("Form import from stream, numberParsingError = " + result.getNumberParsingError()); + } + + return result; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/BindingManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ClientManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ClientManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ClientManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,462 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndContentImpl; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; +import com.sun.syndication.io.SyndFeedInput; +import com.sun.syndication.io.SyndFeedOutput; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.QueryMaker; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiException; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.io.File; +import java.io.FileWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * Class that contains the methods to retrieve the information + * related to the clients + * + * @author schorlet + * @version $Revision$ $Date$ + * @date 2010-01-22 20:18:29 + */ +public class ClientManager { + private static final Log log = LogFactory.getLog(ClientManager.class); + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + public ClientManager(ApplicationConfig config, WikittyProxy wikittyProxy) { + this.config = config; + this.wikittyProxy = wikittyProxy; + } + + /** + * Delete client, users associated and user groups association + * + * @param clientId to delete + * @throws VradiException throw vradiException if exception is occured + */ + public void deleteClient(String clientId) throws VradiException { + + List<User> users = getUsersByClient(clientId); + + for (User user : users) { + deleteUser(user.getWikittyId()); + } + wikittyProxy.delete(clientId); + } + + /** + * Delete users, and groups association + * + * @param userId to delete + * @throws VradiException throw vradiException if exception is occured + */ + public void deleteUser(String userId) throws VradiException { + + List<Group> groups = getGroupsForUser(userId); + for (Group group : groups) { + group.removeUser(userId); + } + + // Delete sending associated + Search search = Search.query(); + search = search.eq(Element.ELT_EXTENSION, Sending.EXT_SENDING); + search = search.eq(Sending.FQ_FIELD_SENDING_USER, userId); + Criteria criteria = search.criteria(); + + PagedResult<Sending> sendings = wikittyProxy.findAllByCriteria(Sending.class, criteria); + + List<Sending> all = sendings.getAll(); + List<String> sendingIds = new ArrayList<String>(); + for (Sending sending : all) { + String sendingId = sending.getWikittyId(); + sendingIds.add(sendingId); + } + + wikittyProxy.delete(sendingIds); + + // Remove sending from session + search = Search.query(); + search = search.eq(Element.ELT_EXTENSION, Session.EXT_SESSION); + search = search.eq(Session.FQ_FIELD_SESSION_SENDING, sendingIds); + criteria = search.criteria(); + + PagedResult<Session> sessionsResult = wikittyProxy.findAllByCriteria(Session.class, criteria); + + List<Session> sessions = sessionsResult.getAll(); + for (Session session : sessions) { + for (String sendingId : sendingIds) { + session.removeSending(sendingId); + } + } + + wikittyProxy.store(sessions); + wikittyProxy.delete(sendingIds); + + // Store groups + wikittyProxy.store(groups); + + // Delete users + wikittyProxy.delete(userId); + } + + /** + * Delete group + * + * @param groupId to delete + * @throws VradiException throw vradiException if exception is occured + */ + public void deleteGroup(String groupId) throws VradiException { + wikittyProxy.delete(groupId); + } + + public User getUser(String userId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getUser(" + userId + ")"); + } + + User user = wikittyProxy.restore(User.class, userId); + return user; + } + + public Client getClient(String clientId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getClient(" + clientId + ")"); + } + + Client client = wikittyProxy.restore(Client.class, clientId); + return client; + } + + public Group getGroup(String groupId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getGroup(" + groupId + ")"); + } + + Group group = wikittyProxy.restore(Group.class, groupId); + return group; + } + + public List<User> getGroupUsers(String groupId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getGroupUsers(" + groupId + ")"); + } + + List<User> users = new ArrayList<User>(); + Group group = getGroup(groupId); + + if (group != null && group.getUser() != null) { + ArrayList<String> userIds = new ArrayList<String>(group.getUser()); + List<User> restore = wikittyProxy.restore(User.class, userIds); + users.addAll(restore); + } + + return users; + } + + /** + * Find all users for a client. + * + * @param clientId client wikitty id + * @return all users for client + */ + public List<User> getUsersByClient(String clientId) { + + // Get user of client + Search search = Search.query().eq(User.FQ_FIELD_USER_CLIENT, clientId); + Criteria criteria = search.criteria(); + criteria.addSortAscending(User.FQ_FIELD_USER_NAME); + + PagedResult<User> usersResult = wikittyProxy.findAllByCriteria(User.class, criteria); + List<User> users = new ArrayList<User>(usersResult.getAll()); + return users; + } + + public List<Group> getGroupsForUser(String userId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("get Groups for user : " + userId); + } + + + Search search = Search.query(); + search = search.eq(Element.ELT_EXTENSION, Group.EXT_GROUP); + search = search.contains(Group.FQ_FIELD_GROUP_USER, userId); + Criteria criteria = search.criteria(); + + PagedResult<Group> groups = wikittyProxy.findAllByCriteria(Group.class, criteria); + + List<Group> all = groups.getAll(); + + if (log.isDebugEnabled()) { + log.debug(all.size() + " groups found"); + } + return all; + } + + public Client getClientByUserId(String userId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getClientByUserId(" + userId + ")"); + } + + User user = getUser(userId); + String clientId = user.getClient(); + + return getClient(clientId); + } + + public List<Client> getAllClients() throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getAllClients()"); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, Client.EXT_CLIENT); + Criteria criteria = search.criteria(); + + PagedResult<Client> clients = wikittyProxy.findAllByCriteria(Client.class, criteria); + List<Client> all = clients.getAll(); + + return new ArrayList<Client>(all); + } + + public List<User> getAllUsers() throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getAllUsers()"); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER); + Criteria criteria = search.criteria(); + + PagedResult<User> users = wikittyProxy.findAllByCriteria(User.class, criteria); + List<User> all = users.getAll(); + + return new ArrayList<User>(all); + } + + public List<Group> getAllGroups() throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getAllGroups()"); + } + + Search search = Search.query().eq(Element.ELT_EXTENSION, Group.EXT_GROUP); + Criteria criteria = search.criteria(); + + PagedResult<Group> groups = wikittyProxy.findAllByCriteria(Group.class, criteria); + List<Group> all = groups.getAll(); + + return new ArrayList<Group>(all); + } + + /** + * Archives the queries of a user, client or group in a RSS file. + * + * @param queryMaker the query maker whose queries are archived + * @throws VradiException throw vradiException if exception is occured + */ + public void archiveQueries(QueryMaker queryMaker) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("archiveQueries(id:" + queryMaker.getWikittyId() + + "; version:" + queryMaker.getWikittyVersion() + ")"); + } + + try { + String wikittyId = queryMaker.getWikittyId(); + Criteria criteria = Search.query().eq(Element.ELT_ID, wikittyId).criteria(); + QueryMaker restored = wikittyProxy.findByCriteria(QueryMaker.class, criteria); + + if (restored != null && restored.getQueries() != null) { + Set<String> restoredQueries = restored.getQueries(); + Set<String> updatedQueries = queryMaker.getQueries(); + + if (updatedQueries != null) { + Collection disjunction = CollectionUtils.disjunction(restoredQueries, updatedQueries); + if (disjunction.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Disjunction between new and old queryMaker is empty"); + } + return; + } + } + } else { + boolean restoredQueriesEmpty = restored == null + || restored.getQueries() == null + || restored.getQueries().isEmpty(); + + Set<String> updatedQueries = queryMaker.getQueries(); + boolean updatedQueriesEmpty = updatedQueries == null + || updatedQueries.isEmpty(); + + if (restoredQueriesEmpty && updatedQueriesEmpty) { + if (log.isDebugEnabled()) { + log.debug("Restored query and updated query are empty"); + } + return; + } + } + + String extName; + if (queryMaker instanceof Client) { + extName = Client.EXT_CLIENT; + + } else if (queryMaker instanceof User) { + extName = User.EXT_USER; + + } else if (queryMaker instanceof Group) { + extName = Group.EXT_GROUP; + + } else { + if (log.isDebugEnabled()) { + log.debug("Extention not found, stopping archiving queries"); + } + return; + } + + File queryHistoryDir = VradiServiceConfigurationHelper.getQueryHistoryDir(config); + File feedFile = new File(queryHistoryDir, wikittyId + ".rss"); + + SyndFeed feed; + if (feedFile.exists()) { + // read existing feed + SyndFeedInput input = new SyndFeedInput(); + feed = input.build(feedFile); + + } else { + feedFile.getParentFile().mkdirs(); + feedFile.createNewFile(); + Object queryMakerName = queryMaker.getField(extName, "name"); + + // creates new feed + feed = new SyndFeedImpl(); + feed.setFeedType("rss_2.0"); + feed.setTitle("Requetes de " + queryMakerName); + feed.setDescription("Historique des requetes"); + feed.setLink(""); + feed.setAuthor("Vradi"); + feed.setPublishedDate(new Date()); + } + + // creates new entry + SyndEntry entry = new SyndEntryImpl(); + entry.setPublishedDate(new Date()); + + if (queryMaker.getExtensionNames().contains(ModificationTag.EXT_MODIFICATIONTAG)) { + entry.setAuthor((String) queryMaker.getField( + ModificationTag.EXT_MODIFICATIONTAG, + ModificationTag.FIELD_MODIFICATIONTAG_LASTMODIFIER)); + } + + // add queries + StringBuffer sb = new StringBuffer("<ul>"); + Set<String> queries = queryMaker.getQueries(); + if (queries != null) { + for (String query : queries) { + try { + QueryBean queryBean = new QueryBean(query); + sb.append("<li>") + .append("<name><![CDATA[").append(queryBean.getName()).append("]]</name>") + .append("<description><![CDATA[").append(queryBean.getDescription()).append("]]</description>") + .append("<query><![CDATA[").append(queryBean.getQuery()).append("]]</query>") + .append("</li>"); + } catch (Exception e) { + log.warn(e.getMessage(), e); + } + } + } + sb.append("</ul>"); + + SyndContent syndQuery = new SyndContentImpl(); + syndQuery.setType("text/html"); + syndQuery.setValue(sb.toString()); + entry.setDescription(syndQuery); + + // add newly created entry to entries + List entries = feed.getEntries(); + entries.add(0, entry); + feed.setEntries(entries); + + Writer writer = new FileWriter(feedFile); + SyndFeedOutput output = new SyndFeedOutput(); + output.output(feed, writer); + writer.close(); + + if (log.isDebugEnabled()) { + log.debug("history recorded to: " + feedFile); + } + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't archive queries", eee); + } + throw new VradiException("Can't archive queries", eee); + } + } + + public String getQueryHistoryFile(String id) { + File queryHistoryDir = VradiServiceConfigurationHelper.getQueryHistoryDir(config); + File queryHistoryFile = new File(queryHistoryDir, id + ".rss"); + + if (!queryHistoryFile.exists()) { + return null; + } + + String dirName = queryHistoryDir.getName(); + + String filePath = queryHistoryFile.getAbsolutePath(); + int indexOf = filePath.indexOf(dirName); + + filePath = filePath.substring(indexOf); + return filePath; + } + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ClientManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/DateParser.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/DateParser.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/DateParser.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,166 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * Parseur de date utilisé lors de l'import des flux. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 10 mars 2010 12:02:21 + */ +public class DateParser { + + static private final Log log = LogFactory.getLog(DateParser.class); + + private static final String ND1 = "N.D."; + + private static final String ND2 = "---"; + + private static final TimeZone timezone = TimeZone.getTimeZone("GMT"); + + //public static final SimpleDateFormat defaultFormat = new SimpleDateFormat(); + // FIXME EC20100510 fix locale dependant tests + public static final SimpleDateFormat defaultFormat = new SimpleDateFormat("", Locale.FRANCE); + + public static final SimpleDateFormat usFormat = new SimpleDateFormat("", Locale.US); + + /** formats frequemments rencontrés. */ + public static final String[] frequentMasks = new String[]{ + // 10 avril 2010, à 12 heures + "dd MMMM yyyy', à' HH 'heures'", + // 5 mai 2010, à 12:00. + "dd MMMM yyyy', à' HH:mm'.'", + // 2 avril 2010, à 15 h 30 + "dd MMMM yyyy', à' HH 'h' mm", + // 2010-04-02 12:00:00 + "yyyy-MM-dd HH:mm:ss", + }; + + /** autres formats et variantes. */ + public static final String[] variantMasks = new String[]{ + // 23 mars 2010 + "dd MMMM yyyy", + // 23 mars 2010. + "dd MMMM yyyy'.'", + + // 10/03/2010 à 12:00 + "dd/MM/yyyy 'à' HH:mm", + // 10/03/2010 à 12:00. + "dd/MM/yyyy 'à' HH:mm'.'", + // 10/03/2010 à 12 heures + "dd/MM/yyyy 'à' HH 'heures'", + // 10/03/2010 + "dd/MM/yyyy", + + // 2010-04-02 12:00:00 + "yyyy-MM-dd HH:mm:ss", + // 2010-04-02 12:00 + "yyyy-MM-dd HH:mm", + // 2008-12-21 + "yyyy-MM-dd", + + // 10 avril 2010 à 12 heures + "dd MMMM yyyy 'à' HH 'heures'", + + // 5 mai 2010 à 12:00 + "dd MMMM yyyy 'à' HH:mm", + // 5 mai 2010 à 12:00. + "dd MMMM yyyy 'à' HH:mm'.'", + // 5 mai 2010, à 12:00 + "dd MMMM yyyy', à' HH:mm", + + // 2 avril 2010 à 15 h 30 + "dd MMMM yyyy 'à' HH 'h' mm", + // 2 avril 2010 à 15h30 + "dd MMMM yyyy 'à' HH'h'mm", + // 2 avril 2010, à 15h30 + "dd MMMM yyyy', à' HH'h'mm", + + // 1.e.r avril 2010, à 17 heures + "'1.e.r' MMMM yyyy', à' HH 'heures'", + // 1.e.r avril 2010 à 17 heures + "'1.e.r' MMMM yyyy 'à' HH 'heures'", + // 1er avril 2010, à 17 heures + "'1er' MMMM yyyy', à' HH 'heures'", + // 1er avril 2010 à 17 heures + "'1er' MMMM yyyy 'à' HH 'heures'" + }; + + /** formats en Locale.US. */ + public static final String[] usMasks = new String[]{ + // Sun, 29 Nov 2009 22:07:29 +0100 + "E, d MMM yyyy HH:mm:ss Z" + }; + + public static Date parse(String source) { + if (source == null) { + return null; + } + + String sourcetrim = source.trim(); + if (sourcetrim.isEmpty() || ND1.equals(sourcetrim) || ND2.equals(sourcetrim)) { + return null; + } + + Date date = parse(source, defaultFormat, frequentMasks); + if (date == null) { + date = parse(source, defaultFormat, variantMasks); + + if (date == null) { + date = parse(source, usFormat, usMasks); + } + } + + return date; + } + + public static Date parse(String source, SimpleDateFormat dateFormat, String... masks) { + dateFormat.setTimeZone(timezone); + for (String mask : masks) { + try { + dateFormat.applyPattern(mask); + Date date = dateFormat.parse(source); + return date; + } catch (ParseException eee) { + if (log.isWarnEnabled()) { + log.warn("Can't parse date", eee); + } + } + } + + return null; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/DateParser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,1537 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiConstants.SessionStatus; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.entities.FormLinkTypeEnum; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.SendingImpl; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.StatusImpl; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.DateUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.chorem.vradi.VradiConstants.FormStatus; +import static org.chorem.vradi.VradiConstants.SendingStatus; +import static org.nuiton.i18n.I18n._; + +/** + * Class containing the methods to manage the forms : + * - creation, update, deletion, retrieving + * - binding forms with clients whose queries are returning the forms + * + * @author schorlet + * @version $Revision$ $Date$ + */ +public class FormManager { + + private static final Log log = LogFactory.getLog(FormManager.class); + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + protected ThesaurusManager thesaurusManager; + + protected SearchManager searchManager; + + public FormManager(ApplicationConfig config, + WikittyProxy wikittyProxy, + ThesaurusManager thesaurusManager, + SearchManager searchManager) { + + this.config = config; + this.wikittyProxy = wikittyProxy; + this.thesaurusManager = thesaurusManager; + this.searchManager = searchManager; + } + + /** + * Update forms and attach forms to specified thesaurus. + * + * @param forms forms to save + * @param thesaurus thesaurus to attach form to (set empty set to clear thesaurus, null = no thesaurus management) + * @return forms saved + * @throws VradiException if exception occured + */ + public List<Form> updateForms(List<Form> forms, Set<String> thesaurus) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateForms(forms)"); + } + + if (forms == null || forms.isEmpty()) { + return forms; + } + + List<Thesaurus> entitiesToSave = new ArrayList<Thesaurus>(); + for (Form form : forms) { + if (log.isDebugEnabled()) { + log.debug("updating form: " + form.getId()); + } + + Date now = new Date(); + if (form.getCreationDate() == null) { + form.setCreationDate(now); + } else { + ModificationTag modificationTag = wikittyProxy.cast(form, ModificationTag.class); + modificationTag.setLastModified(now); + } + + // add specified thesaurus to form + if (thesaurus != null) { + + // search for thesaurus containing current form + // to remove it + List<Thesaurus> attachedThesauruses = thesaurusManager.getThesaurusAttachedToForm(form); + for (Thesaurus attachedThesaurus : attachedThesauruses) { + attachedThesaurus.removeAttachment(form.getId()); + if (!entitiesToSave.contains(attachedThesaurus)) { + entitiesToSave.add(attachedThesaurus); + } + } + + for (String thesaurusId : thesaurus) { + Thesaurus node = thesaurusManager.getThesaurus(thesaurusId); + + if (node.getAttachment() == null + || !node.getAttachment().contains(form.getWikittyId())) { + + node.addAttachment(form.getWikittyId()); + + if (!entitiesToSave.contains(node)) { + entitiesToSave.add(node); + } + } + } + } + } + + // also save form + List<Form> result = wikittyProxy.store(forms); + + if (!entitiesToSave.isEmpty()) { + wikittyProxy.store(entitiesToSave); + } + + return result; + } + + public Session getLastCloseSession() { + + // Get last close session to search after this one + Search search = Search.query().eq(Element.ELT_EXTENSION, Session.EXT_SESSION); + search.eq(Session.FQ_FIELD_SESSION_STATUS, + String.valueOf(VradiConstants.SessionStatus.SENT.getValue())) + .criteria(); + + Criteria criteria = search.criteria(); + criteria.addSortDescending(Session.FQ_FIELD_SESSION_SESSIONDATE); + + PagedResult<Session> result = wikittyProxy.findAllByCriteria(Session.class, criteria); + if (result == null || result.size() == 0) { + return null; + } + return result.getFirst(); + } + + public Session getLastOpenSession() throws VradiException { + + Session lastClose = getLastCloseSession(); + + String formatedLastCloseDate = null; + if (lastClose != null) { + + if (log.isDebugEnabled()) { + log.debug("Last closed session : " + lastClose.getSessionDate()); + } + try { + formatedLastCloseDate = WikittyUtil.formatDate(lastClose.getSessionDate()); + } catch (ParseException e) { + log.error("Cant parse date"); + } + } + Search search = Search.query().eq(Element.ELT_EXTENSION, Session.EXT_SESSION); + + if (formatedLastCloseDate != null) { + search.ge(Session.FQ_FIELD_SESSION_SESSIONDATE, + formatedLastCloseDate); + } + + search.or().eq(Session.FQ_FIELD_SESSION_STATUS, + String.valueOf(SessionStatus.ACTIVE.getValue())) + .eq(Session.FQ_FIELD_SESSION_STATUS, + String.valueOf(SessionStatus.STOPPED.getValue())) + .eq(Session.FQ_FIELD_SESSION_STATUS, + String.valueOf(SessionStatus.ERROR.getValue())); + + Criteria criteria = search.criteria(); + + criteria.addSortDescending(Session.FQ_FIELD_SESSION_SESSIONDATE); + + PagedResult<Session> result = wikittyProxy.findAllByCriteria(Session.class, criteria); + Session session = null; + if (result != null && result.size() > 0) { + session = result.getFirst(); + } + + if (log.isDebugEnabled() && session != null) { + log.debug("Last sessions found : " + session.getWikittyId() + " - " + + session.getSessionDate() + " with status : " + + session.getStatus()); + } + + return session; + } + + /** + * Find all session for specific date. + * + * @param sessionDate session date + * @return all session for date + * @throws VradiException if exception occured + */ + public List<Session> getSessions(Date sessionDate) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getSessions for date " + sessionDate.toString()); + } + Search search = Search.query().eq(Element.ELT_EXTENSION, Session.EXT_SESSION); + + search.bw(Session.FQ_FIELD_SESSION_SESSIONDATE, + getBeginOfDaySolrDate(sessionDate), + getEndOfDaySolrDate(sessionDate)); + + // Get result + Criteria criteria = search.criteria(); + List<Session> allSession = wikittyProxy.findAllByCriteria(Session.class, criteria).getAll(); + + if (log.isDebugEnabled()) { + log.debug(allSession.size() + " sessions found"); + } + + return allSession; + } + + /** + * Retourne la date a minuit au format solr. + * + * @param date + * @return + * @throws VradiException + */ + protected static String getBeginOfDaySolrDate(Date date) throws VradiException { + Date localDate = DateUtil.setMinTimeOfDay(date); + try { + return WikittyUtil.formatDate(localDate); + } catch (ParseException eee) { + throw new VradiException("Cant format date " + date, eee); + } + } + + /** + * Retourne la date a 23h59:59.999 au format solr. + * + * @param date + * @return + * @throws VradiException + */ + protected static String getEndOfDaySolrDate(Date date) throws VradiException { + Date localDate = DateUtil.setMaxTimeOfDay(date); + try { + return WikittyUtil.formatDate(localDate); + } catch (ParseException eee) { + throw new VradiException("Cant format date " + date, eee); + } + } + + /** + * Crée une nouvelle session initialisée. + * + * @return la session créée + * @throws VradiException + */ + public Session createNewSession() throws VradiException { + + Session lastSession = getLastOpenSession(); + if (lastSession != null) { + throw new VradiException(_("Already opened session on %tF", lastSession.getSessionDate())); + } + + // Get all session for this date + Date now = new Date(); + + // TODO EC201009089 ca sert a rien de toutes les récuperer pour avoir le dernier numéro + List<Session> sessionList = getSessions(now); + + // Calculate number af session for day + int num = sessionList.size() + 1; + + // create new session + if (log.isDebugEnabled()) { + log.debug("No session found, creating a new one with num : " + num); + } + + Session currentSession = new SessionImpl(); + currentSession.setSessionDate(now); + currentSession.setNum(num); + currentSession.setStatus(SessionStatus.ACTIVE.getValue()); + currentSession.setParagraph(VradiServiceConfigurationHelper.getSessionDefaultParagraph(config)); + + currentSession = wikittyProxy.store(currentSession); + + return currentSession; + } + + /** + * Recherche tous les formulaires non lié et les lie à la session + * demandée. + * + * @param currentSession session a remplir + * @return la session en argument + * @throws VradiException + */ + public Session bindForms(Session currentSession) throws VradiException { + + if (log.isDebugEnabled()) { + log.debug("bindForms " + currentSession.getNum() + " : " + currentSession.getSessionDate()); + } + + try { + // Throw exception if session is not active + if (!SessionStatus.isActive(currentSession)) { + throw new VradiException("Session is not active, abording"); + } + + // un sending = un utilsateur et ses formulaires + List<Sending> toSend = resetSendings(currentSession); + if (toSend == null) { + toSend = new ArrayList<Sending>(); + } + + // Restore updated session + currentSession = wikittyProxy.restore(Session.class, currentSession.getWikittyId()); + + // Only selected forms + String status = getSelectionneStatus().getWikittyId(); + + List<GroupForms> groupFormToSave = new ArrayList<GroupForms>(); + + // recherche de tous les executeurs de requette (client, groupes...) + // was all query make before + //List<QueryMaker> queryMakers = searchManager.findQueryMakersWithQueries(); + List<Group> groups = searchManager.findGroupsWithQueries(); + + // iterate on the group + for (Group group : groups) { + + // List of the forms to bind ( = not yet bound) + Set<String> formsIdsToBind = new HashSet<String>(); + + // normalement c'est pas null, sinon la requette findGroupsWithQueries + // marche pas + Set<String> queries = group.getQueries(); + + for (String queryEntry : queries) { + + try { + // Get query + QueryBean queryBean = new QueryBean(queryEntry); + String query = queryBean.getQuery(); + + // Create filter + Search filter = Search.query(); + filter.eq(Form.FQ_FIELD_INFOGENE_STATUS, status); + + // Limited on older inscription date + Search filterDateModification = filter.or(); + Date olderInscriptionDate = getOlderInscriptionDate(group.getUser()); + + // Limited on date modification + filterDateModification.isNull(ModificationTag.FQ_FIELD_MODIFICATIONTAG_LASTMODIFIED); + filterDateModification.ge(ModificationTag.FQ_FIELD_MODIFICATIONTAG_LASTMODIFIED, WikittyUtil.formatDate(olderInscriptionDate)); + + // Limited on date peremption + Search filterDatePeremption = filter.or(); + filterDatePeremption.isNull(Form.FQ_FIELD_FORM_DATEPEREMPTION); + filterDatePeremption.ge(Form.FQ_FIELD_FORM_DATEPEREMPTION, WikittyUtil.formatDate(new Date())); + + Criteria criteria = filter.criteria(); + + // create a new VradiFormPage to find all the forms corresponding to the query + FormPagedResult vradiFormPage = new FormPagedResult(); + + // Execute request + vradiFormPage = searchManager.findForms(query, criteria, vradiFormPage); + + // Extract result + Set<String> resultFormsIds = new HashSet<String>(vradiFormPage.getFormsIdsToShow()); + + if (log.isDebugEnabled()) { + log.debug("Query " + query + " return " + resultFormsIds.size() + " forms"); + } + + formsIdsToBind.addAll(resultFormsIds); + } catch (IOException eee) { + throw new VradiException("Can't parse group query", eee); + + } catch (UnsupportedQueryException eee) { + throw new VradiException("Can't execute group query", eee); + + } catch (ParseException eee) { + throw new VradiException("Cant format date : ", eee); + } + } + + // if some forms are to be bound, bind them + if (!formsIdsToBind.isEmpty()) { + + Set<String> userIds = group.getUser(); + if (userIds != null) { + List<User> users = wikittyProxy.restore(User.class, new ArrayList<String>(userIds)); + + for (User user : users) { + + // Create or find current sending for queryMaker + Sending sending = findExistingOrCreateSending(toSend, user); + + sending.setUser(user.getWikittyId()); + if (log.isDebugEnabled()) { + log.debug("Add user " + user.getWikittyId()); + } + + // Replace replace forms by previous + formsIdsToBind = repaceByPreviousReplacedForms(formsIdsToBind); + + ArrayList<String> formsIdsAsList = new ArrayList<String>(formsIdsToBind); + + Set<Form> formsToBind = new HashSet<Form>(wikittyProxy.restore(Form.class, formsIdsAsList)); + + // Remove already bound forms with queryMaker + formsToBind = removeAlreadyBound(currentSession, formsToBind, user); + + formsToBind = removeNotConcernedForms(sending, user, formsToBind); + if (log.isDebugEnabled()) { + log.debug("Adding " + formsToBind.size() + " forms to sending"); + } + + // If not empty + if (!formsToBind.isEmpty()) { + GroupForms groupForms = SendingHelper.createGroupForms(group, formsToBind); + groupFormToSave.add(groupForms); + sending.addGroupForms(groupForms.getWikittyId()); + if (log.isDebugEnabled()) { + log.debug("GroupForm created"); + } + + toSend.add(sending); + } + } + } + } + } + if (toSend.isEmpty()) { + return currentSession; + } + + for (Sending s : toSend) { + currentSession.addSending(s.getWikittyId()); + } + + // Store the session and sending + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + toSave.addAll(groupFormToSave); + toSave.addAll(toSend); + toSave.add(currentSession); + + wikittyProxy.store(toSave); + + // Restore session + currentSession = wikittyProxy.restore(Session.class, currentSession.getWikittyId()); + + if (log.isDebugEnabled()) { + Set<String> sending = currentSession.getSending(); + int size = sending == null ? 0 : sending.size(); + + log.debug("Saving session '" + currentSession.getSessionDate() + + "' number '" + currentSession.getNum() + + "' status '" + SessionStatus.getStatus(currentSession.getStatus()).getDescription() + + "' with '" + size + + "' sending"); + } + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't bind form : ", e); + } + throw new VradiException("Can't bind form : ", e); + } + return currentSession; + } + + /** + * Use to replace forms by previous replace forms + * + * @param resultFormsIds to inspect + * @return return forms with previous replace forms + */ + protected Set<String> repaceByPreviousReplacedForms(Set<String> resultFormsIds) { + List<String> copy = new ArrayList<String>(resultFormsIds); + for (String formId : copy) { + String previousReplaceFormId = getPreviousReplaceForm(formId); + if (previousReplaceFormId != null) { + if (log.isDebugEnabled()) { + Form form = wikittyProxy.restore(Form.class, formId); + Form previousReplaceForm = wikittyProxy.restore(Form.class, previousReplaceFormId); + + log.debug("[Replace] for form : '" + form.getObjet() + "' id '" + form.getId() + "' by previous '" + previousReplaceForm.getId() + "'"); + } + + resultFormsIds.remove(formId); + resultFormsIds.add(previousReplaceFormId); + } + } + return resultFormsIds; + } + + protected List<Sending> resetSendings(Session currentSession) throws VradiException { + + Set<String> sendingsIds = currentSession.getSending(); + if (sendingsIds == null) { + return null; + } + + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + + // Reset sendings + List<Sending> sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingsIds)); + + Set<String> sendingIdsToDelete = new HashSet<String>(); + Set<String> groupFormIdToDelete = new HashSet<String>(); + for (Sending sending : new ArrayList<Sending>(sendings)) { + + if (sending != null) { + + // If its not a manual add, restart with an empty sending + // Remove all binded forms + Set<String> concernedGroup = sending.getGroupForms(); + if (concernedGroup != null) { + List<String> concernedGroupList = new ArrayList<String>(concernedGroup); + groupFormIdToDelete.addAll(concernedGroupList); + sending.clearGroupForms(); + } + + // Restore all added forms manualy + Set<String> groupFormsAddedIds = sending.getAddedGroupForms(); + if (groupFormsAddedIds != null) { + for (String groupFormsAddedId : groupFormsAddedIds) { + + // Other that deleted + GroupForms groupFormsAdded = wikittyProxy.restore(GroupForms.class, groupFormsAddedId); + Set<String> addedForms = SendingHelper.extractForms(groupFormsAdded); + Set<String> deletedForms = SendingHelper.extractForms(wikittyProxy, sending.getDeletedGroupForms()); + + addedForms.removeAll(deletedForms); + + GroupForms groupForms = SendingHelper.createGroupForms(groupFormsAdded.getGroup(), addedForms); + toSave.add(groupForms); + sending.addGroupForms(groupForms.getWikittyId()); + } + } + + // Delete empty sending + Set<String> deletedGroupForm = sending.getDeletedGroupForms(); + if ((concernedGroup == null || concernedGroup.isEmpty()) && + (groupFormsAddedIds == null || groupFormIdToDelete.isEmpty()) && + (deletedGroupForm == null || deletedGroupForm.isEmpty())) { + + String sendingId = sending.getWikittyId(); + sendingIdsToDelete.add(sendingId); + currentSession.removeSending(sendingId); + sendings.remove(sending); + } + } + } + wikittyProxy.delete(groupFormIdToDelete); + wikittyProxy.delete(sendingIdsToDelete); + + toSave.add(currentSession); + toSave.addAll(sendings); + wikittyProxy.store(toSave); + + sendingsIds = currentSession.getSending(); + if (sendingsIds == null) { + return null; + } + return wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingsIds)); + } + + protected Set<Form> removeNotConcernedForms(Sending sending, User user, Set<Form> finalFormsToBind) { + + // Get user begin search date + Date beginSearchDate = user.getBeginSearchDate(); + + // Check date + for (Form f : new ArrayList<Form>(finalFormsToBind)) { + + // Using last modification date + ModificationTag formTag = wikittyProxy.cast(f, ModificationTag.class); + Date lastModifier = formTag.getLastModified(); + + // Get peremption date + Date peremptionDate = f.getDatePeremption(); + + // If not enable, not attach forms + if (!user.getEnable()) { + if (log.isDebugEnabled()) { + log.debug("Removing form '" + + f.getObjet() + + "' because user (" + + user.getName() + + ") is not enable"); + } + + finalFormsToBind.remove(f); + } + + // If date of peremption of form is pass + if (lastModifier != null && lastModifier.before(beginSearchDate)) { + if (log.isDebugEnabled()) { + log.debug("Removing form '" + + f.getObjet() + + "' because date of last modification (" + + peremptionDate + + ") is pass for user : " + + user.getName()); + } + + finalFormsToBind.remove(f); + } + + // If date of peremption of form is pass + if (peremptionDate != null && peremptionDate.before(new Date())) { + if (log.isDebugEnabled()) { + log.debug("Removing form '" + + f.getObjet() + + "' because date of peremption (" + + peremptionDate + + ") is pass for user : " + + user.getName()); + } + + finalFormsToBind.remove(f); + } + + // Remove deleted if are reassociated + Set<String> deletedFormsIds = SendingHelper.extractForms(wikittyProxy, sending.getDeletedGroupForms()); + String fid = f.getWikittyId(); + if (deletedFormsIds.contains(fid)) { + finalFormsToBind.remove(f); + if (log.isDebugEnabled()) { + log.debug("Removing form '" + + f.getObjet() + + "' because form is already deleted" + + " is pass for user : " + + user.getName()); + } + } + } + return finalFormsToBind; + } + + /** + * Retourne la liste {@code forms} d'origine en ayant filtré les formulaires + * qui ont déja été lié. + * + * @param currentSession + * @param forms + * @param queryMaker + * @return + */ + protected Set<Form> removeAlreadyBound(Session currentSession, Set<Form> forms, User user) { + Set<String> formIds = new HashSet<String>(); + + // Extract formIds + for (Form form : forms) { + formIds.add(form.getWikittyId()); + } + + // Recherche d'un sending existant + String userId = user.getWikittyId(); + + // Search all groupForms concerned + Search searchGroupForm = Search.query(); + + // FIXME sletellier 24/10/10 : find a way to join tow requests + searchGroupForm.contains(GroupForms.FQ_FIELD_GROUPFORMS_FORM, formIds); + List<GroupForms> groupForms = wikittyProxy.findAllByCriteria(GroupForms.class, searchGroupForm.criteria()).getAll(); + List<String> groupFormsId = new ArrayList<String>(); + + for (GroupForms gf : groupForms) { + if (gf != null) { + groupFormsId.add(gf.getWikittyId()); + } + } + + Search searchSending = Search.query(); + + Set<String> sendingIds = currentSession.getSending(); + + // Except currents + if (sendingIds != null) { + for (String currentSendingId : sendingIds) { + searchSending.neq(Element.ELT_ID, currentSendingId); + } + } + + // If its attached or deleted + Search formSearch = searchSending.or(); + for (String groupFormId : groupFormsId) { + formSearch.eq(Sending.FQ_FIELD_SENDING_GROUPFORMS, groupFormId); + formSearch.eq(Sending.FQ_FIELD_SENDING_DELETEDGROUPFORMS, groupFormId); + } + + // And attached to client / user / group + searchSending.eq(Sending.FQ_FIELD_SENDING_USER, userId); + + // Find + Criteria criteria = searchSending.criteria(); + + PagedResult<Sending> pagedResult = wikittyProxy.findAllByCriteria(Sending.class, criteria); + + for (Sending send : pagedResult.getAll()) { + Set<String> formsIds = SendingHelper.extractForms(wikittyProxy, send.getGroupForms()); + if (formsIds != null) { + formIds.removeAll(formsIds); + } + Set<String> deletedIds = SendingHelper.extractForms(wikittyProxy, send.getDeletedGroupForms()); + if (deletedIds != null) { + formIds.removeAll(deletedIds); + } + } + if (log.isDebugEnabled()) { + log.debug("Rest " + formIds.size() + " forms"); + } + + List<Form> result = wikittyProxy.restore(Form.class, new ArrayList<String>(formIds)); + return new HashSet<Form>(result); + } + + /** + * Retourne la plus ancienne date du query maker si c'est une date + * ou des user gu groupe si c'est un groupe. + * + * @param queryMaker queryMaker + * @return + */ + protected Date getOlderInscriptionDate(Set<String> usersIds) { + Date result = new Date(); + + if (usersIds != null) { + for (String userId : usersIds) { + User user = wikittyProxy.restore(User.class, userId); + + Date beginSearchDate = user.getBeginSearchDate(); + if (beginSearchDate != null && result.after(DateUtil.setMinTimeOfDay(beginSearchDate))) { + result = beginSearchDate; + } + if (log.isDebugEnabled()) { + log.debug("The older inscription date for user " + user.getName() + " is " + result); + } + } + + if (log.isDebugEnabled()) { + log.debug("The older inscription date " + result); + } + } + return result; + } + + public List<Sending> createAllSending(String currentSessionId, Group group, List<String> formsIdsToBind) { + return createAllSending(currentSessionId, group, new HashSet<String>(formsIdsToBind)); + } + + public List<Sending> createAllSending(String currentSessionId, Group group, Set<String> formsIdsToBind) { + Session currentSession = wikittyProxy.restore(Session.class, currentSessionId); + List<Sending> result = new ArrayList<Sending>(); + + Set<String> userIds = group.getUser(); + if (userIds != null) { + List<User> users = wikittyProxy.restore(User.class, new ArrayList<String>(userIds)); + + for (User user : users) { + Sending sending = createUserSending(currentSession, group, user, formsIdsToBind); + if (sending != null) { + result.add(sending); + } + } + } + return result; + } + + public Sending createUserSending(String currentSessionId, User user, List<String> formsIdsToBind) { + return createUserSending(currentSessionId, user, new HashSet<String>(formsIdsToBind)); + } + + public Sending createUserSending(String currentSessionId, User user, Set<String> formsIdsToBind) { + Session currentSession = wikittyProxy.restore(Session.class, currentSessionId); + + return createUserSending(currentSession, null, user, formsIdsToBind); + } + + protected Sending createUserSending(Session currentSession, Group groupConcerned, User user, Set<String> formsIdsToBind) { + + // Create or find current sending for queryMaker + Sending sending = findExistingOrCreateSending(currentSession, user); + + sending.setUser(user.getWikittyId()); + if (log.isDebugEnabled()) { + log.debug("Add user " + user.getWikittyId()); + } + + // If not empty + if (!formsIdsToBind.isEmpty()) { + + List<GroupForms> groupFormsList = new ArrayList<GroupForms>(); + + GroupForms groupForms = SendingHelper.createGroupForms(groupConcerned, formsIdsToBind); + groupFormsList.add(groupForms); + sending.addGroupForms(groupForms.getWikittyId()); + if (log.isDebugEnabled()) { + log.debug("GroupForm created"); + } + + // If is an manual add, keep it + if (log.isDebugEnabled()) { + log.debug("Adding added " + formsIdsToBind.size() + " forms for user : " + + user.getName()); + } + + // Create an other to keep it in state + GroupForms groupFormsAdded = SendingHelper.createGroupForms(groupConcerned, formsIdsToBind); + groupFormsList.add(groupFormsAdded); + sending.addAddedGroupForms(groupFormsAdded.getWikittyId()); + + currentSession.addSending(sending.getWikittyId()); + + // store datas + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + + // update sending status if deleted + if (SendingStatus.isDeleted(sending)) { + sending.setStatus(SendingStatus.TO_SEND.getValue()); + } + + toSave.addAll(groupFormsList); + toSave.add(sending); + + toSave.add(currentSession); + wikittyProxy.store(toSave); + + return wikittyProxy.restore(Sending.class, sending.getWikittyId()); + } + return null; + } + + public List<Sending> removeAllSending(String sessionId, List<String> formsIds, Group group) throws VradiException { + return removeAllSending(sessionId, new HashSet<String>(formsIds), group); + } + + public List<Sending> removeAllSending(String sessionId, Set<String> formsIds, Group group) throws VradiException { + List<Sending> result = new ArrayList<Sending>(); + + Set<String> userIds = group.getUser(); + if (userIds != null) { + List<User> users = wikittyProxy.restore(User.class, new ArrayList<String>(userIds)); + for (User user : users) { + Sending sending = removeSending(sessionId, formsIds, group, user); + + if (sending != null) { + result.add(sending); + } + } + return wikittyProxy.store(result); + } + return Collections.EMPTY_LIST; + } + + public Sending removeSending(String sessionId, List<String> formsIds, User user) throws VradiException { + return removeSending(sessionId, new HashSet<String>(formsIds), null, user); + } + + protected Sending removeSending(String sessionId, Set<String> formsIds, Group group, User user) throws VradiException { + try { + Session session = wikittyProxy.restore(Session.class, sessionId); + Set<String> sendingSet = session.getSending(); + List<String> sendingList = new ArrayList<String>(); + if (sendingSet != null) { + sendingList = new ArrayList<String>(sendingSet); + } + + List<Sending> sendings = wikittyProxy.restore(Sending.class, sendingList); + + for (Sending sending : sendings) { + + // Only for sendings to send + if (sending != null && SendingStatus.isToSend(sending)) { + if (user.getWikittyId().equals(sending.getUser())) { + boolean formAreRemoved = false; + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(sending.getGroupForms())); + + Set<String> formsIdsRestored = new HashSet<String>(); + for (GroupForms gf : groupForms) { + if (gf != null) { + + for (String formId : formsIds) { + + if (gf.getForm() != null && gf.getForm().contains(formId)) { + // Remove + gf.removeForm(formId); + formAreRemoved = true; + } + } + if (gf.getForm() != null) { + formsIdsRestored.addAll(gf.getForm()); + } + } + } + if (!formAreRemoved) { + return sending; + } + + // Add group concerned + if (log.isDebugEnabled()) { + log.debug("Group concerned for sending of user '" + user.getName() + "' : " + (group == null ? "null" : group.getName())); + } + + GroupForms groupFormsDeleted = SendingHelper.createGroupForms(group, formsIds); + sending.addDeletedGroupForms(groupFormsDeleted.getWikittyId()); + + // If is empty, set deleted + if (formsIdsRestored == null || formsIdsRestored.isEmpty()) { + sending.setStatus(SendingStatus.DELETED.getValue()); + } + + // Save all + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + toSave.addAll(groupForms); + toSave.add(groupFormsDeleted); + toSave.add(sending); + + wikittyProxy.store(toSave); + + // Try to close session if it correct all errors + closeSessionIfNoMoreError(session); + return wikittyProxy.restore(Sending.class, sending.getWikittyId()); + } + } + } + return null; + } catch (Exception eee) { + throw new VradiException("Cant remove forms for user " + user.getName(), eee); + } + } + + /** + * Check if template file form extension name in param + * + * @param forms to remove + * @return false if no session is opened + * @throws VradiException + */ + public boolean removeFormsFromSession(String sessionId, List<String> formsIds) throws VradiException { + return removeFormsFromSession(sessionId, new HashSet<String>(formsIds)); + } + + /** + * Check if template file form extension name in param + * + * @param forms to remove + * @return false if no session is opened + * @throws VradiException + */ + public boolean removeFormsFromSession(String sessionId, Set<String> formsIds) throws VradiException { + try { + Session session = wikittyProxy.restore(Session.class, sessionId); + if (session == null) { + return false; + } + + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + Set<String> sendingsIds = session.getSending(); + if (sendingsIds == null) { + return false; + } + List<Sending> sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingsIds)); + for (Sending sending : sendings) { + + // Only for sendings to send + if (sending != null && SendingStatus.isToSend(sending)) { + + // Remove forms + List<GroupForms> groupsForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(sending.getGroupForms())); + boolean isDeleted = false; + for (GroupForms gf : groupsForms) { + for (String formId : formsIds) { + + if (gf != null) { + + if (gf.getForm() != null && gf.getForm().contains(formId)) { + gf.removeForm(formId); + isDeleted = true; + } + } + } + } + if (isDeleted) { + toSave.addAll(groupsForms); + GroupForms groupFormsDeleted = SendingHelper.createGroupForms((String) null, formsIds); + sending.addDeletedGroupForms(groupFormsDeleted.getWikittyId()); + toSave.add(groupFormsDeleted); + + if (SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()).isEmpty()) { + sending.setStatus(SendingStatus.DELETED.getValue()); + } + toSave.add(sending); + } + } + } + // Store + wikittyProxy.store(toSave); + + // Try to close session if it correct all errors + closeSessionIfNoMoreError(session); + return true; + } catch (Exception eee) { + throw new VradiException("Cant remove all forms for session", eee); + } + } + + /** + * Recherche dans la session l'object sending qui correspond au query maker + * donné ou en crée une nouvelle s'il n'a pas été trouvé. + * <p/> + * Le sending retourné n'est pas affecter au query maker. + * + * @param currentSession + * @param queryMaker + * @return + */ + protected Sending findExistingOrCreateSending(Session currentSession, User user) { + + // Restore existing sending in session + Set<String> sendingsId = currentSession.getSending(); + + // restore sendings + List<Sending> sendings; + if (sendingsId != null) { + sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingsId)); + } else { + sendings = new ArrayList<Sending>(); + } + + return findExistingOrCreateSending(sendings, user); + } + + /** + * Recherche dans la session l'object sending qui correspond au query maker + * donné ou en crée une nouvelle s'il n'a pas été trouvé. + * <p/> + * Le sending retourné n'est pas affecter au query maker. + * + * @param currentSession + * @param queryMaker + * @return + */ + protected Sending findExistingOrCreateSending(List<Sending> sendings, User user) { + + // chargement, si il existe, du sending concernant + // ce client / user / group + for (Sending sending : sendings) { + if (sending != null) { + String userId = user.getWikittyId(); + if (sending != null && userId.equals(sending.getUser())) { + + if (log.isDebugEnabled()) { + log.debug("Sending is existing for queryMaker : " + user.getName()); + } + + return sending; + } + } + } + return createNewSending(user); + } + + protected Sending createNewSending(User user) { + + // Set properties in default + SendingImpl newSending = new SendingImpl(); + newSending.setSentDate(null); + newSending.setReceptionDate(null); + newSending.setParagraph(VradiConstants.DEFAULT_SENDING_PARAGRAPH); + newSending.setReceptionProof(!user.getValidEmail()); + newSending.setStatus(SendingStatus.TO_SEND.getValue()); + newSending.setUser(user.getWikittyId()); + + if (log.isDebugEnabled()) { + log.debug("Sending dont exist for queryMaker : " + user + ", creating one"); + } + return newSending; + } + + public Sending revertDeletion(String sendingId, List<String> formsIdsToUpdate) { + return revertDeletion(sendingId, null, new HashSet<String>(formsIdsToUpdate), true); + } + + protected Sending revertDeletion(String sendingId, String groupId, Set<String> formsIdsToUpdate, boolean save) { + Sending sending = wikittyProxy.restore(Sending.class, sendingId); + + Set<String> groupFormIds = sending.getDeletedGroupForms(); + if (groupFormIds != null) { + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormIds)); + + boolean isDeleted = false; + List<String> toDeleteIds = new ArrayList<String>(); + for (GroupForms gf : groupForms) { + if (gf != null) { + Set<String> formsInGroupForms = gf.getForm(); + for (String formId : formsIdsToUpdate) { + if (formsInGroupForms != null && + !formsInGroupForms.isEmpty() && + formsInGroupForms.contains(formId)) { + + gf.removeForm(formId); + isDeleted = true; + + // If empty, delete it + if (gf.getForm().isEmpty()) { + String toDelete = gf.getWikittyId(); + sending.removeDeletedGroupForms(toDelete); + toDeleteIds.add(toDelete); + } + } + } + } + } + if (!isDeleted) { + return sending; + } + GroupForms groupFormsCreated = SendingHelper.createGroupForms(groupId, formsIdsToUpdate); + sending.addGroupForms(groupFormsCreated.getWikittyId()); + wikittyProxy.delete(toDeleteIds); + wikittyProxy.store(groupForms); + wikittyProxy.store(groupFormsCreated); + + // Update status if was deleted + if (SendingStatus.isDeleted(sending)) { + sending.setStatus(SendingStatus.TO_SEND.getValue()); + } + if (save) { + return wikittyProxy.store(sending); + } + return sending; + } + return sending; + } + + public Sending revertUserDeletion(String sessionId, String userId, String formId) { + return revertUserDeletion(sessionId, null, userId, formId, true); + } + + protected Sending revertUserDeletion(String sessionId, String groupId, String userId, String formId, boolean save) { + Session session = wikittyProxy.restore(Session.class, sessionId); + + Set<String> sendingIds = session.getSending(); + if (sendingIds == null && !SessionStatus.isToSend(session)) { + return null; + } + + List<Sending> sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingIds)); + for (Sending sending : sendings) { + + if (userId.equals(sending.getUser())) { + Set<String> formIds = new HashSet<String>(); + formIds.add(formId); + return revertDeletion(sending.getWikittyId(), groupId, formIds, save); + } + } + return null; + } + + public List<Sending> revertGroupDeletion(String sessionId, String groupId, String formId) { + List<Sending> result = new ArrayList<Sending>(); + + Group group = wikittyProxy.restore(Group.class, groupId); + + Set<String> userIds = group.getUser(); + if (userIds == null) { + return result; + } + + for (String userId : userIds) { + Sending sending = revertUserDeletion(sessionId, groupId, userId, formId, false); + + result.add(sending); + } + return wikittyProxy.store(result); + } + + /** + * Try to close session if rest no error and save + * + * @param session to close + * @return session closed if rest no error + */ + protected Session closeSessionIfNoMoreError(Session session) { + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + Set<String> sendingSet = session.getSending(); + List<String> sendingList = new ArrayList<String>(); + if (sendingSet != null) { + sendingList = new ArrayList<String>(sendingSet); + } + + List<Sending> sendings = wikittyProxy.restore(Sending.class, sendingList); + + session = closeSessionIfNoMoreError(session, sendings); + + return wikittyProxy.store(session); + } + + /** + * Try to close session if rest no error and save + * + * @param session to close + * @return session closed if rest no error + */ + protected Session closeSessionIfNoMoreError(Session session, List<Sending> sendings) { + + int sentCnt = 0; + for (Sending sending : sendings) { + if (sending != null && SendingStatus.isInError(sending)) { + return session; + } + if (sending == null || SendingStatus.isSent(sending)) { + sentCnt++; + } + } + + boolean allAreSent = sentCnt == sendings.size(); + boolean noOneAreSent = sentCnt == 0; + + if (allAreSent) { + // Close if all are sent + session.setStatus(SessionStatus.SENT.getValue()); + session.setSessionDate(new Date()); + session.setSessionLogs(StringUtils.EMPTY); + } else if (noOneAreSent) { + + // Return to active if no one are sent + session.setStatus(SessionStatus.ACTIVE.getValue()); + session.setSessionDate(new Date()); + session.setSessionLogs(StringUtils.EMPTY); + } + return session; + } + + public void deleteSession(String sessionId) throws VradiException { + + if (sessionId == null) { + return; + } + + // Restore session + Session sessionToDelete = wikittyProxy.restore(Session.class, sessionId); + + if (!SessionStatus.isActive(sessionToDelete)) { + throw new VradiException("Session is not active, abording"); + } + List<String> idToDelete = new ArrayList<String>(); + + // Delete all sending asssociated + Set<String> sendingsIds = sessionToDelete.getSending(); + if (sendingsIds != null) { + List<Sending> sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingsIds)); + for (Sending sending : sendings) { + if (sending != null) { + Set<String> toDelete = sending.getAddedGroupForms(); + if (toDelete != null) { + idToDelete.addAll(toDelete); + } + toDelete = sending.getDeletedGroupForms(); + if (toDelete != null) { + idToDelete.addAll(toDelete); + } + toDelete = sending.getGroupForms(); + if (toDelete != null) { + idToDelete.addAll(toDelete); + } + } + } + idToDelete.addAll(sendingsIds); + } + idToDelete.add(sessionId); + + // Delete session + wikittyProxy.delete(idToDelete); + } + + public Session getSessionOfSending(String sendingId) throws VradiException { + try { + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Session.EXT_SESSION) + .contains(Session.FQ_FIELD_SESSION_SENDING, sendingId).criteria(); + + return wikittyProxy.findByCriteria(Session.class, criteria); + } catch (Exception eee) { + log.error("Cant restore session for sending '" + sendingId + "' : ", eee); + throw new VradiException("Cant restore session for sending '" + sendingId + "' : ", eee); + } + } + + /* + * Status + */ + public Status getStatus(String statusId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getStatus(" + statusId + ")"); + } + Status status = wikittyProxy.restore(Status.class, statusId); + return status; + } + + public List<Status> getStatuses(List<String> statusIds) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getStatuses(statusIds)"); + } + List<Status> statuses = wikittyProxy.restore(Status.class, statusIds); + return new ArrayList<Status>(statuses); + } + + public List<Status> createDefaultStatuses() throws VradiException { + if (log.isDebugEnabled()) { + log.debug("createDefaultStatuses()"); + } + + List<Status> all = new ArrayList<Status>(); + all.add(getNonTraiteStatus()); + all.add(getNonSelectionneStatus()); + all.add(getPreselectionneStatus()); + all.add(getSelectionneStatus()); + + return new ArrayList<Status>(all); + } + + public Status getNonTraiteStatus() { + return getOrCreateStatus(FormStatus.NON_TRAITE); + } + + public Status getNonSelectionneStatus() { + return getOrCreateStatus(FormStatus.NON_SELECTIONNE); + } + + public Status getPreselectionneStatus() { + return getOrCreateStatus(FormStatus.PRESELECTIONNE); + } + + public Status getSelectionneStatus() { + return getOrCreateStatus(FormStatus.SELECTIONNE); + } + + protected Status getOrCreateStatus(VradiConstants.FormStatus type) { + if (log.isDebugEnabled()) { + log.debug("getOrCreateStatus(" + type.getName() + ")"); + } + Search search = Search.query() + .eq(Element.ELT_EXTENSION, Status.EXT_STATUS) + .eq(Status.FQ_FIELD_STATUS_NAME, type.getName()); + + Criteria criteria = search.criteria(); + + Status status = wikittyProxy.findByCriteria(Status.class, + criteria); + + if (status == null) { + log.warn("Status not found creating : " + type.getName()); + + status = new StatusImpl(); + status.setName(type.getName()); + status.setValue(type.getValue()); + status.setDescription(type.getDescription()); + status.setModifiable(false); + + status = wikittyProxy.store(status); + } + return status; + } + + public List<Status> updateStatuses(List<Status> statuses) + throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateStatuses(statuses)"); + } + + try { + List<Status> result = wikittyProxy.store(statuses); + return result; + + } catch (Exception eee) { + log.error("Cant update statuses : ", eee); + throw new VradiException("Cant update statuses : ", eee); + } + } + + public Status updateStatus(Status status) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateStatus(status)"); + } + + try { + status = wikittyProxy.store(status); + return status; + + } catch (Exception eee) { + log.error("Cant update status : ", eee); + throw new VradiException("Cant update status : ", eee); + } + } + + public boolean deleteStatuses(List<String> statusIds) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("deleteStatus(" + statusIds + ")"); + } + boolean result = true; + + for (String id : statusIds) { + // Check if status is in use + Search search = Search.query().eq(Element.ELT_EXTENSION, Form.EXT_FORM) + .eq(Form.FQ_FIELD_INFOGENE_STATUS, id); + Criteria criteria = search.criteria(); + PagedResult<Form> forms = wikittyProxy.findAllByCriteria(Form.class, criteria); + if (forms.size() > 0) { + result = false; + } else { + try { + wikittyProxy.delete(id); + } catch (Exception e) { + log.error("Cant delete status : ", e); + throw new VradiException("Cant delete status : ", e); + } + } + } + return result; + } + + protected List<User> getUsersOfClient(String clientId) { + + Search search = Search.query().eq(Element.ELT_EXTENSION, User.EXT_USER) + .eq(User.FQ_FIELD_USER_CLIENT, clientId); + Criteria criteria = search.criteria(); + + PagedResult<User> usersPageResult = wikittyProxy.findAllByCriteria(User.class, criteria); + return new ArrayList<User>(usersPageResult.getAll()); + + } + + public List<String> getRelatedFormsLinkIds(String formId) { + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, FormLink.EXT_FORMLINK) + .eq(FormLink.FQ_FIELD_FORMLINK_FROMFORM, formId) + .eq(FormLink.FQ_FIELD_FORMLINK_TYPE, FormLinkTypeEnum.RELATED.getValueAsString()).criteria(); + + List<FormLink> formLinks = wikittyProxy.findAllByCriteria(FormLink.class, criteria).getAll(); + return extractWikittyId(formLinks); + } + + public List<String> getReplaceFormsLinkIds(String formId) throws VradiException { + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, FormLink.EXT_FORMLINK) + .eq(FormLink.FQ_FIELD_FORMLINK_FROMFORM, formId) + .eq(FormLink.FQ_FIELD_FORMLINK_TYPE, FormLinkTypeEnum.REPLACE.getValueAsString()).criteria(); + + List<FormLink> formLinks = wikittyProxy.findAllByCriteria(FormLink.class, criteria).getAll(); + return extractWikittyId(formLinks); + } + + public boolean isReplaceForm(String formId) { + return getPreviousReplaceFormLink(formId) != null; + } + + public String getPreviousReplaceForm(String formId) { + FormLink replaceFormLink = getPreviousReplaceFormLink(formId); + if (replaceFormLink == null) { + return null; + } + return replaceFormLink.getFromForm(); + } + + protected FormLink getPreviousReplaceFormLink(String formId) { + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, FormLink.EXT_FORMLINK) + .eq(FormLink.FQ_FIELD_FORMLINK_TOFORM, formId) + .eq(FormLink.FQ_FIELD_FORMLINK_TYPE, FormLinkTypeEnum.REPLACE.getValueAsString()).criteria(); + + return wikittyProxy.findByCriteria(FormLink.class, criteria); + } + + protected List<String> extractWikittyId(List<FormLink> formLinks) { + List<String> formsLinkIds = new ArrayList<String>(); + for (FormLink formLink : formLinks) { + formsLinkIds.add(formLink.getWikittyId()); + } + return formsLinkIds; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormTypeManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormTypeManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormTypeManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,437 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants.FormTypeTemplateEnum; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.services.VradiException; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.jdom.output.XMLOutputter; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Class containing the metods to manage the form types : + * - creation, update, retrieving + * - cache filling + * + * @author schorlet + * @version $Revision$ $Date$ + * @date 2010-01-28 08:08:53 + */ +public class FormTypeManager { + private static final Log log = LogFactory.getLog(FormTypeManager.class); + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + public FormTypeManager(ApplicationConfig config, WikittyProxy wikittyProxy) { + this.config = config; + this.wikittyProxy = wikittyProxy; + } + + /** + * Retrieves the form type whose name is the parameter 'name' + * + * @param name the name of the form type we want to retrieve + * @return the form type whose name is the parameter + */ + public WikittyExtension getFormType(String name) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getFormType(" + name + ")"); + } + + try { + WikittyExtension wikittyExtension = wikittyProxy.restoreExtensionLastVersion(name); + return wikittyExtension; + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't get form type", eee); + } + throw new VradiException("Can't get form type", eee); + } + } + + /** + * Retrieves the fields of the form type whose name is the parameter 'name' + * + * @param name the name of the form type we want to retrieve the fields + * @return a map containing the field names and their type + */ + public Map<String, FieldType> getFormTypeFields(String name) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getFormTypeFields(" + name + ")"); + } + + try { + WikittyExtension extension = getFormType(name); + Map<String, FieldType> fields = new HashMap<String, FieldType>(); + + for (String fieldName : extension.getFieldNames()) { + fields.put(fieldName, extension.getFieldType(fieldName)); + } + + return fields; + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't get form type fields", eee); + } + throw new VradiException("Can't get form type fields", eee); + } + } + + /** + * Updates the form type whose name is 'name' + * + * @param name the name of the form type to update + * @param fields the new fields of the form type + * @param requires the new requires of the form type + * @param tagValues the new tag values of the form type + * @return the form type up to date + */ + public WikittyExtension updateFormType(String name, Map<String, FieldType> fields, + String requires, Map<String, String> tagValues) throws VradiException { + + if (log.isDebugEnabled()) { + log.debug("updateFormType(" + name + ", fields, requires, tagValues)"); + } + + if (name != null) { + try { + WikittyExtension lastVersion = getFormType(name); + String newVersion = null; + + if (lastVersion != null) { + newVersion = WikittyUtil.incrementMajorRevision(lastVersion.getVersion()); + } else { + newVersion = WikittyUtil.DEFAULT_VERSION; + } + + WikittyExtension extension = new WikittyExtension(name, newVersion, + requires, new LinkedHashMap<String, FieldType>(fields)); + + if (tagValues != null) { + for (Map.Entry<String, String> entry : tagValues.entrySet()) { + extension.addTagValue(entry.getKey(), entry.getValue()); + } + } + + List<WikittyExtension> extensions = Arrays.asList(extension); + wikittyProxy.storeExtension(extensions); + + log.info(String.format("FormType named %s saved with id: %s and version: %s", + name, extension.getId(), newVersion)); + + return extension; + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't update form type", eee); + } + throw new VradiException("Can't update form type", eee); + } + } + + return null; + } + + /** + * Update the form type given in parameter + * + * @param extension the form type to update + * @return the form type up to date + */ + public WikittyExtension updateFormType(WikittyExtension extension, String templateName) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("updateFormType(" + extension.toDefinition() + ")"); + } + try { + + if (templateName != null) { + extension.addTagValue(FormTypeTemplateEnum.FIELD_TEMPLATE_ATTRIBUTE.getValue(), templateName); + } + + Map<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + + for (String fieldName : extension.getFieldNames()) { + FieldType fieldType = extension.getFieldType(fieldName); + fields.put(fieldName, fieldType); + } + + WikittyExtension updated = updateFormType(extension.getName(), fields, + extension.getRequires(), extension.getTagValues()); + + return updated; + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't update form type", eee); + } + throw new VradiException("Can't update form type", eee); + } + } + + /** + * @param extensionName + * @param templateName + * @return + */ + public File getTemplate(String extensionName, String templateName) { + if (templateName == null) { + return null; + } + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File template = new File(new File(templatesDir, extensionName), templateName); + return template.exists() ? template : null; + } + + /** + * Get the template file names associated with the specified extension. + * + * @param extension extension + * @return extension's template file names + */ + public Collection<String> getTemplateFilenames(WikittyExtension extension) { + + Collection<String> filesNames = null; + + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File templateDir = new File(templatesDir, extension.getName()); + + File[] result = templateDir.listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + return !file.isDirectory() && !file.getName().endsWith(".xml"); + } + }); + + if (result != null) { + filesNames = new ArrayList<String>(); + for (File file : result) { + String fileName = file.getName(); + + if (log.isDebugEnabled()) { + log.debug("Template for formType '" + extension.getName() + "' found : " + fileName); + } + filesNames.add(fileName); + } + } + return filesNames; + } + + /** + * Get association between template fields and extension fields. + * + * @param extensionName + * @param templateName + * @return association map or {@code null} is there is no association yet + * @throws VradiException + */ + public Map<String, String> getAssociatedFields(String extensionName, + String templateName) throws VradiException { + + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File extensionTemplateDir = new File(templatesDir, extensionName); + File templateFieldsFile = new File(extensionTemplateDir, templateName + ".xml"); + + // no association file found, return null + if (!templateFieldsFile.isFile()) { + return null; + } + + // here file does exists, read contents + Map<String, String> fieldMap = new HashMap<String, String>(); + Document document; + try { + SAXBuilder sxb = new SAXBuilder(); + document = sxb.build(templateFieldsFile); + + Element root = document.getRootElement(); + for (Object child : root.getChildren(FormTypeTemplateEnum.FIELD_ELEMENT.getValue())) { + Element field = (Element) child; + String templateField = + field.getAttributeValue(FormTypeTemplateEnum.FIELD_TEMPLATE_ATTRIBUTE.getValue()); + String extensionField = + field.getAttributeValue(FormTypeTemplateEnum.FIELD_EXTENSION_ATTRIBUTE.getValue()); + fieldMap.put(templateField, extensionField); + } + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Impossible d'associer les champs", eee); + } + throw new VradiException("Can't read association file", eee); + } + + return fieldMap; + } + + /** + * Save association between template fields and user selected fields + * into external xml field next to template. + * <p/> + * Xml file is created a first call. + * + * @param extensionName + * @param templateName + * @param fieldMap + * @throws VradiException + */ + public void setAssociatedFields(String extensionName, String templateName, + Map<String, String> fieldMap) throws VradiException { + + File templatesDir = VradiServiceConfigurationHelper.getTemplatesDir(config); + File templateDir = new File(templatesDir, extensionName); + templateDir.mkdirs(); + File targetFile = new File(templateDir, templateName + ".xml"); + + // load content + Document document; + try { + + // load or create dom tree + if (targetFile.isFile()) { + SAXBuilder sxb = new SAXBuilder(); + document = sxb.build(targetFile); + } else { + Element root = new Element(FormTypeTemplateEnum.FIELDS_ELEMENT.getValue()); + document = new Document(root); + } + + // write new content + Element root = document.getRootElement(); + root.removeChildren(FormTypeTemplateEnum.FIELD_ELEMENT.getValue()); + + for (Map.Entry<String, String> field : fieldMap.entrySet()) { + Element child = new Element(FormTypeTemplateEnum.FIELD_ELEMENT.getValue()); + child.setAttribute(FormTypeTemplateEnum.FIELD_TEMPLATE_ATTRIBUTE.getValue(), + field.getKey()); + if (field.getValue() != null) { + child.setAttribute(FormTypeTemplateEnum.FIELD_EXTENSION_ATTRIBUTE.getValue(), + field.getValue()); + } + root.addContent(child); + } + + XMLOutputter xmlOuputter = new XMLOutputter(); + Writer writer = new FileWriter(targetFile); + xmlOuputter.output(document, writer); + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't save extension fields template association", eee); + } + throw new VradiException("Can't save extension fields template association", eee); + } + } + + /** + * Check if a form type name already exists. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + public boolean isFormTypeExists(String formTypeName) throws VradiException { + boolean result = false; + WikittyExtension extension = wikittyProxy.restoreExtensionLastVersion(formTypeName); + if (extension != null) { + result = true; + } + return result; + } + + /** + * Create new form type. + * + * @param formTypeName form type name + * @return new created wikitty extension + * @throws VradiException if name is not valid + */ + public WikittyExtension createFormType(String formTypeName) throws VradiException { + + // check name characters + if (formTypeName == null) { + throw new VradiException("Can't create new form type with null name !"); + } + + // check name characters + if (!formTypeName.matches("\\w+")) { + throw new VradiException("Form name contains invalid characters : " + formTypeName); + } + + // check unicity + if (isFormTypeExists(formTypeName)) { + throw new VradiException("Form name \"" + formTypeName + "\" already exists !"); + } + + WikittyExtension formType; + + try { + formType = new WikittyExtension(formTypeName, + WikittyUtil.DEFAULT_VERSION, + Form.EXT_FORM, new LinkedHashMap<String, FieldType>()); + + wikittyProxy.storeExtension(formType); + } catch (WikittyException ex) { + throw new VradiException("Can't create form type", ex); + } + + return formType; + } + + public String getFormTypeTemplateName(WikittyExtension extension) { + String result = extension == null ? + null : extension.getTagValue(FormTypeTemplateEnum.FIELD_TEMPLATE_ATTRIBUTE.getValue()); + + if (log.isDebugEnabled()) { + log.debug("Template name for form type '" + extension.getName() + "' is : " + result); + } + return result; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/FormTypeManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,605 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.AutoDetectParser; +import org.apache.tika.sax.BodyContentHandler; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiException; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +import javax.activation.DataHandler; +import javax.activation.DataSource; +import javax.activation.FileDataSource; +import javax.mail.Authenticator; +import javax.mail.BodyPart; +import javax.mail.Flags; +import javax.mail.Folder; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.SendFailedException; +import javax.mail.Session; +import javax.mail.Store; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import javax.mail.search.FlagTerm; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Properties; + +import static org.chorem.vradi.VradiConstants.SendingStatus; +import static org.nuiton.i18n.I18n._; + +/** + * Mailing manager. + * <p/> + * Handle: + * <ul> + * <li>mail imap sending/receiving</li> + * </ul> + * + * @author Yolpo, kmorin, chatellier + */ +public class MailingManager { + + private static final Log log = LogFactory.getLog(MailingManager.class); + + protected static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + public MailingManager(ApplicationConfig config, WikittyProxy wikittyProxy) { + this.config = config; + this.wikittyProxy = wikittyProxy; + } + + /** + * Sends an email to the specified recipient with the specified subject + * and the specified message and the specified forms PDF. + * + * @param recipient the email address of the recipient + * @param subject mail subject + * @param message mail content + * @param forms the list of forms to add to the mail + * @param receptionProof if true, ask for a reception proof + * @param attachedFiles files to attach + * @return the message id of the email sent + * @throws VradiException + */ + public String postMail(String recipient, String subject, + String message, List<Form> forms, boolean receptionProof, + Collection<File> attachedFiles) + throws VradiException { + + if (StringUtils.isBlank(recipient) + || message == null && (forms == null || forms.isEmpty())) { + if (log.isWarnEnabled()) { + log.warn(_("Nothing to send : %s", recipient)); + } + return null; + } + String result; + + // TODO EC-20100505 use Session.getDefaultInstance() + // and common Properties form receiving/sending mails ! + Properties props = new Properties(); + props.put("mail.smtp.host", VradiServiceConfigurationHelper.getSmtpHost(config)); + props.put("mail.smtp.port", VradiServiceConfigurationHelper.getSmtpPort(config)); + //props.put("mail.smtp.auth", "true"); + //props.put("mail.smtp.socketFactory.port", config.getSmtpPort()); + //props.put("mail.smtp.socketFactory.class", SSL_FACTORY); + //props.put("mail.smtp.socketFactory.fallback", "false"); + //props.put("mail.debug", config.isMailDebug()); + + Session session = Session.getInstance(props, + new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication( + VradiServiceConfigurationHelper.getMailUser(config), + VradiServiceConfigurationHelper.getMailPassword(config)); + } + }); + + // EC-20100427 : attention, ca affiche le contenu des pdf joint + // c'est absolument illisible + //session.setDebug(log.isDebugEnabled()); + + // create a message + MimeMessage msg = new MimeMessage(session); + + try { + // set the from and to address + InternetAddress addressFrom = new InternetAddress( + VradiServiceConfigurationHelper.getMailFrom(config), + VradiServiceConfigurationHelper.getMailFromName(config)); + + msg.setFrom(addressFrom); + + InternetAddress addressTo = new InternetAddress(recipient); + msg.addRecipient(Message.RecipientType.TO, addressTo); + + if (receptionProof) { + // Optional : You can also set your custom headers in the Email if you Want + msg.addHeader("Return-Receipt-To", VradiServiceConfigurationHelper.getMailFrom(config)); + msg.addHeader("Disposition-Notification-To", VradiServiceConfigurationHelper.getMailFrom(config)); + } + + Multipart multiparts = new MimeMultipart(); + + // create the message part + MimeBodyPart msgBodyPart = new MimeBodyPart(); + msgBodyPart.setText(message); + multiparts.addBodyPart(msgBodyPart); + + //counter to count the number of attachments + int count = 0; + + // manage pdf attachments + if (forms != null) { + + for (Form form : forms) { + File formFile = getGeneratedPdfFile(form); + + if (formFile.exists()) { + // Part two is attachment + MimeBodyPart msgCurrentPdfPart = new MimeBodyPart(); + // default is set to application/octet-stream + msgCurrentPdfPart.setHeader("Content-Type", "application/pdf"); + DataSource source = new FileDataSource(formFile); + msgCurrentPdfPart.setDataHandler(new DataHandler(source)); + msgCurrentPdfPart.setFileName(formFile.getName()); + multiparts.addBodyPart(msgCurrentPdfPart); + //add an attachment + count++; + } else { + if (log.isWarnEnabled()) { + log.warn("No pdf attachment found for form : " + form.getObjet()); + } + } + } + } + + if (count == 0) { + throw new VradiException(_("vradi.error.sending.noAttachedPDF")); + } + + // Manage session attached files + if (attachedFiles != null && !attachedFiles.isEmpty()) { + for (File file : attachedFiles) { + String mineType; + try { + mineType = getMineType(file); + } catch (Exception eee) { + log.error("Failled to get mine type of file : " + file.getName(), eee); + // default is set to application/octet-stream + mineType = "application/octet-stream"; + } + MimeBodyPart msgCurrentPdfPart = new MimeBodyPart(); + msgCurrentPdfPart.setHeader("Content-Type", mineType); + DataSource source = new FileDataSource(file); + msgCurrentPdfPart.setDataHandler(new DataHandler(source)); + msgCurrentPdfPart.setFileName(file.getName()); + multiparts.addBodyPart(msgCurrentPdfPart); + + if (log.isInfoEnabled()) { + log.info("Sending with attached file : " + file.getName()); + } + } + } else { + if (log.isInfoEnabled()) { + log.info("Sending with no attached file"); + } + } + + // Put parts in message + msg.setContent(multiparts); + + // Setting the Subject and Content Type + msg.setSubject(subject); + + try { + Transport.send(msg); + } catch (MessagingException eee) { + if (log.isErrorEnabled()) { + log.error("Cant send mail", eee); + } + + // match SMTPAddressFailedException && SMTPSendFailedException + if (eee.getCause() instanceof SendFailedException) { + SendFailedException exception = (SendFailedException) eee.getCause(); + throw new VradiException(_("SMTP fail to send mail :\n(%s)", exception.getLocalizedMessage()), eee); + } + + throw new VradiException("Can't send message", eee); + } + + if (log.isDebugEnabled()) { + log.debug("MessageID: " + msg.getMessageID()); + } + result = msg.getMessageID(); + + } catch (MessagingException eee) { + if (log.isErrorEnabled()) { + log.error("Can't generate message", eee); + } + throw new VradiException(_("vradi.error.sending.send", eee.getMessage())); + } catch (UnsupportedEncodingException eee) { + if (log.isErrorEnabled()) { + log.error("Can't generate message", eee); + } + throw new VradiException(_("vradi.error.sending.generation", eee.getMessage())); + } + return result; + } + + /** + * Receives the emails and check if some are error emails or reception proofs + * and treat them in consequence. + * + * @throws VradiException + */ + public void receiveMails() throws VradiException { + try { + // mail from mailer daemon are supposed to be + // delivery error + //String mailerDeamonAddress = config.getMailerDaemonEmail(); + + // TODO EC-20100505 use Session.getDefaultInstance() + // and common Properties form receiving/sending mails ! + Properties props = new Properties(); + String imapHost = VradiServiceConfigurationHelper.getImapHost(config); + if (imapHost == null) { + log.warn("imap is not configured, abording"); + return; + } + + final String mailUser = VradiServiceConfigurationHelper.getMailUser(config); + int imapPort = VradiServiceConfigurationHelper.getImapPort(config); + props.put("mail.imap.host", imapHost); + props.put("mail.imap.auth", "true"); + props.put("mail.imap.user", mailUser); + props.put("mail.imap.port", imapPort); + + //props.put("mail.imap.starttls.enable", "true"); + //props.put("mail.imap.socketFactory.port", config.getImapPort()); + //props.put("mail.imap.socketFactory.class", DummySSLSocketFactory.class.getName()); + //props.put("mail.imap.socketFactory.fallback", "false"); + + //props.put("mail.imap.ssl.enable", "true"); + //props.put("mail.imap.ssl.port", config.getImapPort()); + //props.put("mail.imap.ssl.trust", "true"); + //props.put("mail.imap.ssl.socketFactory.class", DummySSLSocketFactory.class.getName()); + //props.put("mail.imap.ssl.socketFactory.fallback", "false"); + + props.put("mail.store.protocol", "imap"); + + Session session = Session.getInstance(props, + new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication( + mailUser, + VradiServiceConfigurationHelper.getMailPassword(config)); + } + }); + + // Récupère la "messagerie" et se connecte + Store store = session.getStore("imap"); + store.connect( + imapHost, + mailUser, + VradiServiceConfigurationHelper.getMailPassword(config)); + + // Récupère le fichier "Boite de réception" et l'ouvre + Folder folder = store.getFolder("INBOX"); + folder.open(Folder.READ_WRITE); + + FlagTerm flagTerm = new FlagTerm(new Flags(Flags.Flag.SEEN), false); + Message messages[] = folder.search(flagTerm); + + for (Message message : messages) { + // pour chaque message, on regarde les messages de type + // multipart, et plus particulierement leur pieces jointe. + // different cas apres le parcours de toutes les "part" + if (message.getContentType().startsWith("multipart/")) { + + // FIXME EC-20100506 , normalement tous les mails + // doivent être marqué comme lu + // mais dans le cas ou plusieurs vradi test les mails + // qu'il n'ont potentiellement pas envoyé + // on ne marque que ceux qu'il ont pu traiter + boolean markAsRead = false; + + if (log.isDebugEnabled()) { + log.debug("Testing message " + Arrays.toString(message.getHeader("Message-ID")) + " as multipart"); + } + + Multipart multiPart = (Multipart) message.getContent(); + + String errorMessage = null; + String errorMessageId = null; + String originalMessageID = null; + for (int index = 0; index < multiPart.getCount(); ++index) { + BodyPart bodyPart = multiPart.getBodyPart(index); + if (log.isDebugEnabled()) { + log.debug("Part " + index + " : " + bodyPart.getContentType()); + } + + // first delivery failure part + if ("message/delivery-status".equals(bodyPart.getContentType())) { + // Diagnostic-Code is part of the content + String content = getStreamContent(bodyPart.getInputStream()); + errorMessage = getHeaderValueInContent("Diagnostic-Code", content); + } + + // second delivery failure part + if ("text/rfc822-headers".equals(bodyPart.getContentType())) { + String content = getStreamContent(bodyPart.getInputStream()); + errorMessageId = getHeaderValueInContent("Message-ID", content); + } + + // response for reception proof + if (bodyPart.getContentType().startsWith("message/disposition-notification")) { + String content = getStreamContent(bodyPart.getInputStream()); + originalMessageID = getHeaderValueInContent("Original-Message-ID", content); + } + } + + // si on a eu un un message message/delivery-status et un + // message/rfc822 + if (StringUtils.isNotEmpty(errorMessage) && StringUtils.isNotEmpty(errorMessageId)) { + // put this message into file + if (log.isInfoEnabled()) { + log.info("Error message received for message " + errorMessageId); + log.info(" error description : " + errorMessage); + } + + Sending sending = getSendingByMessageID(errorMessageId, wikittyProxy); + if (sending != null) { + sending.setStatus(SendingStatus.ERROR + .getValue()); + wikittyProxy.store(sending); + + // FIXME EC20100506 mark all mails as read + markAsRead = true; + } else { + if (log.isWarnEnabled()) { + log.warn("Can't find sending for message id : " + errorMessageId); + } + } + } + + // cas de l'accusé de reception + else if (StringUtils.isNotEmpty(originalMessageID)) { + // put this message into file + if (log.isInfoEnabled()) { + log.info("Proof notification received for message " + originalMessageID); + } + + Sending sending = getSendingByMessageID(originalMessageID, wikittyProxy); + if (sending != null) { + if (SendingStatus.isWaitingReceptionProof(sending)) { + sending.setStatus(SendingStatus.RECEIVED.getValue()); + sending.setReceptionDate(new Date()); + wikittyProxy.store(sending); + setValidEmailForUser(sending); + + // FIXME EC20100506 mark all mails as read + markAsRead = true; + } else { + if (log.isWarnEnabled()) { + log.warn("Received a reception proof for a sending with non reception proof waiting status"); + } + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't find sending for message id : " + originalMessageID); + } + } + } + + // mark message as READ + // FIXME EC20100506 mark all mails as read + message.setFlag(Flags.Flag.SEEN, markAsRead); + } else { + if (log.isWarnEnabled()) { + log.warn("Mail inbox contains non multipart mails !"); + } + } + } + + folder.close(true); + store.close(); + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't recieve messages", e); + } + throw new VradiException("Can't recieve messages", e); + } + + } + + /** + * Set {@link User#FQ_FIELD_USER_VALIDEMAIL} attribute for User associated with sending. + * + * @param sending + */ + protected void setValidEmailForUser(Sending sending) { + + String userId = sending.getUser(); + User user = wikittyProxy.restore(User.class, userId); + + // update valid email field only is necessary + if (user != null && !user.getValidEmail()) { + if (log.isInfoEnabled()) { + log.info("User email " + user.getEmail() + " has been validated"); + } + user.setValidEmail(true); + wikittyProxy.store(user); + } + } + + /** + * Convert an input stream to String. + * + * @param inputStream + * @return + * @throws IOException + */ + protected String getStreamContent(InputStream inputStream) throws IOException { + StringBuilder sb = new StringBuilder(); + String line; + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + while ((line = reader.readLine()) != null) { + sb.append(line).append("\n"); + } + } finally { + inputStream.close(); + } + return sb.toString(); + } + + /** + * Find a header definition in mail content. + * <p/> + * Exemple: + * <pre> + * Original-Message-ID: <1833582695.1.1272991628810.JavaMail.chatellier@genux> + * Diagnostic-Code: smtp; 550 5.1.1 <toto@codelutin.com>: Recipient address + * rejected: User unknown in local recipient table + * Message-ID: <804992706.5.1272991629788.JavaMail.chatellier@genux> + * </pre> + * + * @param headerName + * @param content + * @return + */ + protected String getHeaderValueInContent(String headerName, String content) { + String result = null; + + String headerText = headerName + ":"; + int firstIndex = content.indexOf(headerText) + headerText.length(); + int lastIndex = content.indexOf("\n", firstIndex); + if (lastIndex == -1) { + // case EOF + lastIndex = content.length(); + } + + result = content.substring(firstIndex, lastIndex); + result = result.trim(); + + // TODO EC-20100505 multilines header + + return result; + } + + /** + * Find first sending entity with given messageID. + * + * @param messageID message id to find sending + * @param proxy wikitty proxy + * @return {@link Sending} or {@code null} if none found + */ + protected static Sending getSendingByMessageID(String messageID, WikittyProxy proxy) { + + Sending result = null; + + // find sending with wikitty criteria + Search search = Search.query(); + search.eq(Element.ELT_EXTENSION, Sending.EXT_SENDING).eq( + Sending.FQ_FIELD_SENDING_MESSAGEID, messageID); + Criteria criteria = search.criteria(); + + PagedResult<Sending> sendingsResult = proxy.findAllByCriteria( + Sending.class, criteria); + + List<Sending> sendingList = sendingsResult.getAll(); + if (sendingList.size() == 1) { + result = sendingList.get(0); + } + + return result; + } + + /** + * Return generated pdf file path containing form wikitty id and form version. + * + * @param form form + * @return generated pdf files + */ + public File getGeneratedPdfFile(Form form) { + String filename = form.getWikittyId() + "-" + form.getWikittyVersion() + ".pdf"; + File pdfDir = VradiServiceConfigurationHelper.getPdfDir(config); + File result = new File(pdfDir, filename); + return result; + } + + protected String getMineType(File file) throws IOException, SAXException, TikaException { + FileInputStream is = new FileInputStream(file); + ContentHandler contenthandler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + metadata.set(Metadata.RESOURCE_NAME_KEY, file.getName()); + AutoDetectParser parser = new AutoDetectParser(); + parser.parse(is, contenthandler, metadata); + String result = metadata.get(Metadata.CONTENT_TYPE); + log.info("Mine type of " + file.getName() + " is : " + result); + return result; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,620 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.QueryMaker; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.search.CompareFilter; +import org.chorem.vradi.services.search.Filter; +import org.chorem.vradi.services.search.FilterList; +import org.chorem.vradi.services.search.RangeFilter; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.chorem.vradi.services.search.VradiQueryParser; +import org.nuiton.util.DateUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.WikittyTreeNode; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.nuiton.wikitty.search.operators.Like; +import org.nuiton.wikitty.storage.solr.WikittySolrConstant; + +import java.text.DateFormat; +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.Set; +import java.util.regex.Pattern; + +/** + * Class containing the methods to manage the form research + * + * @author schorlet + * @version $Revision$ $Date$ + * @date 2010-01-29 12:40:26 + */ +public class SearchManager { + private static final Log log = LogFactory.getLog(SearchManager.class); + + protected WikittyProxy wikittyProxy; + + protected ThesaurusManager thesaurusManager; + + private static final DateFormat frenchDateFormat = DateFormat.getDateInstance( + DateFormat.SHORT, Locale.FRANCE); + + private static final DateFormat numericDateFormat = new SimpleDateFormat("yyyyMMdd", Locale.FRANCE); + + /** + * Match dd/mm/yyyy, requiring leading zeros. + * <p/> + * Match the pattern but not the validity of the date, so that <code>01/01/0000</code> will match. + */ + private static final Pattern frenchDateFormatPattern = + Pattern.compile("^(3[01]|[12][0-9]|0[1-9])/(1[0-2]|0[1-9])/[0-9]{4}$"); + + /** Match yyyymmdd, requiring leading zeros. */ + private static final Pattern numericDateFormatPattern = + Pattern.compile("^[0-9]{4}(1[0-2]|0[1-9])(3[01]|[12][0-9]|0[1-9])$"); + + /** + * Match UUID pattern, eg. 32 hexadecimal digits, displayed in 5 groups separated by hyphens, + * in the form 8-4-4-4-12 for a total of 36 characters. + */ + private static final Pattern uuidPattern = + Pattern.compile("^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"); + + /** Match yyyy-mm-ddUUID pattern. */ + private static final Pattern formIdPattern = + Pattern.compile("^[0-9]{4}-(1[0-2]|0[1-9])-(3[01]|[12][0-9]|0[1-9])([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$"); + + /** Alias pour {@link ModificationTag#FIELD_MODIFICATIONTAG_LASTMODIFIER}. */ + public static final String ALIAS_LAST_MODIFIER = "modificateur"; + + /** Alias pour {@link ModificationTag#FIELD_MODIFICATIONTAG_LASTSTATUSMODIFIER}. */ + public static final String ALIAS_LAST_STATUS_MODIFIER = "modificateur.status"; + + /** + * Search manager constructor. + * + * @param wikittyProxy wikitty proxy + * @param thesaurusManager + */ + public SearchManager(WikittyProxy wikittyProxy, ThesaurusManager thesaurusManager) { + this.wikittyProxy = wikittyProxy; + this.thesaurusManager = thesaurusManager; + + // FIXME sletellier 23/12/10 : hack for maven analyse-depency, constant are not concidered like reference, + // So wikitty-solr dependency is concidred like unused + new WikittySolrConstant(); + } + + protected FormPagedResult findForms(String query, Criteria filter, FormPagedResult formPagedResult) + throws UnsupportedQueryException, VradiException { + + // string query to FilterList structure + FilterList queryParsed = VradiQueryParser.parse(query); + + // FilterList to wikitty Search + Search search = Search.query(filter); + buildSearch(queryParsed, search); + Criteria criteria = search.criteria(); + + // add index restriction + // last index can be -1 (all value in UI) + int firstIndex = (formPagedResult.getPageToShow() - 1) * formPagedResult.getNbFormsToShow(); + int lastIndex = formPagedResult.getPageToShow() * formPagedResult.getNbFormsToShow() - 1; + if (firstIndex >= 0 && lastIndex > 0 && lastIndex > firstIndex) { + criteria.setFirstIndex(firstIndex).setEndIndex(lastIndex); + } + + // Add field restriction + if (formPagedResult.getFieldToSort() != null) { + if (!formPagedResult.isAscending()) { + criteria.addSortDescending(formPagedResult.getFieldToSort()); + } else { + criteria.addSortAscending(formPagedResult.getFieldToSort()); + } + } + criteria.addSortAscending(Form.FQ_FIELD_INFOGENE_ID); + + //finds the forms + PagedResult<Form> queryResult = wikittyProxy.findAllByCriteria(Form.class, criteria); + if (log.isDebugEnabled()) { + log.debug("[findForms] found: " + queryResult.size() + " forms"); + } + + List<Form> result = new ArrayList<Form>(queryResult.getAll()); + FormPagedResult formPageResult = new FormPagedResult(result, + queryResult.getNumFound(), formPagedResult.getPageToShow(), + formPagedResult.getNbFormsToShow()); + + return formPageResult; + } + + public FormPagedResult findForms(QueryParameters queryParameters, FormPagedResult formPagedResult) + throws UnsupportedQueryException, VradiException { + + if (log.isDebugEnabled()) { + log.debug(String.format( + "findForms(query:%s, extension:%s, dateFieldName:%s, beginDate:%tc, endDate:%tc, status:%s)", + queryParameters.getQuery(), queryParameters.getExtension(), + queryParameters.getDateFieldName(), queryParameters.getBeginDate(), + queryParameters.getEndDate(), queryParameters.getStatusIds())); + } + + Criteria filter = createFilter(queryParameters); + FormPagedResult formPageResult = findForms(queryParameters.getQuery(), filter, formPagedResult); + return formPageResult; + } + + public Map<Thesaurus, Integer> getChildrenCartography(String thesaurusId, QueryParameters queryParameters) + throws VradiException, UnsupportedQueryException { + + // create search + Criteria filter = createFilter(queryParameters); + + // string query to FilterList structure + FilterList queryParsed = VradiQueryParser.parse(queryParameters.getQuery()); + + // FilterList to wikitty Search + Search search = Search.query(filter); + buildSearch(queryParsed, search); + Criteria criteria = search.criteria(); + + Map<Thesaurus, Integer> results = wikittyProxy.findTreeNode(Thesaurus.class, thesaurusId, criteria); + return results; + } + + public Map<Group, List<QueryBean>> findQueriesReturningForm(String formId) + throws VradiException { + if (log.isDebugEnabled()) { + log.debug("findQueriesReturningForm(formId)"); + } + + Map<Group, List<QueryBean>> results = new HashMap<Group, List<QueryBean>>(); + + if (formId == null) { + return results; + } + + // find QueryMaker which do have queries defined + List<Group> groups = findGroupsWithQueries(); + + results = findQueriesReturningForm(groups, formId); + + if (log.isDebugEnabled()) { + log.debug("Group found : " + results.size()); + } + + return results; + } + + public Map<Group, List<QueryBean>> findQueriesReturningForm(List<Group> groups, String formId) + throws VradiException { + + Map<Group, List<QueryBean>> results = new HashMap<Group, List<QueryBean>>(); + + for (Group group : groups) { + Set<String> queries = group.getQueries(); + + for (String query : queries) { + if (log.isDebugEnabled()) { + log.debug("Searching with query : " + query); + } + try { + QueryBean bean = new QueryBean(query, group.getWikittyId()); + String realQuery = bean.getQuery(); + FilterList filter = VradiQueryParser.parse(realQuery); + + Search search = Search.query(); + search.eq(Element.ELT_ID, formId); + buildSearch(filter, search); + + Criteria criteria = search.criteria(); + + PagedResult<Form> forms = wikittyProxy.findAllByCriteria(Form.class, criteria); + + if (log.isDebugEnabled()) { + log.debug("Search for group " + group.getName() + + " return " + forms.getNumFound() + " results : \n\n" + criteria); + } + + if (forms.getNumFound() > 0) { + if (results.containsKey(group)) { + results.get(group).add(bean); + + } else { + List<QueryBean> list = new ArrayList<QueryBean>(); + list.add(bean); + results.put(group, list); + } + } + + } catch (Exception eee) { + throw new VradiException("Cant get groups", eee); + } + } + } + return results; + } + + /** + * Find all groups with non null queries. + * <p/> + * Warning : do not return {@code QueryMaker} instance. + * + * @return groups + */ + public List<Group> findGroupsWithQueries() { + // find QueryMaker which do have queries defined + Criteria criteria = Search.query().bw(QueryMaker.FQ_FIELD_QUERYMAKER_QUERIES, "*", "*").criteria(); + PagedResult<Group> pagedResult = wikittyProxy.findAllByCriteria(Group.class, criteria); + List<Group> all = pagedResult.getAll(); + return all; + } + + /** + * Build wikitty {@link Search} criteria with all {@link QueryParameters} + * attribute (excepted {@link QueryParameters#query}). + * <p/> + * All parameters can be {@code null}. + * <p/> + * Transform first query to {@link FilterList} and transform this + * {@link FilterList} into wikitty {@link Search}. Then add all parameter + * to {@link Search} query. + * + * @param queryParameters query parameters + * @return wikitty search query + * @throws UnsupportedQueryException + * @throws VradiException + */ + protected Criteria createFilter(QueryParameters queryParameters) + throws UnsupportedQueryException, VradiException { + + // FilterList to wikitty Search + Search search = Search.query(); + boolean addedFilter = false; + + // add the extension in the criteria + if (queryParameters.getExtension() != null) { + search.eq(Element.ELT_EXTENSION, queryParameters.getExtension().getName()); + addedFilter = true; + } + + // add the date in the criteria + if (queryParameters.getDateFieldName() != null && queryParameters.getBeginDate() + != null && queryParameters.getEndDate() != null) { + String beginString = null; + String endString = null; + try { + beginString = WikittyUtil.formatDate(queryParameters.getBeginDate()); + endString = WikittyUtil.formatDate(queryParameters.getEndDate()); + } catch (ParseException eee) { + throw new VradiException("Cant format date : ", eee); + } + search.bw(queryParameters.getDateFieldName(), beginString, endString); + addedFilter = true; + } + + //add the thesaurus in the criteria + if (queryParameters.getThesaurus() != null) { + for (Thesaurus thesaurus : queryParameters.getThesaurus()) { + Search subSearch = search.or(); + subSearch.eq(WikittySolrConstant.TREENODE_PREFIX + thesaurus.getParent(), thesaurus.getWikittyId()); + addedFilter = true; + } + } + + // add the status in the criteria + if (CollectionUtils.isNotEmpty(queryParameters.getStatusIds())) { + Search subSearch = search.or(); + for (String statusId : queryParameters.getStatusIds()) { + subSearch.eq(Form.FQ_FIELD_INFOGENE_STATUS, statusId); + addedFilter = true; + } + } + + // add the xmlStreams in the criteria + if (CollectionUtils.isNotEmpty(queryParameters.getStreamIds())) { + addedFilter = true; + Search subSearch = search.or(); + for (String streamId : queryParameters.getStreamIds()) { + subSearch.eq(Form.FQ_FIELD_FORM_XMLSTREAM, streamId); + addedFilter = true; + } + } + + Criteria criteria = null; + if (addedFilter) { + criteria = search.criteria(); + } + return criteria; + } + + /** + * Transform FilterList part into wikitty sub Search. + * <p/> + * This method recursively explore FilterList, and recursively call + * himself. + * + * @param list current filter list + * @param search parent wikitty search to add new created search + * @throws VradiException + */ + protected void buildSearch(FilterList list, Search search) throws VradiException { + + // create new sub search + FilterList.Operator operator = list.getOperator(); + Search subSearch = null; + switch (operator) { + case FILTER_OR: + subSearch = search.or(); + break; + case FILTER_AND: + subSearch = search.and(); + break; + case FILTER_NOT: + subSearch = search.not(); + break; + } + + // transform each filters into wikitty + List<Filter> filters = list.getFilters(); + for (Filter filter : filters) { + if (filter instanceof FilterList) { + buildSearch((FilterList) filter, subSearch); + + } else if (filter instanceof RangeFilter) { + buildRangeSearch((RangeFilter) filter, subSearch); + + } else if (filter instanceof CompareFilter) { + buildCompareSearch(operator, (CompareFilter) filter, subSearch); + } + + } + } + + /** + * Build wikitty range search. + * + * @param rangeFilter vradi range filter + * @param search wikitty range search + */ + protected void buildRangeSearch(RangeFilter rangeFilter, Search search) { + + String name = rangeFilter.getName(); + String lowerValue = rangeFilter.getLowerValue(); + String upperValue = rangeFilter.getUpperValue(); + + Search subSearch = search.or(); + + // date search + if (rangeFilter.match(numericDateFormatPattern)) { + try { + Date lowerTime = numericDateFormat.parse(lowerValue); + lowerTime = DateUtil.setMinTimeOfDay(lowerTime); + String lowerTimeString = WikittyUtil.formatDate(lowerTime); + + Date upperTime = numericDateFormat.parse(upperValue); + upperTime = DateUtil.setMaxTimeOfDay(upperTime); + String upperTimeString = WikittyUtil.formatDate(upperTime); + + subSearch.bw(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.DATE, lowerTimeString, upperTimeString); + + } catch (ParseException e) { + if (log.isWarnEnabled()) { + log.warn(lowerValue + " OR " + upperValue + " cannot be a date."); + } + } + + // number search + } else if (rangeFilter.isNumber()) { + subSearch.bw(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.NUMERIC, lowerValue, upperValue); + } + + // TODO EC 20100622 il manque pas un else ici ? + // default to string search + subSearch.bw(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.STRING, lowerValue, upperValue); + } + + /** + * Convertit les termes simple (name:value). + * + * @param operator + * @param compareFilter + * @param search + * @throws VradiException + */ + protected void buildCompareSearch(FilterList.Operator operator, CompareFilter compareFilter, + Search search) throws VradiException { + String name = compareFilter.getName(); + String value = compareFilter.getValue(); + + if (VradiQueryParser.DEFAULT_FIELD.equals(name)) { + search.keyword(value); + return; + + } else { + + // loop on each root thesaurus + List<RootThesaurus> rootThesauruses = thesaurusManager.getRootThesaurus(); + for (RootThesaurus rootThesaurus : rootThesauruses) { + if (name.equalsIgnoreCase(rootThesaurus.getName())) { + buildDescripteurSearch(search, rootThesaurus.getWikittyId(), value); + return; + } + } + } + + if (ALIAS_LAST_MODIFIER.equals(name)) { + name = ModificationTag.FIELD_MODIFICATIONTAG_LASTMODIFIER; + + } else if (ALIAS_LAST_STATUS_MODIFIER.equals(name)) { + name = ModificationTag.FIELD_MODIFICATIONTAG_LASTSTATUSMODIFIER; + } + + Search subSearch = search.or(); + + // a confirmer, mais l'explication doit être : + // - si c'est not, ca doit ne pas être la date en question + // - sinon, ca doit être compris entre le début et la fin du jour + // en question + if (operator == FilterList.Operator.FILTER_NOT) { + // date search + if (compareFilter.match(frenchDateFormatPattern)) { + try { + Date time = frenchDateFormat.parse(value); + String timeString = WikittyUtil.formatDate(time); + + subSearch.eq(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.DATE, timeString); + + } catch (ParseException e) { + if (log.isWarnEnabled()) { + log.warn(value + " cannot be a date."); + } + } + } + + } else { + // date search + if (compareFilter.match(frenchDateFormatPattern)) { + try { + Date time = frenchDateFormat.parse(value); + + Date beginDate = DateUtil.setMinTimeOfDay(time); + Date endDate = DateUtil.setMaxTimeOfDay(time); + + String beginString = WikittyUtil.formatDate(beginDate); + String endString = WikittyUtil.formatDate(endDate); + + subSearch.bw(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.DATE, beginString, endString); + + } catch (ParseException e) { + if (log.isWarnEnabled()) { + log.warn(value + " cannot be a date."); + } + } + } + } + + // text search + subSearch.like(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.STRING, value, Like.SearchAs.AsText); + + // boolean search + if (compareFilter.isBoolean()) { + subSearch.eq(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.BOOLEAN, value); + + // number search + } else if (compareFilter.isNumber()) { + subSearch.eq(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.NUMERIC, value); + + // extension id search (eq) + } else if (compareFilter.match(formIdPattern)) { + subSearch.eq(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.STRING, value); + + // extension id search (ew) + } else if (compareFilter.match(uuidPattern)) { + subSearch.ew(Criteria.ALL_EXTENSIONS + Criteria.SEPARATOR + + name + Criteria.SEPARATOR + + Element.ElementType.STRING, value); + } + } + + /** + * Cherche tous les thesaurus en base qui correspondent à {@code value} + * et ajoute un critère {@link Form#FQ_FIELD_THESAURUS} a la Search query + * (ou entre tous les résultats s'il y en a plusieurs). + * <p/> + * Les formulaires sont taggués avec tous les noeuds de thesaurus + * auquel ils appartiennent depuis le noeud jusqu'a sa racine. + * <p/> + * recherche : TreeNode.wikittyidparent : TreeNode.wikittyid + * <p/> + * FIXME sletellier 20/12/10 : doit etre independant de l'indexer solr choisi + * + * @param rootThesaurusId filtering on thesaurus node of root thesaurus + * @param search parent search + * @param value thesaurus value (can be solr pattern with * by expemple) + */ + protected void buildDescripteurSearch(Search search, String rootThesaurusId, String value) { + + Criteria criteria = Search.query() + .eq(WikittyTreeNode.FQ_FIELD_WIKITTYTREENODE_NAME, value) + .eq(Thesaurus.FQ_FIELD_THESAURUS_ROOTTHESAURUS, rootThesaurusId) + .criteria(); + + PagedResult<Thesaurus> queryResult = wikittyProxy.findAllByCriteria(Thesaurus.class, criteria); + + if (queryResult.getNumFound() > 0) { + Search subSearch = search.or(); + + List<Thesaurus> result = queryResult.getAll(); + for (Thesaurus thesaurus : result) { + if (thesaurus.getParent() == null) { + subSearch.eq(WikittySolrConstant.TREENODE_ROOT, thesaurus.getWikittyId()); + } else { + subSearch.eq(WikittySolrConstant.TREENODE_PREFIX + thesaurus.getParent(), thesaurus.getWikittyId()); + } + } + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/SearchManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,422 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uri.ExternalUriReferenceTranslator; +import com.sun.star.uri.XExternalUriReferenceTranslator; +import com.sun.star.util.XRefreshable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.ooo.SingletonOOo; +import org.nuiton.util.ApplicationConfig; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Template manager. + * <p/> + * Handle: + * <ul> + * <li>OpenOffice.org PDF creation</li> + * </ul> + * + * @author chatellier + */ +public class TemplateManager { + + /** Log. */ + private static final Log log = LogFactory.getLog(TemplateManager.class); + + protected ApplicationConfig config; + + protected XComponentContext context = null; + + protected XComponentLoader loader = null; + + protected XComponent document = null; + + public static final int IMAGE_UNKNOWN = -1; + + public static final int IMAGE_JPEG = 0; + + public static final int IMAGE_PNG = 1; + + public static final int IMAGE_GIF = 2; + + /** + * Prefix des champs texte utilisateurs dans les template ODT. + * <p/> + * TODO EC 20100528 according to documentation, it's "com.sun.star.text.textfield.User" + * <p/> + * En ooo2, la casse est differente : com.sun.star.text.FieldMaster.User + */ + protected static final String USER_TEXT_FIELD_PREFIX = "com.sun.star.text.fieldmaster.User."; + + /** + * Init template with managed template file. + * + * @param templateFile + * @throws VradiException + */ + public TemplateManager(ApplicationConfig config, File templateFile) throws VradiException { + this.config = config; + initOpenOfficeContext(); + document = createDoc(templateFile); + } + + /** Init openoffice bootstrap?. */ + protected void initOpenOfficeContext() throws VradiException { + + try { + String oOoExecFolder = VradiServiceConfigurationHelper.getOpenOfficeExecDir(config); + context = SingletonOOo.GetInstance(oOoExecFolder).getXContext(); + loader = SingletonOOo.GetInstance(oOoExecFolder).getLoader(); + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't init openoffice bootstrap", ex); + } + throw new VradiException("Can't init openoffice bootstrap", ex); + } + + } + + /** + * Créer un document. + * + * @param templateFile Le template du document + * @return le document construit + * @throws VradiException if document can't be created + */ + public XComponent createDoc(File templateFile) throws VradiException { + try { + // Propriété générale du document (voir com.sun.star.document.MediaDescriptor). + List<PropertyValue> props = new ArrayList<PropertyValue>(); + + // Autorise l'utilisation d'un Template. + PropertyValue p1 = new PropertyValue(); + p1.Name = "AsTemplate"; + p1.Value = Boolean.TRUE; + props.add(p1); + + // Rend le document invisible. + PropertyValue p2 = new PropertyValue(); + p2.Name = "Hidden"; + p2.Value = Boolean.TRUE; + props.add(p2); + + PropertyValue[] properties = new PropertyValue[props.size()]; + properties = props.toArray(properties); + + String templateFileURL = createUNOFileURL(templateFile); + document = loader.loadComponentFromURL(templateFileURL, // URL du temlpate + "_blank", // Nom de la fenetre (_blank en crée une nouvelle). + 0, // On ne cherche pas de flag. + properties); // Propriétées. + + return document; + + } catch (Exception e) { + throw new VradiException("Can't create document. File " + templateFile + + " can also not exist or not be read !", e); + } + } + + public void generateDoc(String targetFileName, + Map<String, Object> myValues, String... imagesUrls) throws VradiException { + fillFields(myValues); + for (String imageUrl : imagesUrls) { + insertImageInEndOfDocument(imageUrl); + } + storeDocComponent(document, targetFileName); + } + + /** + * Sauver un doc donné a l'url donnée au format pdf. + * + * @param xDoc Le document a sauvegarder (XComponent) + * @param storeUrl Url complete du fichier (String) + * @throws VradiException if pdf can't be exported + */ + public void storeDocComponent(XComponent xDoc, String storeUrl) + throws VradiException { + try { + XStorable xStorable = UnoRuntime.queryInterface( + XStorable.class, xDoc); + // FIXME give a File here + storeUrl = createUNOFileURL(new File(storeUrl)); + + if (log.isDebugEnabled()) { + log.debug("Storing pdf file to " + storeUrl); + } + + PropertyValue[] storeProps = new PropertyValue[2]; + storeProps[0] = new PropertyValue(); + storeProps[0].Name = "FilterName"; + storeProps[0].Value = "writer_pdf_Export"; + storeProps[1] = new PropertyValue(); + storeProps[1].Name = "Overwrite"; + storeProps[1].Value = Boolean.TRUE; + xStorable.storeToURL(storeUrl, storeProps); + + // TODO EC20100427 les lignes suivantes ont l'air + // de fermer un truc qu'il ne faut pas, le les génération suivantes + // echouent + + //xDoc.dispose(); + //XComponent xComp = (XComponent) UnoRuntime.queryInterface( + //XComponent.class, xStorable); + //xComp.dispose(); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't export template as PDF", eee); + } + throw new VradiException("Can't export template as PDF", eee); + } + } + + /** + * Creating a correct File URL that OpenOffice can handle. This is + * necessary to be platform independent. + * + * @param filelocation + * @return openoffice internal url + * @throws VradiException in cas of MalformedURLException + */ + protected String createUNOFileURL(File file) throws VradiException { + String internalURL; + try { + URL before = file.toURI().toURL(); + + XExternalUriReferenceTranslator translator = ExternalUriReferenceTranslator.create(context); + internalURL = translator.translateToInternal(before.toExternalForm()); + } catch (MalformedURLException eee) { + throw new VradiException("Can't convert url", eee); + } + + return internalURL; + } + + /** + * Remplir les champs de mailing. + * <p/> + * Manage only com.sun.star.text.textfield.User.* fields. + * + * @param myValues value to replace into template fields + * @throws VradiException if values can't be replaced + */ + protected void fillFields(Map<String, Object> myValues) throws VradiException { + + try { + XTextFieldsSupplier xTextFieldsSupplier = UnoRuntime + .queryInterface(XTextFieldsSupplier.class, document); + + XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters(); + XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields(); + String allFieldNames[] = xNamedFieldMasters.getElementNames(); + + String[] fieldNames = new String[allFieldNames.length]; + //Object[] fieldMasters = new Object[allFieldNames.length]; + XPropertySet[] xPropertySets = new XPropertySet[allFieldNames.length]; + int fieldCount = 0; + + for (String allFieldName : allFieldNames) { + + // compare en toLowerCase parce que : + // ooo2 : com.sun.star.text.FieldMaster.User + // ooo3 : com.sun.star.text.fieldmaster.User + if (allFieldName.toLowerCase().startsWith(USER_TEXT_FIELD_PREFIX.toLowerCase())) { + String shortFieldName = allFieldName.substring(USER_TEXT_FIELD_PREFIX.length()); + fieldNames[fieldCount] = shortFieldName; + // ??? + //fieldMasters[fieldCount] = xNamedFieldMasters.getByName(allFieldName); + // xPropertySets[fieldCount] = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, fieldMasters[fieldCount]); + Object fieldMaster = xNamedFieldMasters.getByName(allFieldName); + xPropertySets[fieldCount] = UnoRuntime.queryInterface(XPropertySet.class, fieldMaster); + + fieldCount++; + } + } + + XRefreshable xRefreshable = UnoRuntime + .queryInterface(XRefreshable.class, xEnumeratedFields); + + for (int i = 0; i < fieldCount; i++) { + if (log.isDebugEnabled()) { + log.debug("Replacing " + fieldNames[i] + " with " + + myValues.get(fieldNames[i])); + } + + xPropertySets[i].setPropertyValue("Content", myValues + .get(fieldNames[i])); + + + if (log.isDebugEnabled() && myValues.get(fieldNames[i]) == null) { + log.debug("Field " + fieldNames[i] + " could not be found"); + } + } + + xRefreshable.refresh(); + } catch (Exception eee) { + throw new VradiException("Can't replace template fields", eee); + } + } + + /** + * Inserts an image to the end of the document. + * <p/> + * Source : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=6357&p=31958 + * + * @param image the file containing the image to insert + * @throws VradiException + */ + protected void insertImageInEndOfDocument(String imageUrl) throws VradiException { + + if (log.isDebugEnabled()) { + log.debug("Insert image at end of document : " + imageUrl); + } + + try { + BufferedImage image = ImageIO.read(new URL(imageUrl)); + int width = image.getWidth(); + int height = image.getHeight(); + if (log.isDebugEnabled()) { + log.debug("Image size : " + width + "*" + height); + } + + XTextDocument xTextDocument = UnoRuntime.queryInterface( + XTextDocument.class, document); + + // Créé un TextRange au début du document + XTextRange xStart = xTextDocument.getText().getStart(); + XTextCursor xCursor = xStart.getText().createTextCursorByRange(xStart); + + // Querying for the interface XMultiServiceFactory on the XTextDocument + XMultiServiceFactory xMSFDoc = UnoRuntime + .queryInterface(XMultiServiceFactory.class, xTextDocument); + + // Creating the service GraphicObject + //XTextContent xImage = (XTextContent)xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject"); + XTextContent xImage = UnoRuntime.queryInterface(XTextContent.class, + xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject")); + + // Getting the text and append new paragraph + XText xText = xCursor.getText(); + xText.insertControlCharacter(xText.getEnd(), + ControlCharacter.APPEND_PARAGRAPH, false); + + // Querying for the interface XPropertySet on the graphic object + XPropertySet xProps = UnoRuntime.queryInterface( + XPropertySet.class, xImage); + + // Détermine l'ancrage à la page + xProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH); + + // Détermine l'URL concernant l'image (Format: file:///C:/temp/image.gif) + xProps.setPropertyValue("GraphicURL", imageUrl); + + //Détermine si l'objet sera imprimé aussi lors de l'impression du doc. + xProps.setPropertyValue("Print", true); + xProps.setPropertyValue("Width", width * 15); + xProps.setPropertyValue("Height", height * 15); + + //Setting the top margin + xProps.setPropertyValue("TopMargin", height * 15); + + // Insert image to the end + xText.insertTextContent(xText.getEnd(), xImage, false); + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't insert image", eee); + } + throw new VradiException("Can't insert image", eee); + } + + } + + /** + * Gets the user fields or database fields of the ooo document. + * <p/> + * Some help : http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fi... + * <p/> + * Manage fields : + * - com.sun.star.text.textfield.User + * Variables - User Field. Creates a global document variable and displays it whenever this field occurs in the text. + * + * @return an array of String containing the field names + */ + public List<String> getDocumentFields() { + + XTextFieldsSupplier xTextFieldsSupplier = UnoRuntime + .queryInterface(XTextFieldsSupplier.class, document); + XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters(); + + String allFieldNames[] = xNamedFieldMasters.getElementNames(); + List<String> fieldNames = new ArrayList<String>(); + + for (String allFieldName : allFieldNames) { + // compare en toLowerCase parce que : + // ooo2 : com.sun.star.text.FieldMaster.User + // ooo3 : com.sun.star.text.fieldmaster.User + if (allFieldName.toLowerCase().startsWith(USER_TEXT_FIELD_PREFIX.toLowerCase())) { + String shortFieldName = allFieldName.substring(USER_TEXT_FIELD_PREFIX.length()); + fieldNames.add(shortFieldName); + } + } + + if (log.isDebugEnabled()) { + log.debug("Found field in document : " + fieldNames); + } + + return fieldNames; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ThesaurusManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ThesaurusManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ThesaurusManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,531 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.managers; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.search.CompareFilter; +import org.chorem.vradi.services.search.Filter; +import org.chorem.vradi.services.search.FilterList; +import org.chorem.vradi.services.search.VradiQueryParser; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.FacetTopic; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; +import org.nuiton.wikitty.search.operators.Like; +import org.nuiton.wikitty.services.WikittyEvent; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Class containing the methods to manage the thesaurus : + * - node creation, update, retrieving, deletion + * - get child node number + * - get children + * + * @author schorlet + * @version $Revision$ $Date$ + * @date 2010-01-22 20:18:29 + */ +public class ThesaurusManager { + + /** log. */ + private static final Log log = LogFactory.getLog(ThesaurusManager.class); + + protected WikittyProxy wikittyProxy; + + public ThesaurusManager(WikittyProxy proxy) { + wikittyProxy = proxy; + } + + /** + * Return root thesaurus ids (ie thesaurus nodes without parent) sorted + * by root thesaurus name. + * + * @return a {@link RootThesaurus} collection + * @throws VradiException if excepetion occured + */ + public List<RootThesaurus> getRootThesaurus() throws VradiException { + + Search search = Search.query().eq(Element.ELT_EXTENSION, RootThesaurus.EXT_ROOTTHESAURUS); + Criteria criteria = search.criteria(); + criteria.addSortAscending(RootThesaurus.FQ_FIELD_WIKITTYTREENODE_NAME); + + PagedResult<RootThesaurus> rootThesaurusResult = wikittyProxy.findAllByCriteria(RootThesaurus.class, criteria); + List<RootThesaurus> rootThesaurus = rootThesaurusResult.getAll(); + + if (log.isDebugEnabled()) { + log.debug("Root thesaurus list : " + rootThesaurus); + } + return rootThesaurus; + } + + /** + * Retourne l'ensemble des thesaurus qui sont attachés a un formulaire + * sorted by thesaurus name. + * + * @param form form dont on veut les thesaurus + * @return thesaurus attachés au formulaire + */ + public List<Thesaurus> getThesaurusAttachedToForm(Form form) { + Search searchThesaurus = Search.query(); + searchThesaurus.eq(Thesaurus.FQ_FIELD_WIKITTYTREENODE_ATTACHMENT, form.getWikittyId()); + Criteria criteria = searchThesaurus.criteria(); + criteria.addSortAscending(Thesaurus.FQ_FIELD_WIKITTYTREENODE_NAME); + + PagedResult<Thesaurus> findAllByCriteria = wikittyProxy.findAllByCriteria( + Thesaurus.class, criteria); + List<Thesaurus> thesaurus = findAllByCriteria.getAll(); + return thesaurus; + } + + public Thesaurus getThesaurus(String thesaurusId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getThesaurus(" + thesaurusId + ")"); + } + Thesaurus node = wikittyProxy.restore(Thesaurus.class, thesaurusId); + return node; + } + + public List<Thesaurus> getThesaurus(List<String> thesaurusIds) + throws VradiException { + if (log.isDebugEnabled()) { + log.debug("getThesaurus(" + thesaurusIds + ")"); + } + List<Thesaurus> nodes = wikittyProxy.restore(Thesaurus.class, thesaurusIds); + + return nodes; + } + + /** + * Returns all children of the specified {@code thesaurusId} sorted by + * ordre and name. + * + * @param thesaurusId thesaurus wikitty id + * @return all list of <code>TreeNodeImpl</code> + * @throws VradiException if excepetion occured + */ + public List<Thesaurus> getChildrenThesaurus(String thesaurusId) + throws VradiException { + + if (log.isTraceEnabled()) { + log.trace("getChildrenThesaurus(" + thesaurusId + ")"); + } + + Search query = Search.query(); + query.eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS); + query.eq(Thesaurus.FQ_FIELD_WIKITTYTREENODE_PARENT, thesaurusId); + + Criteria criteria = query.criteria(); + criteria.addSortAscending(Thesaurus.FQ_FIELD_THESAURUS_ORDER); + criteria.addSortAscending(Thesaurus.FQ_FIELD_WIKITTYTREENODE_NAME); + + PagedResult<Thesaurus> nodes = wikittyProxy + .findAllByCriteria(Thesaurus.class, criteria); + List<Thesaurus> all = nodes.getAll(); + + return all; + } + + /** + * Delete all thesaurus and sub thesaurus. + * + * @param thesaurusId thesaurusId to delete + * @return delete thesaurus ids + * @throws VradiException if excepetion occured + */ + public Collection<String> deleteThesaurus(String thesaurusId) throws VradiException { + WikittyEvent wikittyEvent = wikittyProxy.deleteTree(thesaurusId); + Map<String, Date> wikittyMap = wikittyEvent.getRemoveDate(); + if (wikittyMap != null) { + return wikittyMap.keySet(); + } + return Collections.EMPTY_LIST; + } + + /** + * Delete all thesaurus recursively. + * + * @throws VradiException if excepetion occured + */ + public void deleteAllThesaurus() throws VradiException { + + List<RootThesaurus> rootThesauruses = getRootThesaurus(); + for (RootThesaurus rootThesaurus : rootThesauruses) { + wikittyProxy.deleteTree(rootThesaurus.getWikittyId()); + } + } + + public int getNbFormsForThesaurus(String thesaurusId) + throws VradiException { + if (log.isTraceEnabled()) { + log.trace("getNbFormsForThesaurus(" + thesaurusId + ")"); + } + + Map.Entry<Thesaurus, Integer> entry = + wikittyProxy.restoreNode(Thesaurus.class, thesaurusId, null); + + if (entry == null) { + return 0; + } + + return entry.getValue(); + } + + /** + * Propose thesaurus nodes that might be in relation with a specified form. + * Does'nt return thesaurus already associated with form. + * + * @param formId the <code>Form</code> containing the information needed + * to search the thesaurus nodes + * @return a list of <code>Thesaurus</code> + * @throws VradiException if excepetion occured + */ + public List<Thesaurus> proposeThesaurus(String formId) throws VradiException { + if (log.isDebugEnabled()) { + log.debug("proposeThesaurus(form)"); + } + + // recherche les thesaurus qui ont des tags et qui ne sont pas + // deja associés au formulaire courant + Search canditateSearch = Search.query(); + canditateSearch.bw(Thesaurus.FQ_FIELD_THESAURUS_TAGS, "*", "*"); + canditateSearch.neq(Thesaurus.FQ_FIELD_WIKITTYTREENODE_ATTACHMENT, formId); + Criteria candidateCriteria = canditateSearch.criteria(); + PagedResult<Thesaurus> pagedResult = wikittyProxy.findAllByCriteria(Thesaurus.class, candidateCriteria); + List<Thesaurus> canditateThesauruses = pagedResult.getAll(); + + // search for the specified form + Criteria criteria = Search.query() + .eq(Element.ELT_EXTENSION, Form.EXT_FORM) + .eq(Element.ELT_ID, formId) + .criteria(); + + // add a facet criteria for each thesaurus node id, + // searching for tags of each thesaurus nodes + for (Thesaurus canditateThesaurus : canditateThesauruses) { + + Set<String> tags = canditateThesaurus.getTags(); + Search tagSearch = Search.query(Search.KIND.OR); + for (String tag : tags) { + if (StringUtils.isNotBlank(tag)) { + tagSearch = tagSearch.keyword(tag); + } + } + + Criteria facetCriteria = tagSearch.criteria(canditateThesaurus.getWikittyId()); + criteria.addFacetCriteria(facetCriteria); + } + + // execute the search + criteria.setEndIndex(0); + PagedResult<Form> forms = wikittyProxy.findAllByCriteria(Form.class, criteria); + List<Thesaurus> result = new ArrayList<Thesaurus>(); + + // collects topic names (which are thesaurus node ids) + if (forms != null && forms.getNumFound() > 0) { + List<String> thesaurusIds = new ArrayList<String>(); + + Map<String, List<FacetTopic>> facetsMap = forms.getFacets(); + for (Map.Entry<String, List<FacetTopic>> entry : facetsMap.entrySet()) { + List<FacetTopic> facetTopics = entry.getValue(); + for (FacetTopic facetTopic : facetTopics) { + if (facetTopic.getCount() > 0) { + thesaurusIds.add(facetTopic.getTopicName()); + break; + } + } + } + + if (!thesaurusIds.isEmpty()) { + result = getThesaurus(thesaurusIds); + } + } + + return result; + } + + /** + * Gets the query makers whose queries are potentially to modify + * after a thesaurus node modification + * + * @param rootThesaurusName rootThesaurus name + * @param thesaurusName the modified thesaurus node + * @return a map containing the query makers and their queries which contains + * the thesaurus node name + */ + public Map<Group, List<QueryBean>> getQueriesToModifyAfterThesaurusModification( + String rootThesaurusName, String thesaurusName) { + if (log.isDebugEnabled()) { + log.debug("getQueriesToModifyAfterThesaurusModification(" + rootThesaurusName + ", " + thesaurusName + ")"); + } + Map<Group, List<QueryBean>> results = new HashMap<Group, List<QueryBean>>(); + + if (rootThesaurusName == null) { + return results; + } + + String requestPart = rootThesaurusName + ":" + (thesaurusName == null ? "" : thesaurusName); + Criteria criteria = Search.query() + .eq(Element.ELT_EXTENSION, Group.EXT_GROUP) + .like(Group.FQ_FIELD_QUERYMAKER_QUERIES, requestPart, Like.SearchAs.AsText) + .criteria(); + + PagedResult<Group> pagedResult = wikittyProxy.findAllByCriteria(Group.class, criteria); + List<Group> groups = pagedResult.getAll(); + + if (log.isDebugEnabled()) { + log.debug("[getQueriesToModifyAfterThesaurusModification] " + groups.size() + + "Groups found for request part requestPart : " + requestPart); + } + + for (Group group : groups) { + + Set<String> queries = group.getQueries(); + List<QueryBean> queriesToModify = new ArrayList<QueryBean>(); + + for (String query : queries) { + try { + QueryBean queryBean = new QueryBean(query, group.getWikittyId()); + FilterList filter = VradiQueryParser.parse(queryBean.getQuery()); + + if (isThesaurusInQuery(filter, rootThesaurusName, thesaurusName)) { + queriesToModify.add(queryBean); + } + + } catch (Exception e) { + // ignored exception + log.warn(e.getMessage(), e); + } + } + + if (!queriesToModify.isEmpty()) { + results.put(group, queriesToModify); + } + } + + return results; + } + + protected boolean isThesaurusInQuery(FilterList list, String rootThesaurusName, String thesaurusName) { + boolean insideQuery = false; + List<Filter> filters = list.getFilters(); + + for (Filter filter : filters) { + if (filter instanceof FilterList) { + insideQuery = isThesaurusInQuery((FilterList) filter, rootThesaurusName, thesaurusName); + + } else if (filter instanceof CompareFilter) { + insideQuery = isThesaurusInQuery((CompareFilter) filter, rootThesaurusName, thesaurusName); + } + + if (insideQuery) { + break; + } + } + return insideQuery; + } + + protected boolean isThesaurusInQuery(CompareFilter compareFilter, + String rootThesaurusName, String thesaurusName) { + String name = compareFilter.getName(); + String value = compareFilter.getValue(); + boolean result = rootThesaurusName.equals(name) + && (thesaurusName == null || thesaurusName.equals(value)); + + if (log.isDebugEnabled()) { + log.debug("[isThesaurusInQuery] Root Thesaurus name : " + rootThesaurusName + + " name : " + name + " ThesaurusName : " + + thesaurusName + " value : " + value + " result : " + result); + } + return result; + } + + protected void replaceThesaurusInQuery(FilterList list, + String oldRootThesaurusName, String newRootThesaurusName, + String oldThesaurusName, String newThesaurusName) { + + List<Filter> filters = list.getFilters(); + + for (Filter filter : filters) { + if (filter instanceof FilterList) { + replaceThesaurusInQuery((FilterList) filter, + oldRootThesaurusName, newRootThesaurusName, + oldThesaurusName, newThesaurusName); + + } else if (filter instanceof CompareFilter) { + replaceThesaurusInQuery((CompareFilter) filter, + oldRootThesaurusName, newRootThesaurusName, + oldThesaurusName, newThesaurusName); + } + } + } + + protected void replaceThesaurusInQuery(CompareFilter compareFilter, + String oldRootThesaurusName, String newRootThesaurusName, + String oldThesaurusName, String newThesaurusName) { + String value = compareFilter.getValue(); + + if (value.equals(oldThesaurusName)) { + String name = compareFilter.getName(); + + if (oldRootThesaurusName.equals(name)) { + + compareFilter.setName(newRootThesaurusName); + compareFilter.setValue(newThesaurusName); + } + } + } + + /** + * Create new thesaurus. + * + * @param rootThesaurusName root thesaurus name (must contains only alphnum characters) + * @return new created thesaurus + * @throws VradiException if name is not valid + */ + public RootThesaurus createRootThesaurus(String rootThesaurusName) throws VradiException { + + // check null name + if (rootThesaurusName == null) { + throw new VradiException("Null root thesaurus name"); + } + + // check name characters + if (!rootThesaurusName.matches("\\w+")) { + throw new VradiException("Root thesaurus name contains invalid characters : " + rootThesaurusName); + } + + // check unicity + if (isRootThesaurusNameExists(rootThesaurusName, null)) { + throw new VradiException("Root thesaurus \"" + rootThesaurusName + "\" already exists"); + } + + // create thesaurus + RootThesaurus newRootThesaurus = new RootThesaurusImpl(); + newRootThesaurus.setName(rootThesaurusName); + newRootThesaurus = wikittyProxy.store(newRootThesaurus); + + return newRootThesaurus; + } + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @return true if rootThesaurusName already exists + */ + public boolean isRootThesaurusNameExists(String rootThesaurusName) { + return isRootThesaurusNameExists(rootThesaurusName, null); + } + + /** + * Return true if rootThesaurusName already exists. + * + * @param rootThesaurusName rootThesaurus name to test + * @param exceptedRootThesaurusId in case of rename, exclude exceptedRootThesaurusId from check + * @return true if rootThesaurusName already exists + */ + public boolean isRootThesaurusNameExists(String rootThesaurusName, String exceptedRootThesaurusId) { + Search query = Search.query(); + query = query.eq(Element.ELT_EXTENSION, RootThesaurus.EXT_ROOTTHESAURUS); + query = query.eq(Thesaurus.FQ_FIELD_WIKITTYTREENODE_NAME, rootThesaurusName); + if (exceptedRootThesaurusId != null) { + query = query.neq(Element.ELT_ID, exceptedRootThesaurusId); + } + + Criteria criteria = query.criteria(); + criteria.setFirstIndex(0); + criteria.setEndIndex(0); + + PagedResult<Wikitty> pagedResults = wikittyProxy.findAllByCriteria(criteria); + + boolean result = false; + if (pagedResults.getNumFound() > 0) { + result = true; + } + return result; + } + + /** + * Check if name of thesaurus is existing in rootThesaurus. + * + * @param rootThesaurus to check + * @param thesaurusName name to check + * @return true if thesaurus already exist + */ + public boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName) { + return isThesaurusNameExistsInRootThesaurus(rootThesaurus, thesaurusName, null); + } + + /** + * Check if name of thesaurus is existing in rootThesaurus. + * + * @param rootThesaurus to check + * @param thesaurusName name to check + * @param exceptedThesaurusId in case of rename, exclude exceptedThesaurusId from check + * @return true if thesaurus already exist + */ + public boolean isThesaurusNameExistsInRootThesaurus(RootThesaurus rootThesaurus, String thesaurusName, String exceptedThesaurusId) { + + Search query = Search.query(); + query = query.eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS); + query = query.eq(Thesaurus.FQ_FIELD_THESAURUS_ROOTTHESAURUS, rootThesaurus.getWikittyId()); + query = query.eq(Thesaurus.FQ_FIELD_WIKITTYTREENODE_NAME, thesaurusName); + if (exceptedThesaurusId != null) { + query = query.neq(Element.ELT_ID, exceptedThesaurusId); + } + + Criteria criteria = query.criteria(); + criteria.setFirstIndex(0); + criteria.setEndIndex(0); + + PagedResult<Wikitty> pagedResults = wikittyProxy.findAllByCriteria(criteria); + + boolean result = false; + if (pagedResults.getNumFound() > 0) { + result = true; + } + return result; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/ThesaurusManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapConnector.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapConnector.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapConnector.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,243 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.ooo; + +import com.sun.star.bridge.UnoUrlResolver; +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.comp.helper.Bootstrap; +import com.sun.star.comp.helper.BootstrapException; +import com.sun.star.connection.ConnectionSetupException; +import com.sun.star.connection.NoConnectException; +import com.sun.star.frame.XDesktop; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; + +/** + * A bootstrap connector which establishes a connection to an OOo server. + * <p/> + * Most of the source code in this class has been taken from the Java class + * "Bootstrap.java" (Revision: 1.15) from the UDK projekt (Uno Software Develop- + * ment Kit) from OpenOffice.org (http://udk.openoffice.org/). The source code + * is available for example through a browser based online version control + * access at http://udk.openoffice.org/source/browse/udk/. The Java class + * "Bootstrap.java" is there available at + * http://udk.openoffice.org/source/browse/udk/javaunohelper/com/sun/star/comp/... + * <p/> + * The idea to develop this BootstrapConnector comes from the blog "Getting + * started with the OpenOffice.org API part III : starting OpenOffice.org with + * jars not in the OOo install dir by Wouter van Reeven" + * (http://technology.amis.nl/blog/?p=1284) and from various posts in the + * "(Unofficial) OpenOffice.org Forum" at http://www.oooforum.org/ and the + * "OpenOffice.org Community Forum" at http://user.services.openoffice.org/ + * complaining about "no ooo executable found!". + */ +public class BootstrapConnector { + + /** The OOo server. */ + private OOoServer oooServer; + + /** The connection string which has ben used to establish the connection. */ + private String oooConnectionString; + + /** + * Constructs a bootstrap connector which uses the folder of the OOo + * installation containing the soffice executable. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + */ + public BootstrapConnector(String oooExecFolder) { + + oooServer = new OOoServer(oooExecFolder); + oooConnectionString = null; + } + + /** + * Constructs a bootstrap connector which connects to the specified + * OOo server. + * + * @param oooServer The OOo server + */ + public BootstrapConnector(OOoServer oooServer) { + + this.oooServer = oooServer; + oooConnectionString = null; + } + + /** + * Connects to an OOo server using the specified accept option and + * connection string and returns a component context for using the + * connection to the OOo server. + * <p/> + * The accept option and the connection string should match to get a + * connection. OOo provides to different types of connections: + * 1) The socket connection + * 2) The named pipe connection + * <p/> + * To create a socket connection a host and port must be provided. + * For example using the host "localhost" and the port "8100" the + * accept option and connection string looks like this: + * - accept option : -accept=socket,host=localhost,port=8100;urp; + * - connection string: uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext + * <p/> + * To create a named pipe a pipe name must be provided. For example using + * the pipe name "oooPipe" the accept option and connection string looks + * like this: + * - accept option : -accept=pipe,name=oooPipe;urp; + * - connection string: uno:pipe,name=oooPipe;urp;StarOffice.ComponentContext + * + * @param oooAcceptOption The accept option + * @param oooConnectionString The connection string + * @return The component context + */ + public XComponentContext connect(String oooAcceptOption, String oooConnectionString) throws BootstrapException { + + this.oooConnectionString = oooConnectionString; + + XComponentContext xContext = null; + try { + // get local context + XComponentContext xLocalContext = getLocalContext(); + + oooServer.start(oooAcceptOption); + + // initial service manager + XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); + if (xLocalServiceManager == null) { + throw new BootstrapException("no initial service manager!"); + } + // create a URL resolver + XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext); + + // wait until ooo is started + for (int i = 0; ; ++i) { + try { + xContext = getRemoteContext(xUrlResolver); + break; + } catch (NoConnectException ex) { + // Wait 500 ms, then try to connect again, but do not wait + // longer than 5 min (= 600 * 500 ms) total: + if (i == 600) { + throw new BootstrapException(ex.toString()); + } + Thread.sleep(500); + } + } + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new BootstrapException(e); + } + return xContext; + } + + /** + * Disconnects from an OOo server using the connection string from the + * previous connect. + * <p/> + * If there has been no previous connect, the disconnects does nothing. + * <p/> + * If there has been a previous connect, disconnect tries to terminate + * the OOo server and kills the OOo server process the connect started. + */ + public void disconnect() { + + if (oooConnectionString == null) { + return; + } + + // call ooo to terminate itself + try { + // get local context + XComponentContext xLocalContext = getLocalContext(); + + // create a URL resolver + XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext); + + // get remote context + XComponentContext xRemoteContext = getRemoteContext(xUrlResolver); + + // get desktop to terminate ooo + Object desktop = xRemoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xRemoteContext); + XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop); + xDesktop.terminate(); + } catch (Exception e) { + // Bad luck, unable to terminate ooo + } + + oooServer.kill(); + oooConnectionString = null; + } + + /** + * Create default local component context. + * + * @return The default local component context + */ + private XComponentContext getLocalContext() throws BootstrapException, Exception { + + XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null); + if (xLocalContext == null) { + throw new BootstrapException("no local component context!"); + } + return xLocalContext; + } + + /** + * Try to connect to ooo. + * + * @return The remote component context + */ + private XComponentContext getRemoteContext(XUnoUrlResolver xUrlResolver) throws BootstrapException, ConnectionSetupException, IllegalArgumentException, NoConnectException { + + Object context = xUrlResolver.resolve(oooConnectionString); + XComponentContext xContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, context); + if (xContext == null) { + throw new BootstrapException("no component context!"); + } + return xContext; + } + + /** + * Bootstraps a connection to an OOo server in the specified soffice + * executable folder of the OOo installation using the specified accept + * option and connection string and returns a component context for using + * the connection to the OOo server. + * <p/> + * The accept option and the connection string should match in connection + * type and pipe name or host and port to get a connection. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + * @param oooAcceptOption The accept option + * @param oooConnectionString The connection string + * @return The component context + */ + public static final XComponentContext bootstrap(String oooExecFolder, String oooAcceptOption, String oooConnectionString) throws BootstrapException { + + BootstrapConnector bootstrapConnector = new BootstrapConnector(oooExecFolder); + return bootstrapConnector.connect(oooAcceptOption, oooConnectionString); + } +} \ No newline at end of file Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapConnector.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapSocketConnector.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapSocketConnector.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapSocketConnector.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,122 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.ooo; + +import com.sun.star.comp.helper.BootstrapException; +import com.sun.star.uno.XComponentContext; + +/** A Bootstrap Connector which uses a socket to connect to an OOo server. */ +public class BootstrapSocketConnector extends BootstrapConnector { + + /** + * Constructs a bootstrap socket connector which uses the folder of the OOo installation containing the soffice executable. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + */ + public BootstrapSocketConnector(String oooExecFolder) { + + super(oooExecFolder); + } + + /** + * Constructs a bootstrap socket connector which connects to the specified + * OOo server. + * + * @param oooServer The OOo server + */ + public BootstrapSocketConnector(OOoServer oooServer) { + + super(oooServer); + } + + /** + * Connects to an OOo server using a default socket and returns a + * component context for using the connection to the OOo server. + * + * @return The component context + */ + public XComponentContext connect() throws BootstrapException { + + // create random pipe name + String host = "localhost"; + int port = 8100; + + return connect(host, port); + } + + /** + * Connects to an OOo server using the specified host and port for the + * socket and returns a component context for using the connection to the + * OOo server. + * + * @param host The host + * @param port The port + * @return The component context + */ + public XComponentContext connect(String host, int port) throws BootstrapException { + + // host and port + String hostAndPort = "host=" + host + ",port=" + port; + + // accept option + String oooAcceptOption = "-accept=socket," + hostAndPort + ";urp;"; + + // connection string + String unoConnectString = "uno:socket," + hostAndPort + ";urp;StarOffice.ComponentContext"; + + return connect(oooAcceptOption, unoConnectString); + } + + /** + * Bootstraps a connection to an OOo server in the specified soffice + * executable folder of the OOo installation using a default socket and + * returns a component context for using the connection to the OOo server. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + * @return The component context + */ + public static final XComponentContext bootstrap(String oooExecFolder) throws BootstrapException { + + BootstrapSocketConnector bootstrapSocketConnector = new BootstrapSocketConnector(oooExecFolder); + return bootstrapSocketConnector.connect(); + } + + /** + * Bootstraps a connection to an OOo server in the specified soffice + * executable folder of the OOo installation using the specified host and + * port for the socket and returns a component context for using the + * connection to the OOo server. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + * @param host The host + * @param port The port + * @return The component context + */ + public static final XComponentContext bootstrap(String oooExecFolder, String host, int port) throws BootstrapException { + + BootstrapSocketConnector bootstrapSocketConnector = new BootstrapSocketConnector(oooExecFolder); + return bootstrapSocketConnector.connect(host, port); + } +} \ No newline at end of file Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/BootstrapSocketConnector.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/OOoServer.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/OOoServer.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/OOoServer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,205 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.ooo; + +import com.sun.star.comp.helper.BootstrapException; +import com.sun.star.lib.util.NativeLibraryLoader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; + +/** + * Starts and stops an OOo server. + * <p/> + * Most of the source code in this class has been taken from the Java class + * "Bootstrap.java" (Revision: 1.15) from the UDK projekt (Uno Software Develop- + * ment Kit) from OpenOffice.org (http://udk.openoffice.org/). The source code + * is available for example through a browser based online version control + * access at http://udk.openoffice.org/source/browse/udk/. The Java class + * "Bootstrap.java" is there available at + * http://udk.openoffice.org/source/browse/udk/javaunohelper/com/sun/star/comp/... + */ +public class OOoServer { + + private static Log log = LogFactory.getLog(OOoServer.class); + + /** The OOo server process. */ + private Process oooProcess; + + /** The folder of the OOo installation containing the soffice executable. */ + private String oooExecFolder; + + /** The options for starting the OOo server. */ + private List oooOptions; + + /** + * Constructs an OOo server which uses the folder of the OOo installation + * containing the soffice executable and a list of default options to start + * OOo. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + */ + public OOoServer(String oooExecFolder) { + oooProcess = null; + this.oooExecFolder = oooExecFolder; + oooOptions = getDefaultOOoOptions(); + } + + /** + * Constructs an OOo server which uses the folder of the OOo installation + * containing the soffice executable and a given list of options to start + * OOo. + * + * @param oooExecFolder The folder of the OOo installation containing the soffice executable + * @param oooOptions The list of options + */ + public OOoServer(String oooExecFolder, List oooOptions) { + + oooProcess = null; + this.oooExecFolder = oooExecFolder; + this.oooOptions = oooOptions; + } + + /** + * Starts an OOo server which uses the specified accept option. + * <p/> + * The accept option can be used for two different types of connections: + * 1) The socket connection + * 2) The named pipe connection + * <p/> + * To create a socket connection a host and port must be provided. + * For example using the host "localhost" and the port "8100" the + * accept option looks like this: + * - accept option : -accept=socket,host=localhost,port=8100;urp; + * <p/> + * To create a named pipe a pipe name must be provided. For example using + * the pipe name "oooPipe" the accept option looks like this: + * - accept option : -accept=pipe,name=oooPipe;urp; + * + * @param oooAcceptOption The accept option + */ + public void start(String oooAcceptOption) throws BootstrapException, IOException, MalformedURLException { + + // find ooo executable relative to this class's class loader + String sOffice = System.getProperty("os.name").startsWith("Windows") ? + "soffice.exe" : "soffice"; + + URL[] oooExecFolderURL = new URL[]{new File(oooExecFolder).toURI().toURL()}; + URLClassLoader loader = new URLClassLoader(oooExecFolderURL); + File fOffice = NativeLibraryLoader.getResource(loader, sOffice); + if (fOffice == null) { + log.error("no ooo executable found!"); + throw new BootstrapException("no ooo executable found!"); + } + + // create call with arguments + int arguments = oooOptions != null ? oooOptions.size() + 1 : 1; + if (oooAcceptOption != null) { + arguments++; + } + + String[] oooCommand = new String[arguments]; + oooCommand[0] = fOffice.getPath(); + + for (int i = 0; i < oooOptions.size(); i++) { + oooCommand[i + 1] = (String) oooOptions.get(i); + } + + if (oooAcceptOption != null) { + oooCommand[arguments - 1] = oooAcceptOption; + } + + // start ooo process + oooProcess = Runtime.getRuntime().exec(oooCommand); + +// pipe(oooProcess.getInputStream(), System.out, "CO> "); +// pipe(oooProcess.getErrorStream(), System.err, "CE> "); + } + + /** + * Kills the OOo server process from the previous start. + * <p/> + * If there has been no previous start of the OOo server, the kill does + * nothing. + * <p/> + * If there has been a previous start, kill destroys the process. + */ + public void kill() { + + if (oooProcess != null) { + oooProcess.destroy(); + oooProcess = null; + } + } + + private static void pipe(final InputStream in, PrintStream out, final String prefix) { + new Thread("Pipe: " + prefix) { + @Override + public void run() { + BufferedReader r = new BufferedReader(new InputStreamReader(in)); + try { + for (; ;) { + String s = r.readLine(); + if (s == null) { + break; + } + log.info(prefix + s); + } + } catch (IOException e) { + e.printStackTrace(System.err); + } + } + }.start(); + } + + /** + * Returns the list of default options. + * + * @return The list of default options + */ + public static List getDefaultOOoOptions() { + + ArrayList options = new ArrayList(); + + options.add("-nologo"); + options.add("-nodefault"); + options.add("-norestore"); + options.add("-nocrashreport"); + options.add("-nolockcheck"); + + return options; + } +} \ No newline at end of file Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/OOoServer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/SingletonOOo.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/SingletonOOo.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/SingletonOOo.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,176 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.ooo; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.bridge.XBridge; +import com.sun.star.bridge.XBridgeFactory; +import com.sun.star.comp.helper.BootstrapException; +import com.sun.star.connection.XConnection; +import com.sun.star.connection.XConnector; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author Yolpo, kmorin + * <p/> + * Source : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=17839 + */ +public class SingletonOOo { + + private static Log log = LogFactory.getLog(SingletonOOo.class); + + private XComponentContext xContext = null; + + private static SingletonOOo oOo = null; + + private XMultiComponentFactory serviceManager = null; + + private Object desktop = null; + + private XComponentLoader loader = null; + + private static XBridge bridge; + + private Object mxMSF; + + public static final String DEFAULT_CONNECTION_STRING + = "socket,host=localhost,port=8100"; + + + private SingletonOOo(String oOoExecFolder) + throws com.sun.star.uno.Exception, BootstrapException { + openConnectionOpenOffice(oOoExecFolder); + } + + public static synchronized SingletonOOo GetInstance(String oOoExecFolder) + throws com.sun.star.uno.Exception, BootstrapException { + + if (oOo == null || bridge == null) { + oOo = new SingletonOOo(oOoExecFolder); + } + return oOo; + } + + public XMultiComponentFactory getServiceManager() { + + return serviceManager; + } + + public XComponentContext getXContext() { + + return xContext; + } + + public XComponentLoader getLoader() { + + return loader; + } + + public void openConnectionOpenOffice(String oOoExecFolder) + throws BootstrapException, com.sun.star.uno.Exception { + xContext = BootstrapSocketConnector.bootstrap(oOoExecFolder); + + // Création de l'objet de type Connector permettant de créer une + // connection entre java et OOo + Object x = xContext.getServiceManager().createInstanceWithContext( + "com.sun.star.connection.Connector", xContext); + XConnector xConnector = (XConnector) UnoRuntime + .queryInterface(XConnector.class, x); + + // Création de la connection entre java et OOo + XConnection connection = xConnector + .connect(DEFAULT_CONNECTION_STRING); + + // Création du bridge, étape très importante pour pouvoir + // fermer OOo sans avoir à faire un system.exit(); + // Le bridge est créé suivant la connection connection et le + // protocol de discussion urp + x = xContext.getServiceManager().createInstanceWithContext( + "com.sun.star.bridge.BridgeFactory", xContext); + + XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime + .queryInterface(XBridgeFactory.class, x); + + if (xBridgeFactory != null) { + + bridge = xBridgeFactory.createBridge("", "urp", connection, null); + + // Création de la XMultiComponentFactory qui permettra d'avoir + // acces aux services tels que le mailmerge + XComponent xComponent = (XComponent) UnoRuntime + .queryInterface(XComponent.class, bridge); + if (bridge != null) { + x = bridge.getInstance("StarOffice.ServiceManager"); + serviceManager = (XMultiComponentFactory) UnoRuntime + .queryInterface(XMultiComponentFactory.class, x); + + XPropertySet xProperySet = (XPropertySet) UnoRuntime + .queryInterface(XPropertySet.class, serviceManager); + + Object oDefaultContext = xProperySet + .getPropertyValue("DefaultContext"); + + xContext = (XComponentContext) UnoRuntime + .queryInterface(XComponentContext.class, oDefaultContext); + + serviceManager = xContext.getServiceManager(); + + desktop = serviceManager.createInstanceWithContext( + "com.sun.star.frame.Desktop", xContext); + + loader = (XComponentLoader) UnoRuntime + .queryInterface(XComponentLoader.class, desktop); + + if (mxMSF == null) { + mxMSF = UnoRuntime + .queryInterface(XMultiServiceFactory.class, + serviceManager); + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't bridge to ooo server"); + } + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't init bridge factory"); + } + } + } + + public void closeConnectionOpenOffice() { + XComponent xcomponent = (XComponent) UnoRuntime + .queryInterface(XComponent.class, bridge); + xcomponent.dispose(); + } + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/ooo/SingletonOOo.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/CompareFilter.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/CompareFilter.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/CompareFilter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,97 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.commons.lang.math.NumberUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * <code>CompareFilter</code> is the association of a term and a value. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class CompareFilter implements Filter { + + /** serialVersionUID. */ + private static final long serialVersionUID = 2L; + + protected String term = null; + + protected String value = null; + + public CompareFilter(String term, String value) { + this.term = term; + this.value = value; + } + + public String getName() { + return term; + } + + public void setName(String name) { + term = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return String.format("%s = %s", term, value); + } + + public boolean isBoolean() { + if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { + return true; + } + return false; + } + + public boolean isNumber() { + return NumberUtils.isNumber(value); + } + + public boolean isPhrase() { + int indexOf = value.indexOf(' '); + if (indexOf > -1) { + return true; + } + return false; + } + + public boolean match(Pattern pattern) { + Matcher matcher = pattern.matcher(value); + return matcher.matches(); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/CompareFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/Filter.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/Filter.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/Filter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,46 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import java.io.Serializable; + +/** + * A filter represents a term part or a sub filter. + * <p/> + * Example (valid filters): + * <ul> + * <li>thesaurus:xyz</li> + * <li>acheteur:ert OR date:eee</li> + * <li>not departement:44<li> + * <li>(acheteur:ert OR date:eee) AND (not departement:44)</li> + * <ul> + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public interface Filter extends Serializable { + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/Filter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterList.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterList.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterList.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,127 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.lucene.search.BooleanClause; + +import java.util.ArrayList; +import java.util.List; + +/** + * <code>FilterList</code> is an union of <code>Filters</code> + * which must obey the same <code>FilterList.Operator</code>. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class FilterList implements Filter { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + protected Operator operator; + + protected List<Filter> filters; + + public static enum Operator { + /** And. */ + FILTER_AND, + /** Or. */ + FILTER_OR, + /** Not. */ + FILTER_NOT; + + /** + * Find operator corresponding to lucene {@link BooleanClause} + * definition. + * + * @param booleanClause boolean clause to inspect + * @return operator to use + */ + public static Operator getOperator(BooleanClause booleanClause) { + Operator operator = null; + + if (booleanClause != null && booleanClause.isProhibited()) { + operator = FILTER_NOT; + + } else if (booleanClause != null && booleanClause.isRequired()) { + operator = FILTER_AND; + + } else { + operator = FILTER_OR; + } + + return operator; + } + + /** + * Return lucene operator String value used to recompose decomposed query. + * + * @return lucene operator value + */ + public String getValue() { + String luceneOperator = null; + switch (this) { + case FILTER_NOT: + luceneOperator = "NOT"; + break; + case FILTER_AND: + luceneOperator = "AND"; + break; + case FILTER_OR: + luceneOperator = "OR"; + break; + } + return luceneOperator; + } + } + + public FilterList() { + this(Operator.FILTER_AND); + } + + public FilterList(Operator operator) { + this.operator = operator; + filters = new ArrayList<Filter>(); + } + + public Operator getOperator() { + return operator; + } + + public void setOperator(Operator operator) { + this.operator = operator; + } + + public List<Filter> getFilters() { + return filters; + } + + public boolean addFilter(Filter filter) { + return filters.add(filter); + } + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterList.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterListQueryHandler.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterListQueryHandler.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterListQueryHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,233 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.PrefixQuery; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TermRangeQuery; +import org.apache.lucene.search.WildcardQuery; +import org.chorem.vradi.services.search.FilterList.Operator; + +import java.util.List; +import java.util.Stack; + +/** + * <code>FilterListHandler</code> handles lucene queries and assembles them into + * a <code>FilterList</code> tree. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class FilterListQueryHandler implements QueryHandler { + private static final Log log = LogFactory.getLog(FilterListQueryHandler.class); + + protected Stack<FilterList> filterListStack = new Stack<FilterList>(); + + public FilterListQueryHandler() { + FilterList filterList = new FilterList(); + filterListStack.push(filterList); + } + + @Override + public void prefixQuery(PrefixQuery query, BooleanClause booleanClause) { + Term term = query.getPrefix(); + Filter filter = new CompareFilter(term.field(), term.text() + "*"); + filter(filter, booleanClause); + } + + @Override + public void termQuery(TermQuery query, BooleanClause booleanClause) { + Term term = query.getTerm(); + Filter filter = new CompareFilter(term.field(), term.text()); + filter(filter, booleanClause); + } + + @Override + public void rangeQuery(TermRangeQuery query, BooleanClause booleanClause) { + String field = query.getField(); + String lowerTerm = query.getLowerTerm(); + String upperTerm = query.getUpperTerm(); + + Filter filter = new RangeFilter(field, lowerTerm, upperTerm); + filter(filter, booleanClause); + } + + @Override + public void wildcardQuery(WildcardQuery query, BooleanClause booleanClause) { + Term term = query.getTerm(); + Filter filter = new CompareFilter(term.field(), term.text()); + filter(filter, booleanClause); + } + + @Override + public void group(BooleanClause booleanClause) { + if (booleanClause == null) { + return; + } + + FilterList.Operator operator = Operator.getOperator(booleanClause); + FilterList filterList = new FilterList(operator); + + if (log.isTraceEnabled()) { + log.trace("group: " + operator.toString()); + } + + FilterList peek = filterListStack.peek(); + peek.addFilter(filterList); + + filterListStack.push(filterList); + } + + @Override + public void ungroup() { + if (filterListStack.size() > 1) { + filterListStack.pop(); + } + } + + public FilterList getFilterList() { + FilterList list = filterListStack.get(0); + + if (log.isDebugEnabled()) { + traceFilterList(list, ""); + } + + return list; + } + + public static String getQueryFromFilterList(FilterList list) { + if (list == null) { + return null; + } + FilterList parameter; + List<Filter> filters = list.getFilters(); + if (filters.size() == 1 && filters.get(0) instanceof FilterList) { + parameter = (FilterList) filters.get(0); + } else { + parameter = list; + } + String[] result = recomposeQuery(parameter); + return result[0] == null ? result[1] : + String.format("%s:(%s)", result[0], result[1]); + } + + static void traceFilterList(FilterList list, String spaces) { + Operator operator = list.getOperator(); + log.debug(String.format("%s%s [", spaces, operator.toString())); + spaces = spaces + " "; + List<Filter> filters = list.getFilters(); + for (Filter filter : filters) { + if (filter instanceof FilterList) { + traceFilterList((FilterList) filter, spaces); + } else { + log.debug(String.format("%s%s", spaces, filter.toString())); + } + } + spaces = spaces.substring(0, spaces.length() - 2); + log.debug(spaces + "]"); + } + + private void filter(Filter filter, BooleanClause booleanClause) { + FilterList peek = filterListStack.peek(); + FilterList.Operator operator = Operator.getOperator(booleanClause); + + if (operator == FilterList.Operator.FILTER_NOT && + peek.getOperator() != operator) { + + group(booleanClause); + peek = filterListStack.peek(); + peek.addFilter(filter); + ungroup(); + + } else { + peek.addFilter(filter); + } + } + + private static String[] recomposeQuery(FilterList filterList) { + String[] result = new String[2]; + + List<Filter> filters = filterList.getFilters(); + for (Filter filter : filters) { + String term = null; + String value = null; + String openSeparator = null; + String closeSeparator = null; + + if (filter instanceof FilterList) { + FilterList lFilter = (FilterList) filter; + String[] listResult = recomposeQuery(lFilter); + term = listResult[0]; + value = listResult[1]; + openSeparator = "("; + closeSeparator = ")"; + + } else if (filter instanceof CompareFilter) { + CompareFilter cFilter = (CompareFilter) filter; + term = cFilter.getName(); + value = "\"" + cFilter.getValue() + "\""; + openSeparator = ""; + closeSeparator = ""; + } + + //if it is the first filter + if (result[0] == null && result[1] == null) { + result[0] = term; + result[1] = String.format("%s%s%s", openSeparator, value, + closeSeparator); + + } else if (result[0] != null) { + //if the previous filter was concerning the same term + if (result[0].equals(term)) { + result[1] = String.format("%s %s %s%s%s", result[1], + filterList.getOperator().getValue(), + openSeparator, value, closeSeparator); + + //if the previous filter was concerning another term + } else { + result[1] = String.format("%s:(%s) %s %s:(%s)", + result[0], result[1], + filterList.getOperator().getValue(), + term, value); + result[0] = null; + } + + } else { + result[1] = String.format("%s %s %s:(%s)", result[1], + filterList.getOperator().getValue(), + term, value); + } + } + + return result; + } + + +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/FilterListQueryHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/LuceneQueryParser.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/LuceneQueryParser.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/LuceneQueryParser.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,123 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.PhraseQuery; +import org.apache.lucene.search.PrefixQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TermRangeQuery; +import org.apache.lucene.search.WildcardQuery; + +/** + * <code>LuceneQueryParser</code> parses a lucene <code>Query</code> object. + * Inner queries are passed to a <code>QueryHandler</code>. + * + * @author $Author$ + * @version $Revision$ $Date$ + */ +public class LuceneQueryParser { + private static final Log log = LogFactory.getLog(LuceneQueryParser.class); + + protected final QueryHandler termsFactory; + + protected BooleanClause booleanClause = null; + + public LuceneQueryParser(QueryHandler termsFactory) { + this.termsFactory = termsFactory; + } + + public synchronized void parse(Query query) throws UnsupportedQueryException { + if (log.isTraceEnabled()) { + log.trace("parse: " + query); + } + + if (query instanceof BooleanQuery) { + render((BooleanQuery) query); + } else if (query instanceof PrefixQuery) { + render((PrefixQuery) query); + } else if (query instanceof TermQuery) { + render((TermQuery) query); + } else if (query instanceof PhraseQuery) { + render((PhraseQuery) query); + } else if (query instanceof WildcardQuery) { + render((WildcardQuery) query); + } else if (query instanceof TermRangeQuery) { + render((TermRangeQuery) query); + } else { + throw new UnsupportedQueryException(query); + } + } + + protected void render(BooleanQuery query) throws UnsupportedQueryException { + BooleanClause booleanClauses[] = query.getClauses(); + + booleanClause = booleanClauses[0]; + termsFactory.group(booleanClause); + + for (int i = 0; i < booleanClauses.length; i++) { + booleanClause = booleanClauses[i]; + parse(booleanClause.getQuery()); + } + + termsFactory.ungroup(); + } + + protected void render(TermQuery query) { + termsFactory.termQuery(query, booleanClause); + } + + protected void render(PrefixQuery query) { + termsFactory.prefixQuery(query, booleanClause); + } + + protected void render(WildcardQuery query) { + termsFactory.wildcardQuery(query, booleanClause); + } + + protected void render(TermRangeQuery query) { + termsFactory.rangeQuery(query, booleanClause); + } + + protected void render(PhraseQuery query) { + Term terms[] = query.getTerms(); + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < terms.length; i++) { + Term term = terms[i]; + sb.append(term.text()).append(" "); + } + + String toString = sb.toString().trim(); + Term term = new Term(terms[0].field(), toString); + + render(new TermQuery(term)); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/LuceneQueryParser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/QueryHandler.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/QueryHandler.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/QueryHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.PrefixQuery; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TermRangeQuery; +import org.apache.lucene.search.WildcardQuery; + +/** + * a <code>QueryHandler</code> is able to handle lucene queries. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public interface QueryHandler { + + /** + * handles a <code>TermQuery</code>. + * + * @param termquery + * @param booleanClause + */ + void termQuery(TermQuery termquery, BooleanClause booleanClause); + + /** + * handles a <code>PrefixQuery</code>. + * + * @param prefixquery + * @param booleanClause + */ + void prefixQuery(PrefixQuery prefixquery, BooleanClause booleanClause); + + /** + * handles a <code>WildcardQuery</code>. + * + * @param wildcardquery + * @param booleanClause + */ + void wildcardQuery(WildcardQuery wildcardquery, BooleanClause booleanClause); + + /** + * handles a <code>TermRangeQuery</code>. + * + * @param rangequery + * @param booleanClause + */ + void rangeQuery(TermRangeQuery rangequery, BooleanClause booleanClause); + + /** + * indicates the start of new group of queries. + * + * @param booleanClause + */ + void group(BooleanClause booleanClause); + + /** indicates the end of the current group. */ + void ungroup(); +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/QueryHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/RangeFilter.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/RangeFilter.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/RangeFilter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,90 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.commons.lang.math.NumberUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * RangeFilter. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 4 mars 2010 10:38:16 + */ +public class RangeFilter extends CompareFilter { + private static final long serialVersionUID = 1L; + + protected String lowerValue = null; + + protected String upperValue = null; + + public RangeFilter(String term, String lowerValue, String upperValue) { + super(term, lowerValue); + this.lowerValue = lowerValue; + this.upperValue = upperValue; + } + + @Override + public void setValue(String value) { + this.value = value; + lowerValue = value; + } + + public void setLowerValue(String value) { + lowerValue = value; + } + + public String getLowerValue() { + return lowerValue; + } + + public void setUpperValue(String value) { + upperValue = value; + } + + public String getUpperValue() { + return upperValue; + } + + @Override + public boolean isNumber() { + return NumberUtils.isNumber(lowerValue) && NumberUtils.isNumber(upperValue); + } + + @Override + public boolean match(Pattern pattern) { + Matcher lowerMatcher = pattern.matcher(lowerValue); + Matcher upperMatcher = pattern.matcher(upperValue); + return lowerMatcher.matches() && upperMatcher.matches(); + } + + @Override + public String toString() { + return String.format("%s = [%s TO %s]", term, lowerValue, upperValue); + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/RangeFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/UnsupportedQueryException.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/UnsupportedQueryException.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/UnsupportedQueryException.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,59 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.lucene.search.Query; + +import static org.nuiton.i18n.I18n._; + +/** + * <code>UnsupportedQueryException</code> indicates that a <code>Query</code> + * is not supported by the <code>LuceneQueryParser</code>. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class UnsupportedQueryException extends Exception { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** Query that throw the exception. */ + protected String query = null; + + public UnsupportedQueryException(String query, Throwable cause) { + super(_("Unsupported query: %s", query), cause); + this.query = query; + } + + public UnsupportedQueryException(Query query) { + super("unsupported query: " + query.toString()); + } + + public String getQuery() { + return query; + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/UnsupportedQueryException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/VradiQueryParser.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/VradiQueryParser.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/VradiQueryParser.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,109 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services.search; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.WhitespaceAnalyzer; +import org.apache.lucene.queryParser.ParseException; +import org.apache.lucene.queryParser.QueryParser; +import org.apache.lucene.search.Query; +import org.apache.lucene.util.Version; + +/** + * VradiQueryParser supports the analysis of textual queries. + * <p/> + * Queries are analyzed by the lucene <code>QueryParser</code>, so they + * must obey his syntax. + * See at <a href="http://lucene.apache.org/java/3_0_2/queryparsersyntax.html"> + * queryparsersyntax.html</a> for a complete documentation. + * <p/> + * Analyzer used to parse queries is <code>WhitespaceAnalyzer</code> and the default + * parser operator is <code>QueryParser.Operator.AND</code>. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class VradiQueryParser { + + private static final Log log = LogFactory.getLog(VradiQueryParser.class); + + public static final String DEFAULT_FIELD = "text"; + + /** + * Parses the specified <code>expression</code> and returns a <code>FilterList</code>. + * + * @param expression the expression + * @return a <code>FilterList</code> + * @throws UnsupportedQueryException + */ + public static FilterList parse(String expression) throws UnsupportedQueryException { + return parse(expression, DEFAULT_FIELD); + } + + /** + * Parses the specified <code>expression</code> and returns a <code>FilterList</code>. + * + * @param expression the expression + * @param defaultField the default search field + * @return a <code>FilterList</code> + * @throws UnsupportedQueryException + */ + public static FilterList parse(String expression, String defaultField) throws UnsupportedQueryException { + FilterListQueryHandler queryHandler = new FilterListQueryHandler(); + parse(queryHandler, expression, defaultField); + + FilterList filterList = queryHandler.getFilterList(); + return filterList; + } + + static void parse(QueryHandler queryHandler, String expression, String defaultField) throws UnsupportedQueryException { + if (log.isDebugEnabled()) { + log.debug("expression: " + expression); + } + + Analyzer analyzer = new WhitespaceAnalyzer(); + QueryParser parser = new QueryParser(Version.LUCENE_29, defaultField, analyzer); + + parser.setAllowLeadingWildcard(true); + parser.setDefaultOperator(QueryParser.Operator.AND); + + if (expression == null || expression.trim().isEmpty()) { + expression = defaultField + ":*"; + } + + try { + Query query = parser.parse(expression.trim()); + + LuceneQueryParser luceneQueryParser = new LuceneQueryParser(queryHandler); + luceneQueryParser.parse(query); + + } catch (ParseException e) { + throw new UnsupportedQueryException(expression, e); + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/VradiQueryParser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/package-info.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/package-info.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/package-info.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,31 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +/** + * Ensemble de classes utilisée pour parser les requetes utilisateurs et + * éléments de filtre (date...) pour les transformer en une structure plus + * facile a manipuler ({@link FilterList}). + */ +package org.chorem.vradi.services.search; + Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/search/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ImportXmlStreamTasks.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ImportXmlStreamTasks.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ImportXmlStreamTasks.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,204 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.tasks; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfigurationHelper; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.managers.BindingManager; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ExceptionUtil; +import org.nuiton.wikitty.WikittyProxy; + +import javax.mail.Authenticator; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import java.io.UnsupportedEncodingException; +import java.util.List; +import java.util.Properties; +import java.util.TimerTask; + +import static org.nuiton.i18n.I18n._; + +/** + * This task run at specified stream import time to import new stream. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ImportXmlStreamTasks extends TimerTask { + + private static final Log log = LogFactory.getLog(ImportXmlStreamTasks.class); + + protected ApplicationConfig config; + + protected WikittyProxy wikittyProxy; + + protected BindingManager bindingManager; + + /** Il faut l'id du flux et non le flux (wikitty obselete). */ + protected String xmlStreamId; + + public ImportXmlStreamTasks(ApplicationConfig config, WikittyProxy wikittyProxy, BindingManager bindingManager, String xmlStreamId) { + this.config = config; + this.wikittyProxy = wikittyProxy; + this.bindingManager = bindingManager; + this.xmlStreamId = xmlStreamId; + } + + /* + * @see java.util.TimerTask#run() + */ + @Override + public void run() { + + try { + XmlStream xmlStream = wikittyProxy.restore(XmlStream.class, xmlStreamId); + if (log.isInfoEnabled()) { + log.info("Starting xml stream import on : " + xmlStream.getName() + "..."); + } + XmlStreamImportResult importResult = bindingManager.importFormsFromXmlStream(xmlStream); + if (log.isInfoEnabled()) { + log.info("Xml stream " + xmlStream.getName() + " imported : " + importResult.getCreatedFormCount() + " new forms."); + } + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't import forms from stream " + xmlStreamId, eee); + } + sendEmailError(xmlStreamId, eee); + } + } + + protected void sendEmailError(String xmlStreamId, VradiException error) { + + log.info("Error is occured, sending error email"); + + // Restore XmlStream + XmlStream xmlStream = wikittyProxy.restore(XmlStream.class, xmlStreamId); + + // Get admin emails + List<String> mailAdmin = VradiServiceConfigurationHelper.getMailAdmin(config); + for (String email : mailAdmin) { + + if (log.isDebugEnabled()) { + log.debug("Sending error email to " + email); + } + if (StringUtils.isBlank(email)) { + if (log.isWarnEnabled()) { + log.warn("Email is empty : " + email); + } + return; + } + + // TODO EC-20100505 use Session.getDefaultInstance() + // and common Properties form receiving/sending mails ! + Properties props = new Properties(); + props.put("mail.smtp.host", VradiServiceConfigurationHelper.getSmtpHost(config)); + props.put("mail.smtp.port", VradiServiceConfigurationHelper.getSmtpPort(config)); + //props.put("mail.smtp.auth", "true"); + //props.put("mail.smtp.socketFactory.port", config.getSmtpPort()); + //props.put("mail.smtp.socketFactory.class", SSL_FACTORY); + //props.put("mail.smtp.socketFactory.fallback", "false"); + //props.put("mail.debug", config.isMailDebug()); + + Session session = Session.getInstance(props, + new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication( + VradiServiceConfigurationHelper.getMailUser(config), + VradiServiceConfigurationHelper.getMailPassword(config)); + } + }); + + // EC-20100427 : attention, ca affiche le contenu des pdf joint + // c'est absolument illisible + //session.setDebug(log.isDebugEnabled()); + + // create a message + MimeMessage msg = new MimeMessage(session); + + try { + // set the from and to address + InternetAddress addressFrom = new InternetAddress(VradiServiceConfigurationHelper.getMailFrom(config), + VradiServiceConfigurationHelper.getMailFromName(config)); + + msg.setFrom(addressFrom); + + InternetAddress addressTo = new InternetAddress(email); + msg.addRecipient(Message.RecipientType.TO, addressTo); + + Multipart multiparts = new MimeMultipart(); + + // create the message part + MimeBodyPart msgBodyPart = new MimeBodyPart(); + msgBodyPart.setText(_("vradi.error.errorImportXmlStream", xmlStream.getName(), + ExceptionUtil.stackTrace(error))); + + multiparts.addBodyPart(msgBodyPart); + + // Put parts in message + msg.setContent(multiparts); + + // Setting the Subject and Content Type + msg.setSubject(_("vradi.error.errorImportXmlStream.subject", xmlStream.getName())); + + try { + Transport.send(msg); + } catch (MessagingException eee) { + if (log.isErrorEnabled()) { + log.error("Cant send mail", eee); + } + } + + + } catch (MessagingException eee) { + if (log.isErrorEnabled()) { + log.error("Can't generate message", eee); + } + } catch (UnsupportedEncodingException eee) { + if (log.isErrorEnabled()) { + log.error("Can't generate message", eee); + } + } + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ImportXmlStreamTasks.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ReceiveMailTasks.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ReceiveMailTasks.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ReceiveMailTasks.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,71 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.tasks; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.managers.MailingManager; + +import java.util.TimerTask; + +/** + * This task import xml stream at stream specified time. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ReceiveMailTasks extends TimerTask { + + private static final Log log = LogFactory.getLog(ReceiveMailTasks.class); + + protected MailingManager mailingManager; + + public ReceiveMailTasks(MailingManager mailingManager) { + this.mailingManager = mailingManager; + } + + /* + * @see java.util.TimerTask#run() + */ + @Override + public void run() { + try { + if (log.isInfoEnabled()) { + log.info("Checking for notification and error emails..."); + } + mailingManager.receiveMails(); + + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Mailing task can't run", eee); + } + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/ReceiveMailTasks.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/TasksManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/TasksManager.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/TasksManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,265 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.tasks; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.managers.BindingManager; +import org.chorem.vradi.services.managers.MailingManager; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.services.WikittyEvent; +import org.nuiton.wikitty.services.WikittyListener; + +import java.util.Calendar; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Timer; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; + +/** + * This manager handle tasks management in + * {@code org.chorem.vradi.services.tasks} package. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class TasksManager implements WikittyListener { + + private static final Log log = LogFactory.getLog(TasksManager.class); + + protected ApplicationConfig config; + + /** Cron task to check mails every 10 minutes. */ + protected Timer mailCronTimer; + + /** Cron task to import streams. */ + protected ScheduledExecutorService xmlStreamScheduler; + + protected ReceiveMailTasks receiveMailTasks; + + /** Map entre les id des flux, et les taches gérant. */ + protected Map<String, ScheduledFuture<?>> xmlStreamImportTasks; + + protected WikittyProxy wikittyProxy; + + protected MailingManager mailingManager; + + protected BindingManager bindingManager; + + public TasksManager(ApplicationConfig config, WikittyProxy wikittyProxy, MailingManager mailingManager, BindingManager bindingManager) { + this.config = config; + this.wikittyProxy = wikittyProxy; + this.mailingManager = mailingManager; + this.bindingManager = bindingManager; + xmlStreamImportTasks = new HashMap<String, ScheduledFuture<?>>(); + } + + /** Init all tasks. */ + public void initTasks() { + initMailTask(); + initXmlStreamTasks(); + } + + /** Init and start mail tasks (check every 10 minutes) */ + protected void initMailTask() { + mailCronTimer = new Timer("vradi-mail-task"); + receiveMailTasks = new ReceiveMailTasks(mailingManager); + mailCronTimer.schedule(receiveMailTasks, 0, 10 * 60 * 1000); + } + + /** Init and start xml stream tasks. */ + protected void initXmlStreamTasks() { + + // les imports sont fait sequentiellement + xmlStreamScheduler = Executors.newScheduledThreadPool(1); + + List<XmlStream> xmlStreams = bindingManager.getAllXmlStreams(); + + for (XmlStream xmlStream : xmlStreams) { + if (xmlStream != null) { + initXmlStreamTask(xmlStream); + } + } + } + + /** + * Init single xml stream task. + * + * @param xmlStream xml stream + */ + protected void initXmlStreamTask(XmlStream xmlStream) { + String streamImportTime = xmlStream.getImportTime(); + + if (StringUtils.isBlank(streamImportTime)) { + // par defaut minuit, si pas de données + streamImportTime = "0:0"; + } + + Matcher matchImportTime = VradiConstants.XML_STREAM_IMPORT_TIME.matcher(streamImportTime); + if (matchImportTime.find()) { + String hours = matchImportTime.group(1); + String minutes = matchImportTime.group(2); + + // calcule le nombre de minutes entre maitenant + // et l'heure d'import du flux + Calendar nowCalendar = Calendar.getInstance(); + int nowHours = nowCalendar.get(Calendar.HOUR_OF_DAY); + int nowMinutes = nowCalendar.get(Calendar.MINUTE); + + int toHours = Integer.parseInt(hours); + int toMinutes = Integer.parseInt(minutes); + + int delayInMinute = toHours * 60 + toMinutes - (nowHours * 60 + nowMinutes); + if (delayInMinute < 0) { + delayInMinute += 24 * 60; + } + + // TODO EC20100921 prevoir le cas où une tâche dure plus d'une journée + ImportXmlStreamTasks importTask = new ImportXmlStreamTasks(config, wikittyProxy, bindingManager, xmlStream.getWikittyId()); + ScheduledFuture<?> sheduledImportTask = xmlStreamScheduler.scheduleAtFixedRate(importTask, delayInMinute, 24 * 60, TimeUnit.MINUTES); + xmlStreamImportTasks.put(xmlStream.getWikittyId(), sheduledImportTask); + + if (log.isInfoEnabled()) { + log.info("Starting import of xml stream " + xmlStream.getName() + " at " + streamImportTime); + log.info(" - in scheduler, delai : " + delayInMinute + "min, period " + 24 * 60 + "min"); + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't parse " + streamImportTime + " for stream " + xmlStream.getWikittyId()); + } + } + } + + /** + * Cancel import task for specified id and restart a new task if requiered. + * + * @param xmlStreamId xml stream id + * @param restart restart a new import task for stream id + */ + protected void cancelXmlImportTask(String xmlStreamId, boolean restart) { + + // just cancel task + if (log.isDebugEnabled()) { + log.debug("Canceling import stream task for " + xmlStreamId); + } + ScheduledFuture<?> sheduledImportTask = xmlStreamImportTasks.get(xmlStreamId); + if (sheduledImportTask != null) { + xmlStreamImportTasks.remove(xmlStreamId); + sheduledImportTask.cancel(false); + } else { + // ca peut arriver lors de la creation de stream (pas de précédente) + if (log.isDebugEnabled()) { + log.debug("Nothing to cancel for wikitty id " + xmlStreamId); + } + } + + // restart when stream is updated + if (restart) { + XmlStream xmlStream = wikittyProxy.restore(XmlStream.class, xmlStreamId); + if (xmlStream == null) { + if (log.isErrorEnabled()) { + log.error("Can't restart import task for non existing xml stream " + xmlStreamId); + } + } else { + initXmlStreamTask(xmlStream); + } + } + } + + @Override + public void putWikitty(WikittyEvent event) { + + if (log.isDebugEnabled()) { + log.debug("Receiving wikitty event : " + event); + } + + // ecoute les modification faites sur les formulaires + Map<String, Wikitty> wikittiesMap = event.getWikitties(); + Collection<Wikitty> wikitties = wikittiesMap.values(); + for (Wikitty wikitty : wikitties) { + if (wikitty instanceof XmlStream) { + cancelXmlImportTask(((XmlStream) wikitty).getWikittyId(), true); + } + } + } + + @Override + public void removeWikitty(WikittyEvent event) { + + if (log.isDebugEnabled()) { + log.debug("Receiving wikitty event : " + event); + } + + // ecoute les modification faites sur les formulaires + // on ne peut pas savoir si c'est un xmlstream + // mais on c'est si l'id est lancé + Map<String, Wikitty> wikittyMap = event.getWikitties(); + if (wikittyMap != null) { + Set<String> wikittyIds = wikittyMap.keySet(); + for (String wikittyId : wikittyIds) { + // if pas indispensable, mais ca evite des log inutiles + if (xmlStreamImportTasks.containsKey(wikittyId)) { + cancelXmlImportTask(wikittyId, false); + } + } + } + } + + @Override + public void clearWikitty(WikittyEvent event) { + + } + + @Override + public void putExtension(WikittyEvent event) { + + } + + @Override + public void removeExtension(WikittyEvent event) { + + } + + @Override + public void clearExtension(WikittyEvent event) { + + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/TasksManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/package-info.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/package-info.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/package-info.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +/** + * Gestionnaire de taches de type cron. + */ +package org.chorem.vradi.services.tasks; Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/services/tasks/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/java/org/chorem/vradi/util/SSLUtils.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/util/SSLUtils.java (rev 0) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/util/SSLUtils.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,80 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.util; + +import com.sun.star.uno.RuntimeException; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; + +/** + * SSL utilities. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class SSLUtils { + + /** Trusted manager : accept every things. */ + protected static class SSLUtilsTrustManager implements X509TrustManager { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted( + X509Certificate[] certs, String authType) { + } + + @Override + public void checkServerTrusted( + X509Certificate[] certs, String authType) { + } + } + + /** Install a ssl {TrustManager} that accept every certificate. */ + public static void intallCertificateTruster() { + + // Install the all-trusting trust manager + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[]{new SSLUtilsTrustManager()}, + new SecureRandom()); + HttpsURLConnection + .setDefaultSSLSocketFactory(sc.getSocketFactory()); + } catch (Exception e) { + throw new RuntimeException( + "Can't install default ssl trust manager", e); + } + } +} Property changes on: trunk/vradi-services/src/main/java/org/chorem/vradi/util/SSLUtils.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties =================================================================== --- trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties (rev 0) +++ trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,90 @@ +Already\ opened\ session\ on\ %tF=Vous disposez d\u00E9j\u00E0 d'une session ouverte (le %1$td/%1$tm/%1$tY) +File\ upload\ failed\ \:\ invalid\ response= +File\ upload\ failed\ \:\ server\ response\ %d= +Nothing\ to\ send\ \:\ %s= +SMTP\ fail\ to\ send\ mail\ \:\\n(%s)=L'envoi de l'email a \u00E9chou\u00E9 \:\n(%s) +Unsupported\ query\:\ %s= +Version\ change\ detected\ \:\ %s.\ Reindexing\ data...= +vradi.adminXmlStream.config.interval.days=jours +vradi.adminXmlStream.config.interval.hours=heures +vradi.adminXmlStream.config.interval.minutes=minutes +vradi.email.status.deleted=Supprim\u00E9e +vradi.email.status.error=Erreur +vradi.email.status.received=Re\u00E7u +vradi.email.status.sent=Envoy\u00E9 +vradi.email.status.toSend=\u00C0 envoyer +vradi.email.status.waitingReceptionProof=En attente de l'accus\u00E9 +vradi.error.errorImportXmlStream=L'import automatique des flux xml '%1$s' \u00E0 \u00E9chou\u00E9 \:\n\n %2$s +vradi.error.errorImportXmlStream.subject=L'import automatique des flux xml '%1$s' \u00E0 \u00E9chou\u00E9 +vradi.error.sending.emailIsBlank=L'email de l'envoi pour l'utilisateur '%1$s' est vide +vradi.error.sending.failedToSend=L'envoi pour l'utilisateur '%1$s' a \u00E9chou\u00E9 \: %2$s +vradi.error.sending.formsEmpty=L'envoi pour l'utilisateur '%1$s' ne contient pas de formulaire +vradi.error.sending.generation=Erreur lors de la g\u00E9n\u00E9ration du m\u00E9ssage \: %1$s +vradi.error.sending.noAttachedPDF=Pas de pdf associ\u00E9 +vradi.error.sending.send=Erreur lors de l'envoie du m\u00E9ssage \: %1$s +vradi.error.session.stopped=L'envoie de la session '%1$s %2$s' a \u00E9t\u00E9 stopp\u00E9 par l'utilisateur +vradi.service.config.application.version.description= +vradi.service.config.cacheusecopies.description= +vradi.service.config.configFileName.description= +vradi.service.config.data.dir.description= +vradi.service.config.deleteObseleteThesaurus.description= +vradi.service.config.deleteObseleteUsers.description= +vradi.service.config.exportClients.description=Export des clients en csv +vradi.service.config.exportThesaurus.description=Export des thesaurus en csv +vradi.service.config.forceAllOldUserEnable.description= +vradi.service.config.help.description= +vradi.service.config.imap.host.description= +vradi.service.config.imap.port.description= +vradi.service.config.importFiles.description=Import des fichiers csv +vradi.service.config.listenevents.description= +vradi.service.config.mail.admin= +vradi.service.config.mail.admin.description= +vradi.service.config.mail.debug.description= +vradi.service.config.mail.from.description= +vradi.service.config.mail.fromname.description= +vradi.service.config.mail.offer.subject.description= +vradi.service.config.mail.password.description= +vradi.service.config.mail.user.description= +vradi.service.config.migration.skip.description= +vradi.service.config.oOo.exec.folder.description= +vradi.service.config.reIndexSolr.description= +vradi.service.config.reinitStatus.description= +vradi.service.config.session.defaultParagraph.description= +vradi.service.config.smtp.host.description= +vradi.service.config.smtp.port.description= +vradi.service.config.ui.locale= +vradi.service.config.ui.locale.description= +vradi.service.config.version.description= +vradi.service.config.wikitty.jgroupschannelname.description= +vradi.service.config.wikitty.notifier.transporter.class= +vradi.service.config.wikitty.notifier.transporter.class.description= +vradi.service.config.wikitty.propagate.description= +vradi.service.config.wikitty.propagate.propagateEvent= +vradi.service.config.wikitty.xmpp.room= +vradi.service.config.wikitty.xmpp.room.description= +vradi.service.config.wikitty.xmpp.server= +vradi.service.config.wikitty.xmpp.server.description= +vradi.sessionStatus.active=Active +vradi.sessionStatus.canceled=Annul\u00E9e +vradi.sessionStatus.error=Erreur +vradi.sessionStatus.sent=Envoy\u00E9e +vradi.sessionStatus.stopped=Stopp\u00E9e +vradi.status.nonselectionne.description=Trait\u00E9 et non s\u00E9lectionn\u00E9 +vradi.status.nonselectionne.name=Non s\u00E9lectionn\u00E9 +vradi.status.nontraite.description=Par d\u00E9faut toute nouvelle information +vradi.status.nontraite.name=Non trait\u00E9 +vradi.status.preselectionne.description=Trait\u00E9 et pr\u00E9s\u00E9lectionn\u00E9 +vradi.status.preselectionne.name=Pr\u00E9selectionn\u00E9 +vradi.status.selectionne.description=Trait\u00E9 et s\u00E9lectionn\u00E9 +vradi.status.selectionne.name=S\u00E9lectionn\u00E9 +vradi.xmlStreams= +vradi.xmlStreams.config= +vradi.xmlStreams.config.interval= +vradi.xmlStreams.config.interval.hour= +vradi.xmlStreams.config.interval.minute= +vradi.xmlStreams.config.interval.unit= +vradi.xmlStreams.config.interval.value= +wikitty.notifier.transporter.class= +wikitty.propagate.propagateEvent= +wikitty.xmpp.room= +wikitty.xmpp.server= Property changes on: trunk/vradi-services/src/main/resources/i18n/vradi-services_fr_FR.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/resources/log4j.properties =================================================================== --- trunk/vradi-services/src/main/resources/log4j.properties (rev 0) +++ trunk/vradi-services/src/main/resources/log4j.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,48 @@ +### +# #%L +# Vradi :: Services +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +# Global logging configuration +log4j.rootLogger=ERROR, stdout, file + +# Console output +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.file=vradi.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=4 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c - %m%n + +# Vradi +log4j.logger.org.chorem.vradi=INFO + +# Wikitty +log4j.logger.org.nuiton.wikitty.services.WikittyServiceStorage=INFO + +# Solr +log4j.logger.org.apache.solr.core.SolrCore=WARN Property changes on: trunk/vradi-services/src/main/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/resources/vradi-services.properties =================================================================== --- trunk/vradi-services/src/main/resources/vradi-services.properties (rev 0) +++ trunk/vradi-services/src/main/resources/vradi-services.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,72 @@ +### +# #%L +# Vradi :: Services +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +application.name=${project.name} +application.version=${project.version} + +vradi.objectStore.dir=${vradi.data.dir}/objectStore +vradi.temp.dir=/tmp + +wikitty.data.directory=${vradi.data.dir}/wikitty +oOo.exec.folder=/usr/bin +solr.data.dir=${wikitty.searchengine.solr.directory.data} + +# Mail (offer) +vradi.mail.offer.subject=Nouveaux appels d'offres \u00e0 ne pas manquer + +# Email configuration +vradi.smtp.host=smtp.codelutin.com +vradi.smtp.port=25 +vradi.imap.host=imap.codelutin.com +vradi.imap.port=143 +vradi.mail.user=vradi +vradi.mail.from=vradi@codelutin.com +vradi.mail.fromname=Vradi Bot +vradi.mail.password=xxxxxxxx + +# Default session paragraph +vradi.session.defaultParagraph=Voici la liste des nouveaux appels d'offres.\n\nCordialement.\n\n\L'\u00e9quipe ???.\n + +# Wikitty configuration +wikitty.searchengine.solr.directory.factory=solr.StandardDirectoryFactory +wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceStorage,\ +org.nuiton.wikitty.services.WikittyServiceNotifier,\ +org.chorem.vradi.services.VradiPDFCleanerService,\ +org.nuiton.wikitty.services.WikittyServiceCached,\ +org.nuiton.wikitty.services.WikittyServiceSecurity +wikitty.WikittyServiceStorage.components=org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC,\ +org.nuiton.wikitty.jdbc.WikittyStorageJDBC,\ +org.nuiton.wikitty.storage.solr.WikittySearchEngineSolr +wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter +wikitty.service.cache.listenevents=false +wikitty.service.cache.allwaysRestoreCopies=false +wikitty.service.event.propagate=true +wikitty.service.event.listen=false +wikitty.addon.export.threadnumber=1 +wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS +#wikitty.service.cache.priority.extensions=Thesaurus +jcs.default= +jcs.default.cacheattributes.MaxObjects=10000 +#jcs.priority.cacheattributes.MaxObjects=10000 Property changes on: trunk/vradi-services/src/main/resources/vradi-services.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/main/resources/webHarvest/OuestFranceImmo.xml =================================================================== --- trunk/vradi-services/src/main/resources/webHarvest/OuestFranceImmo.xml (rev 0) +++ trunk/vradi-services/src/main/resources/webHarvest/OuestFranceImmo.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + + +<config charset="UTF-8"> + + <!-- parse list web page --> + <var-def name="content"> + <html-to-xml> + <http url="${url}"/> + </html-to-xml> + </var-def> + + <!-- get all items --> + <var-def name="link"> + <xpath expression="//td[@class='Description']/a/@href"> + <var name="content"/> + </xpath> + </var-def> + + <!-- take the first and parse detail page web --> + <var-def name="contentDetail"> + <html-to-xml> + <http url="http://www.ouestfrance-immo.com${link.get(0)}"/> + </html-to-xml> + </var-def> + + <!-- init while condition : if page contains suivante href, continue --> + <var-def name="next"> + <xpath expression="//a[contains(., 'Suivante')]/@href"> + <var name="content"/> + </xpath> + </var-def> + + <!-- store result in var result --> + <var-def name="result"> + + <!-- write result template --> + <template><![CDATA[<?xml version="1.0" encoding="UTF-8"?> + <ouestFranceImmoDetail> + <title>ouestfrance-immo</title> + <description></description> + <lastBuildDate>${sys.datetime("dd.MM.yyyy, HH:mm:ss")}</lastBuildDate> + <link>www.ouestfrance-immo.com</link> ]]> + </template> + + <!-- while --> + <while condition="${next != null && !next.isEmpty()}" index="i_cnt"> + + <!-- empty to not write follow var --> + <empty> + + <!-- extract title --> + <var-def name="title"> + <xpath + expression="//div[@class='Contour02']/h2[@class='TtrNavigation02']/text()"> + <var name="contentDetail"/> + </xpath> + </var-def> + + <!-- extract prix --> + <var-def name="prix"> + <xpath + expression="//div[@class='Contour02']/h2[@class='TtrNavigation02']/em/text()"> + <var name="contentDetail"/> + </xpath> + </var-def> + + <!-- extract date --> + <var-def name="dateToParse"> + <xpath + expression="//div[@class='Contour02']/h2[@class='dateAnnonce']/text()"> + <var name="contentDetail"/> + </xpath> + </var-def> + + <!-- extract description --> + <var-def name="desc"> + <xpath + expression="//div[@class='Contour02']/div[@id='TexteAnn']/div[@class='Texte DiversTxtAnn']/text()"> + <var name="contentDetail"/> + </xpath> + </var-def> + </empty> + <template> + + <!-- write item --> + <![CDATA[ + <item> + <title>${title}</title> + <description>${desc}</description> + <pubDate>${dateToParse}</pubDate> + <link>${url}></link> + <prix>${prix}</prix> + </item> + ]]> + </template> + <empty> + <!-- extract next url --> + <var-def name="next"> + <xpath expression="//a[contains(., 'Suivante')]/@href"> + <var name="contentDetail"/> + </xpath> + </var-def> + + <!-- parse next page web --> + <var-def name="contentDetail"> + <html-to-xml> + <http + url="http://www.ouestfrance-immo.com/scripts/consult/PA/${next}"/> + </html-to-xml> + </var-def> + </empty> + </while> + <!-- add end balise --> + <template> + <![CDATA[ + </ouestFranceImmoDetail> ]]> + </template> + </var-def> + + +</config> \ No newline at end of file Property changes on: trunk/vradi-services/src/main/resources/webHarvest/OuestFranceImmo.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/site/rst/index.rst =================================================================== --- trunk/vradi-services/src/site/rst/index.rst (rev 0) +++ trunk/vradi-services/src/site/rst/index.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI :: Module services +======================== + +Ce module contient les services de VRADI. \ No newline at end of file Property changes on: trunk/vradi-services/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/site/site_fr.xml =================================================================== --- trunk/vradi-services/src/site/site_fr.xml (rev 0) +++ trunk/vradi-services/src/site/site_fr.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <menu ref="parent"/> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> \ No newline at end of file Property changes on: trunk/vradi-services/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,454 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.FieldTypeEnum; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.StatusImpl; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.UserImpl; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlFieldBindingImpl; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.entities.XmlStreamImpl; +import org.chorem.vradi.services.FileService; +import org.chorem.vradi.services.FileServiceImpl; +import org.chorem.vradi.services.ServiceFactory; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiDataServiceImpl; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiStorageService; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.Resource; +import org.nuiton.util.converter.ConverterUtil; +import org.nuiton.wikitty.WikittyConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Vradi common class for Junit tests. + * + * @version $Revision$ $Date$ + */ +public abstract class VradiTestAbstract { + + /** Log. */ + static private final Log log = LogFactory.getLog(VradiTestAbstract.class); + + protected ApplicationConfig config; + + /** Wikitty service. */ + protected WikittyProxy wikittyProxy; + + /** Data service. */ + protected VradiDataService dataService; + + /** Vradi service. */ + protected VradiStorageService storageService; + + /** File service. */ + protected FileService fileService; + + @BeforeClass + public static void initConfig() { + ConverterUtil.initConverters(); + + // static call : init + VradiServiceConfiguration instance = VradiTestConfiguration.getInstance(); + + instance.setSystemDefaultProps(); + + // Create tmpdir if not exist + String tmpdir = System.getProperty("java.io.tmpdir"); + File file = new File(tmpdir); + if (!file.exists()) { + file.mkdirs(); + } + + // file where to put wikitty datas + File dataDirectory = new File(tmpdir, "wikitty-data-store"); + if (log.isInfoEnabled()) { + log.info("Will use data directory : " + dataDirectory); + } + + // set data dir configuration + instance.setOption(WikittyConfig.WikittyOption.WIKITTY_DATA_DIR.key, + dataDirectory.getAbsolutePath()); + + if (log.isInfoEnabled()) { + log.info("Creating tmp dir : " + file); + } + } + + /** + * Clear database before each test. + * + * @throws Exception + */ + @Before + public void clear() throws Exception { + log.debug("--clear-----------------------------------------"); + + config = VradiTestConfiguration.getInstance(); + + storageService = ServiceFactory.getVradiStorageService(); + wikittyProxy = ServiceFactory.getWikittyProxy(); + wikittyProxy.clear(); + dataService = new VradiDataServiceImpl(config, wikittyProxy); + fileService = new FileServiceImpl(config); + } + + protected WikittyExtension createFileFormType() throws VradiException { + Map<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + fields.put("name", FieldTypeEnum.STRING.getFieldType()); + fields.put("dir", FieldTypeEnum.STRING.getFieldType()); + fields.put("size", FieldTypeEnum.NUMERIC.getFieldType()); + fields.put("lastModified", FieldTypeEnum.DATE_TIME.getFieldType()); + fields.put("modified", FieldTypeEnum.STRING.getFieldType()); + fields.put("description", FieldTypeEnum.TEXT.getFieldType()); + + return createFormType("file", fields); + } + + protected WikittyExtension createAnnonceFormType() throws VradiException { + Map<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + fields.put("acheteur", FieldTypeEnum.STRING.getFieldType()); + fields.put("date", FieldTypeEnum.STRING.getFieldType()); + fields.put("departement", FieldTypeEnum.STRING.getFieldType()); + fields.put("description", FieldTypeEnum.STRING.getFieldType()); + fields.put("intitule", FieldTypeEnum.STRING.getFieldType()); + + return createFormType("annonce", fields); + } + + protected WikittyExtension createDatesFormType() throws VradiException { + Map<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + fields.put("id", FieldTypeEnum.STRING.getFieldType()); + fields.put("date", FieldTypeEnum.DATE_TIME.getFieldType()); + return createFormType("dates", fields); + } + + /** + * Creates a <code>FormType</code> with the specified name and fields. + * If a <code>FormType</code> already exists with this name, it is returned as is, its + * fields may not be the same as those specified. + * + * @param name the name of <code>FormType</code> + * @param fields the fields of <code>FormType</code> + * @return a <code>WikittyExtension</code> + * @throws Exception + */ + protected WikittyExtension createFormType(String name, Map<String, FieldType> fields) throws VradiException { + WikittyExtension extension = dataService.getFormType(name); + + if (extension == null) { + extension = dataService.updateFormType(name, fields, Form.EXT_FORM, null); + } + + return extension; + } + + /** + * creates as many <code>XmlFieldBinding</code> as there are fields + * defined in the specified extension. + * + * @param extension the <code>WikittyExtension</code> to look at fields + * @return a list of <code>XmlFieldBinding</code> + * @throws Exception + */ + protected List<XmlFieldBinding> createXmlBindings(WikittyExtension extension) throws Exception { + List<XmlFieldBinding> bindings = new ArrayList<XmlFieldBinding>(); + + String name = extension.getName(); + Collection<String> fieldNames = extension.getFieldNames(); + + for (String field : fieldNames) { + XmlFieldBinding binding = new XmlFieldBindingImpl(); + binding.setFormField(name + "." + field); + binding.addXmlField(field); + + bindings.add(binding); + } + + bindings = dataService.updateXmlFieldBindings(bindings); + return bindings; + } + + /** + * Creates a <code>XmlStream</code> with the specified url, name and bindings. + * + * @param extension + * @param bindings + * @return a newly created <code>XmlStream</code> + * @throws Exception + */ + protected XmlStream createXmlStream(WikittyExtension extension, List<XmlFieldBinding> bindings, + URL resource) throws Exception { + XmlStream stream = new XmlStreamImpl(); + stream.setName(extension.getId()); + stream.setFormTypeName(extension.getName()); + + log.info("Setting xmlStream url to: " + resource.toExternalForm()); + stream.setUrl(resource.toExternalForm()); + + for (XmlFieldBinding fieldBinding : bindings) { + stream.addXmlFieldBinding(fieldBinding.getWikittyId()); + } + + BusinessEntity updateEntity = wikittyProxy.store(stream); + return (XmlStream) updateEntity; + } + + protected XmlStream createXmlStream(WikittyExtension extension, List<XmlFieldBinding> bindings) throws Exception { + String url = "/" + extension.getName() + ".xml"; + URL resource = Resource.getURL(url); + return createXmlStream(extension, bindings, resource); + } + + /** + * Creates a <code>Status</code> with the specified name, description + * value and modifiable + * + * @param name + * @param description + * @param value + * @param modifiable + * @return a newly created <code>Status</code> + * @throws Exception + */ + protected Status createSatus(String name, String description, + int value, boolean modifiable) + throws Exception { + Status status = new StatusImpl(); + status.setName(name); + status.setDescription(description); + status.setValue(value); + status.setModifiable(modifiable); + + BusinessEntity updateEntity = wikittyProxy.store(status); + return (Status) updateEntity; + } + + /** + * Creates a <code>Client</code> with the specified name and queries. + * + * @param name the client name + * @param queries + * @return a newly created <code>Client</code> + * @throws Exception + */ + protected Client createClient(String name, String... queries) + throws Exception { + Client client = new ClientImpl(); + client.setName(name); + client = wikittyProxy.store(client); + return client; + } + + /** + * Creates a <code>User</code> with the specified name and queries. + * + * @param name the user name + * @param queries + * @return a newly created <code>User</code> + * @throws Exception + */ + protected User createUser(String name, String... queries) + throws Exception { + User user = new UserImpl(); + user.setName(name); + user = wikittyProxy.store(user); + return user; + } + + /** + * Creates a <code>Group</code> with the specified name and queries. + * + * @param name the group name + * @param queries + * @return a newly created <code>Group</code> + * @throws Exception + */ + protected Group createGroup(String name, String... queries) + throws Exception { + Group group = new GroupImpl(); + for (String query : queries) { + group.addQueries(query); + } + group.setName(name); + group = wikittyProxy.store(group); + return group; + } + + protected WikittyExtension createThesaurusExtension() throws Exception { + WikittyExtension thesaurusExtension = ThesaurusImpl.extensionThesaurus; + thesaurusExtension = dataService.updateFormType(thesaurusExtension); + return thesaurusExtension; + } + + protected Thesaurus createThesaurus(String name, RootThesaurus rootThesaurus, String... tags) throws Exception { + return createThesaurus(name, null, rootThesaurus, tags); + } + + protected Thesaurus createThesaurus(String name, String parent, RootThesaurus rootThesaurus, String... tags) throws Exception { + + Thesaurus result = new ThesaurusImpl(); + + result.setName(name); + result.setParent(parent); + + // can't be null + result.setRootThesaurus(rootThesaurus.getWikittyId()); + + if (tags != null) { + for (String tag : tags) { + result.addTags(tag); + } + } + + result = wikittyProxy.store(result); + return result; + } + + /* + * Exports all data to the specified <code>fileName</code>. + * + * @param fileName + * @throws Exception + * + protected void export(String fileName) throws Exception { + String exportData = storageService.exportData(); + Writer output = new BufferedWriter(new FileWriter(fileName)); + IOUtils.write(exportData, output); + IOUtils.closeQuietly(output); + } + + /* + * Imports all the data from the specified <code>fileName</code>. + * + * @param fileName + * @throws Exception + * + protected void importt(String fileName) throws Exception { + storageService.importData(new File(fileName)); + }*/ + + protected void testSearch(String query, int count) throws Exception { + FormPagedResult testSearch = testSearch(query); + Assert.assertEquals(count, testSearch.getTotalFoundFormNb()); + } + + protected FormPagedResult testSearch(String query) throws Exception { + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters(query); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + + if (log.isTraceEnabled()) { + traceFormsFound(formPagedResult); + } + + return formPagedResult; + } + + protected void testSearch(Status[] statuses, int count) throws Exception { + FormPagedResult testSearch = testSearch(statuses); + Assert.assertEquals(count, testSearch.getTotalFoundFormNb()); + } + + protected FormPagedResult testSearch(Status[] statuses) throws Exception { + List<String> statusIds = null; + if (statuses != null) { + statusIds = new ArrayList<String>(statuses.length); + for (int i = 0; i < statuses.length; i++) { + statusIds.add(statuses[i].getWikittyId()); + } + } + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters(); + queryParameters.setStatusIds(statusIds); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + + if (log.isTraceEnabled()) { + traceFormsFound(formPagedResult); + } + + return formPagedResult; + } + + protected void traceFormsFound(FormPagedResult formPageDTO) { + List<String> formsIds = formPageDTO.getFormsIdsToShow(); + + List<Form> forms = wikittyProxy.restore(Form.class, formsIds); + for (Form form : forms) { + + Collection<String> extensions = form.getExtensionNames(); + log.trace(form.getWikittyId()); + + for (String extension : extensions) { + Collection<String> extensionFields = form + .getExtensionFields(extension); + + for (String field : extensionFields) { + log.trace(String.format(" %s: %.100s", field, form + .getField(extension, field))); + } + } + } + } + + protected XmlStreamImportResult initData(WikittyExtension extension) + throws Exception { + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings); + return storageService.importFormsFromXmlStream(xmlStream); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestAbstract.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestConfiguration.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestConfiguration.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestConfiguration.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.apache.commons.lang.UnhandledException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.wikitty.WikittyConfig; + +import java.io.InputStream; +import java.util.Locale; +import java.util.Properties; + +/** + * Test configuration. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiTestConfiguration extends VradiServiceConfiguration { + + /** log. */ + private static final Log log = LogFactory.getLog(VradiTestConfiguration.class); + + /* + * Overwrite getInstance to setup a Test specific one. + */ + public static synchronized VradiServiceConfiguration getInstance() { + if (instance == null) { + + // Be sure to not read other config files + InputStream input = VradiServiceConfiguration.class.getResourceAsStream("/vradi-services.properties"); + Properties options = new Properties(); + try { + options.load(input); + } catch (Exception e) { + throw new UnhandledException(e); + } + instance = new VradiServiceConfiguration(); + + // set wikitty option as default + for (WikittyConfig.WikittyOption o : WikittyConfig.WikittyOption.values()) { + if (o.getDefaultValue() != null) { + instance.setOption(o.getKey(), o.getDefaultValue()); + } + } + + // Set vradi condig test options + instance.setOptions(options); + + // fix locale during test + VradiServiceConfigurationHelper.setLocale(instance, Locale.FRANCE); + } + return instance; + } + + +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/VradiTestConfiguration.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/beans/QueryBeanTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/beans/QueryBeanTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/beans/QueryBeanTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,93 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.beans; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; + +/** + * Query bean tests. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class QueryBeanTest { + + /** Test du constructeur vide. */ + @Test + public void testQueryBean() { + QueryBean queryBean = new QueryBean(); + Assert.assertNull(queryBean.getId()); + } + + /** + * Test du constructeur avec 1 argument. + * + * @throws IOException + */ + @Test + public void testQueryBean2() throws IOException { + QueryBean queryBean = new QueryBean("test,test,test"); + Assert.assertEquals(3, queryBean.queryArray.length); + } + + /** Test du parsing/encoding. */ + @Test + public void testQueryBeanParsing() { + QueryBean queryBean = new QueryBean(); + queryBean = queryBean.setDescription("description"); + queryBean = queryBean.setName("Ma requete"); + queryBean = queryBean.setQuery("thesaurus:all"); + + Assert.assertEquals("\"thesaurus:all\",\"Ma requete\",\"description\"", queryBean.getCSVQuery()); + } + + /** + * Test des caracteres speciaux dans l'encodage CSV. + * + * @throws IOException + */ + @Test + public void testQueryBeanSpecialChars() throws IOException { + QueryBean queryBean = new QueryBean("\"avec des \"\",dans les quotes\"\"\",\"avec des ,\",\"avec des \"\"quotes\"\"\""); + + Assert.assertEquals("avec des \",dans les quotes\"", queryBean.toArray()[0]); + Assert.assertEquals("avec des ,", queryBean.toArray()[1]); + Assert.assertEquals("avec des \"quotes\"", queryBean.toArray()[2]); + + queryBean = queryBean.setDescription("double\"\"quote\"\""); + queryBean = queryBean.setName("double,,"); + queryBean = queryBean.setQuery("mix \",\","); + + Assert.assertEquals("\"mix \"\",\"\",\",\"double,,\",\"double\"\"\"\"quote\"\"\"\"\"", queryBean.getCSVQuery()); + } + +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/beans/QueryBeanTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/MiscServicesTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/MiscServicesTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/MiscServicesTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,125 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Test; +import org.nuiton.wikitty.WikittyService; + +import java.io.Serializable; +import java.lang.reflect.Method; + +/** + * Misc test for all services. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class MiscServicesTest { + + static private final Log log = LogFactory.getLog(MiscServicesTest.class); + + protected boolean isValidServiceType(Class<?> clazz) { + boolean result = false; + + if (clazz.isInterface() || clazz.isPrimitive()) { + result = true; + } else { + if (Serializable.class.isAssignableFrom(clazz)) { + result = true; + } + } + + // fail if "file" + if (clazz.getName().equals("java.io.File")) { + result = false; + } + + if (clazz.getName().equals("org.nuiton.wikitty.WikittyTransaction")) { + if (log.isWarnEnabled()) { + log.warn("Warning : method parameter " + clazz.getName() + " is only tolerated (can't be used) !"); + } + result = true; + } + + return result; + } + + /** + * Test que tous les parametres des methodes et les types de retour + * sur les interfaces de services sont {@link Serializable}. + */ + @Test + public void testSerializableParamsAndReturnForService() { + + boolean foundNotSerializable = false; + + Class<?>[] classesToTest = { + VradiDataService.class, + VradiStorageService.class, + WikittyService.class + }; + + for (Class<?> clazz : classesToTest) { + + Method[] methods = clazz.getDeclaredMethods(); + for (Method method : methods) { + + // test des parametres + Class<?>[] parameters = method.getParameterTypes(); + + for (Class<?> parameter : parameters) { + if (!isValidServiceType(parameter)) { + if (log.isErrorEnabled()) { + log.error(clazz.getSimpleName() + "#" + method.getName() + + " uses a non allowed parameter type : " + parameter.getCanonicalName()); + } + foundNotSerializable = true; + } + } + + // test du type de retour + Class<?> returnType = method.getReturnType(); + + if (!isValidServiceType(returnType)) { + if (log.isErrorEnabled()) { + log.error(clazz.getSimpleName() + "#" + method.getName() + + " uses a non allowed return type : " + returnType.getCanonicalName()); + } + + foundNotSerializable = true; + } + } + } + + Assert.assertFalse("A service class uses not serializable stuff !", foundNotSerializable); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/MiscServicesTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiDataServiceTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiDataServiceTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiDataServiceTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,449 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.UserImpl; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author sletellier + * @version $Revision$ $Date$ + */ +public class VradiDataServiceTest extends VradiTestAbstract { + static private final Log log = LogFactory.getLog(VradiStorageServiceTest.class); + + protected String[] initClientDatas() { + Client client = new ClientImpl(); + client.setName("newClient"); + + User user = new UserImpl(); + user.setName("newUser"); + user.setClient(client.getWikittyId()); + + Group group = new GroupImpl(); + group.setName("newGroup"); + group.addUser(user.getWikittyId()); + + client = wikittyProxy.store(client); + user = wikittyProxy.store(user); + group = wikittyProxy.store(group); + + return new String[]{client.getWikittyId(), user.getWikittyId(), group.getWikittyId()}; + } + + /** + * Test search through Thesaurus + * + * @throws Exception when an error occurred during test + */ + @Test + public void testPropositions() throws Exception { + + // first thesaurus : thesaurus + RootThesaurus rootThesaurus = new RootThesaurusImpl(); + rootThesaurus.setName("thesaurus"); + wikittyProxy.store(rootThesaurus); + + //import data + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //test the propositions with a form containing Nogent + FormPagedResult fpNogent = testSearch("Nogent"); + String fIdNogent = fpNogent.getFormsIdsToShow().get(0); + Assert.assertNotNull(fIdNogent); + + //test with no thesaurus node recorded + //should return an empty list + List<Thesaurus> list = dataService.proposeThesaurus(fIdNogent); + Assert.assertNotNull(list); + Assert.assertEquals(list.size(), 0); + + //test with a thesaurus node with the tag Nogent + //should return a list containing the thesaurus node + Thesaurus nogent = createThesaurus("Nogent", rootThesaurus, "Nogent"); + list = dataService.proposeThesaurus(fIdNogent); + Assert.assertNotNull(list); + Assert.assertEquals(list.size(), 1); + Assert.assertNotNull(list.get(0)); + Assert.assertEquals(list.get(0).getWikittyId(), nogent.getWikittyId()); + + //add the thesaurus to the form, + // the thesaurus should not be in the propositions anymore + nogent.addAttachment(fIdNogent); + wikittyProxy.store(nogent); + list = dataService.proposeThesaurus(fIdNogent); + Assert.assertNotNull(list); + Assert.assertEquals(list.size(), 0); + } + + /** + * Test search through Thesaurus. + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testPropositions2() throws Exception { + // first thesaurus : thesaurus + RootThesaurus rootThesaurus = new RootThesaurusImpl(); + rootThesaurus.setName("thesaurus"); + wikittyProxy.store(rootThesaurus); + + //WikittyExtension thesaurusExt = createThesaurusExtension(); + WikittyExtension extension = createFileFormType(); + initData(extension); + + Thesaurus tagSoiree = createThesaurus("abc", rootThesaurus, "soirée"); + Thesaurus tagFrites = createThesaurus("def", rootThesaurus, "frites"); + + String formIdSoiree = testSearch("description:soirée").getFormsIdsToShow().get(0); + List<Thesaurus> nodes = dataService.proposeThesaurus(formIdSoiree); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 1); + String node1 = nodes.get(0).getWikittyId(); + Assert.assertEquals(node1, tagSoiree.getWikittyId()); + + String formIdFrites = testSearch("description:frites").getFormsIdsToShow().get(0); + nodes = dataService.proposeThesaurus(formIdFrites); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 1); + node1 = nodes.get(0).getWikittyId(); + Assert.assertEquals(node1, tagFrites.getWikittyId()); + + // ajout d'un noeud de thesaurus ayant les mêmes tags que les 2 autres noeuds + Thesaurus tagSoireeFrites = createThesaurus("ghi", rootThesaurus, "soirée", "frites"); + + nodes = dataService.proposeThesaurus(formIdSoiree); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 2); + node1 = nodes.get(0).getWikittyId(); + String node2 = nodes.get(1).getWikittyId(); + Assert.assertTrue(node1.equals(tagSoiree.getWikittyId()) + || node1.equals(tagSoireeFrites.getWikittyId())); + Assert.assertTrue(node2.equals(tagSoiree.getWikittyId()) + || node2.equals(tagSoireeFrites.getWikittyId())); + + nodes = dataService.proposeThesaurus(formIdFrites); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 2); + node1 = nodes.get(0).getWikittyId(); + node2 = nodes.get(1).getWikittyId(); + Assert.assertTrue(node1.equals(tagFrites.getWikittyId()) + || node1.equals(tagSoireeFrites.getWikittyId())); + Assert.assertTrue(node2.equals(tagFrites.getWikittyId()) + || node2.equals(tagSoireeFrites.getWikittyId())); + + // ajout d'un noeud de thesaurus + Thesaurus tagSoeur = createThesaurus("jkl", rootThesaurus, "soeur"); + nodes = dataService.proposeThesaurus(formIdSoiree); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 2); + node1 = nodes.get(0).getWikittyId(); + node2 = nodes.get(1).getWikittyId(); + Assert.assertTrue(node1.equals(tagSoiree.getWikittyId()) + || node1.equals(tagSoireeFrites.getWikittyId())); + Assert.assertTrue(node2.equals(tagSoiree.getWikittyId()) + || node2.equals(tagSoireeFrites.getWikittyId())); + + nodes = dataService.proposeThesaurus(formIdFrites); + Assert.assertNotNull(nodes); + Assert.assertEquals(nodes.size(), 3); + node1 = nodes.get(0).getWikittyId(); + node2 = nodes.get(1).getWikittyId(); + String node3 = nodes.get(2).getWikittyId(); + Assert.assertTrue(node1.equals(tagFrites.getWikittyId()) + || node1.equals(tagSoireeFrites.getWikittyId()) + || node1.equals(tagSoeur.getWikittyId())); + Assert.assertTrue(node2.equals(tagFrites.getWikittyId()) + || node2.equals(tagSoireeFrites.getWikittyId()) + || node2.equals(tagSoeur.getWikittyId())); + Assert.assertTrue(node3.equals(tagFrites.getWikittyId()) + || node3.equals(tagSoireeFrites.getWikittyId()) + || node3.equals(tagSoeur.getWikittyId())); + } + + /** + * Test getBeginOfDaySolrDate. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testGetSessionForDay() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session2 = new SessionImpl(); + session2.setSessionDate(date); + session2.setNum(1); + session2.setStatus(VradiConstants.SessionStatus.ERROR.getValue()); + sessions.add(session2); + + Session session3 = new SessionImpl(); + session3.setSessionDate(date); + session3.setNum(2); + session3.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session3); + + wikittyProxy.store(sessions); + + //Check that we got three sessions for date + List<Session> sessionList = dataService.getSessions(date); + Assert.assertEquals(3, sessionList.size()); + + //check that we got no session for date+1 day + List<Session> sessionList2 = dataService.getSessions(DateUtils.addDays(date, 1)); + Assert.assertEquals(0, sessionList2.size()); + + //Add an active session for date + Session session4 = new SessionImpl(); + session4.setSessionDate(DateUtils.addSeconds(date, 1)); + session4.setNum(3); + session4.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + wikittyProxy.store(session4); + + // check that we got 0 session for date+1 day + // no session creation asked, so no session + List<Session> sessionList3 = dataService.getSessions(DateUtils.addDays(date, 1)); + Assert.assertEquals(0, sessionList3.size()); + } + + /** + * Test getLastOpenedSession. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testGetLastCloseSession() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(3); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session2 = new SessionImpl(); + session2.setSessionDate(DateUtils.addMinutes(date, -1)); + session2.setNum(2); + session2.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session2); + + Session session3 = new SessionImpl(); + session3.setSessionDate(DateUtils.addMinutes(date, -2)); + session3.setNum(10); + session3.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session3); + + Session session4 = new SessionImpl(); + session4.setSessionDate(DateUtils.addDays(date, -1)); + session4.setNum(1); + session4.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session4); + + Session session5 = new SessionImpl(); + session5.setSessionDate(DateUtils.addDays(date, -2)); + session5.setNum(1); + session5.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session5); + + wikittyProxy.store(sessions); + + Session result = dataService.getLastCloseSession(); + Assert.assertEquals(10, result.getNum()); + } + + /** + * Test getLastOpenedSession. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testGetLastOpenedSession() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(3); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session2 = new SessionImpl(); + session2.setSessionDate(DateUtils.addMinutes(date, -1)); + session2.setNum(2); + session2.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session2); + + Session session3 = new SessionImpl(); + session3.setSessionDate(DateUtils.addMinutes(date, -2)); + session3.setNum(1); + session3.setStatus(VradiConstants.SessionStatus.ERROR.getValue()); + sessions.add(session3); + + Session session4 = new SessionImpl(); + session4.setSessionDate(DateUtils.addDays(date, -1)); + session4.setNum(1); + session4.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session4); + + Session session5 = new SessionImpl(); + session5.setSessionDate(DateUtils.addDays(date, -2)); + session5.setNum(1); + session5.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session5); + + wikittyProxy.store(sessions); + + Session result = dataService.getLastOpenSession(); + Assert.assertEquals(3, result.getNum()); + } + + /** + * Test getLastOpenedSession. + * <p/> + * Depuis le 20100909 la session n'est plus créée si elle sont + * toutes fermées. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testGetLastOpenedSessionAllClosed() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(DateUtils.addMinutes(date, -2)); + session.setNum(1); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session2 = new SessionImpl(); + session2.setSessionDate(DateUtils.addMinutes(date, -1)); + session2.setNum(2); + session2.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session2); + + Session session3 = new SessionImpl(); + session3.setSessionDate(date); + session3.setNum(3); + session3.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session3); + + wikittyProxy.store(sessions); + + // aucune ouvert, retourne null + Session result = dataService.getLastOpenSession(); + Assert.assertNull(result); + } + + /** + * Test client deletion, user associated and group association + * + * @throws VradiException + */ + public void testDeleteClient() throws Exception { + String[] ids = initClientDatas(); + + dataService.deleteClient(ids[0]); + + Client client = wikittyProxy.restore(Client.class, ids[0]); + Assert.assertNull(client); + + User user = wikittyProxy.restore(User.class, ids[1]); + Assert.assertNull(user); + + Group group = wikittyProxy.restore(Group.class, ids[2]); + Assert.assertNull(group.getUser()); + + } + + /** + * Test user deletion and group association + * + * @throws VradiException + */ + public void testDeleteUser() throws VradiException { + String[] ids = initClientDatas(); + + dataService.deleteUser(ids[1]); + + User user = wikittyProxy.restore(User.class, ids[1]); + Assert.assertNull(user); + + Group group = wikittyProxy.restore(Group.class, ids[2]); + Assert.assertNull(group.getUser()); + } + + /** + * Test group deletion + * + * @throws VradiException + */ + public void testDeleteGroup() throws VradiException { + String[] ids = initClientDatas(); + + dataService.deleteUser(ids[2]); + + Group group = wikittyProxy.restore(Group.class, ids[2]); + Assert.assertNull(group); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiDataServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiStorageServiceTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiStorageServiceTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiStorageServiceTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,2116 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import com.sun.star.comp.helper.BootstrapException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.FieldTypeEnum; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.ModificationTagImpl; +import org.chorem.vradi.entities.QueryMakerImpl; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.UserImpl; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.managers.MailingManager; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyTreeNodeImpl; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; + +import java.io.File; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** @version $Revision$ $Date$ */ +public class VradiStorageServiceTest extends VradiTestAbstract { + static private final Log log = LogFactory.getLog(VradiStorageServiceTest.class); + + /** @throws Exception when an error occurred during test */ + @Test + public void testXmlStreamDuplication() throws Exception { + WikittyExtension extension = createAnnonceFormType(); + + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings); + + XmlStreamImportResult result = storageService.importFormsFromXmlStream(xmlStream); + Assert.assertEquals(5, result.getCreatedFormCount()); + Assert.assertEquals(0, result.getAlreadyExistsFormCount()); + testSearch("*", 5); + + result = storageService.importFormsFromXmlStream(xmlStream); + Assert.assertEquals(0, result.getCreatedFormCount()); + Assert.assertEquals(5, result.getAlreadyExistsFormCount()); + testSearch("*", 5); + } + + /** @throws Exception when an error occurred during test */ + @Test + public void testDateInterval() throws Exception { + WikittyExtension extension = createFileFormType(); + XmlStreamImportResult initData = initData(extension); + Assert.assertEquals(4, initData.getCreatedFormCount()); + + FormPagedResult formPageDTO = new FormPagedResult(); + Date end = new Date(); + + Calendar begin = new GregorianCalendar(); + begin.setTime(end); + begin.set(Calendar.MINUTE, begin.get(Calendar.MINUTE) - 1); + + QueryParameters queryParameters = new QueryParameters(); + queryParameters.setDateFieldName(Infogene.FQ_FIELD_INFOGENE_CREATIONDATE); + queryParameters.setBeginDate(begin.getTime()); + queryParameters.setEndDate(end); + formPageDTO = dataService.findForms(queryParameters, formPageDTO); + int total = formPageDTO.getTotalFoundFormNb(); + Assert.assertEquals(4, total); + + queryParameters.setEndDate(begin.getTime()); + formPageDTO = dataService.findForms(queryParameters, formPageDTO); + total = formPageDTO.getTotalFoundFormNb(); + Assert.assertEquals(0, total); + } + + /** + * Test that partial request return results. + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testFindFormWithPartialQuery() throws Exception { + Form form = new FormImpl(); + form.setObjet("Entretien des propriétés de silène à Saint Nazaire"); + wikittyProxy.store(form); + + FormPagedResult pagedResult = testSearch("objet:silene"); + Assert.assertEquals(1, pagedResult.getTotalFoundFormNb()); + + pagedResult = testSearch("Entretien des propriétés de silène à Saint Nazaire"); + Assert.assertEquals(1, pagedResult.getTotalFoundFormNb()); + + pagedResult = testSearch("objet:(Entretien des propriétés de silène à Saint Nazaire)"); + Assert.assertEquals(1, pagedResult.getTotalFoundFormNb()); + + pagedResult = testSearch("objet:(silène à Saint Nazaire)"); + Assert.assertEquals(1, pagedResult.getTotalFoundFormNb()); + } + + /** + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testSearchFile() throws Exception { + WikittyExtension extension = createFileFormType(); + XmlStreamImportResult initData = initData(extension); + Assert.assertEquals(4, initData.getCreatedFormCount()); + + // text + testSearch((String) null, 4); + testSearch("", 4); + testSearch("*", 4); + + testSearch("soirée", 1); + testSearch("soiree", 1); + + // description + testSearch("description:soirée", 1); + testSearch("description:soiree", 1); + + // dir + testSearch("dir:(tmp)", 4); + testSearch("dir:(/tmp)", 4); + testSearch("dir:(NOT /tmp)", 0); + testSearch("NOT dir:(/tmp)", 0); + + // name + testSearch("name:(tr.txt)", 1); + testSearch("name:(enscript.txt)", 1); + testSearch("name:(wifi.txt)", 1); + + testSearch("name:(tr.txt OR enscript.txt)", 2); + testSearch("name:(tr.txt AND enscript.txt)", 0); + testSearch("name:(tr.txt OR enscript.txt OR wifi.txt)", 3); + testSearch("name:(tr.txt OR enscript.txt) OR name:(wifi.txt)", 3); + + testSearch("name:(tr.txt) OR dir:(/tmp)", 4); + testSearch("name:(tr.txt AND enscript.txt) OR dir:(/tmp)", 4); + testSearch("name:(tr.txt OR enscript.txt) OR dir:(/tmp)", 4); + testSearch("name:(tr.txt OR enscript.txt) AND dir:(/tmp)", 2); + + testSearch("name:[e TO u]", 2); + testSearch("name:[e TO v]", 3); + testSearch("name:[e TO w]", 3); + testSearch("name:[e TO x]", 4); + + // size + testSearch("size:(203)", 1); + testSearch("size:203", 1); + testSearch("size:203 OR size:814", 2); + testSearch("size:203 AND size:814", 0); + testSearch("size:(203 OR 814) AND NOT size:125", 2); + testSearch("size:(814)", 1); + testSearch("size:(125)", 1); + testSearch("size:(490)", 1); + testSearch("size:(203 OR 814 OR 125 OR 490)", 4); + testSearch("size:(203 OR 814) AND NOT size:(490)", 2); + + testSearch("size:(203) OR name:(tr.txt)", 1); + testSearch("size:(203 OR 814 OR 125 OR 490) AND name:(tr.txt OR enscript.txt)", 2); + testSearch("size:(203 OR 814 OR 125 OR 490) OR name:(tr.txt OR enscript.txt)", 4); + testSearch("size:[125 TO 900]", 4); + testSearch("size:[100 TO 300]", 2); + + // modified + testSearch("modified:(2009-11-29)", 1); + testSearch("modified:(2008-12-21)", 1); + testSearch("modified:(2009-09-28)", 1); + testSearch("modified:(2009-09-06)", 1); + testSearch("modified:[2008 TO 2009]", 1); + testSearch("modified:[2008 TO 2009-10]", 3); + + // lastModified + testSearch("lastModified:06/09/2009", 1); + testSearch("lastModified:\"06/09/2009\"", 1); + testSearch("lastModified:28/09/2009", 1); + testSearch("lastModified:\"28/09/2009\"", 1); + testSearch("lastModified:[20090906 TO 20090928]", 2); + testSearch("lastModified:[20090906 TO 20090920]", 1); + + // wikittyid + FormPagedResult testSearch = testSearch("size:203"); + String formId = testSearch.getFormsIdsToShow().get(0); + + Form form = wikittyProxy.restore(Form.class, formId); + testSearch("id:" + form.getId(), 1); + testSearch("id:" + form.getWikittyId(), 1); + } + + /** + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testSearchAnnonce() throws Exception { + WikittyExtension extension = createAnnonceFormType(); + XmlStreamImportResult initData = initData(extension); + Assert.assertEquals(5, initData.getCreatedFormCount()); + + testSearch((String) null, 5); + testSearch("", 5); + testSearch("*", 5); + + testSearch("Localité", 2); + testSearch("Localite", 2); + + testSearch("acheteur:(Infocom94)", 1); + testSearch("acheteur:(Infocom)", 1); + testSearch("acheteur:(Ville de Nogent sur Marne)", 1); + testSearch("acheteur:(Ville de Saint Joseph)", 1); + testSearch("acheteur:(Ville de Saint Joseph)", 1); + testSearch("acheteur:(Ville)", 2); + testSearch("acheteur:(Ville de)", 2); + testSearch("acheteur:(Marne)", 1); + testSearch("acheteur:(Joseph)", 1); + testSearch("acheteur:(EMOC)", 2); + + testSearch("acheteur:(*OC)", 2); + testSearch("acheteur:EM*", 2); + testSearch("acheteur:(EM*)", 2); + testSearch("acheteur:(E*OC)", 2); + testSearch("acheteur:(E?OC)", 2); + testSearch("acheteur:(EM?C)", 2); + testSearch("acheteur:(EMO?)", 2); + testSearch("acheteur:(EM??C)", 0); + + testSearch("departement:(972)", 1); + testSearch("departement:(2)", 0); + testSearch("departement:(*2)", 1); + + testSearch("departement:(94)", 2); + testSearch("departement:(9)", 0); + + testSearch("departement:9*", 3); + testSearch("departement:(9*)", 3); + testSearch("departement:(N.D.)", 2); + + testSearch("date:(N.D.)", 2); + testSearch("date:(N.)", 2); + +// FIXME sletellier 19/10/2010 : Dont work... That return all results +// testSearch("date:(\\-\\-\\-)", 1); + + testSearch("date:(25/01/2010)", 1); + testSearch("date:(19/01/2010)", 1); + testSearch("date:(\"25/01/2010\"*)", 1); + testSearch("date:(\"19/01/2010\"*)", 1); + testSearch("date:(\"25/01/2010 17:00\")", 1); + testSearch("date:(\"19/01/2010 - 11:00\")", 1); + } + + /** @throws Exception when an error occurred during test */ + @Test + public void testDateFormats() throws Exception { + WikittyExtension extension = createDatesFormType(); + XmlStreamImportResult initData = initData(extension); + Assert.assertEquals(30, initData.getCreatedFormCount()); + Assert.assertEquals(5, initData.getDateParsingError()); + } + + /** @throws Exception when an error occurred during test */ + @Test + public void testSearchStatus() throws Exception { + testSearch((Status[]) null, 0); + Status testStatus1 = createSatus("test1", null, 0, false); + Status testStatus2 = createSatus("test2", null, 0, false); + + Form fWithStatus1 = new FormImpl(); + fWithStatus1.setObjet("form with status1"); + fWithStatus1.setStatus(testStatus1.getWikittyId()); + wikittyProxy.store(fWithStatus1); + + Form fWithStatus2 = new FormImpl(); + fWithStatus2.setObjet("form with status2"); + fWithStatus2.setStatus(testStatus2.getWikittyId()); + wikittyProxy.store(fWithStatus2); + + Form fWithoutStatus = new FormImpl(); + fWithoutStatus.setObjet("form without status"); + wikittyProxy.store(fWithoutStatus); + + testSearch((Status[]) null, 3); + testSearch(new Status[0], 3); + testSearch(new Status[]{testStatus1}, 1); + testSearch(new Status[]{testStatus2}, 1); + testSearch(new Status[]{testStatus1, testStatus2}, 2); + } + + /* + @Test + public void testImportExport() throws Exception { + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + String fileName = "target/export-annonce.xml"; + export(fileName); + importt(fileName); + + testSearchAnnonce(); + } + */ + + /** + * Test search through Thesaurus. + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testSearchThesaurus() throws Exception { + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + testSearch("", 5); + + RootThesaurus rootThesaurus = new RootThesaurusImpl(); + rootThesaurus.setName("thesaurus"); + wikittyProxy.store(rootThesaurus); + + Thesaurus abc = createThesaurus("ab c", null, rootThesaurus, "ab c"); + Thesaurus def = createThesaurus("de f", abc.getWikittyId(), rootThesaurus, "de f"); + Thesaurus ghi = createThesaurus("gh & i", abc.getWikittyId(), rootThesaurus, "gh & i"); + Thesaurus jkl = createThesaurus("jk l", abc.getWikittyId(), rootThesaurus, "jk l"); + + Thesaurus abc2 = createThesaurus("ab c", jkl.getWikittyId(), rootThesaurus, "ab c"); + Thesaurus def2 = createThesaurus("de f", jkl.getWikittyId(), rootThesaurus, "de f"); + Thesaurus ghi2 = createThesaurus("gh & i", jkl.getWikittyId(), rootThesaurus, "gh & i"); + + FormPagedResult result = testSearch("acheteur:(Ville de Nogent sur Marne)"); + String formId1 = result.getFormsIdsToShow().get(0); + Form form1 = wikittyProxy.restore(Form.class, formId1); + abc.addAttachment(form1.getWikittyId()); + ghi.addAttachment(form1.getWikittyId()); + abc = wikittyProxy.store(abc); + ghi = wikittyProxy.store(ghi); + + result = testSearch("acheteur:(Ville de Saint Joseph)"); + String formId2 = result.getFormsIdsToShow().get(0); + Form form2 = wikittyProxy.restore(Form.class, formId2); + jkl.addAttachment(form2.getWikittyId()); + ghi2.addAttachment(form2.getWikittyId()); + jkl = wikittyProxy.store(jkl); + ghi2 = wikittyProxy.store(ghi2); + + result = testSearch("acheteur:Infocom94"); + String formIds3 = result.getFormsIdsToShow().get(0); + Form form3 = wikittyProxy.restore(Form.class, formIds3); + def.addAttachment(form3.getWikittyId()); + abc2.addAttachment(form3.getWikittyId()); + def = wikittyProxy.store(def); + abc2 = wikittyProxy.store(abc2); + + /* + * Thesaurus node names are not unique accross the tree. + * + * abc form1 + * +--def form3 + * +--ghi form1 + * +--jkl form2 + * +--abc form3 + * +--def + * +--ghi form2 + */ + + testSearch("thesaurus:(\"ab c\")", 3); + testSearch("thesaurus:(\"de f\")", 1); + testSearch("thesaurus:(\"gh \\& i\")", 2); + testSearch("thesaurus:(\"jk l\")", 2); + + testSearch("thesaurus:(\"ab c\") AND thesaurus:(\"gh \\& i\")", 2); + testSearch("thesaurus:(\"ab c\") OR thesaurus:(\"gh \\& i\")", 3); + + testSearch("thesaurus:(\"ab c\") AND thesaurus:(\"de f\")", 1); + testSearch("thesaurus:(\"ab c\") OR thesaurus:(\"de f\")", 3); + + testSearch("thesaurus:(\"ab c\") AND thesaurus:(\"jk l\")", 2); + testSearch("thesaurus:(\"ab c\") OR thesaurus:(\"jk l\")", 3); + + testSearch("thesaurus:(\"de f\") OR thesaurus:(\"gh \\& i\")", 3); + + testSearch("thesaurus:(\"pas de resultat\")", 0); + } + + /** + * Test search through Thesaurus + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testSearchMultiThesaurus() throws Exception { + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + testSearch("", 5); + + // first thesaurus : thesaurus + RootThesaurus rootThesaurus = new RootThesaurusImpl(); + rootThesaurus.setName("thesaurus"); + wikittyProxy.store(rootThesaurus); + + Thesaurus abc = createThesaurus("abc1", null, rootThesaurus); + Thesaurus def = createThesaurus("def1", abc.getWikittyId(), rootThesaurus); + Thesaurus ghi = createThesaurus("ghi1", abc.getWikittyId(), rootThesaurus); + + // second thesaurus : Descripteurs + RootThesaurus rootDescripteur = new RootThesaurusImpl(); + rootDescripteur.setName("Descripteurs"); // test case + wikittyProxy.store(rootDescripteur); + + Thesaurus abc2 = createThesaurus("abc2", null, rootDescripteur); + Thesaurus def2 = createThesaurus("def2", abc2.getWikittyId(), rootDescripteur); + Thesaurus ghi2 = createThesaurus("ghi2", def2.getWikittyId(), rootDescripteur); + + // make one form association with thesaurus + FormPagedResult result = testSearch("acheteur:(Ville de Nogent sur Marne)"); + String formId1 = result.getFormsIdsToShow().get(0); + Form form1 = wikittyProxy.restore(Form.class, formId1); + abc.addAttachment(form1.getWikittyId()); + ghi.addAttachment(form1.getWikittyId()); + abc = wikittyProxy.store(abc); + ghi = wikittyProxy.store(ghi); + + // make one form association with Descripteurs + result = testSearch("acheteur:(Ville de Saint Joseph)"); + String formIds2 = result.getFormsIdsToShow().get(0); + Form form2 = wikittyProxy.restore(Form.class, formIds2); + ghi2.addAttachment(form2.getWikittyId()); + wikittyProxy.store(form2); + ghi2 = wikittyProxy.store(ghi2); + + // make one form association with thesaurus && Descripteurs + result = testSearch("acheteur:Infocom94"); + String formIds3 = result.getFormsIdsToShow().get(0); + Form form3 = wikittyProxy.restore(Form.class, formIds3); + def.addAttachment(form3.getWikittyId()); + abc2.addAttachment(form3.getWikittyId()); + def = wikittyProxy.store(def); + abc2 = wikittyProxy.store(abc2); + + // make some search (also test case) + testSearch("Thesaurus:(\"abc1\")", 2); + testSearch("thesaurus:(\"ghi1\")", 1); + testSearch("thesaurus:(\"none\")", 0); + + // other descripteur + testSearch("descripteurs:(\"ghi2\")", 1); + testSearch("descripteurs:(\"none\")", 0); + + // pas de resultat + testSearch("toto:(\"titi\")", 0); + testSearch("toto:(\"abc1\")", 0); + testSearch("toto:(\"abc2\")", 0); + + // test que abc* ne cherche que dans un seul thesaurus + // bien que les deux thesaurus ont un noeud abc1 et abc2 + testSearch("thesaurus:abc*", 2); + testSearch("descripteurs:abc*", 2); + } + + @Test + public void testQueryArchiving() throws Exception { + createClient("Client", "test1", "test2"); + createUser("User", "test1", "test2"); + createGroup("Group", "test1", "test2"); + } + + /** + * Test export of test data. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testExportAsCSV() throws Exception { + + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Search search = Search.query().keyword("*"); + Criteria criteria = search.criteria(); + String exportString = storageService.exportAsCSV(criteria); + + Assert.assertNotNull(exportString); + Assert.assertTrue(exportString.indexOf("annonce.description") > 0); + } + + /** + * Test to import testimport.csv file, and export it to + * test if data in import are present in export. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testImportAsCSV() throws Exception { + + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + URL importURL = VradiStorageServiceTest.class.getResource("/csv/testimport.csv"); + + storageService.importAsCSV(importURL.toExternalForm()); + + Search search = Search.query().keyword("*"); + Criteria criteria = search.criteria(); + String exportString = storageService.exportAsCSV(criteria); + + FileUtils.writeStringToFile(File.createTempFile("exportimport", ".csv"), exportString); + Assert.assertNotNull(exportString); + Assert.assertTrue(exportString.indexOf("TATA TOTO") > 0); + } + + /** + * Teste l'import de clients et d'utilisateurs. Les clients sont d'abord + * importés, puis les utilisateurs. On vérifie ensuite que le lien entre les + * entités est bien fait. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testImportAsCSVWithQueries() throws Exception { + + wikittyProxy.storeExtension(ClientImpl.extensionClient); + wikittyProxy.storeExtension(UserImpl.extensionUser); + wikittyProxy.storeExtension(ModificationTagImpl.extensionModificationTag); + wikittyProxy.storeExtension(QueryMakerImpl.extensionQueryMaker); + + // Import clients + URL importURL = VradiStorageServiceTest.class.getResource("/csv/clients.csv"); + storageService.importAsCSV(importURL.toExternalForm()); + + //Import users + importURL = VradiStorageServiceTest.class.getResource("/csv/users.csv"); + storageService.importAsCSV(importURL.toExternalForm()); + + //Search user Eric Chatellier + Search lookingForEric = Search.query().eq(User.FQ_FIELD_USER_NAME, "Eric Chatellier"); + User eric = wikittyProxy.findByCriteria(User.class, lookingForEric.criteria()); + + //Check that it is linked to the Client Code Lutin + String codeLutinId = eric.getClient(); + Client codeLutin = wikittyProxy.restore(Client.class, codeLutinId); + Assert.assertNotNull(codeLutin); + Assert.assertEquals("Code Lutin", codeLutin.getName()); + + //Search user Pierre Cros + Search pierreSearch = Search.query().eq(User.FQ_FIELD_USER_NAME, "Pierre Cros"); + User pierre = wikittyProxy.findByCriteria(User.class, pierreSearch.criteria()); + + //Check that it is linked to the User Libre entreprise + String libreEntrepriseId = pierre.getClient(); + Client libreEntreprise = wikittyProxy.restore(Client.class, libreEntrepriseId); + Assert.assertNotNull(libreEntreprise); + Assert.assertEquals("Libre entreprise", libreEntreprise.getName()); + } + + /** + * Test l'import avec la gestion du champs extensions supplémentaire. + * Les extensions manquaient auparement sur l'import des RootThesaurus. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testImportAsCSVWithExtension() throws Exception { + + wikittyProxy.storeExtension(WikittyTreeNodeImpl.extensionWikittyTreeNode); + wikittyProxy.storeExtension(ThesaurusImpl.extensionThesaurus); + wikittyProxy.storeExtension(RootThesaurusImpl.extensionRootThesaurus); + + // Import clients + URL importURL = VradiStorageServiceTest.class.getResource("/csv/thesaurus.csv"); + storageService.importAsCSV(importURL.toExternalForm()); + + // make some test on imported thesaurus + // especially of RootThesaurus import that was buggued (missing extension) + //Search user Eric Chatellier + List<RootThesaurus> rootThesaurus = dataService.getRootThesaurus(); + Assert.assertEquals(1, rootThesaurus.size()); + Assert.assertEquals("TestRootThesaurus", rootThesaurus.get(0).getName()); + + Assert.assertTrue(dataService.isThesaurusNameExistsInRootThesaurus(rootThesaurus.get(0), "Foot")); + Assert.assertFalse(dataService.isThesaurusNameExistsInRootThesaurus(rootThesaurus.get(0), "Rugby")); + } + + /** + * Test thesaurus cartographie. + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception when an error occurred during test + */ + @Test + @Ignore + public void testGetChildrenCartography() throws Exception { + + // first thesaurus : thesaurus + RootThesaurus rootThesaurus = new RootThesaurusImpl(); + rootThesaurus.setName("MyThesaurus"); + wikittyProxy.store(rootThesaurus); + + WikittyExtension extension = createFileFormType(); + WikittyExtension thesaurusExtension = createThesaurusExtension(); + XmlStreamImportResult initData = initData(extension); + Assert.assertEquals(4, initData.getCreatedFormCount()); + + /* + * creation des noeuds de thesaurus, et répartition des formulaires par noeuds + * + * Thesaurus | form1 + form2 + * +---Domaine | | + * +--Science | | + * +--Histoire | | + * +--Sport | | + * +--Tennis de table | | + * +--Tennis | | + * +--Foot | | + * +--Foot en salle | | * + * +--Foot en extérieur| * | + */ + Thesaurus tDomaine = createThesaurus("Domaine", rootThesaurus.getWikittyId(), rootThesaurus); + Thesaurus tScience = createThesaurus("Science", tDomaine.getWikittyId(), rootThesaurus); + Thesaurus tHistoire = createThesaurus("Histoire", tDomaine.getWikittyId(), rootThesaurus); + Thesaurus tSport = createThesaurus("Sport", tDomaine.getWikittyId(), rootThesaurus); + + Thesaurus tTennisDeTable = createThesaurus("Tennis de table", tSport.getWikittyId(), rootThesaurus); + Thesaurus tTennis = createThesaurus("Tennis", tSport.getWikittyId(), rootThesaurus); + Thesaurus tFoot = createThesaurus("Foot", tSport.getWikittyId(), rootThesaurus); + + Thesaurus tFootSalle = createThesaurus("Foot en salle", tFoot.getWikittyId(), rootThesaurus); + Thesaurus tFootExterieur = createThesaurus("Foot en extérieur", tFoot.getWikittyId(), rootThesaurus); + + FormPagedResult result1 = testSearch("size:203"); + String formId1 = result1.getFormsIdsToShow().get(0); + tFootExterieur.addAttachment(formId1); + tFootExterieur = wikittyProxy.store(tFootExterieur); + + FormPagedResult result2 = testSearch("size:125"); + String formId2 = result2.getFormsIdsToShow().get(0); + tFootSalle.addAttachment(formId2); + tFootSalle = wikittyProxy.store(tFootSalle); + + QueryParameters queryParameters = new QueryParameters("size:125 OR size:203"); + Map<Thesaurus, Integer> childrenCartography = dataService.getChildrenCartography(tSport.getWikittyId(), queryParameters); + Assert.assertEquals(2, childrenCartography.get(tFoot).intValue()); + + queryParameters = new QueryParameters("MyThesaurus:Domaine"); + childrenCartography = dataService.getChildrenCartography(rootThesaurus.getWikittyId(), queryParameters); + Assert.assertEquals(2, childrenCartography.get(tDomaine).intValue()); + } + + /** + * Test to get forms from a basic feed. + * + * @throws Exception when an error occurred during test + */ +// @Ignore + @Test + public void testBasicFeedImport() throws Exception { + + try { + String leMondeUneFeed = "http://www.lemonde.fr/rss/une.xml"; + URL leMondeUneURL = new URL(leMondeUneFeed); + + WikittyExtension extension = createAnnonceFormType(); + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings, leMondeUneURL); + + XmlStreamImportResult importResult = storageService.importFormsFromXmlStream(xmlStream); + Assert.assertTrue(importResult.getCreatedFormCount() > 0); + } catch (VradiException eee) { + + if (eee.getCause() instanceof UnknownHostException) { + if (log.isWarnEnabled()) { + log.warn("No internet connection, skip test", eee); + } + } else { + throw eee; + } + } + } + + /** + * Test to get forms from an https url. + * (was not working in vradi < 0.1.0 + * + * @throws Exception when an error occurred during test + */ + @Test + public void testHttpsFeedImport() throws Exception { + + try { + String labsFeed = "https://labs.libre-entreprise.org/export/rss_sfnews.php"; + + URL labsURL = new URL(labsFeed); + + WikittyExtension extension = createAnnonceFormType(); + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings, labsURL); + + XmlStreamImportResult importResult = storageService.importFormsFromXmlStream(xmlStream); + Assert.assertTrue(importResult.getCreatedFormCount() > 0); + + } catch (VradiException eee) { + + if (eee.getCause() instanceof UnknownHostException) { + if (log.isWarnEnabled()) { + log.warn("No internet connection, skip test", eee); + } + } else { + throw eee; + } + } + } + + /** + * Test a feed with additional extrenal references (dtd...) + * + * @throws Exception when an error occurred during test + */ + @Test + public void testAdditionalFeedImport() throws Exception { + + try { + String gentooFeed = "http://www.gentoo.org/rdf/en/gentoo-news.rdf"; + + URL gentooURL = new URL(gentooFeed); + + WikittyExtension extension = createAnnonceFormType(); + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings, gentooURL); + + XmlStreamImportResult importResult = storageService.importFormsFromXmlStream(xmlStream); + Assert.assertTrue(importResult.getCreatedFormCount() > 0); + + } catch (VradiException eee) { + + if (eee.getCause() instanceof UnknownHostException) { + if (log.isWarnEnabled()) { + log.warn("No internet connection, skip test", eee); + } + } else { + throw eee; + } + } + } + + /** + * Test form extension to test inner template fields replacement. + * + * @return a test extension + * @throws Exception if test extension can't be created + */ + protected WikittyExtension createPersonneFormType() throws Exception { + Map<String, FieldType> fields = new LinkedHashMap<String, FieldType>(); + fields.put("nom", FieldTypeEnum.STRING.getFieldType()); + fields.put("prenom", FieldTypeEnum.STRING.getFieldType()); + return createFormType("Personne", fields); + } + + /** + * Test fields name list on a test ott template. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testFieldNames() throws Exception { + URL resource = VradiStorageServiceTest.class.getResource("/ooo/test.ott"); + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(resource, localFile); + + try { + WikittyExtension extension = createPersonneFormType(); + fileService.uploadTemplate(localFile, extension.getName()); + List<String> fieldNames = storageService.getDocumentFields(extension, localFile.getName()); + Assert.assertEquals(fieldNames.size(), 2); + Assert.assertEquals(fieldNames.get(0), "nom"); + Assert.assertEquals(fieldNames.get(1), "prenom"); + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * Test fields name list on a test odt template. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testFieldNames2() throws Exception { + URL resource = VradiStorageServiceTest.class.getResource("/ooo/vradi_template.odt"); + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(resource, localFile); + + try { + WikittyExtension extension = createPersonneFormType(); + fileService.uploadTemplate(localFile, extension.getName()); + List<String> fieldNames = storageService.getDocumentFields(extension, localFile.getName()); + Assert.assertEquals(fieldNames.size(), 8); + + Assert.assertEquals(fieldNames.get(0), "acheteur"); + Assert.assertEquals(fieldNames.get(1), "objet"); + Assert.assertEquals(fieldNames.get(2), "description"); + Assert.assertEquals(fieldNames.get(3), "departement"); + Assert.assertEquals(fieldNames.get(4), "id"); + Assert.assertEquals(fieldNames.get(5), "url"); + Assert.assertEquals(fieldNames.get(6), "date"); + Assert.assertEquals(fieldNames.get(7), "test"); + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * This test methods fails because inner document fields are not + * "User fields". + * + * @throws Exception when an error occurred during test + */ + @Test + public void testFieldNames3() throws Exception { + URL resource = VradiStorageServiceTest.class.getResource("/ooo/modelePDF2.odt"); + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(resource, localFile); + + try { + WikittyExtension extension = createPersonneFormType(); + fileService.uploadTemplate(localFile, extension.getName()); + List<String> fieldNames = storageService.getDocumentFields(extension, localFile.getName()); + Assert.assertEquals(fieldNames.size(), 0); + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * Les fichiers variousfieldtypes.odt contient differents type de + * champ possibles (user / non user, texte / non texte)... + * + * @throws Exception when an error occurred during test + */ + @Test + public void testFieldNamesPossibilities() throws Exception { + URL resource = VradiStorageServiceTest.class.getResource("/ooo/variousfieldtypes.odt"); + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(resource, localFile); + + try { + WikittyExtension extension = createPersonneFormType(); + fileService.uploadTemplate(localFile, extension.getName()); + List<String> fieldNames = storageService.getDocumentFields(extension, localFile.getName()); + Assert.assertEquals(fieldNames.size(), 2); + Assert.assertEquals(fieldNames.get(0), "usertexte"); + Assert.assertEquals(fieldNames.get(1), "userstd"); + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * Test pdf generation. + * <p/> + * Save a field association and generate a pdf with that association. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testGeneration() throws Exception { + URL resource = VradiStorageServiceTest.class.getResource("/ooo/test.ott"); + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(resource, localFile); + + try { + + // create a new form extension + WikittyExtension formType = createPersonneFormType(); + formType.addTagValue("template", localFile.getName()); + dataService.updateFormType(formType); + + // create a new form with that extension + FormImpl form = new FormImpl(); + Wikitty wikitty = form.getWikitty(); + wikitty.addExtension(formType); + form.setField("Personne", "nom", "Morin"); + form.setField("Personne", "prenom", "Kevin"); + + // build form/template association + Map<String, String> fieldMap = new HashMap<String, String>(); + fieldMap.put("nom", "Personne.nom"); + fieldMap.put("prenom", "Personne.prenom"); + + // upload template + fileService.uploadTemplate(localFile, formType.getName()); + storageService.setAssociatedFields(formType.getName(), localFile.getName(), fieldMap); + + form = wikittyProxy.store(form); + String uri = storageService.generatePDF(form.getWikittyId(), true); + File pdfFile = fileService.downloadPDF(uri); + Assert.assertNotNull(pdfFile); + Assert.assertTrue(pdfFile.exists()); + + /* + Disable automatic mail sending. + try { + MailingManager mailingManager = new MailingManager(null); + mailingManager.postMail("test@codelutin.com", "test", + "ceci est un test avec des pdf attachés", forms, true); + } catch (Exception e) { + e.printStackTrace(); + }*/ + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause().getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * This test sends real message. + * <p/> + * Don't enable it automatically. + * + * @throws VradiException when an error occurred during test + */ + public void testPostMessage() throws VradiException { + MailingManager mailingManager = new MailingManager(config, null); + mailingManager.postMail("toto@codelutin.com", "test", + "ceci est un test", null, true, null); + } + + /** + * Test to receive mails. + * <p/> + * Don't enable it automatically. + * + * @throws VradiException when an error occurred during test + */ + public void testReceiveMessages() throws VradiException { + storageService.receiveMessages(); + } + + /** + * Test image addition at end of document and generated into PDF. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testTemplatesAttachments() throws Exception { + + File localFile = File.createTempFile("local-file", ".ott"); + localFile.deleteOnExit(); + FileUtils.copyURLToFile(VradiStorageServiceTest.class.getResource("/ooo/test.ott"), localFile); + + File image1 = File.createTempFile("local-image1", ".ott"); + File image2 = File.createTempFile("local-image2", ".ott"); + File image3 = File.createTempFile("local-image3", ".ott"); + image1.deleteOnExit(); + image2.deleteOnExit(); + image3.deleteOnExit(); + FileUtils.copyURLToFile(VradiStorageServiceTest.class.getResource("/images/enregistrement.png"), image1); + FileUtils.copyURLToFile(VradiStorageServiceTest.class.getResource("/images/flux.gif"), image2); + FileUtils.copyURLToFile(VradiStorageServiceTest.class.getResource("/images/form.jpg"), image3); + + try { + // create test extension + WikittyExtension formType = createPersonneFormType(); + formType.addTagValue("template", localFile.getName()); + dataService.updateFormType(formType); + + // create test forms + FormImpl form = new FormImpl(); + Wikitty wikitty = form.getWikitty(); + wikitty.addExtension(formType); + form.setField("Personne", "nom", "John"); + form.setField("Personne", "prenom", "Doe"); + + // set template fields associations + Map<String, String> fieldMap = new HashMap<String, String>(); + fieldMap.put("nom", "Personne.nom"); + fieldMap.put("prenom", "Personne.prenom"); + + // add some attachements + fileService.uploadFormEmbeddedFile(image1, form.getWikittyId()); + fileService.uploadFormEmbeddedFile(image2, form.getWikittyId()); + fileService.uploadFormEmbeddedFile(image3, form.getWikittyId()); + + form.addFiles(image1.getName()); + form.addFiles(image2.getName()); + form.addFiles(image3.getName()); + + // generation + fileService.uploadTemplate(localFile, formType.getName()); + storageService.setAssociatedFields(formType.getName(), localFile.getName(), fieldMap); + + // Store form + form = wikittyProxy.store(form); + + String uri = storageService.generatePDF(form.getWikittyId(), true); + String url = fileService.getPDFUrl(uri); + + FileUtils.copyURLToFile(new URL(url), File.createTempFile("result", ".pdf")); + + File pdfFile = fileService.downloadPDF(uri); + Assert.assertNotNull(pdfFile); + Assert.assertTrue(pdfFile.exists()); + + // on peut pas trop verfier que les images sont bien dedans :( + /*try { + MailingManager mailingManager = new MailingManager(null); + mailingManager.postMail("test@codelutin.com", "test", + "ceci est un test avec des pdf attachés et ... oh ... des images", + forms, false); + } catch (Exception e) { + e.printStackTrace(); + }*/ + + } catch (VradiException eee) { + + // cause BootstrapException, oo not instaled, not fail test + if (eee.getCause().getCause() instanceof BootstrapException) { + log.error("OOo cannot be loaded : ", eee); + } else { + throw eee; + } + } + } + + /** + * Test sending creation for a user. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testCreateSendingForUser() throws Exception { + + // Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Date date = new Date(); + + //Create the session + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + + session = wikittyProxy.store(session); + + User user = new UserImpl(); + + // Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + Sending sending = storageService.createSending(session.getWikittyId(), user, formsIds); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got one sending + Set<String> sendingsFromSession = session.getSending(); + Assert.assertNotNull(sendingsFromSession); + Assert.assertEquals(1, sendingsFromSession.size()); + + //Get back forms + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + Assert.assertEquals(user.getWikittyId(), sending.getUser()); + + //Check we got 5 forms in sending + Assert.assertEquals(5, sendingForms.size()); + } + + /** + * Test sending creation for a Group with users. + * + * @throws Exception when an error occurred during test + */ + @Test + public void testCreateSendingForGroup() throws Exception { + + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //Create the session + Session session = storageService.createNewSession(); + + //Create the group + Group group = new GroupImpl(); + + User user = new UserImpl(); + group.addUser(user.getWikittyId()); + + user = wikittyProxy.store(user); + group = wikittyProxy.store(group); + session = wikittyProxy.store(session); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + List<Sending> sendings = storageService.createAllSending(session.getWikittyId(), group, formsIds); + + //Check we got only one sending + Assert.assertEquals(1, sendings.size()); + + //Get back forms + Sending sending = sendings.get(0); + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + //Check sending + Assert.assertEquals(5, sendingForms.size()); + Assert.assertEquals(user.getWikittyId(), sending.getUser()); + } + + + /** + * Test sending creation for a Group with users that already got sendings + * + * @throws Exception when an error occurred during test + */ + @Test + public void testCreateSendingForGroupWithAlreadyCreatedSendings() throws Exception { + + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //Create the session + Session session = storageService.createNewSession(); + + //Create the group + Group group = new GroupImpl(); + + //Create the users + User user1 = new UserImpl(); + User user2 = new UserImpl(); + User user3 = new UserImpl(); + + wikittyProxy.store(user1); + wikittyProxy.store(user2); + wikittyProxy.store(user3); + wikittyProxy.store(session); + + group.addUser(user1.getWikittyId()); + group.addUser(user2.getWikittyId()); + group.addUser(user3.getWikittyId()); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + List<Sending> sendings = storageService.createAllSending(session.getWikittyId(), group, formsIds); + + //Check we got four sendings + Assert.assertEquals(3, sendings.size()); + + //Get back forms + Sending sending = sendings.get(0); + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + //Check we got 5 forms in sending + Assert.assertEquals(5, sendingForms.size()); + } + + /** + * Test removeAllSendings method on a user + * + * @throws Exception when an error occurred during test + */ + @Test + public void testRemoveAllSendingsOnUser() throws Exception { + + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Date date = new Date(); + + //Create the session + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + wikittyProxy.store(session); + + User user = new UserImpl(); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + Sending sending = storageService.createSending(session.getWikittyId(), user, formsIds); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got one sending + Set<String> sendingsFromSession = session.getSending(); + Assert.assertNotNull(sendingsFromSession); + Assert.assertEquals(1, sendingsFromSession.size()); + + //Get back forms + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + //Check we got 5 forms in sending + Assert.assertEquals(5, sendingForms.size()); + + //RemoveAllSending + List<String> formId = new ArrayList<String>(); + formId.add(formsIds.get(0)); + sending = storageService.removeSending(session.getWikittyId(), formId, user); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got one sending + Assert.assertEquals(1, session.getSending().size()); + + //Get back forms + Set<String> sendingForms2 = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + //Check we got 4 forms in sending + Assert.assertEquals(4, sendingForms2.size()); + } + + /** + * Test removeAllSendings method on a user + * + * @throws Exception when an error occurred during test + */ + @Test + public void testRemoveAllSendingsOnGroup() throws Exception { + + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Date date = new Date(); + + //Create the session + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + session = wikittyProxy.store(session); + + //Create the group + Group group = new GroupImpl(); + + //Create the users + User user1 = new UserImpl(); + User user2 = new UserImpl(); + User user3 = new UserImpl(); + + wikittyProxy.store(user1); + wikittyProxy.store(user2); + wikittyProxy.store(user3); + + group.addUser(user1.getWikittyId()); + group.addUser(user2.getWikittyId()); + group.addUser(user3.getWikittyId()); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + List<Sending> sendings = storageService.createAllSending(session.getWikittyId(), group, formsIds); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got one sending + Assert.assertEquals(3, sendings.size()); + Set<String> sendingsFromSession = session.getSending(); + Assert.assertNotNull(sendingsFromSession); + Assert.assertEquals(3, sendingsFromSession.size()); + + //Get back forms + Sending sending = sendings.get(0); + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + + //Check we got 5 forms in sending + Assert.assertEquals(5, sendingForms.size()); + + //RemoveAllSending + List<String> formId = new ArrayList<String>(); + formId.add(formsIds.get(0)); + sendings = storageService.removeAllSending(session.getWikittyId(), formId, group); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got 3 sending + Assert.assertEquals(3, sendings.size()); + Assert.assertEquals(3, session.getSending().size()); + + //Check we got 4 forms in sendings + Set<String> sendingForms0 = SendingHelper.extractForms(wikittyProxy, sendings.get(0).getGroupForms()); + Set<String> sendingForms1 = SendingHelper.extractForms(wikittyProxy, sendings.get(1).getGroupForms()); + Set<String> sendingForms2 = SendingHelper.extractForms(wikittyProxy, sendings.get(2).getGroupForms()); + Assert.assertEquals(4, sendingForms0.size()); + Assert.assertEquals(4, sendingForms1.size()); + Assert.assertEquals(4, sendingForms2.size()); + } + + /** + * Test session deletion + * + * @throws VradiException + */ + @Test + public void testDeleteSession() throws Exception { + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Session session = storageService.createNewSession(); + + //Create the group + Group group = new GroupImpl(); + + //Create the users + User user1 = new UserImpl(); + User user2 = new UserImpl(); + User user3 = new UserImpl(); + + wikittyProxy.store(user1); + wikittyProxy.store(user2); + wikittyProxy.store(user3); + wikittyProxy.store(session); + + group.addUser(user1.getWikittyId()); + group.addUser(user2.getWikittyId()); + group.addUser(user3.getWikittyId()); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("*"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + List<Sending> sendings = storageService.createAllSending(session.getWikittyId(), group, formsIds); + + // Delete sessions + storageService.deleteSession(session.getWikittyId()); + + // Restore sessions + Session sessionRestored = wikittyProxy.restore(Session.class, session.getWikittyId()); + + // One must be deleted + Assert.assertNull(sessionRestored); + + // Same for sending + Sending sending = wikittyProxy.restore(Sending.class, sendings.get(0).getWikittyId()); + + Assert.assertNull(sending); + + // Same test for session with status in error + Session session2 = storageService.createNewSession(); + session2.setStatus(VradiConstants.SessionStatus.ERROR.getValue()); + session2 = wikittyProxy.store(session2); + + List<Sending> sendings2 = storageService.createAllSending(session2.getWikittyId(), group, formsIds); + + // Delete with error status must return a VradiException + try { + storageService.deleteSession(session2.getWikittyId()); + Assert.fail("Session in error is deleted"); + } catch (VradiException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't delete status in error", eee); + } + } + + Session session2Restored = wikittyProxy.restore(Session.class, session2.getWikittyId()); + + Sending sending2 = wikittyProxy.restore(Sending.class, sendings2.get(0).getWikittyId()); + + // Second not deleted (with status in error) + Assert.assertNotNull(session2Restored); + Assert.assertNotNull(sending2); + } + + /** + * Test that the archive file is created and can be downloaded + * + * @throws Exception when an error occurred during test + */ + @Test + public void testArchiveQueries() throws Exception { + + Group group = new GroupImpl(); + group.setName("Groupe de test"); + + QueryBean bean = new QueryBean("titi,tata,ALONZEAU"); + + group.addQueries(bean.getCSVQuery()); + + storageService.archiveQueries(group); + + //String url = fileService.getRequestHistoryURL(group.getWikittyId() + ".rss"); + + File history = fileService.downloadRequestHistory(group.getWikittyId() + ".rss"); + + Assert.assertTrue(history.exists()); + List lines = FileUtils.readLines(history); + Assert.assertEquals(17, lines.size()); + Assert.assertEquals(" <title>Requetes de Groupe de test</title>", lines.get(3)); + Assert.assertEquals(" <description><ul><li><" + + "name><![CDATA[tata]]</name><description><" + + "![CDATA[ALONZEAU]]</description><query><" + + "![CDATA[titi]]</query></li></ul>" + + "</description>", lines.get(10)); + } + + /** + * Test que l'on ne peut pas avoir plus d'une session ouverte. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testNewSessionFail() throws VradiException { + storageService.createNewSession(); + // la 2eme fail + storageService.createNewSession(); + } + + /** + * Test that a new session is created if needed when bindForm is called + * Test that forms in "vradi.status.selectionne.name" status are added to + * this session. + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception if an error occurred in test + */ + @Test + @Ignore + public void testBindFormNormalUse() throws Exception { + + Date beginSearchDate = DateUtils.addDays(new Date(), -2); + + // Create a client and user + Client testClient = new ClientImpl(); + testClient.setName("Bayern Munchen"); + testClient = wikittyProxy.store(testClient); + User testUser = new UserImpl(); + testUser.setName("Franck Ribery"); + testUser.setClient(testClient.getWikittyId()); + testUser.setEnable(true); + testUser.setBeginSearchDate(beginSearchDate); + testUser = wikittyProxy.store(testUser); + + // Create a group with query + Group testGroup = new GroupImpl(); + testGroup.setName("Zahia fans"); + QueryBean bean = new QueryBean("ALONZEAU,tata,titi"); + testGroup.addQueries(bean.getCSVQuery()); + testGroup.addUser(testUser.getWikittyId()); + wikittyProxy.store(testGroup); + + // Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + // Create new session + Session session = storageService.createNewSession(); + + // bind forms + session = storageService.bindForms(session); + + // get back last open session that should have been created by the + // bindForm method + Assert.assertNotNull(session); + Assert.assertEquals(1, session.getNum()); + + //Session should have no sending as no form was selected + Set<String> sendings = session.getSending(); + Assert.assertNull(sendings); + + //Simulate the session sending (change status to sent) + session.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + wikittyProxy.store(session); + + //Get the status selectionne + Status selectionne = dataService.getStatus(VradiConstants.FormStatus.SELECTIONNE.getName()); + + //The form id, needed to check that the right form is bound at the end + //of test + String formId = ""; + + //Select form and try again + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("ALONZEAU"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + List<Form> forms = wikittyProxy.restore(Form.class, formsIds); + + for (Form form : forms) { + + formId = form.getWikittyId(); + + //Change status + form.setStatus(selectionne.getWikittyId()); + + //Change publication date + form.setDatePub(new Date()); + + //save + wikittyProxy.store(form); + } + + //Check that we will get the right sessions + formPagedResult = new FormPagedResult(); + queryParameters = new QueryParameters("ALONZEAU"); + queryParameters.setStatusIds(Collections.singletonList(selectionne.getWikittyId())); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + Assert.assertEquals(1, formPagedResult.getFormsIdsToShow().size()); + + //bind forms + Session session2 = storageService.createNewSession(); + session2 = storageService.bindForms(session2); + + //get back last open session that should have been created by the + //bindForm method. Should have number 2 + Assert.assertNotNull(session2); + Assert.assertEquals(2, session2.getNum()); + + //Session should have 2 sendings. 1 for user, with one form + //each + sendings = session2.getSending(); + Assert.assertNotNull(sendings); + Assert.assertEquals(1, sendings.size()); + + //Check that it is the right form that is bound. + for (String sendingId : sendings) { + Sending sending = wikittyProxy.restore(Sending.class, sendingId); + Set<String> sendingForms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + Assert.assertNotNull(sendingForms); + Assert.assertEquals(1, sendingForms.size()); + Assert.assertTrue(sendingForms.contains(formId)); + } + } + + /** + * Test to bind form with form with non passed date. + * + * @throws Exception + */ + @Test + public void testBindingValidityDate() throws Exception { + + Date now = new Date(); + Date beginSearchDate = DateUtils.addDays(now, -100); + Date datePub = DateUtils.addDays(now, -10); + Date datePer = DateUtils.addDays(now, -2); + + // Create a client and user + Client testClient = new ClientImpl(); + testClient.setName("Bayern Munchen"); + testClient = wikittyProxy.store(testClient); + + User testUser = new UserImpl(); + testUser.setName("Franck Ribery"); + testUser.setClient(testClient.getWikittyId()); + testUser.setEnable(true); + testUser.setBeginSearchDate(beginSearchDate); + testUser = wikittyProxy.store(testUser); + + // Create a group with query + Group testGroup = new GroupImpl(); + testGroup.setName("Zahia fans"); + QueryBean bean = new QueryBean("ALONZEAU,tata,titi"); + testGroup.addQueries(bean.getCSVQuery()); + testGroup.addUser(testUser.getWikittyId()); + wikittyProxy.store(testGroup); + + // Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //Get the status selectionne + Status selectionne = dataService.getStatus(VradiConstants.FormStatus.SELECTIONNE.getName()); + + //Select form and try again + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("ALONZEAU"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + List<Form> forms = wikittyProxy.restore(Form.class, formsIds); + for (Form form : forms) { + //Change status + form.setStatus(selectionne.getWikittyId()); + + // Change publication date + form.setDatePub(datePub); + form.setDatePeremption(datePer); + + //save + wikittyProxy.store(form); + } + + // Check that we will get the right sessions + formPagedResult = new FormPagedResult(); + queryParameters = new QueryParameters("ALONZEAU"); + queryParameters.setStatusIds(Collections.singletonList(selectionne.getWikittyId())); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + Assert.assertEquals(1, formPagedResult.getFormsIdsToShow().size()); + + // bind forms + Session session = storageService.createNewSession(); + session = storageService.bindForms(session); + + // la session ne doit avoir rien matché dans ce cas, tous les + // formulaire sont périmés + Assert.assertNotNull(session); + Assert.assertNull(session.getSending()); + } + + /** + * Test to bind form with form with non passed date. + * + * @throws Exception + */ + @Test + public void testBindingModificationDate() throws Exception { + + Date now = new Date(); + Date beginSearchDate = DateUtils.addDays(now, 3); + Date datePub = DateUtils.addDays(now, -10); + Date datePer = DateUtils.addDays(now, +2); + + // Create a client and user + Client testClient = new ClientImpl(); + testClient.setName("Bayern Munchen"); + testClient = wikittyProxy.store(testClient); + + User testUser = new UserImpl(); + testUser.setName("Franck Ribery"); + testUser.setClient(testClient.getWikittyId()); + testUser.setEnable(true); + testUser.setBeginSearchDate(beginSearchDate); + testUser = wikittyProxy.store(testUser); + + // Create a group with query + Group testGroup = new GroupImpl(); + testGroup.setName("Zahia fans"); + QueryBean bean = new QueryBean("ALONZEAU,tata,titi"); + testGroup.addQueries(bean.getCSVQuery()); + testGroup.addUser(testUser.getWikittyId()); + wikittyProxy.store(testGroup); + + // Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //Get the status selectionne + Status selectionne = dataService.getStatus(VradiConstants.FormStatus.SELECTIONNE.getName()); + + //Select form and try again + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("ALONZEAU"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + List<Form> forms = wikittyProxy.restore(Form.class, formsIds); + + for (Form form : forms) { + + //Change status + form.setStatus(selectionne.getWikittyId()); + + // Change publication date + form.setDatePub(datePub); + form.setDatePeremption(datePer); + + ModificationTag formTag = wikittyProxy.cast(form, ModificationTag.class); + formTag.setLastModified(new Date()); + + //save + wikittyProxy.store(form); + } + + // Check that we will get the right sessions + formPagedResult = new FormPagedResult(); + queryParameters = new QueryParameters("ALONZEAU"); + queryParameters.setStatusIds(Collections.singletonList(selectionne.getWikittyId())); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + Assert.assertEquals(1, formPagedResult.getFormsIdsToShow().size()); + + // bind forms + Session session = storageService.createNewSession(); + session = storageService.bindForms(session); + + // la session ne doit avoir rien matché dans ce cas, car tous les + // formulaires ont été publié après la date d'inscription + // de l'utilisateur + Assert.assertNotNull(session); + Assert.assertNull(session.getSending()); + } + + /** + * Test to bind form with form with non passed date. + * + * @throws Exception + */ + @Test + public void testBindingUserPeremptionDate() throws Exception { + + Date now = new Date(); + Date beginSearchDate = DateUtils.addDays(now, -10); + Date datePub = DateUtils.addDays(now, -1); + Date datePer = DateUtils.addDays(now, -1); + + // Create a client and user + Client testClient = new ClientImpl(); + testClient.setName("Bayern Munchen"); + testClient = wikittyProxy.store(testClient); + + User testUser = new UserImpl(); + testUser.setName("Franck Ribery"); + testUser.setClient(testClient.getWikittyId()); + testUser.setEnable(true); + testUser.setBeginSearchDate(beginSearchDate); + testUser = wikittyProxy.store(testUser); + + // Create a group with query + Group testGroup = new GroupImpl(); + testGroup.setName("Zahia fans"); + QueryBean bean = new QueryBean("ALONZEAU,tata,titi"); + testGroup.addQueries(bean.getCSVQuery()); + testGroup.addUser(testUser.getWikittyId()); + wikittyProxy.store(testGroup); + + // Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + //Get the status selectionne + Status selectionne = dataService.getStatus(VradiConstants.FormStatus.SELECTIONNE.getName()); + + //Select form and try again + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("ALONZEAU"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + List<Form> forms = wikittyProxy.restore(Form.class, formsIds); + + for (Form form : forms) { + + //Change status + form.setStatus(selectionne.getWikittyId()); + + // Change publication date + form.setDatePub(datePub); + form.setDatePeremption(datePer); + + //save + wikittyProxy.store(form); + } + + + // Check that we will get the right sessions + formPagedResult = new FormPagedResult(); + queryParameters = new QueryParameters("ALONZEAU"); + queryParameters.setStatusIds(Collections.singletonList(selectionne.getWikittyId())); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + Assert.assertEquals(1, formPagedResult.getFormsIdsToShow().size()); + + // bind forms + Session session = storageService.createNewSession(); + session = storageService.bindForms(session); + + // la session ne doit avoir rien matché dans ce cas, car tous les + // formulaires sont perime + Assert.assertNotNull(session); + Assert.assertNull(session.getSending()); + } + + /** + * Test the deletion of forms from last session opened + * <p/> + * FIXME tchemit-20011-04-11 Remove this when Like operator will be back in Wikitty. + * + * @throws Exception + */ + @Test + @Ignore + public void testRemoveFormsFromSession() throws Exception { + + //Import forms + WikittyExtension extension = createAnnonceFormType(); + initData(extension); + + Date date = new Date(); + + //Create the session + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + wikittyProxy.store(session); + + //Create the group + Group group = new GroupImpl(); + QueryBean bean = new QueryBean("*,*,*"); + group.addQueries(bean.getCSVQuery()); + + //Create the users + Date now = new Date(); + Date beginSearchDate = DateUtils.addDays(now, -10); + Date datePub = DateUtils.addDays(now, -1); + + User user1 = new UserImpl(); + user1.setEnable(true); + user1.setBeginSearchDate(beginSearchDate); + User user2 = new UserImpl(); + user2.setEnable(true); + user2.setBeginSearchDate(beginSearchDate); + User user3 = new UserImpl(); + user3.setEnable(true); + user3.setBeginSearchDate(beginSearchDate); + + wikittyProxy.store(user1); + wikittyProxy.store(user2); + wikittyProxy.store(user3); + + group.addUser(user1.getWikittyId()); + group.addUser(user2.getWikittyId()); + group.addUser(user3.getWikittyId()); + + wikittyProxy.store(group); + + //Get forms + FormPagedResult formPagedResult = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters("adjudicateur"); + formPagedResult = dataService.findForms(queryParameters, formPagedResult); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + + // Prepare datas + //Get the status selectionne + Status selectionne = dataService.getStatus(VradiConstants.FormStatus.SELECTIONNE.getName()); + + //The form id, needed to check that the right form is bound at the end + //of test + FormPagedResult allFormPagedResult = new FormPagedResult(); + QueryParameters allQueryParameters = new QueryParameters("*"); + allFormPagedResult = dataService.findForms(allQueryParameters, allFormPagedResult); + List<String> allFormsIds = allFormPagedResult.getFormsIdsToShow(); + List<Form> allForms = wikittyProxy.restore(Form.class, allFormsIds); + + for (Form form : allForms) { + + //Change status + form.setStatus(selectionne.getWikittyId()); + + //Change publication date + form.setDatePub(datePub); + form.setCreationDate(datePub); + + //save + wikittyProxy.store(form); + } + + List<Sending> sendings = storageService.createAllSending(session.getWikittyId(), group, formsIds); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + //Check we got one sending + Assert.assertEquals(3, sendings.size()); + Set<String> sendingsFromSession = session.getSending(); + Assert.assertNotNull(sendingsFromSession); + Assert.assertEquals(3, sendingsFromSession.size()); + + //Get back forms + Sending sending0 = sendings.get(0); + + List<String> sendingForms = new ArrayList<String>(SendingHelper.extractForms(wikittyProxy, sending0.getGroupForms())); + + //Check we got 5 forms in sending + Assert.assertEquals(4, sendingForms.size()); + + //Remove 2 first forms + List<String> formsIdsToRemove = new ArrayList<String>(); + formsIdsToRemove.add(sendingForms.get(0)); + formsIdsToRemove.add(sendingForms.get(1)); + + // Remove forms from sendings + storageService.removeFormsFromSession(session.getWikittyId(), formsIdsToRemove); + + session = wikittyProxy.restore(Session.class, session.getWikittyId()); + + sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(session.getSending())); + + //Check we got 3 sending + Assert.assertEquals(3, sendings.size()); + Assert.assertEquals(3, session.getSending().size()); + + //Check we got 3 forms in sendings + Set<String> sendingForms0 = SendingHelper.extractForms(wikittyProxy, sendings.get(0).getGroupForms()); + Set<String> sendingForms1 = SendingHelper.extractForms(wikittyProxy, sendings.get(1).getGroupForms()); + Set<String> sendingForms2 = SendingHelper.extractForms(wikittyProxy, sendings.get(2).getGroupForms()); + Assert.assertEquals(2, sendingForms0.size()); + Assert.assertEquals(2, sendingForms1.size()); + Assert.assertEquals(2, sendingForms2.size()); + + // Check we have 2 deleted forms + Set<String> deletedForm0 = SendingHelper.extractForms(wikittyProxy, sendings.get(0).getDeletedGroupForms()); + Set<String> deletedForm1 = SendingHelper.extractForms(wikittyProxy, sendings.get(1).getDeletedGroupForms()); + Set<String> deletedForm2 = SendingHelper.extractForms(wikittyProxy, sendings.get(2).getDeletedGroupForms()); + Assert.assertEquals(2, deletedForm0.size()); + Assert.assertEquals(2, deletedForm1.size()); + Assert.assertEquals(2, deletedForm2.size()); + + // Check that deleted forms are not reassociated + // Update session and sendings to sent + for (Sending sending : sendings) { + sending.setStatus(VradiConstants.SendingStatus.SENT.getValue()); + } + wikittyProxy.store(sendings); + + session.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + wikittyProxy.store(session); + + // bind forms + session = storageService.createNewSession(); + session = storageService.bindForms(session); + + Set<String> sendingIds = session.getSending(); + sendings = wikittyProxy.restore(Sending.class, new ArrayList<String>(sendingIds)); + + for (Sending sending : sendings) { + for (String deletedId : formsIdsToRemove) { + Assert.assertFalse(SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()).contains(deletedId)); + } + } + } + + /** + * Test la creation d'un noeud de thesaurus avec un nom invalid. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testInvalidRootThesaurus() throws VradiException { + dataService.createRootThesaurus("été"); + } + + /** + * Test la creation d'un noeud de thesaurus avec un nom invalid. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testInvalidRootThesaurus2() throws VradiException { + dataService.createRootThesaurus("test test"); + } + + /** + * Test la creation d'un noeud de thesaurus avec un nom invalid. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testInvalidRootThesaurus3() throws VradiException { + dataService.createRootThesaurus("test+test"); + } + + /** + * Test la creation d'un noeud de thesaurus avec un nom invalid. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testInvalidRootThesaurus4() throws VradiException { + dataService.createRootThesaurus(null); + } + + /** + * Test de creer un root thesaurs 2 fois. + * + * @throws VradiException + */ + @Test + public void testNomUniqueRootThesaurus() throws VradiException { + RootThesaurus rootThesaurus = dataService.createRootThesaurus("uniquename"); + Assert.assertNotNull(rootThesaurus); + try { + dataService.createRootThesaurus("uniquename"); + Assert.fail("Root thesaurus created twice"); + } catch (VradiException ex) { + if (log.isDebugEnabled()) { + log.debug("Can't create root thesaurus", ex); + } + } + } + +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/VradiStorageServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/BindingManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/BindingManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/BindingManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,120 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import junit.framework.Assert; +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.WebHarvestStreamImpl; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.entities.XmlStreamImpl; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Test class for {@link BindingManager}. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class BindingManagerTest extends VradiTestAbstract { + + protected BindingManager bindingManager; + + @Before + public void initBindingManager() { + bindingManager = new BindingManager(config, wikittyProxy, null, null); + } + + /** Test to get all xml streams (including XmlStreams). */ + @Test + public void testGetAllXmlStreams() { + XmlStream xmlStreamEquipe = new XmlStreamImpl(); + xmlStreamEquipe.setName("equipe.fr"); + XmlStream xmlStreamDalinux = new XmlStreamImpl(); + xmlStreamDalinux.setName("dalinux"); + WebHarvestStream xmlStreamOuestFrance = new WebHarvestStreamImpl(); + xmlStreamOuestFrance.setName("xmlStreamOuestFrance"); + + List<XmlStream> xmlStreams = new ArrayList<XmlStream>(); + xmlStreams.add(xmlStreamEquipe); + xmlStreams.add(xmlStreamDalinux); + xmlStreams.add(xmlStreamOuestFrance); + wikittyProxy.store(xmlStreams); + + List<XmlStream> xmlStreamsRestored = bindingManager.getAllXmlStreams(); + Assert.assertEquals(3, xmlStreamsRestored.size()); + + int count = 0; + // test plus precis sur les instances retournées + for (XmlStream xmlStream : xmlStreamsRestored) { + if (xmlStream.getName().equals("equipe.fr")) { + Assert.assertTrue(xmlStream instanceof XmlStream); + count++; + } else if (xmlStream.getName().equals("dalinux")) { + Assert.assertTrue(xmlStream instanceof XmlStream); + count++; + } else if (xmlStream.getName().equals("xmlStreamOuestFrance")) { + Assert.assertTrue(xmlStream instanceof WebHarvestStream); + count++; + } + } + Assert.assertEquals(3, count); + } + + /** Test to get all WebHarvest xml streams. */ + @Test + public void testGetAllWebHarvestStreams() { + XmlStream xmlStreamEquipe = new XmlStreamImpl(); + xmlStreamEquipe.setName("equipe.fr"); + XmlStream xmlStreamDalinux = new XmlStreamImpl(); + xmlStreamDalinux.setName("dalinux"); + WebHarvestStream xmlStreamOuestFrance = new WebHarvestStreamImpl(); + xmlStreamOuestFrance.setName("xmlStreamOuestFrance"); + + List<XmlStream> xmlStreams = new ArrayList<XmlStream>(); + xmlStreams.add(xmlStreamEquipe); + xmlStreams.add(xmlStreamDalinux); + xmlStreams.add(xmlStreamOuestFrance); + wikittyProxy.store(xmlStreams); + + List<WebHarvestStream> xmlStreamsRestored = bindingManager.getAllWebHarvestStreams(); + Assert.assertEquals(1, xmlStreamsRestored.size()); + + // test plus precis sur les instances retournées + for (WebHarvestStream xmlStream : xmlStreamsRestored) { + if (xmlStream.getName().equals("xmlStreamOuestFrance")) { + Assert.assertTrue(xmlStream instanceof WebHarvestStream); + } + } + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/BindingManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,215 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.apache.commons.lang.time.DateUtils; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.StatusImpl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +/** + * Form manager tests. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FormManagerTest extends VradiTestAbstract { + + protected DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.US); + + protected FormManager manager; + + @Before + public void initFormManager() throws Exception { + manager = new FormManager(config, wikittyProxy, null, null); + } + + /** + * Test getBeginOfDaySolrDate. + * <p/> + * FIXME EC20100601 test is failing + * + * @throws Exception if an error occurred during test + */ + public void getBeginOfDaySolrDateTestGmt1() throws Exception { + Date d1 = dateFormat.parse("January 16, 2010 3:30:32pm"); + String dateAsString = FormManager.getBeginOfDaySolrDate(d1); + Assert.assertEquals("2010-01-16T00:00:00.000Z", dateAsString); + } + + /** + * Test getBeginOfDaySolrDate. + * <p/> + * FIXME EC20100601 test is failing + * + * @throws Exception if an error occurred during test + */ + public void getBeginOfDaySolrDateTestGmt2() throws Exception { + Date d1 = dateFormat.parse("July 16, 2010 3:30:32pm"); + String dateAsString = FormManager.getBeginOfDaySolrDate(d1); + Assert.assertEquals("2010-07-16T00:00:00.000Z", dateAsString); + } + + /** + * Test getBeginOfDaySolrDate. + * <p/> + * FIXME EC20100601 test is failing + * + * @throws Exception if an error occurred during test + */ + public void getEndOfDaySolrDateTestGmt1() throws Exception { + Date d1 = dateFormat.parse("January 16, 2010 3:30:32pm"); + String dateAsString = FormManager.getEndOfDaySolrDate(d1); + Assert.assertEquals("2010-01-16T23:59:59.999Z", dateAsString); + } + + /** + * Test getBeginOfDaySolrDate. + * <p/> + * FIXME EC20100601 test is failing + * + * @throws Exception if an error occurred during test + */ + public void getEndOfDaySolrDateTestGmt2() throws Exception { + Date d1 = dateFormat.parse("July 16, 2010 3:30:32pm"); + String dateAsString = FormManager.getEndOfDaySolrDate(d1); + Assert.assertEquals("2010-07-16T23:59:59.999Z", dateAsString); + } + + /** + * Test getLastClosedSession, normal case. + * + * @throws Exception if an error occurred during test + */ + @Test + public void testGetLastClosedSession() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session2 = new SessionImpl(); + session2.setSessionDate(DateUtils.addDays(date, -1)); + session2.setNum(1); + session2.setStatus(VradiConstants.SessionStatus.SENT.getValue()); + sessions.add(session2); + + Session session3 = new SessionImpl(); + session3.setSessionDate(DateUtils.addDays(date, -2)); + session3.setNum(2); + session3.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session3); + + wikittyProxy.store(sessions); + + Session result = manager.getLastCloseSession(); + Assert.assertEquals(1, result.getNum()); + } + + /** + * Test getLastClosedSession, when no closed session in base. + * + * @throws Exception if an error occurred during test + */ + @Test + public void testGetLastClosedSessionWhenNoClosedSession() throws Exception { + Date date = new Date(); + + List<Session> sessions = new ArrayList<Session>(); + + Session session = new SessionImpl(); + session.setSessionDate(date); + session.setNum(0); + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session); + + Session session3 = new SessionImpl(); + session3.setSessionDate(DateUtils.addDays(date, -2)); + session3.setNum(2); + session3.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + sessions.add(session3); + + wikittyProxy.store(sessions); + + Session result = manager.getLastCloseSession(); + Assert.assertNull(result); + } + + /** + * Test status is not deleted if in use + * + * @throws Exception if an error occurred during test + */ + @Test + public void testDeleteStatus() throws Exception { + Form form1 = new FormImpl(); + + Status selectionne = manager.getSelectionneStatus(); + Status toDelete = new StatusImpl(); + + form1.setStatus(selectionne.getWikittyId()); + + wikittyProxy.store(form1); + wikittyProxy.store(toDelete); + + // Extract ids + List<String> ids = new ArrayList<String>(); + ids.add(selectionne.getWikittyId()); + ids.add(toDelete.getWikittyId()); + + // False because selectionne is not deleted + boolean result = manager.deleteStatuses(ids); + Assert.assertFalse(result); + + // Restore it + selectionne = wikittyProxy.restore(Status.class, selectionne.getWikittyId()); + Assert.assertNotNull(selectionne); + toDelete = wikittyProxy.restore(Status.class, toDelete.getWikittyId()); + Assert.assertNull(toDelete); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormTypeManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormTypeManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormTypeManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,86 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.services.VradiException; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.nuiton.wikitty.entities.WikittyExtension; + +/** + * Test class for {@link FormTypeManager}. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FormTypeManagerTest extends VradiTestAbstract { + + private static final Log log = LogFactory.getLog(FormTypeManagerTest.class); + + protected FormTypeManager manager; + + @Before + public void initFormTypeManager() throws Exception { + manager = new FormTypeManager(config, wikittyProxy); + } + + /** + * Test la creation d'un type de formulaire invalid. + * + * @throws VradiException + */ + @Test(expected = VradiException.class) + public void testCreateInvalidFormType() throws VradiException { + manager.createFormType("invalid name"); + } + + /** + * Test la creation d'un type de formulaire dupliqué. + * + * @throws VradiException + */ + @Test + public void testCreateDuplicatedFormType() throws VradiException { + WikittyExtension formType = dataService.createFormType("uniquename"); + Assert.assertNotNull(formType); + try { + manager.createFormType("uniquename"); + Assert.fail("Form type created twice"); + } catch (VradiException ex) { + if (log.isDebugEnabled()) { + log.debug("Can't create form type", ex); + } + } + } + +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/FormTypeManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/MailingManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/MailingManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/MailingManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,122 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; + +/** + * Test for mails sending receiving, parsing... + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class MailingManagerTest extends VradiTestAbstract { + + protected MailingManager mailingManager; + + @Before + public void initMailingManager() { + mailingManager = new MailingManager(config, wikittyProxy); + } + + /** Test get header parsing in mail content. */ + @Test + public void testGetHeaderInContent1() { + String testString = "Final-Recipient: rfc822; toto@codelutin.com\n" + + "Original-Recipient: rfc822;toto@codelutin.com\n" + + "Action: failed\n" + + "Status: 5.1.1\n" + + "Remote-MTA: dns; 87.98.187.174\n" + + "Diagnostic-Code: smtp; 550 5.1.1 <toto@codelutin.com>: Recipient address\n" + + " rejected: User unknown in local recipient table\n"; + + String headerValue = mailingManager.getHeaderValueInContent( + "Diagnostic-Code", testString); + Assert.assertEquals( + "smtp; 550 5.1.1 <toto@codelutin.com>: Recipient address", + headerValue); + } + + /** Test get header parsing in mail content. */ + @Test + public void testGetHeaderInContent2() { + String testString = "Reporting-UA: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.5pre)\n" + + "Gecko/20100503 Icedove/2.0.0.12\n" + + "Final-Recipient: rfc822;chatellier@codelutin.com\n" + + "Original-Message-ID: <1833582695.1.1272991628810.JavaMail.chatellier@genux>\n" + + "Disposition: manual-action/MDN-sent-manually; displayed"; + + String headerValue = mailingManager.getHeaderValueInContent( + "Original-Message-ID", testString); + Assert.assertEquals( + "<1833582695.1.1272991628810.JavaMail.chatellier@genux>", + headerValue); + } + + /** Test get header parsing in mail content. */ + @Test + public void testGetHeaderInContent3() { + String testString = "From: vradi\n" + + "To: toto@codelutin.com\n" + + "Message-ID: <804992706.5.1272991629788.JavaMail.chatellier@genux>"; + + String headerValue = mailingManager.getHeaderValueInContent( + "Message-ID", testString); + Assert.assertEquals( + "<804992706.5.1272991629788.JavaMail.chatellier@genux>", + headerValue); + } + + /** + * Test que le nom du fichier pdf généré contient l'id du formulaire et sa + * version. + */ + @Test + public void testGetGeneratePDFFile() { + Form myForm = new FormImpl(); + myForm = wikittyProxy.store(myForm); + + File formFile = mailingManager.getGeneratedPdfFile(myForm); + System.out.println(formFile); + Assert.assertTrue(formFile.getName().endsWith("-1.0.pdf")); + + // new save, increase version + myForm.setObjet("toto"); + myForm = wikittyProxy.store(myForm); + formFile = mailingManager.getGeneratedPdfFile(myForm); + Assert.assertTrue(formFile.getName().endsWith("-2.0.pdf")); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/MailingManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/SearchManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/SearchManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/SearchManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,89 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupImpl; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Test for SearchManager. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class SearchManagerTest extends VradiTestAbstract { + + protected SearchManager searchManager; + + /** Init search manager with wikitty proxy. */ + @Before + public void initSearchManager() { + searchManager = new SearchManager(wikittyProxy, null); + } + + /** Test to get only groups with non empty queries. */ + @Test + public void testFindGroupsWithQueries() { + + Group groupCodeLutin = new GroupImpl(); + groupCodeLutin.setName("codelutin"); + groupCodeLutin.addQueries("queryname, querydescription, queryquery"); + groupCodeLutin.addQueries("queryname2, querydescription2, queryquery2"); + + Group groupSun = new GroupImpl(); + groupSun.setName("sun"); + + Group groupFFF = new GroupImpl(); + groupSun.setName("equipe de france"); + groupSun.addQueries("footname1, footdescription1, footquery2"); + + List<Group> groups = new ArrayList<Group>(); + groups.add(groupCodeLutin); + groups.add(groupSun); + groups.add(groupFFF); + + groups = wikittyProxy.store(groups); + List<Group> groupsWithQuery = searchManager.findGroupsWithQueries(); + + Assert.assertEquals(2, groupsWithQuery.size()); + + // test que les objets retournés sont de vrai instance + // de group ou autre chose, mais pas de query maker + for (Group groupWithQuery : groupsWithQuery) { + Assert.assertTrue(groupWithQuery instanceof Group); + } + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/SearchManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ThesaurusManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ThesaurusManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ThesaurusManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,248 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.managers; + +import org.chorem.vradi.VradiTestAbstract; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.services.VradiException; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Test class for {@link ThesaurusManager}. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ThesaurusManagerTest extends VradiTestAbstract { + + protected ThesaurusManager thesaurusManager; + + @Before + public void initThesaurusManager() { + thesaurusManager = new ThesaurusManager(wikittyProxy); + } + + /** + * Test les contraintes d'unicité sur le root thesaurus. + * + * @throws VradiException + */ + @Test + public void testIsRootThesaurusNameExists() throws VradiException { + + // build first thesaurus + thesaurusManager.createRootThesaurus("Thesaurus"); + + Assert.assertTrue(thesaurusManager.isRootThesaurusNameExists("Thesaurus")); + Assert.assertFalse(thesaurusManager.isRootThesaurusNameExists("NoExists")); + } + + /** + * Test les contraintes d'unicité sur le thesaurus. + * + * @throws VradiException + */ + @Test + public void testIsThesaurusNameExistInThesaurus() throws VradiException { + + // build first thesaurus + RootThesaurus rootThesaurus = thesaurusManager.createRootThesaurus("Thesaurus"); + Thesaurus thesaurus1 = new ThesaurusImpl(); + thesaurus1.setName("AO Global"); + thesaurus1.setParent(rootThesaurus.getWikittyId()); + thesaurus1.setRootThesaurus(rootThesaurus.getWikittyId()); + Thesaurus thesaurus2 = new ThesaurusImpl(); + thesaurus2.setName("Appel d'offre regionnal"); + thesaurus2.setParent(thesaurus1.getWikittyId()); + thesaurus2.setRootThesaurus(rootThesaurus.getWikittyId()); + + // build second descripteur + RootThesaurus rootDescripteurs = thesaurusManager.createRootThesaurus("descripteur"); + Thesaurus thesaurus3 = new ThesaurusImpl(); + thesaurus3.setName("AO Local"); + thesaurus3.setParent(rootDescripteurs.getWikittyId()); + thesaurus3.setRootThesaurus(rootDescripteurs.getWikittyId()); + + List<Thesaurus> thesauruses = new ArrayList<Thesaurus>(); + thesauruses.add(thesaurus1); + thesauruses.add(thesaurus2); + thesauruses.add(thesaurus3); + wikittyProxy.store(thesauruses); + + // some tests + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "AO Global")); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Appel d'offre regionnal")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "AO Global")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "Appel d'offre regionnal")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "AO Local")); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "AO Local")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Toto")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "Titi")); + + // test excepted optionnal parameters + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "AO Global", thesaurus1.getWikittyId())); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "AO Global", "9980d1ae-18bf-4284-884b-746ca916234f")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Appel d'offre regionnal", thesaurus2.getWikittyId())); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Appel d'offre regionnal", "930db6ef-770e-4a41-ab4c-2416122ec743")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "AO Local", thesaurus3.getWikittyId())); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootDescripteurs, "AO Local")); + } + + /** + * Test la suppression d'un thesaurus et verifie que ses sous thesaurus + * sont également supprimés. + * + * @throws VradiException + */ + @Test + public void testDeleteThesaurus() throws VradiException { + RootThesaurus rootThesaurus = thesaurusManager.createRootThesaurus("RootThesaurus"); + + Thesaurus thesaurus1 = new ThesaurusImpl(); + thesaurus1.setName("Thesaurus 1"); + thesaurus1.setParent(rootThesaurus.getWikittyId()); + thesaurus1.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurus11 = new ThesaurusImpl(); + thesaurus11.setName("Thesaurus 1.1"); + thesaurus11.setParent(thesaurus1.getWikittyId()); + thesaurus11.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurus111 = new ThesaurusImpl(); + thesaurus111.setName("Thesaurus 1.1.1"); + thesaurus111.setParent(thesaurus11.getWikittyId()); + thesaurus111.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurus112 = new ThesaurusImpl(); + thesaurus112.setName("Thesaurus 1.1.2"); + thesaurus112.setParent(thesaurus11.getWikittyId()); + thesaurus112.setRootThesaurus(rootThesaurus.getWikittyId()); + + List<Thesaurus> thesauruses = new ArrayList<Thesaurus>(); + thesauruses.add(thesaurus1); + thesauruses.add(thesaurus11); + thesauruses.add(thesaurus111); + thesauruses.add(thesaurus112); + wikittyProxy.store(thesauruses); + + Collection<String> deletedIds = thesaurusManager.deleteThesaurus(thesaurus11.getWikittyId()); + Assert.assertEquals(3, deletedIds.size()); + Assert.assertTrue(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Thesaurus 1")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Thesaurus 1.1")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Thesaurus 1.1.1")); + Assert.assertFalse(thesaurusManager.isThesaurusNameExistsInRootThesaurus(rootThesaurus, "Thesaurus 1.1.2")); + } + + /** + * Test la proposition de thesaurus pour les formulaires. + * + * @throws VradiException + */ + @Test + public void testProposeThesaurus() throws VradiException { + RootThesaurus rootThesaurus = thesaurusManager.createRootThesaurus("Thesaurus"); + + Form form = new FormImpl(); + + Thesaurus thesaurusInfo = new ThesaurusImpl(); + thesaurusInfo.setName("Informatique"); + thesaurusInfo.addTags("linux"); + thesaurusInfo.addTags("windows"); + thesaurusInfo.addTags("internet"); + thesaurusInfo.setParent(rootThesaurus.getWikittyId()); + thesaurusInfo.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurusSci = new ThesaurusImpl(); + thesaurusSci.setName("Science"); + thesaurusSci.setParent(thesaurusInfo.getWikittyId()); + thesaurusSci.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurusHis = new ThesaurusImpl(); + thesaurusHis.setName("Histoire"); + thesaurusHis.addTags("revolution"); + thesaurusHis.addAttachment(form.getWikittyId()); + thesaurusHis.setParent(thesaurusSci.getWikittyId()); + thesaurusHis.setRootThesaurus(rootThesaurus.getWikittyId()); + + Thesaurus thesaurusSport = new ThesaurusImpl(); + thesaurusSport.setName("Sport"); + thesaurusSport.setParent(thesaurusSci.getWikittyId()); + thesaurusSport.addTags("foot"); + thesaurusSport.addTags("rugby"); + thesaurusSport.addTags("tennis"); + thesaurusSport.setRootThesaurus(rootThesaurus.getWikittyId()); + + List<Thesaurus> thesauruses = new ArrayList<Thesaurus>(); + thesauruses.add(thesaurusInfo); + thesauruses.add(thesaurusSci); + thesauruses.add(thesaurusHis); + thesauruses.add(thesaurusSport); + wikittyProxy.store(thesauruses); + + // add some forms + form.setDescription("Rien"); + form = wikittyProxy.store(form); + + String formId = form.getWikittyId(); + + List<Thesaurus> propositions = thesaurusManager.proposeThesaurus(formId); + Assert.assertEquals(0, propositions.size()); + + form.setDescription("developpent internet"); + form = wikittyProxy.store(form); + propositions = thesaurusManager.proposeThesaurus(formId); + Assert.assertEquals(1, propositions.size()); + + form.setDescription("Et c'est le foot !!!!!!!!!"); + form = wikittyProxy.store(form); + propositions = thesaurusManager.proposeThesaurus(formId); + Assert.assertEquals(1, propositions.size()); + + form.setDescription("Mais le foot c'est aussi sur internet"); + form = wikittyProxy.store(form); + propositions = thesaurusManager.proposeThesaurus(formId); + Assert.assertEquals(2, propositions.size()); + + form.setDescription("C'est la revolution dans le foot"); + form = wikittyProxy.store(form); + propositions = thesaurusManager.proposeThesaurus(formId); + // revolution ne match pas (deja associé) + Assert.assertEquals(1, propositions.size()); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/managers/ThesaurusManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/VradiQueryParserTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/VradiQueryParserTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/VradiQueryParserTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,91 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.search; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Query parsing test. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiQueryParserTest { + + /** + * Test des resultats de parsing de certaines requetes. + * + * @throws UnsupportedQueryException + */ + @Test + public void testQueryParse() throws UnsupportedQueryException { + + // test 1 + String query1 = "thesaurus:toto AND NOT (acheteur:titi OR acheteur:tata)"; + FilterList filterList = VradiQueryParser.parse(query1); + Assert.assertEquals(1, filterList.getFilters().size()); + + // test 2 + String query2 = "toto AND NOT (acheteur:titi OR acheteur:tata)"; + filterList = VradiQueryParser.parse(query2); + Assert.assertEquals(1, filterList.getFilters().size()); + + // test 3 + String query3 = "text:toto AND NOT (acheteur:titi OR acheteur:tata)"; + filterList = VradiQueryParser.parse(query3); + Assert.assertEquals(1, filterList.getFilters().size()); + + // test 4 + String query4 = "toto AND NOT (acheteur:titi OR acheteur:tata)"; + filterList = VradiQueryParser.parse(query4, "anotherfield"); + Assert.assertEquals(1, filterList.getFilters().size()); + + // test 5 + String query5 = "object:\"tata titi toto\""; + filterList = VradiQueryParser.parse(query5); + Assert.assertEquals(1, filterList.getFilters().size()); + CompareFilter f = (CompareFilter) filterList.getFilters().get(0); + Assert.assertEquals("tata titi toto", f.getValue()); + } + + /** + * Test des resultats de parsing de certaines requetes qui produise des erreur. + * + * @throws UnsupportedQueryException + */ + @Test(expected = UnsupportedQueryException.class) + public void testQueryParseException() throws UnsupportedQueryException { + + // test 1 + String query1 = "AND OR NOT"; + VradiQueryParser.parse(query1); + + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/search/VradiQueryParserTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/TasksManagerTest.java =================================================================== --- trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/TasksManagerTest.java (rev 0) +++ trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/TasksManagerTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,68 @@ +/* + * #%L + * Vradi :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.tasks; + +import junit.framework.Assert; +import org.chorem.vradi.VradiConstants; +import org.junit.Test; + +import java.util.regex.Matcher; + +/** + * Test for {@link TasksManager} class. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class TasksManagerTest { + + /** Test la pattern de match des heures d'import des flux. */ + @Test + public void testXmlStreamTimePattern() { + + Matcher matcher = VradiConstants.XML_STREAM_IMPORT_TIME.matcher("12:35"); + Assert.assertTrue(matcher.find()); + Assert.assertEquals("12", matcher.group(1)); + Assert.assertEquals("35", matcher.group(2)); + + Matcher matcher2 = VradiConstants.XML_STREAM_IMPORT_TIME.matcher("2:35"); + Assert.assertTrue(matcher2.find()); + Assert.assertEquals("2", matcher2.group(1)); + Assert.assertEquals("35", matcher2.group(2)); + + Matcher matcher3 = VradiConstants.XML_STREAM_IMPORT_TIME.matcher("0:36"); + Assert.assertTrue(matcher3.find()); + Assert.assertEquals("0", matcher3.group(1)); + Assert.assertEquals("36", matcher3.group(2)); + + Assert.assertFalse(VradiConstants.XML_STREAM_IMPORT_TIME.matcher("1").find()); + Assert.assertFalse(VradiConstants.XML_STREAM_IMPORT_TIME.matcher("122:35").find()); + Assert.assertFalse(VradiConstants.XML_STREAM_IMPORT_TIME.matcher("12:35.999").find()); + } +} Property changes on: trunk/vradi-services/src/test/java/org/chorem/vradi/services/tasks/TasksManagerTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/annonce.xml =================================================================== --- trunk/vradi-services/src/test/resources/annonce.xml (rev 0) +++ trunk/vradi-services/src/test/resources/annonce.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,543 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + #%L + Vradi :: Services + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<opt> + <item> + <acheteur>Infocom94</acheteur> + <date>N.D.</date> + <departement>94</departement> + <description>Numéro d'annonce : 3689 + + Parue le 03/01/2010 + + Cliquez-ici, pour télécharger le DCE ou répondre en ligne + + + Information sur le marché + + + Objet du marché : fourniture et pose de mobiliers urbains à l'usage des + vélos + + + Type de marché + + + FOURNITURES + SERVICES + + Type de procédure + + : ouverte (1 enveloppe) + + Date de clôture des offres + + : 15/02/2010 à 12:00 + + Descriptif du marché + + : + + + Nom & adresse officiels du pouvoir adjudicateur ou de l'entité + adjudicatrice + + Organisme + + : Ville de Nogent sur Marne + + Adresse + + : Hôtel de Ville Square d'Estienne d'Orves + + Code postal + + : 94130 + + Localité/Ville + + : Nogent sur Marne + + + Coordonnées de la personne auprès de laquelle des informations + complémentaires peuvent être obtenues + + + Classification des produits + + : 90 Assainissement, voirie et gestion des déchets + + Département de publication + + : 94 + + + AVIS D'APPEL PUBLIC A LA CONCURRENCE + ==================================== + + Marché de fournitures + Marché de services + + + IDENTIFICATION DE L'ORGANISME QUI PASSE LE MARCHE + ------------------------------------------------- + + + Nom et adresse officiels de l'organisme acheteur : + + Ville de Nogent sur Marne + M. le Maire + Hôtel de Ville Square d'Estienne d'Orves + 94130 Nogent sur Marne + France + Tél : 0143246360 + Fax : 0143246359 + URL : http://ville-nogentsurmarne.infocom94.fr + + + OBJET DU MARCHE + --------------- + + fourniture et pose de mobiliers urbains à l'usage des vélos + + + Justifications à produire quant aux qualités et capacités du candidat : + + * DC 4 (Lettre de candidature et d'habilitation du mandataire par ses + co-traitants, disponible à l'adresse suivante : http://www.minefe.gouv.fr, + thème : marchés publics) + + * DC 5 (Déclaration du candidat, disponible à l'adresse suivante : + http://www.minefe.gouv.fr, thème : marchés publics) + + * Documents à produire dans tous les cas au stade de l'attribution du + marché : Pièces prévues aux articles D.8222-5 ou D.8222-7 et D.8222-8 du + code du travail + + * Documents à produire dans tous les cas au stade de l'attribution du + marché : Attestations et certificats délivrés par les administrations et + organismes compétents prouvant que le candidat a satisfait à ses + obligations fiscales et sociales (si ces éléments ne sont pas déjà + demandés dans le cadre du DC 7, ci-après) ou documents équivalents en cas + de candidat étranger + + * Justifications autres en saisie libre : + + + voir le réglement de la consultation + + + CRITERES D'ATTRIBUTION + ---------------------- + + Offre économiquement la plus avantageuse appréciée en fonction des + critères énoncés dans le cahier des charges (règlement de la consultation, + lettre d'invitation) + + + PROCEDURES + ---------- + + + Mode de passation : + + Procédure adaptée + + + CONDITIONS DE DELAI + ------------------- + + + Date limite de réception des offres : + + 15/02/2010 à 12 H 00 + + + AUTRES RENSEIGNEMENTS + --------------------- + + + Numéro de référence attribué au marché par le pouvoir adjudicateur / + l'entité adjudicatrice : + + M10.102/202 + + + MARCHE DIVISE EN LOTS + --------------------- + + * Lot N° 1 + + + Description : fourniture et pose de supports à vélos* Lot N° 2 + + + Description : fourniture et pose d'abris à vélos + + + </description> + <intitule>Fourniture et pose de mobiliers urbains à l'usage des vélos + </intitule> + </item> + <item> + <acheteur>Ville de Nogent sur Marne</acheteur> + <date>N.D.</date> + <departement>94</departement> + <description>Numéro d'annonce : 3689 + + Parue le 03/01/2010 + + Cliquez-ici, pour télécharger le DCE ou répondre en ligne + + + Information sur le marché + + + Objet du marché : fourniture et pose de mobiliers urbains à l'usage des + vélos + + + Type de marché + + + FOURNITURES + SERVICES + + Type de procédure + + : ouverte (1 enveloppe) + + Date de clôture des offres + + : 15/02/2010 à 12:00 + + Descriptif du marché + + : + + + Nom & adresse officiels du pouvoir adjudicateur ou de l'entité + adjudicatrice + + Organisme + + : Ville de Nogent sur Marne + + Adresse + + : Hôtel de Ville Square d'Estienne d'Orves + + Code postal + + : 94130 + + Localité/Ville + + : Nogent sur Marne + + + Coordonnées de la personne auprès de laquelle des informations + complémentaires peuvent être obtenues + + + Classification des produits + + : 90 Assainissement, voirie et gestion des déchets + + Département de publication + + : 94 + + + AVIS D'APPEL PUBLIC A LA CONCURRENCE + ==================================== + + Marché de fournitures + Marché de services + + + IDENTIFICATION DE L'ORGANISME QUI PASSE LE MARCHE + ------------------------------------------------- + + + Nom et adresse officiels de l'organisme acheteur : + + Ville de Nogent sur Marne + M. le Maire + Hôtel de Ville Square d'Estienne d'Orves + 94130 Nogent sur Marne + France + Tél : 0143246360 + Fax : 0143246359 + URL : http://ville-nogentsurmarne.infocom94.fr + + + OBJET DU MARCHE + --------------- + + fourniture et pose de mobiliers urbains à l'usage des vélos + + + Justifications à produire quant aux qualités et capacités du candidat : + + * DC 4 (Lettre de candidature et d'habilitation du mandataire par ses + co-traitants, disponible à l'adresse suivante : http://www.minefe.gouv.fr, + thème : marchés publics) + + * DC 5 (Déclaration du candidat, disponible à l'adresse suivante : + http://www.minefe.gouv.fr, thème : marchés publics) + + * Documents à produire dans tous les cas au stade de l'attribution du + marché : Pièces prévues aux articles D.8222-5 ou D.8222-7 et D.8222-8 du + code du travail + + * Documents à produire dans tous les cas au stade de l'attribution du + marché : Attestations et certificats délivrés par les administrations et + organismes compétents prouvant que le candidat a satisfait à ses + obligations fiscales et sociales (si ces éléments ne sont pas déjà + demandés dans le cadre du DC 7, ci-après) ou documents équivalents en cas + de candidat étranger + + * Justifications autres en saisie libre : + + + voir le réglement de la consultation + + + CRITERES D'ATTRIBUTION + ---------------------- + + Offre économiquement la plus avantageuse appréciée en fonction des + critères énoncés dans le cahier des charges (règlement de la consultation, + lettre d'invitation) + + + PROCEDURES + ---------- + + + Mode de passation : + + Procédure adaptée + + + CONDITIONS DE DELAI + ------------------- + + + Date limite de réception des offres : + + 15/02/2010 à 12 H 00 + + + AUTRES RENSEIGNEMENTS + --------------------- + + + Numéro de référence attribué au marché par le pouvoir adjudicateur / + l'entité adjudicatrice : + + M10.102/202 + + + MARCHE DIVISE EN LOTS + --------------------- + + * Lot N° 1 + + + Description : fourniture et pose de supports à vélos* Lot N° 2 + + + Description : fourniture et pose d'abris à vélos + + + </description> + <intitule>Fourniture et pose de mobiliers urbains à l'usage des vélos + </intitule> + </item> + <item> + <acheteur>Ville de Saint Joseph</acheteur> + <date>19/01/2010 - 11:00</date> + <departement>972</departement> + <description>Date et heure limites de réception des offres : 08/02/2010 + 12:00 + + 35 jour(s) et 19 heure(s) + + + Objet : FOURNITURE DE BETON PRET A L'EMPLOI + + + Lieu : Saint-joseph + + + Personne Morale : Mairie de Saint Joseph + + + Type de contrat : Marché public + + + Mode de passation : Appel d'offres ouvert + + + Service des Marchés Publics, des Achats et de la Réglementation : + + + Adresse de renseignements administratifs : + + + MAIRIE DE SAINT-JOSEPH Service des Marchés Publics, des Achats et de la + Réglementation Rue de la République 97212 SAINT-JOSEPH + + + Auprès de : + + + Mme ALONZEAU + + + Adresse de retrait des documents : + + + MAIRIE DE SAINT-JOSEPH Service des Marchés Publics, des Achats et de la + Réglementation Rue de la République 97212 SAINT-JOSEPH + + + Avis de publication + + Règlement Consultation + + Téléchargement + + Répondre + </description> + <intitule>FOURNITURE DE BETON PRET A L'EMPLOI</intitule> + </item> + <item> + <acheteur>EMOC</acheteur> + <date>25/01/2010 17:00</date> + <departement>N.D.</departement> + <description>Nom et adresse du pouvoir adjudicateur + + Organisme : EMOC + + Adresse : 30 RUE DU CHATEAU DES RENTIERS 75013 PARIS + + Code postal : + + Ville : PARIS + + Pays : FRANCE + + Intitulé du marché : Concours restreint de maîtrise d'oeuvre sur esquisse + relatif à l'extension du musée Picasso à Paris. + + Numéro d'opération : concours moe Picasso + + Type de marché : Services + + Lieu d'exécution: + + Classification CPV : + + Type de procédure : Procédure adaptée + + Date de remise des offres : le 12/02/2010 à 15:00 + + Adresse auprès de laquelle les informations complémentaires peuvent être + obtenues + + Identité : Bertrand Desmarais + + Téléphone : 01.44.97.78.04 + + Télécopieur : + + Adresse électronique : b.desmarais@emoc.fr + + Lien vers le fichier : Compléments d'information + + </description> + <intitule>Concours restreint de maîtrise d'oeuvre sur esquisse relatif à + l'extension du musée Picasso à Paris. + </intitule> + </item> + <item> + <acheteur>EMOC</acheteur> + <date>---</date> + <departement>N.D.</departement> + <description>Nom et adresse du pouvoir adjudicateur + + Organisme : EMOC + + Adresse : 30 RUE DU CHATEAU DES RENTIERS 75013 PARIS + + Code postal : + + Ville : PARIS + + Pays : FRANCE + + Intitulé du marché : Marché de maîtrise d'oeuvre de l'aménagement du + Palais de Tokyo passé en application des articles 74 III 1°, 74 III alinéa + 5 -b et 35 I 2° du code des marchés publics. + + Numéro d'opération : Palais de Tokyo - Mo + + Type de marché : Services + + Lieu d'exécution: Palais de Tokyo 13, avenue du Président Wilson 7 + + Classification CPV : + + Type de procédure : Procédure négociée + + Date de remise des candidatures : le 02/02/2010 à 12:00 + + Date de remise des offres : le 30/11/0002 à 00:00 + + Adresse auprès de laquelle les informations complémentaires peuvent être + obtenues + + Identité : Jamila Makhloufi + + Téléphone : + + Télécopieur : 01.44.97.79.03 + + Adresse électronique : j.makhloufi@emoc.fr + + Lien vers le fichier : Compléments d'information + + </description> + <intitule>Marché de maîtrise d'oeuvre de l'aménagement du Palais de Tokyo + passé en application des articles 74 III 1°, 74 III alinéa 5 -b et 35 I 2° + du code des marchés publics. + </intitule> + </item> +</opt> + Property changes on: trunk/vradi-services/src/test/resources/annonce.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/csv/clients.csv =================================================================== --- trunk/vradi-services/src/test/resources/csv/clients.csv (rev 0) +++ trunk/vradi-services/src/test/resources/csv/clients.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,3 @@ +"ModificationTag.lastModified","ModificationTag.lastModifier","ModificationTag.lastStatusModifier","Client.address","Client.contact","Client.creationDate","Client.name","Client.phone" +"2010-08-31T14:10:01.380+0000Z","a",,,,,"Code Lutin", +"2010-09-01T10:38:18.641+0000Z","a",,,,,"Libre entreprise", Property changes on: trunk/vradi-services/src/test/resources/csv/clients.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/csv/testimport.csv =================================================================== --- trunk/vradi-services/src/test/resources/csv/testimport.csv (rev 0) +++ trunk/vradi-services/src/test/resources/csv/testimport.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,473 @@ +"Wikitty.Id","Form.attachments","Form.datePeremption","Form.datePub","Form.files","Form.sending","Form.thesaurus","Form.xmlStream","Infogene.country","Infogene.creationDate","Infogene.department","Infogene.description","Infogene.entity","Infogene.id","Infogene.objet","Infogene.sourceText","Infogene.sourceURL","Infogene.status","XmlFieldBinding.defaultValue","XmlFieldBinding.formField","XmlFieldBinding.xmlField","annonce.acheteur","annonce.date","annonce.departement","annonce.description","annonce.intitule","Status.description","Status.modifiable","Status.name","Status.value","XmlStream.formTypeName","XmlStream.name","XmlStream.url","XmlStream.xmlFieldBinding" +"0bc30ce5-44b0-4481-9399-4237a0409883",,,,,,,,,,,,,,,,,,,"annonce.intitule","intitule",,,,,,,,,,,,, +"37f08a2e-f737-44d3-bb2f-60bcb590287a",,,,,,,,,,,,,,,,,,,"annonce.description","description",,,,,,,,,,,,, +"94535807-4b4e-407e-b829-faa6d959f89b",,,,,,,,,,,,,,,,,,,"annonce.acheteur","acheteur",,,,,,,,,,,,, +"4084ff9a-8477-4053-a717-b629ee8c3f42",,,,,,,,,,,,,,,,,,,"annonce.departement","departement",,,,,,,,,,,,, +"a82452ec-0b63-4f85-9742-ea18708f1106",,,,,,,,,,,,,,,,,,,"annonce.date","date",,,,,,,,,,,,, +"59cbeb37-072e-42f6-a8d4-260cc2c59865",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"annonce","annonce[0.0]","file:vradi/vradi-services/target/test-classes/annonce.xml","94535807-4b4e-407e-b829-faa6d959f89b,a82452ec-0b63-4f85-9742-ea18708f1106,4084ff9a-8477-4053-a717-b629ee8c3f42,37f08a2e-f737-44d3-bb2f-60bcb590287a,0bc30ce5-44b0-4481-9399-4237a0409883" +"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,,,,,,,,,,,,,,,,,,,,,,,"par défaut toute nouvelle information","false","Non traité","0",,,, +"f0f5cba1-eff9-49b5-9a1b-d62256f6b742",,,,,,,"file:vradi/vradi-services/target/test-classes/annonce.xml",,"2010-04-21T13:54:27.719+0000Z",,,,"2010-04-21f0f5cba1-eff9-49b5-9a1b-d62256f6b742",,,,"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,"TATA TOTO","---","N.D.","Nom et adresse du pouvoir adjudicateur + +Organisme : EMOC + +Adresse : 30 RUE DU CHATEAU DES RENTIERS 75013 PARIS + +Code postal : + +Ville : PARIS + +Pays : FRANCE + +Intitulé du marché : Marché de maîtrise d'oeuvre de l'aménagement du Palais de Tokyo passé en application des articles 74 III 1°, 74 III alinéa 5 -b et 35 I 2° du code des marchés publics. + +Numéro d'opération : Palais de Tokyo - Mo + +Type de marché : Services + +Lieu d'exécution: Palais de Tokyo 13, avenue du Président Wilson 7 + +Classification CPV : + +Type de procédure : Procédure négociée + +Date de remise des candidatures : le 02/02/2010 à 12:00 + +Date de remise des offres : le 30/11/0002 à 00:00 + +Adresse auprès de laquelle les informations complémentaires peuvent être obtenues + +Identité : Jamila Makhloufi + +Téléphone : + +Télécopieur : 01.44.97.79.03 + +Adresse électronique : j.makhloufi@emoc.fr + +Lien vers le fichier : Compléments d'information","Marché de maîtrise d'oeuvre de l'aménagement du Palais de Tokyo passé en application des articles 74 III 1°, 74 III alinéa 5 -b et 35 I 2° du code des marchés publics.",,,,,,,, +"9cdd0e42-88bd-4350-a65b-d4334d349fc7",,,,,,,"file:vradi/vradi-services/target/test-classes/annonce.xml",,"2010-04-21T13:54:27.720+0000Z",,,,"2010-04-219cdd0e42-88bd-4350-a65b-d4334d349fc7",,,,"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,"Ville de Nogent sur Marne","N.D.","94","Numéro d'annonce : 3689 + +Parue le 03/01/2010 + +Cliquez-ici, pour télécharger le DCE ou répondre en ligne + + +Information sur le marché + + + + + + + + + +Objet du marché : fourniture et pose de mobiliers urbains à l'usage des vélos + + +Type de marché + + +FOURNITURES +SERVICES + +Type de procédure + +: ouverte (1 enveloppe) + +Date de clôture des offres + +: 15/02/2010 à 12:00 + +Descriptif du marché + +: + + +Nom & adresse officiels du pouvoir adjudicateur ou de l'entité adjudicatrice + +Organisme + +: Ville de Nogent sur Marne + +Adresse + +: Hôtel de Ville Square d'Estienne d'Orves + +Code postal + +: 94130 + +Localité/Ville + +: Nogent sur Marne + + +Coordonnées de la personne auprès de laquelle des informations complémentaires peuvent être obtenues + + +Classification des produits + +: 90 Assainissement, voirie et gestion des déchets + +Département de publication + +: 94 + + + + + + + + + + + +AVIS D'APPEL PUBLIC A LA CONCURRENCE +==================================== + +Marché de fournitures +Marché de services + + +IDENTIFICATION DE L'ORGANISME QUI PASSE LE MARCHE +------------------------------------------------- + + +Nom et adresse officiels de l'organisme acheteur : + +Ville de Nogent sur Marne +M. le Maire +Hôtel de Ville Square d'Estienne d'Orves +94130 Nogent sur Marne +France +Tél : 0143246360 +Fax : 0143246359 +URL : http://ville-nogentsurmarne.infocom94.fr + + +OBJET DU MARCHE +--------------- + +fourniture et pose de mobiliers urbains à l'usage des vélos + + +Justifications à produire quant aux qualités et capacités du candidat : + + * DC 4 (Lettre de candidature et d'habilitation du mandataire par ses co-traitants, disponible à l'adresse suivante : http://www.minefe.gouv.fr, thème : marchés publics) + + * DC 5 (Déclaration du candidat, disponible à l'adresse suivante : http://www.minefe.gouv.fr, thème : marchés publics) + + * Documents à produire dans tous les cas au stade de l'attribution du marché : Pièces prévues aux articles D.8222-5 ou D.8222-7 et D.8222-8 du code du travail + + * Documents à produire dans tous les cas au stade de l'attribution du marché : Attestations et certificats délivrés par les administrations et organismes compétents prouvant que le candidat a satisfait à ses obligations fiscales et sociales (si ces éléments ne sont pas déjà demandés dans le cadre du DC 7, ci-après) ou documents équivalents en cas de candidat étranger + + * Justifications autres en saisie libre : + + + voir le réglement de la consultation + + +CRITERES D'ATTRIBUTION +---------------------- + +Offre économiquement la plus avantageuse appréciée en fonction des critères énoncés dans le cahier des charges (règlement de la consultation, lettre d'invitation) + + +PROCEDURES +---------- + + +Mode de passation : + +Procédure adaptée + + +CONDITIONS DE DELAI +------------------- + + +Date limite de réception des offres : + +15/02/2010 à 12 H 00 + + +AUTRES RENSEIGNEMENTS +--------------------- + + +Numéro de référence attribué au marché par le pouvoir adjudicateur / l'entité adjudicatrice : + +M10.102/202 + + +MARCHE DIVISE EN LOTS +--------------------- + + * Lot N° 1 + + + Description : fourniture et pose de supports à vélos* Lot N° 2 + + + Description : fourniture et pose d'abris à vélos","Fourniture et pose de mobiliers urbains à l'usage des vélos",,,,,,,, +"88ee1fcb-bf3c-4860-b571-abc888a7454f",,,,,,,"file:vradi/vradi-services/target/test-classes/annonce.xml",,"2010-04-21T13:54:27.720+0000Z",,,,"2010-04-2188ee1fcb-bf3c-4860-b571-abc888a7454f",,,,"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,"Infocom94","N.D.","94","Numéro d'annonce : 3689 + +Parue le 03/01/2010 + +Cliquez-ici, pour télécharger le DCE ou répondre en ligne + + +Information sur le marché + + + + + + + + + +Objet du marché : fourniture et pose de mobiliers urbains à l'usage des vélos + + +Type de marché + + +FOURNITURES +SERVICES + +Type de procédure + +: ouverte (1 enveloppe) + +Date de clôture des offres + +: 15/02/2010 à 12:00 + +Descriptif du marché + +: + + +Nom & adresse officiels du pouvoir adjudicateur ou de l'entité adjudicatrice + +Organisme + +: Ville de Nogent sur Marne + +Adresse + +: Hôtel de Ville Square d'Estienne d'Orves + +Code postal + +: 94130 + +Localité/Ville + +: Nogent sur Marne + + +Coordonnées de la personne auprès de laquelle des informations complémentaires peuvent être obtenues + + +Classification des produits + +: 90 Assainissement, voirie et gestion des déchets + +Département de publication + +: 94 + + + + + + + + + + + +AVIS D'APPEL PUBLIC A LA CONCURRENCE +==================================== + +Marché de fournitures +Marché de services + + +IDENTIFICATION DE L'ORGANISME QUI PASSE LE MARCHE +------------------------------------------------- + + +Nom et adresse officiels de l'organisme acheteur : + +Ville de Nogent sur Marne +M. le Maire +Hôtel de Ville Square d'Estienne d'Orves +94130 Nogent sur Marne +France +Tél : 0143246360 +Fax : 0143246359 +URL : http://ville-nogentsurmarne.infocom94.fr + + +OBJET DU MARCHE +--------------- + +fourniture et pose de mobiliers urbains à l'usage des vélos + + +Justifications à produire quant aux qualités et capacités du candidat : + + * DC 4 (Lettre de candidature et d'habilitation du mandataire par ses co-traitants, disponible à l'adresse suivante : http://www.minefe.gouv.fr, thème : marchés publics) + + * DC 5 (Déclaration du candidat, disponible à l'adresse suivante : http://www.minefe.gouv.fr, thème : marchés publics) + + * Documents à produire dans tous les cas au stade de l'attribution du marché : Pièces prévues aux articles D.8222-5 ou D.8222-7 et D.8222-8 du code du travail + + * Documents à produire dans tous les cas au stade de l'attribution du marché : Attestations et certificats délivrés par les administrations et organismes compétents prouvant que le candidat a satisfait à ses obligations fiscales et sociales (si ces éléments ne sont pas déjà demandés dans le cadre du DC 7, ci-après) ou documents équivalents en cas de candidat étranger + + * Justifications autres en saisie libre : + + + voir le réglement de la consultation + + +CRITERES D'ATTRIBUTION +---------------------- + +Offre économiquement la plus avantageuse appréciée en fonction des critères énoncés dans le cahier des charges (règlement de la consultation, lettre d'invitation) + + +PROCEDURES +---------- + + +Mode de passation : + +Procédure adaptée + + +CONDITIONS DE DELAI +------------------- + + +Date limite de réception des offres : + +15/02/2010 à 12 H 00 + + +AUTRES RENSEIGNEMENTS +--------------------- + + +Numéro de référence attribué au marché par le pouvoir adjudicateur / l'entité adjudicatrice : + +M10.102/202 + + +MARCHE DIVISE EN LOTS +--------------------- + + * Lot N° 1 + + + Description : fourniture et pose de supports à vélos* Lot N° 2 + + + Description : fourniture et pose d'abris à vélos","Fourniture et pose de mobiliers urbains à l'usage des vélos",,,,,,,, +"6f5339be-faa0-48c6-915f-423ec969cc43",,,,,,,"file:vradi/vradi-services/target/test-classes/annonce.xml",,"2010-04-21T13:54:27.720+0000Z",,,,"2010-04-216f5339be-faa0-48c6-915f-423ec969cc43",,,,"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,"EMOC","25/01/2010 17:00","N.D.","Nom et adresse du pouvoir adjudicateur + +Organisme : EMOC + +Adresse : 30 RUE DU CHATEAU DES RENTIERS 75013 PARIS + +Code postal : + +Ville : PARIS + +Pays : FRANCE + +Intitulé du marché : Concours restreint de maîtrise d'oeuvre sur esquisse relatif à l'extension du musée Picasso à Paris. + +Numéro d'opération : concours moe Picasso + +Type de marché : Services + +Lieu d'exécution: + +Classification CPV : + +Type de procédure : Procédure adaptée + +Date de remise des offres : le 12/02/2010 à 15:00 + +Adresse auprès de laquelle les informations complémentaires peuvent être obtenues + +Identité : Bertrand Desmarais + +Téléphone : 01.44.97.78.04 + +Télécopieur : + +Adresse électronique : b.desmarais@emoc.fr + +Lien vers le fichier : Compléments d'information","Concours restreint de maîtrise d'oeuvre sur esquisse relatif à l'extension du musée Picasso à Paris.",,,,,,,, +"fd31005a-a4f1-4c07-9ecc-8d34f8b97836",,,,,,,"file:vradi/vradi-services/target/test-classes/annonce.xml",,"2010-04-21T13:54:27.720+0000Z",,,,"2010-04-21fd31005a-a4f1-4c07-9ecc-8d34f8b97836",,,,"af2ae6c6-feae-45fb-ab5c-5d9fcf707fb1",,,,"Ville de Saint Joseph","19/01/2010 - 11:00","972","Date et heure limites de réception des offres : 08/02/2010 12:00 + +35 jour(s) et 19 heure(s) + + +Objet : FOURNITURE DE BETON PRET A L'EMPLOI + + +Lieu : Saint-joseph + + +Personne Morale : Mairie de Saint Joseph + + +Type de contrat : Marché public + + +Mode de passation : Appel d'offres ouvert + + + +Service des Marchés Publics, des Achats et de la Réglementation : + + + + +Adresse de renseignements administratifs : + + +MAIRIE DE SAINT-JOSEPH Service des Marchés Publics, des Achats et de la Réglementation Rue de la République 97212 SAINT-JOSEPH + + + + +Auprès de : + + +Mme ALONZEAU + + + + +Adresse de retrait des documents : + + +MAIRIE DE SAINT-JOSEPH Service des Marchés Publics, des Achats et de la Réglementation Rue de la République 97212 SAINT-JOSEPH + + +Avis de publication + +Règlement Consultation + +Téléchargement + +Répondre","FOURNITURE DE BETON PRET A L'EMPLOI",,,,,,,, Property changes on: trunk/vradi-services/src/test/resources/csv/testimport.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/csv/thesaurus.csv =================================================================== --- trunk/vradi-services/src/test/resources/csv/thesaurus.csv (rev 0) +++ trunk/vradi-services/src/test/resources/csv/thesaurus.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,11 @@ +"Wikitty.Id","Wikitty.ext","WikittyTreeNode.attachment","WikittyTreeNode.name","WikittyTreeNode.parent","Thesaurus.comment","Thesaurus.order","Thesaurus.rootThesaurus","Thesaurus.tags" +"5814884c-d911-4810-8942-47c8645aa338",,,"Sport","fdb2540a-0a4a-4233-a8ad-201e58e70301",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"7ae3e83d-3ea7-4561-8035-a9d23b8051bc",,,"Tennis","5814884c-d911-4810-8942-47c8645aa338",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"2b3ad76c-b6b3-4630-ba82-039f5688dcf5",,,"Tennis de table","5814884c-d911-4810-8942-47c8645aa338",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"0d42666c-f848-440c-8289-525ebfda7449",,,"Golf","5814884c-d911-4810-8942-47c8645aa338",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"e7bbebb1-f5ef-401b-87fb-6a4cc1d3ef62",,,"Dance","5814884c-d911-4810-8942-47c8645aa338",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"b40416e9-af56-42a2-b490-050f92045276",,,"Foot","5814884c-d911-4810-8942-47c8645aa338",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301","(equipe de france)" +"c65ed830-09ff-4a7d-b0d4-107da21ef302",,,"Foot en salle","b40416e9-af56-42a2-b490-050f92045276",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"346c598d-3aad-48e2-a591-69d97318cbde",,,"Foot extérieur","b40416e9-af56-42a2-b490-050f92045276",,,"fdb2540a-0a4a-4233-a8ad-201e58e70301", +"fdb2540a-0a4a-4233-a8ad-201e58e70301","RootThesaurus",,"TestRootThesaurus","d14f87f1-ac6b-4181-a9dd-04537a1f2658",,,, + Property changes on: trunk/vradi-services/src/test/resources/csv/thesaurus.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/csv/users.csv =================================================================== --- trunk/vradi-services/src/test/resources/csv/users.csv (rev 0) +++ trunk/vradi-services/src/test/resources/csv/users.csv 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,3 @@ +"ModificationTag.lastModified","ModificationTag.lastModifier","ModificationTag.lastStatusModifier","User.address","User.client","User.creationDate","User.email","User.enable","User.beginSearchDate","User.name","User.phone","User.service","User.validEmail" +"2010-09-01T13:22:33.943+0000Z","a",,,"Client.name=""Libre entreprise""","2010-06-24T14:14:38.585+0000Z",,"true","2010-06-30T22:00:00.000+0000Z","Pierre Cros",,, +"2010-09-01T13:43:23.039+0000Z","a",,,"Client.name=""Code Lutin""","2010-06-24T14:14:25.473+0000Z","chatellier@codelutin.com","true","2010-06-30T22:00:00.000+0000Z","Eric Chatellier",,, Property changes on: trunk/vradi-services/src/test/resources/csv/users.csv ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/dates.xml =================================================================== --- trunk/vradi-services/src/test/resources/dates.xml (rev 0) +++ trunk/vradi-services/src/test/resources/dates.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,175 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<channel> + <item> + <id>1</id> + <date>---</date> + </item> + <item> + <id>2</id> + <date>N.D.</date> + </item> + <item> + <id>3</id> + <date></date> + </item> + <item> + <id>4</id> + <!-- E, d MMM yyyy HH:mm:ss Z --> + <date>Sun, 29 Nov 2009 22:07:29 +0100</date> + </item> + <item> + <id>5</id> + <!-- yyyy-MM-dd --> + <date>2008-12-21</date> + </item> + <item> + <id>6</id> + <!-- yyyy-MM-dd HH:mm:ss --> + <date>2010-04-02 12:00:00</date> + </item> + <item> + <id>7</id> + <!-- yyyy-MM-dd HH:mm --> + <date>2010-04-02 12:00</date> + </item> + <item> + <id>8</id> + <!-- dd MMMM yyyy --> + <date>23 mars 2010</date> + </item> + <item> + <id>9</id> + <!-- dd MMMM yyyy'.' --> + <date>23 mars 2010.</date> + </item> + <item> + <id>10</id> + <!-- dd/MM/yyyy 'à' HH:mm --> + <date>10/03/2010 à 12:00</date> + </item> + <item> + <id>11</id> + <!-- dd/MM/yyyy 'à' HH:mm'.' --> + <date>10/03/2010 à 12:00.</date> + </item> + <item> + <id>12</id> + <!-- dd/MM/yyyy 'à' HH 'heures' --> + <date>10/03/2010 à 12 heures</date> + </item> + <item> + <id>13</id> + <!-- dd MMMM yyyy 'à' HH 'heures' --> + <date>10 avril 2010 à 12 heures</date> + </item> + <item> + <id>14</id> + <!-- dd MMMM yyyy', à' HH 'heures' --> + <date>10 avril 2010, à 12 heures</date> + </item> + <item> + <id>15</id> + <!-- dd MMMM yyyy 'à' HH:mm --> + <date>5 mai 2010 à 12:00</date> + </item> + <item> + <id>16</id> + <!-- dd MMMM yyyy 'à' HH:mm'.' --> + <date>5 mai 2010 à 12:00.</date> + </item> + <item> + <id>17</id> + <!-- dd MMMM yyyy', à' HH:mm --> + <date>5 mai 2010, à 12:00</date> + </item> + <item> + <id>18</id> + <!-- dd MMMM yyyy', à' HH:mm'.' --> + <date>5 mai 2010, à 12:00.</date> + </item> + <item> + <id>19</id> + <!-- dd MMMM yyyy 'à' HH 'h' mm --> + <date>2 avril 2010 à 15 h 30</date> + </item> + <item> + <id>20</id> + <!-- dd MMMM yyyy', à' HH 'h' mm --> + <date>2 avril 2010, à 15 h 30</date> + </item> + <item> + <id>21</id> + <!-- dd MMMM yyyy 'à' HH'h'mm --> + <date>2 avril 2010 à 15h30</date> + </item> + <item> + <id>22</id> + <!-- dd MMMM yyyy', à' HH'h'mm --> + <date>2 avril 2010, à 15h30</date> + </item> + <item> + <id>23</id> + <!-- '1.e.r' MMMM yyyy', à' HH 'heures' --> + <date>1.e.r avril 2010, à 17 heures</date> + </item> + <item> + <id>24</id> + <!-- '1.e.r' MMMM yyyy 'à' HH 'heures' --> + <date>1.e.r avril 2010 à 17 heures</date> + </item> + <item> + <id>25</id> + <!-- '1er' MMMM yyyy', à' HH 'heures' --> + <date>1er avril 2010, à 17 heures</date> + </item> + <item> + <id>26</id> + <!-- '1er' MMMM yyyy 'à' HH 'heures' --> + <date>1er avril 2010 à 17 heures</date> + </item> + + <item> + <id>27</id> + <date>RENSEIGNEMENTS COMPLEMENTAIRES</date> + </item> + <item> + <id>28</id> + <date>Au lieu de : 15 mars 2010, à 12:00</date> + </item> + <item> + <id>29</id> + <date>180 (à compter de la date limite de réception des offres)</date> + </item> + + <item> + <id>30</id> + <!-- dd MMMM yyyy (supporté car "The method may not use the entire text of the given string.")--> + <date>18 juin 2010 à midi.</date> + </item> + +</channel> Property changes on: trunk/vradi-services/src/test/resources/dates.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/file.xml =================================================================== --- trunk/vradi-services/src/test/resources/file.xml (rev 0) +++ trunk/vradi-services/src/test/resources/file.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<channel> + <item> + <name>tr.txt</name> + <dir>/tmp</dir> + <size>203</size> + <lastModified>Sun, 29 Nov 2009 22:07:29 +0100</lastModified> + <modified>2009-11-29</modified> + <description> + <![CDATA[<Tito> ce soir je me fais beau pour la soirée chez lucie et vous savez ce que je vais ramener dans mes filets ? ^^ +<Keedo> vu ta gueule je dirais des thons +<Jo> +1 +<Seb> +1 +<Biby> +1 +<Teo> +1 +<Tito> ... +-- http://danstonchat.com/11100.html]]> + </description> + </item> + <item> + <name>update-rc.d.txt</name> + <dir>/tmp</dir> + <size>814</size> + <lastModified>Sun, 21 Dec 2008 13:04:16 +0100</lastModified> + <modified>2008-12-21</modified> + <description> + <![CDATA[Jo' : Tout à l'heure, j'ai mangé moules frites tu vois +Jo' : Et si tu veux y'a mon chat qu'est venu pour demander à bouffer +Jo' : Et j'ai demandé à ma mère : "tu crois que la chatte elle aime les moules ?" +Jo' : Ma mère a donc piqué un fou-rire, et m'a répondu "demande à ta soeur" +Jo' : Et c'est depuis ce moment que j'ai appris que ma soeur était lesbienne +Jo' : ... +-- http://danstonchat.com/11097.html]]> + </description> + </item> + <item> + <name>enscript.txt</name> + <dir>/tmp</dir> + <size>125</size> + <lastModified>Mon, 28 Sep 2009 14:29:57 +0200</lastModified> + <modified>2009-09-28</modified> + <description> + <![CDATA[<OPH> Ma soeur est un monstre, elle a littéralement tapissé mon bureau de raccourcis internet explorer après avoir au préalable désinstallé firefox et safari. +<OPH> Le pire c'est qu'elle a mis un mot de passe à ma session et m'a créé un compte limité. +<OPH> En plus maintenant j'ai un fond d'écran Lorie/Tokio Hotel et un curseur dinosaure. +<OPH> Et tout ça pour quoi ? Hier soir, j'avais mis les glaçons du congélo dans son lit. +<Wo_Ouaf> Famille de barges... +-- http://danstonchat.com/11095.htm]]> + </description> + </item> + <item> + <name>wifi.txt</name> + <dir>/tmp</dir> + <size>490</size> + <lastModified>Sun, 6 Sep 2009 07:27:46 +0200</lastModified> + <modified>2009-09-06</modified> + </item> +</channel> Property changes on: trunk/vradi-services/src/test/resources/file.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/images/enregistrement.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/images/enregistrement.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/images/flux.gif =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/images/flux.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/images/form.jpg =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/images/form.jpg ___________________________________________________________________ Added: svn:mime-type + image/jpeg Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/log4j.properties =================================================================== --- trunk/vradi-services/src/test/resources/log4j.properties (rev 0) +++ trunk/vradi-services/src/test/resources/log4j.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,52 @@ +### +# #%L +# Vradi :: Services +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% + +### +# Global logging configuration +log4j.rootLogger=WARN, stdout, file + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%-5p %c:%L - %m%n + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=${project.build.directory}/vradi-services.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=4 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c - %m%n + +# Vradi +log4j.logger.org.chorem.vradi=INFO + +# wikitty +log4j.logger.org.nuiton.wikitty=INFO +#log4j.logger.org.nuiton.wikitty.solr.WikittySearchEngineSolr=DEBUG +#log4j.logger.org.nuiton.wikitty.solr.SolrQParser=DEBUG +#log4j.logger.org.nuiton.wikitty.jdbc.WikittyJDBCUtil=INFO + +# solr +log4j.logger.org.apache.solr=WARN +log4j.logger.org.apache.solr.core=WARN + Property changes on: trunk/vradi-services/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services/src/test/resources/ooo/modelePDF2.odt =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/ooo/modelePDF2.odt ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/ooo/test.ott =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/ooo/test.ott ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/ooo/variousfieldtypes.odt =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/ooo/variousfieldtypes.odt ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/ooo/vradi_template.odt =================================================================== (Binary files differ) Property changes on: trunk/vradi-services/src/test/resources/ooo/vradi_template.odt ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services/src/test/resources/vradi-services.properties =================================================================== --- trunk/vradi-services/src/test/resources/vradi-services.properties (rev 0) +++ trunk/vradi-services/src/test/resources/vradi-services.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,74 @@ +### +# #%L +# Vradi :: Services +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +application.name=${project.name} +application.version=${project.version} +vradi.service.version=${project.version} + +vradi.data.dir=target/vradi +vradi.objectStore.dir=${vradi.data.dir}/objectStore +vradi.temp.dir=target/vradi/tmp +vradi.queryHistory.dir=target/vradi/queryHistory +vradi.embeddedFiles.dir=target/vradi/embeddedFiles +vradi.templates.dir=target/vradi/templates +vradi.pdf.dir=target/vradi/pdf +solr.data.dir=${wikitty.searchengine.solr.directory.data} + +wikitty.data.directory=${vradi.data.dir}/wikitty +oOo.exec.folder=/usr/bin + +wikitty.storage.jdbc.queryfile=wikitty-jdbc-query.properties +wikitty.storage.jdbc.driver=org.h2.Driver +wikitty.storage.jdbc.host=jdbc:h2:file:${wikitty.data.directory}/data/db +wikitty.storage.jdbc.login=sa +wikitty.storage.jdbc.password= +wikitty.storage.jdbc.xadatasource=org.h2.jdbcx.JdbcDataSource +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.URL=${wikitty.storage.jdbc.host} +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.user=${wikitty.storage.jdbc.login} +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.password=${wikitty.storage.jdbc.password} +wikitty.searchengine.solr.directory.data=${wikitty.data.directory}/solr +wikitty.searchengine.solr.directory.factory=solr.StandardDirectoryFactory +wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceStorage,\ +org.nuiton.wikitty.services.WikittyServiceNotifier,\ +org.nuiton.wikitty.services.WikittyServiceCached,\ +org.nuiton.wikitty.services.WikittyServiceSecurity +wikitty.WikittyServiceStorage.components=org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC,\ +org.nuiton.wikitty.jdbc.WikittyStorageJDBC,\ +org.nuiton.wikitty.storage.solr.WikittySearchEngineSolr +wikitty.transaction.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceInMemory +wikitty.service.cache.allwaysRestoreCopies=false +wikitty.service.event.propagate=true +wikitty.service.event.listen=false +wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter +wikitty.service.event.transporter.xmpp.server=im.codelutin.com +wikitty.service.event.transporter.xmpp.room=slave@conference.im.codelutin.com +wikitty.service.slave.async.store=false +wikitty.service.slave.master.xmpp.server=im.codelutin.com +wikitty.service.slave.master.xmpp.room=test@conference.im.codelutin.com +wikitty.addon.export.threadnumber=1 +wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS +#wikitty.service.cache.priority.extensions=Thesaurus +jcs.default= +jcs.default.cacheattributes.MaxObjects=10000 +#jcs.priority.cacheattributes.MaxObjects=10000 Property changes on: trunk/vradi-services/src/test/resources/vradi-services.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/LICENSE.txt =================================================================== --- trunk/vradi-services-web/LICENSE.txt (rev 0) +++ trunk/vradi-services-web/LICENSE.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. Property changes on: trunk/vradi-services-web/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-services-web/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-services-web/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/pom.xml =================================================================== --- trunk/vradi-services-web/pom.xml (rev 0) +++ trunk/vradi-services-web/pom.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>vradi</artifactId> + <version>0.6-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.vradi</groupId> + <artifactId>vradi-services-web</artifactId> + + <packaging>war</packaging> + + <name>Vradi :: Services Web</name> + <description>Vradi service web module</description> + + <dependencies> + <!-- sibling dependencies --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-entities</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-services</artifactId> + <version>${project.version}</version> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>com.caucho</groupId> + <artifactId>hessian</artifactId> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-runner</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>commons-fileupload</groupId> + <artifactId>commons-fileupload</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + </dependencies> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>**/*</include> + </includes> + </resource> + </resources> + <testResources> + <testResource> + <directory>src/test/resources</directory> + <filtering>true</filtering> + <includes> + <include>**/*</include> + </includes> + </testResource> + </testResources> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>org.nuiton.util.war.JettyLauncher</mainClass> + </manifest> + </archive> + <overlays> + <overlay> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + <type>jar</type> + <includes> + <include>**/war/Jetty*</include> + </includes> + </overlay> + <overlay> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-runner</artifactId> + <type>jar</type> + </overlay> + </overlays> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> Property changes on: trunk/vradi-services-web/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/license/THIRD-PARTY.properties =================================================================== --- trunk/vradi-services-web/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/vradi-services-web/src/license/THIRD-PARTY.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,54 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache 2 +# - Apache License +# - Apache Software License - Version 2.0 +# - Apache Software License, Version 2.0 +# - Apache Software License, version 1.1 +# - BSD License +# - BSD style +# - CDDL +# - CDDL 1.0 +# - Common Development and Distribution License (CDDL) v1.0 +# - Common Public License Version 1.0 +# - Eclipse Public License - Version 1.0 +# - Eclipse Public License v1.0 +# - GNU LESSER GENERAL PUBLIC LICENSE +# - GNU Lesser General Public License, Version 3 +# - GPLv2+CE +# - General Public License (GPL) v 3.0 +# - Indiana University Extreme! Lab Software License +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - JDom license +# - Java Transaction API (JTA) License +# - LGPL 2.1 +# - LGPL 2.1 / Apache Software License - Version 2.0 +# - Lesser General Public License (LGPL) v 3.0 +# - License Agreement for Java(TM) Servlet API Specification Interface Classes +# - MIT License +# - Mozilla Public License +# - Mozilla Public License Version 1.0 +# - Public Domain +# - Public domain +# - TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +# - The Apache Software License, Version 1.1 +# - The Apache Software License, Version 2.0 +# - The H2 License, Version 1.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 23 18:07:52 CET 2010 +commons-cli--commons-cli--1.2--jar=Apache Software License, Version 2.0 +commons-primitives--commons-primitives--1.0--jar=Apache Software License, Version 2.0 +concurrent--concurrent--1.0--jar=TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +groovy--groovy-all--1.0-jsr-06--jar=Apache Software License, Version 2.0 +javax.servlet--servlet-api--2.5--jar=License Agreement for Java(TM) Servlet API Specification Interface Classes +javax.transaction--jta--1.1--jar=Java Transaction API (JTA) License +jboss--jnet--3.2.1--jar=GNU Lesser General Public License, Version 3 +org.apache.commons--commons-email--1.2--jar=Apache Software License, Version 2.0 +org.jdom--jdom--1.1--jar=JDom license +rome--rome--1.0--jar=Apache Software License, Version 2.0 +woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / Apache Software License - Version 2.0 +xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme\! Lab Software License Property changes on: trunk/vradi-services-web/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/FileServlet.java =================================================================== --- trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/FileServlet.java (rev 0) +++ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/FileServlet.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,349 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.nuiton.util.FileUtil; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URLDecoder; +import java.util.Arrays; +import java.util.List; + +/** + * Vradi file service (upload/download). + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FileServlet extends HttpServlet { + + /** serialVersionUID. */ + private static final long serialVersionUID = -5368725458920800210L; + + /** log. */ + private static final Log log = LogFactory.getLog(FileServlet.class); + + /** File service instance. */ + protected FileService fileService = new FileServiceImpl(); + + /** + * Get parameters from URI. + * <p/> + * If servlet is called with url : /vradi/file/TEMPLATE/AO + * and mapped on /file/* in web.xml + * <p/> + * Parameters will be { "TEMPLATE", "AO" } + * <p/> + * Another example is : + * Called url : /vradi/file/PDF/xyz/toto.pdf + * Parameters will be { "PDF", "xyz/toto.pdf" } + * + * @param request + * @return + */ + protected String[] getParametersFormRequestURI(HttpServletRequest request) { + + String params = request.getRequestURI(); + params = StringUtils.removeStart(params, request.getContextPath()); + params = StringUtils.removeStart(params, request.getServletPath()); + params = StringUtils.removeStart(params, "/"); + String[] paramsArray = params.split("/"); + + return paramsArray; + } + + /* + * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // get is used to download file + // paramsArray = type and uri + String[] paramsArray = getParametersFormRequestURI(request); + + // get file type + String uploadType = paramsArray[0]; + if (log.isDebugEnabled()) { + log.debug("Managing download type : " + uploadType); + } + VradiConstants.FileType fileType = VradiConstants.FileType.valueOf(uploadType); + if (fileType == null) { + throw new ServletException("Invalid request : unknown upload type : " + uploadType); + } + + try { + File file = null; + switch (fileType) { + case TEMPLATE: { + // two elements : extensionname/file.ext + String extensionName = paramsArray[1]; + String templateName = paramsArray[2]; + file = fileService.downloadTemplate(false, extensionName, templateName); + break; + } + case PDF: { + // one element : file.ext + String uri = paramsArray[1]; + file = fileService.downloadPDF(false, uri); + break; + } + case WEB_HARVEST: { + // one element : file.ext + String uri = paramsArray[1]; + file = fileService.downloadWebHarvestScript(false, uri); + break; + } + case EMBEDDED_FORM_FILES: { + // two element : formid/file.ext + String formId = paramsArray[1]; + String fileName = paramsArray[2]; + fileName = URLDecoder.decode(fileName, "UTF-8"); + file = fileService.downloadFormEmbeddedFile(false, fileName, formId); + break; + } + case ATTACHMENTS_FORM_FILES: { + // two element : formid/file.ext + String formId = paramsArray[1]; + String fileName = paramsArray[2]; + fileName = URLDecoder.decode(fileName, "UTF-8"); + file = fileService.downloadFormAttachment(false, fileName, formId); + break; + } + case ATTACHMENTS_SESSION_FILES: { + // two element : formid/file.ext + String formId = paramsArray[1]; + String fileName = paramsArray[2]; + fileName = URLDecoder.decode(fileName, "UTF-8"); + file = fileService.downloadSessionAttachment(false, fileName, formId); + break; + } + case QUERY_HISTORY: { + // two element : groupId/file.ext + String uri = paramsArray[1]; + file = fileService.downloadRequestHistory(false, uri); + break; + } + } + + if (file != null && file.isFile()) { + goGetFile(request, response, file, fileType); + } else { + if (log.isDebugEnabled()) { + log.debug("Can't find file for params : " + Arrays.toString(paramsArray)); + } + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + } + + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't download file", eee); + } + throw new ServletException("Can't download file", eee); + } + + } + + /** + * Stream file to response output to download. + * + * @param request request + * @param response response + * @param file file to download + */ + protected void goGetFile(HttpServletRequest request, + HttpServletResponse response, File file, VradiConstants.FileType fileType) throws IOException { + + // get some infos + InputStream in = null; + OutputStream output = null; + try { + output = response.getOutputStream(); + ServletContext context = getServletConfig().getServletContext(); + String mimetype = context.getMimeType(file.getName()); + + String mimeType = mimetype != null ? mimetype : fileType.getMineType(); + if (log.isDebugEnabled()) { + log.debug("Sent with mime type : " + mimeType); + } + + // add header + response.setContentType(mimeType); + response.setContentLength((int) file.length()); + response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\""); + + // stream file to response output + in = new DataInputStream(new FileInputStream(file)); + IOUtils.copy(in, output); + } finally { + IOUtils.closeQuietly(in); + if (output != null) { + output.flush(); + output.close(); + } + } + + } + + /* + * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // post is used to upload file + + // Check that we have a file upload request + boolean isMultipart = ServletFileUpload.isMultipartContent(request); + if (isMultipart) { + + String[] paramsArray = getParametersFormRequestURI(request); + + // Create a factory for disk-based file items + FileItemFactory factory = new DiskFileItemFactory(); + + // Create a new file upload handler + ServletFileUpload upload = new ServletFileUpload(factory); + + // Parse the request + try { + + // first, parse multipart parameters + String uploadType = paramsArray[0]; + if (log.isDebugEnabled()) { + log.debug("Managing upload type : " + uploadType); + } + VradiConstants.FileType fileType = VradiConstants.FileType.valueOf(uploadType); + + // currently, can't manage multiples files due to + // returned fileuri response + List<FileItem> items = upload.parseRequest(request); + if (items.size() != 1) { + throw new ServletException("Invalid request : " + items.size() + " files found !"); + } + FileItem item = items.get(0); + String fileName = item.getName(); + + File tempDirectory = FileUtil.createTempDirectory("vradi-temp", ""); + File tempFile = new File(tempDirectory, fileName); + item.write(tempFile); + + String fileUri = null; + switch (fileType) { + case TEMPLATE: { + // single name here + String extensionName = paramsArray[1]; + fileUri = fileService.uploadTemplate(tempFile, extensionName); + break; + } + case WEB_HARVEST: { + fileUri = fileService.uploadWebHarvestScript(tempFile); + break; + } + case ATTACHMENTS_FORM_FILES: { + // single name here + String formId = paramsArray[1]; + fileUri = fileService.uploadFormAttachment(tempFile, formId); + break; + } + case ATTACHMENTS_SESSION_FILES: { + // single name here + String formId = paramsArray[1]; + fileUri = fileService.uploadSessionAttachment(tempFile, formId); + break; + } + case EMBEDDED_FORM_FILES: { + // single name here + String formId = paramsArray[1]; + fileUri = fileService.uploadFormEmbeddedFile(tempFile, formId); + break; + } + case PDF: { + // PDF are generated server side, can't be uploaded + throw new ServletException("Forbidden operation"); + } + case QUERY_HISTORY: { + // Request history are generated server side, can't be uploaded + throw new ServletException("Forbidden operation"); + } + case TEMP_FILE: { + // no name here (not important) + fileUri = fileService.uploadTempFile(tempFile); + break; + } + } + + // return file uri as response + // correspond to uri relative to fileType upload + response.setHeader("fileuri", fileUri); + + FileUtils.deleteDirectory(tempDirectory); + + if (log.isDebugEnabled()) { + log.debug("Uploaded file " + fileName + "(" + item.getSize() + "b)" + + " saved to " + fileUri); + } + + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't parse uploaded files", ex); + } + throw new ServletException("Can't parse uploaded files", ex); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("Request is not multipart"); + } + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + } + } +} Property changes on: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/FileServlet.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java =================================================================== --- trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java (rev 0) +++ trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,48 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services; + +import org.nuiton.wikitty.services.WikittyServiceDelegator; + +/** + * Wikitty proxy delegator. + * <p/> + * This delegator exist only because we cannot put instance as hessian service. + * <p/> + * This delegator just delegate everything to a static real wikitty service. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiWikittyServiceDelegator extends WikittyServiceDelegator { + + public VradiWikittyServiceDelegator() { + super(ServiceFactory.getWikittyService()); + } +} Property changes on: trunk/vradi-services-web/src/main/java/org/chorem/vradi/services/VradiWikittyServiceDelegator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/resources/jbossts-properties.xml =================================================================== --- trunk/vradi-services-web/src/main/resources/jbossts-properties.xml (rev 0) +++ trunk/vradi-services-web/src/main/resources/jbossts-properties.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <!-- vradi.objectStore.dir property is defined when application starts --> + <entry key="ObjectStoreEnvironmentBean.objectStoreDir"> + ${vradi.objectStore.dir} + </entry> +</properties> Property changes on: trunk/vradi-services-web/src/main/resources/jbossts-properties.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/resources/log4j.properties =================================================================== --- trunk/vradi-services-web/src/main/resources/log4j.properties (rev 0) +++ trunk/vradi-services-web/src/main/resources/log4j.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,53 @@ +### +# #%L +# Vradi :: Services Web +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +# Global logging configuration +log4j.rootLogger=ERROR, stdout, file + +# Console output +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%-5p %c:%L - %m%n + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=${catalina.base}/vradi-services.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=4 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c - %m%n + +# Vradi +log4j.logger.org.chorem.vradi=INFO +#log4j.logger.org.chorem.vradi=DEBUG +#log4j.logger.org.chorem.vradi.services.managers.FormManager=DEBUG +#log4j.logger.org.apache.solr=DEBUG +log4j.logger.org.nuiton.wikitty.JGroupsNotifier=INFO +log4j.logger.org.nuiton.wikitty=INFO +#log4j.logger.org.postgresql=DEBUG + +#log4j.logger.org.nuiton.wikitty.services.WikittyServiceCached=DEBUG + +# Solr +log4j.logger.org.apache.solr.core.SolrCore=WARN \ No newline at end of file Property changes on: trunk/vradi-services-web/src/main/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/resources/solrconfig.xml =================================================================== --- trunk/vradi-services-web/src/main/resources/solrconfig.xml (rev 0) +++ trunk/vradi-services-web/src/main/resources/solrconfig.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,556 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%L + Vradi :: Services Web + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 CodeLutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!-- FIXME sletellier 20/12/10 : Overided to desable cache in solr to improve performence in vradi --> + +<config> + <!-- Set this to 'false' if you want solr to continue working after it has + encountered an severe configuration error. In a production environment, + you may want solr to keep working even if one handler is mis-configured. + + You may also set this to false using by setting the system property: + -Dsolr.abortOnConfigurationError=false + --> + <abortOnConfigurationError>${solr.abortOnConfigurationError:true} + </abortOnConfigurationError> + + <!-- Used to specify an alternate directory to hold all index data + other than the default ./data under the Solr home. + If replication is in use, this should match the replication configuration. --> + <dataDir>${wikitty.searchengine.solr.directory.data:./solr/data}</dataDir> + + <!-- The DirectoryFactory to use for indexes. + solr.StandardDirectoryFactory, the default, is filesystem based. + solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. + A prefix of "solr." for class names is an alias that + causes solr to search appropriate packages, including + org.apache.solr.(search|update|request|core|analysis) + --> + <directoryFactory name="DirectoryFactory" + class="${wikitty.searchengine.solr.directory.factory:solr.StandardDirectoryFactory}"/> + + <indexDefaults> + <!-- Values here affect all index writers and act as a default unless overridden. --> + <useCompoundFile>false</useCompoundFile> + + <mergeFactor>10</mergeFactor> + <!-- + If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first. + + --> + <!--<maxBufferedDocs>1000</maxBufferedDocs>--> + <!-- Tell Lucene when to flush documents to disk. + Giving Lucene more memory for indexing means faster indexing at the cost of more RAM + + If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first. + + --> + <ramBufferSizeMB>32</ramBufferSizeMB> + <maxMergeDocs>2147483647</maxMergeDocs> + <maxFieldLength>10000</maxFieldLength> + <writeLockTimeout>1000</writeLockTimeout> + <commitLockTimeout>10000</commitLockTimeout> + + <!-- + This option specifies which Lucene LockFactory implementation to use. + + single = SingleInstanceLockFactory - suggested for a read-only index + or when there is no possibility of another process trying + to modify the index. + native = NativeFSLockFactory + simple = SimpleFSLockFactory + + (For backwards compatibility with Solr 1.2, 'simple' is the default + if not specified.) + --> + <lockType>simple</lockType> + </indexDefaults> + + <mainIndex> + <!-- options specific to the main on-disk lucene index --> + <useCompoundFile>false</useCompoundFile> + <ramBufferSizeMB>32</ramBufferSizeMB> + <mergeFactor>10</mergeFactor> + <!-- Deprecated --> + <!--<maxBufferedDocs>1000</maxBufferedDocs>--> + <maxMergeDocs>2147483647</maxMergeDocs> + <maxFieldLength>10000</maxFieldLength> + + <!-- If true, unlock any held write or commit locks on startup. + This defeats the locking mechanism that allows multiple + processes to safely access a lucene index, and should be + used with care. + This is not needed if lock type is 'none' or 'single' + --> + <unlockOnStartup>true</unlockOnStartup> + </mainIndex> + + <!-- Enables JMX if and only if an existing MBeanServer is found, use + this if you want to configure JMX through JVM parameters. Remove + this to disable exposing Solr configuration and statistics to JMX. + + If you want to connect to a particular server, specify the agentId + e.g. <jmx agentId="myAgent" /> + + If you want to start a new MBeanServer, specify the serviceUrl + e.g <jmx serviceurl="service:jmx:rmi:///jndi/rmi://localhost:9999/solr" /> + + For more details see http://wiki.apache.org/solr/SolrJmx + --> + <jmx/> + + <!-- the default high-performance update handler --> + <updateHandler class="solr.DirectUpdateHandler2"> + </updateHandler> + + + <query> + <!-- Maximum number of clauses in a boolean query (default: 1024). can affect + range or prefix queries that expand to big boolean + queries. An exception is thrown if exceeded. --> + <maxBooleanClauses>2147483647</maxBooleanClauses> + + + <!-- Cache used by SolrIndexSearcher for filters (DocSets), + unordered sets of *all* documents that match a query. + When a new searcher is opened, its caches may be prepopulated + or "autowarmed" using data from caches in the old searcher. + autowarmCount is the number of items to prepopulate. For LRUCache, + the autowarmed items will be the most recently accessed items. + Parameters: + class - the SolrCache implementation (currently only LRUCache) + size - the maximum number of entries in the cache + initialSize - the initial capacity (number of entries) of + the cache. (seel java.util.HashMap) + autowarmCount - the number of entries to prepopulate from + and old cache. + --> + <!--filterCache + class="solr.LRUCache" + size="512" + initialSize="512" + autowarmCount="0"/--> + + <!-- queryResultCache caches results of searches - ordered lists of +document ids (DocList) based on a query, a sort, and the range +of documents requested. --> + <!--queryResultCache + class="solr.LRUCache" + size="512" + initialSize="512" + autowarmCount="0"/--> + + <!-- documentCache caches Lucene Document objects (the stored fields for each document). +Since Lucene internal document ids are transient, this cache will not be autowarmed. --> + <!--documentCache + class="solr.LRUCache" + size="512" + initialSize="512" + autowarmCount="0"/--> + + <!-- If true, stored fields that are not requested will be loaded lazily. + + This can result in a significant speed improvement if the usual case is to + not load all stored fields, especially if the skipped fields are large compressed + text fields. + --> + <!--enableLazyFieldLoading>true</enableLazyFieldLoading--> + + <!-- An optimization for use with the queryResultCache. When a search +is requested, a superset of the requested number of document ids +are collected. For example, if a search for a particular query +requests matching documents 10 through 19, and queryWindowSize is 50, +then documents 0 through 49 will be collected and cached. Any further +requests in that range can be satisfied via the cache. --> + <!-- + | Code Lutin + | 1 si Wikitty est plus utilise pour de l'ecriture que de la lecture + | la valeur par defaut est 50. Il semble convenable de mettre deux fois + | la taille de la recherche. Si on pagine par 25, 50 est une bonne valeur. + +--> + <!--queryResultWindowSize>1</queryResultWindowSize--> + + <!-- Maximum number of documents to cache for any entry in the + queryResultCache. --> + <!--queryResultMaxDocsCached>200</queryResultMaxDocsCached--> + + <!-- This entry enables an int hash representation for filters (DocSets) + when the number of items in the set is less than maxSize. For smaller + sets, this representation is more memory efficient, more efficient to + iterate over, and faster to take intersections. --> + <!--HashDocSet maxSize="3000" loadFactor="0.75"/--> + + <!-- If a search request comes in and there is no current registered searcher, + then immediately register the still warming searcher and use it. If + "false" then all requests will block until the first searcher is done + warming. --> + <!--useColdSearcher>false</useColdSearcher--> + + <!-- Maximum number of searchers that may be warming in the background + concurrently. An error is returned if this limit is exceeded. Recommend + 1-2 for read-only slaves, higher for masters w/o cache warming. --> + <!--maxWarmingSearchers>5</maxWarmingSearchers--> + + </query> + + <!-- + Let the dispatch filter handler /select?qt=XXX + handleSelect=true will use consistent error handling for /select and /update + handleSelect=false will use solr1.1 style error formatting + --> + <requestDispatcher handleSelect="true"> + <!--Make sure your system has some authentication before enabling remote streaming! --> + <requestParsers enableRemoteStreaming="false" + multipartUploadLimitInKB="2048"/> + </requestDispatcher> + + + <!-- FIXME clean requestHandler to keep only necessary requestHandler --> + + + <!-- requestHandler plugins... incoming queries will be dispatched to the + correct handler based on the path or the qt (query type) param. + Names starting with a '/' are accessed with the a path equal to the + registered name. Names without a leading '/' are accessed with: + http://host/app/select?qt=name + If no qt is defined, the requestHandler that declares default="true" + will be used. + --> + <requestHandler name="standard" class="solr.SearchHandler" default="true"> + <!-- default values for query parameters --> + <lst name="defaults"> + <str name="echoParams">explicit</str> + <!-- + <int name="rows">10</int> + <str name="fl">*</str> + <str name="version">2.1</str> + --> + </lst> + </requestHandler> + + + <!-- DisMaxRequestHandler allows easy searching across multiple fields + for simple user-entered phrases. It's implementation is now + just the standard SearchHandler with a default query type + of "dismax". + see http://wiki.apache.org/solr/DisMaxRequestHandler + --> + <requestHandler name="dismax" class="solr.SearchHandler"> + <lst name="defaults"> + <str name="defType">dismax</str> + <str name="echoParams">explicit</str> + <float name="tie">0.01</float> + <str name="qf"> + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + </str> + <str name="pf"> + text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9 + </str> + <str name="bf"> + ord(popularity)^0.5 recip(rord(price),1,1000,1000)^0.3 + </str> + <str name="fl"> + id,name,price,score + </str> + <str name="mm"> + 2<-1 5<-2 6<90% + </str> + <int name="ps">100</int> + <str name="q.alt">*:*</str> + <!-- example highlighter config, enable per-query with hl=true --> + <str name="hl.fl">text features name</str> + <!-- for this field, we want no fragmenting, just highlighting --> + <str name="f.name.hl.fragsize">0</str> + <!-- instructs Solr to return the field itself if no query terms are + found --> + <str name="f.name.hl.alternateField">name</str> + <str name="f.text.hl.fragmenter">regex</str> + <!-- defined below --> + </lst> + </requestHandler> + + <!-- Note how you can register the same handler multiple times with + different names (and different init parameters) + --> + <requestHandler name="partitioned" class="solr.SearchHandler"> + <lst name="defaults"> + <str name="defType">dismax</str> + <str name="echoParams">explicit</str> + <str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0</str> + <str name="mm">2<-1 5<-2 6<90%</str> + <!-- This is an example of using Date Math to specify a constantly + moving date range in a config... + --> + <str name="bq">incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2</str> + </lst> + <!-- In addition to defaults, "appends" params can be specified + to identify values which should be appended to the list of + multi-val params from the query (or the existing "defaults"). + + In this example, the param "fq=instock:true" will be appended to + any query time fq params the user may specify, as a mechanism for + partitioning the index, independent of any user selected filtering + that may also be desired (perhaps as a result of faceted searching). + + NOTE: there is *absolutely* nothing a client can do to prevent these + "appends" values from being used, so don't use this mechanism + unless you are sure you always want it. + --> + <lst name="appends"> + <str name="fq">inStock:true</str> + </lst> + <!-- "invariants" are a way of letting the Solr maintainer lock down + the options available to Solr clients. Any params values + specified here are used regardless of what values may be specified + in either the query, the "defaults", or the "appends" params. + + In this example, the facet.field and facet.query params are fixed, + limiting the facets clients can use. Faceting is not turned on by + default - but if the client does specify facet=true in the request, + these are the only facets they will be able to see counts for; + regardless of what other facet.field or facet.query params they + may specify. + + NOTE: there is *absolutely* nothing a client can do to prevent these + "invariants" values from being used, so don't use this mechanism + unless you are sure you always want it. + --> + <lst name="invariants"> + <str name="facet.field">cat</str> + <str name="facet.field">manu_exact</str> + <str name="facet.query">price:[* TO 500]</str> + <str name="facet.query">price:[500 TO *]</str> + </lst> + </requestHandler> + + + <!-- + Search components are registered to SolrCore and used by Search Handlers + + By default, the following components are avaliable: + + <searchComponent name="query" class="org.apache.solr.handler.component.QueryComponent" /> + <searchComponent name="facet" class="org.apache.solr.handler.component.FacetComponent" /> + <searchComponent name="mlt" class="org.apache.solr.handler.component.MoreLikeThisComponent" /> + <searchComponent name="highlight" class="org.apache.solr.handler.component.HighlightComponent" /> + <searchComponent name="debug" class="org.apache.solr.handler.component.DebugComponent" /> + + Default configuration in a requestHandler would look like: + <arr name="components"> + <str>query</str> + <str>facet</str> + <str>mlt</str> + <str>highlight</str> + <str>debug</str> + </arr> + + If you register a searchComponent to one of the standard names, that will be used instead. + To insert handlers before or after the 'standard' components, use: + + <arr name="first-components"> + <str>myFirstComponentName</str> + </arr> + + <arr name="last-components"> + <str>myLastComponentName</str> + </arr> + --> + + <!-- The spell check component can return a list of alternative spelling +suggestions. --> + <searchComponent name="spellcheck" class="solr.SpellCheckComponent"> + + <str name="queryAnalyzerFieldType">textSpell</str> + + <lst name="spellchecker"> + <str name="name">default</str> + <str name="field">spell</str> + <str name="spellcheckIndexDir">./spellchecker1</str> + + </lst> + <lst name="spellchecker"> + <str name="name">jarowinkler</str> + <str name="field">spell</str> + <!-- Use a different Distance Measure --> + <str name="distanceMeasure"> + org.apache.lucene.search.spell.JaroWinklerDistance + </str> + <str name="spellcheckIndexDir">./spellchecker2</str> + + </lst> + + <lst name="spellchecker"> + <str name="classname">solr.FileBasedSpellChecker</str> + <str name="name">file</str> + <str name="sourceLocation">spellings.txt</str> + <str name="characterEncoding">UTF-8</str> + <str name="spellcheckIndexDir">./spellcheckerFile</str> + </lst> + </searchComponent> + + <!-- a request handler utilizing the spellcheck component --> + <requestHandler name="/spellCheckCompRH" class="solr.SearchHandler"> + <lst name="defaults"> + <!-- omp = Only More Popular --> + <str name="spellcheck.onlyMorePopular">false</str> + <!-- exr = Extended Results --> + <str name="spellcheck.extendedResults">false</str> + <!-- The number of suggestions to return --> + <str name="spellcheck.count">1</str> + </lst> + <arr name="last-components"> + <str>spellcheck</str> + </arr> + </requestHandler> + + <!-- a search component that enables you to configure the top results for + a given query regardless of the normal lucene scoring.--> + + <!-- poussin 20090902 remove elevate this file is empty, what need ? + <searchComponent name="elevator" class="solr.QueryElevationComponent" > + <str name="queryFieldType">string</str> + <str name="config-file">elevate.xml</str> + </searchComponent> + --> + <!-- a request handler utilizing the elevator component --> + <!-- + <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy"> + <lst name="defaults"> + <str name="echoParams">explicit</str> + </lst> + <arr name="last-components"> + <str>elevator</str> + </arr> + </requestHandler> + --> + + <!-- Update request handler. + + Note: Since solr1.1 requestHandlers requires a valid content type header if posted in + the body. For example, curl now requires: -H 'Content-type:text/xml; charset=utf-8' + The response format differs from solr1.1 formatting and returns a standard error code. + + To enable solr1.1 behavior, remove the /update handler or change its path + --> + <requestHandler name="/update" class="solr.XmlUpdateRequestHandler"/> + + <!-- + Analysis request handler. Since Solr 1.3. Use to returnhow a document is analyzed. Useful + for debugging and as a token server for other types of applications + --> + <requestHandler name="/analysis" class="solr.AnalysisRequestHandler"/> + + + <!-- CSV update handler, loaded on demand --> + <requestHandler name="/update/csv" class="solr.CSVRequestHandler" + startup="lazy"/> + + + <!-- + Admin Handlers - This will register all the standard admin RequestHandlers. Adding + this single handler is equivolent to registering: + + <requestHandler name="/admin/luke" class="org.apache.solr.handler.admin.LukeRequestHandler" /> + <requestHandler name="/admin/system" class="org.apache.solr.handler.admin.SystemInfoHandler" /> + <requestHandler name="/admin/plugins" class="org.apache.solr.handler.admin.PluginInfoHandler" /> + <requestHandler name="/admin/threads" class="org.apache.solr.handler.admin.ThreadDumpHandler" /> + <requestHandler name="/admin/properties" class="org.apache.solr.handler.admin.PropertiesRequestHandler" /> + <requestHandler name="/admin/file" class="org.apache.solr.handler.admin.ShowFileRequestHandler" > + + If you wish to hide files under ${solr.home}/conf, explicitly register the ShowFileRequestHandler using: + <requestHandler name="/admin/file" class="org.apache.solr.handler.admin.ShowFileRequestHandler" > + <lst name="invariants"> + <str name="hidden">synonyms.txt</str> + <str name="hidden">anotherfile.txt</str> + </lst> + </requestHandler> + --> + <requestHandler name="/admin/" + class="org.apache.solr.handler.admin.AdminHandlers"/> + + <!-- ping/healthcheck --> + <requestHandler name="/admin/ping" class="PingRequestHandler"> + <lst name="defaults"> + <str name="qt">standard</str> + <str name="q">solrpingquery</str> + <str name="echoParams">all</str> + </lst> + </requestHandler> + + <!-- Echo the request contents back to the client --> + <requestHandler name="/debug/dump" class="solr.DumpRequestHandler"> + <lst name="defaults"> + <str name="echoParams">explicit</str> + <!-- for all params (including the default etc) use: 'all' --> + <str name="echoHandler">true</str> + </lst> + </requestHandler> + + + <highlighting> + <!-- Configure the standard fragmenter --> + <!-- This could most likely be commented out in the "default" case --> + <fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" + default="true"> + <lst name="defaults"> + <int name="hl.fragsize">100</int> + </lst> + </fragmenter> + + <!-- A regular-expression-based fragmenter (f.i., for sentence extraction) --> + <fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter"> + <lst name="defaults"> + <!-- slightly smaller fragsizes work better because of slop --> + <int name="hl.fragsize">70</int> + <!-- allow 50% slop on fragment sizes --> + <float name="hl.regex.slop">0.5</float> + <!-- a basic sentence pattern --> + <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str> + </lst> + </fragmenter> + </highlighting> + + <queryParser name="lucene" + class="org.nuiton.wikitty.storage.solr.WikittyQueryParser"/> + <queryParser name="wikitty" + class="org.nuiton.wikitty.storage.solr.WikittyQueryParser"/> + + <!-- example of registering a query parser + <queryParser name="lucene" class="org.apache.solr.search.LuceneQParserPlugin"/> + --> + + <!-- example of registering a custom function parser + <valueSourceParser name="myfunc" class="com.mycompany.MyValueSourceParser" /> + --> + + <!-- config for the admin interface --> + <admin> + <defaultQuery>solr</defaultQuery> + + <!-- configure a healthcheck file for servers behind a loadbalancer + <healthcheck type="file">server-enabled</healthcheck> + --> + </admin> + +</config> Property changes on: trunk/vradi-services-web/src/main/resources/solrconfig.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + + <display-name>Vradi</display-name> + + <servlet> + <servlet-name>vradiStorageServlet</servlet-name> + <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class> + <init-param> + <param-name>home-api</param-name> + <param-value>org.chorem.vradi.services.VradiStorageService</param-value> + </init-param> + <init-param> + <param-name>home-class</param-name> + <param-value>org.chorem.vradi.services.VradiStorageServiceImpl + </param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet> + <servlet-name>wikittyServiceServlet</servlet-name> + <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class> + <init-param> + <param-name>home-api</param-name> + <param-value>org.nuiton.wikitty.WikittyService</param-value> + </init-param> + <init-param> + <param-name>home-class</param-name> + <param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator + </param-value> + </init-param> + <load-on-startup>2</load-on-startup> + </servlet> + <servlet> + <servlet-name>fileServlet</servlet-name> + <servlet-class>org.chorem.vradi.services.FileServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>vradiStorageServlet</servlet-name> + <url-pattern>/vradiservice</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>wikittyServiceServlet</servlet-name> + <url-pattern>/wikittyservice</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>fileServlet</servlet-name> + <url-pattern>/file/*</url-pattern> + </servlet-mapping> + +</web-app> Property changes on: trunk/vradi-services-web/src/main/webapp/WEB-INF/web.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/main/webapp/favicon.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-services-web/src/main/webapp/favicon.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-services-web/src/main/webapp/index.jsp =================================================================== --- trunk/vradi-services-web/src/main/webapp/index.jsp (rev 0) +++ trunk/vradi-services-web/src/main/webapp/index.jsp 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,35 @@ +<!-- +#%L +Vradi :: Services Web + +$Id$ +$HeadURL$ +%% +Copyright (C) 2009 - 2010 Codelutin +%% +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 3 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, see +<http://www.gnu.org/licenses/gpl-3.0.html>. +#L% +--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<%@page contentType="text/html" pageEncoding="UTF-8" %> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>Vradi services</title> +</head> +<body> +Vradi is up and running (<%=org.chorem.vradi.VradiServiceConfigurationn("application.version")%>)... +</body> +</html> \ No newline at end of file Property changes on: trunk/vradi-services-web/src/main/webapp/index.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/site/rst/index.rst =================================================================== --- trunk/vradi-services-web/src/site/rst/index.rst (rev 0) +++ trunk/vradi-services-web/src/site/rst/index.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI :: Module services-web +============================ + +Ce module embarque les services dans un conteneur web. \ No newline at end of file Property changes on: trunk/vradi-services-web/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/site/site_fr.xml =================================================================== --- trunk/vradi-services-web/src/site/site_fr.xml (rev 0) +++ trunk/vradi-services-web/src/site/site_fr.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <menu ref="parent"/> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> \ No newline at end of file Property changes on: trunk/vradi-services-web/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java =================================================================== --- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java (rev 0) +++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,40 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +/** + * TestService. + * <p/> + * TODO EC20100913 : ce service devrait pouvoir être supprimé, + * et le service hessian devrait pourvoir faire un clear() sur le proxy. + * Mais bizarement en le supprimant certains test ne passent plus :( + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 21 févr. 2010 02:51:51 + */ +public interface ClearService { + void clear(); +} Property changes on: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java =================================================================== --- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java (rev 0) +++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,51 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Ignore; +import org.nuiton.wikitty.WikittyProxy; + +/** + * TestServiceImpl. + * <p/> + * vradi.data.dir is overridden by environment variable jetty/surefire. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 21 févr. 2010 02:52:31 + */ +@Ignore +public class ClearServiceImpl implements ClearService { + static final Log log = LogFactory.getLog(ClearServiceImpl.class); + + @Override + public void clear() { + WikittyProxy proxy = ServiceFactory.getWikittyProxy(); + proxy.clear(); + } + +} Property changes on: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/ClearServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java =================================================================== --- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java (rev 0) +++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,200 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import com.caucho.hessian.client.HessianProxyFactory; +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlStream; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mortbay.jetty.runner.Runner; +import org.nuiton.util.Resource; +import org.nuiton.util.converter.ConverterUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.net.URL; +import java.util.Date; +import java.util.List; + +/** + * VradiHessianStorageTest. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 21 févr. 2010 02:13:16 + */ +public class VradiHessianStorageTest extends VradiStorageServiceTest { + static final Log log = LogFactory.getLog(VradiHessianStorageTest.class); + + static final String port = "9000"; + + static final String clearUrl = "http://localhost:" + port + "/clearservice"; + + static final String storageUrl = "http://localhost:" + port + "/vradiservice"; + + static final String wikittyUrl = "http://localhost:" + port + "/wikittyservice"; + + static final String fileUrl = "http://localhost:" + port + "/file"; + + static VradiJettyRunner runner; + + public static class VradiJettyRunner extends Runner { + @Override + public void run() throws Exception { + _server.start(); + // Skip join + } + + public void stop() throws Exception { + _server.stop(); + } + } + + @BeforeClass + public static void startServer() throws Exception { + runner = new VradiJettyRunner(); + + // This is the file to find to get the path of vradi-services-web module + String placeHolder = "/vradi_services_web.place_holder"; + + // Find the file + URL url = Resource.getURL(placeHolder); + + // Remove the file name and folder 'target/test-classes' + String contextPath = url.toString(); + String target = "/target/test-classes"; + contextPath = contextPath.substring(0, contextPath.length() - (placeHolder.length() + target.length())); + + // Add webapp context + contextPath += "/src/test/webapp"; + String[] args = {"--port", port, contextPath}; + runner.configure(args); + + runner.run(); + } + + @AfterClass + public static void stopServer() throws Exception { + runner.stop(); + } + + @Override + @Before + public void clear() throws Exception { + ConverterUtil.initConverters(); + + HessianProxyFactory factory = new HessianProxyFactory(); + factory.setHessian2Request(true); + factory.setOverloadEnabled(true); + + log.debug("--clear-----------------------------------------"); + ClearService clearService = (ClearService) factory.create(ClearService.class, clearUrl); + clearService.clear(); + storageService = (VradiStorageService) factory.create(VradiStorageService.class, storageUrl); + WikittyService wikittyService = (WikittyService) factory.create(WikittyService.class, wikittyUrl); + wikittyProxy = new WikittyProxy(wikittyService); + dataService = new VradiDataServiceImpl(wikittyProxy); + + // fait avec le proxy > servlet pour tester + fileService = new FileServiceProxy(fileUrl); + } + + @Override + protected XmlStreamImportResult initData(WikittyExtension extension) + throws Exception { + List<XmlFieldBinding> bindings = createXmlBindings(extension); + XmlStream xmlStream = createXmlStream(extension, bindings); + return storageService.importFormsFromXmlStream(xmlStream); + } + + /* + * TODO add doc about this test !!! + * + */ + @Test + public void testPropagation() throws Exception { + + Session session = new SessionImpl(); + + session.setNum(7); + wikittyProxy.getWikitty(session).addExtension( + new WikittyExtension("ouaf", "2.0", null, + WikittyUtil.buildFieldMapExtension( + "Numeric a", + "Numeric b", + "String c"))); + session.setSessionDate(new Date()); + + session.setStatus(VradiConstants.SessionStatus.ACTIVE.getValue()); + + session = wikittyProxy.store(session); + + session.setField("ouaf", "a", 1); + session.setField("ouaf", "b", 1.0); + session.setField("ouaf", "c", "Ouaf"); + session.setNum(1); + session.setSessionDate(DateUtils.addMinutes(new Date(), 15)); + Session sessionService = wikittyProxy.store(session); + + if (session.getWikittyId().equals(sessionService.getWikittyId())) { + int scInt = wikittyProxy.getWikitty(sessionService).getFieldAsInt("ouaf", "a"); + int lcInt = wikittyProxy.getWikitty(session).getFieldAsInt("ouaf", "a"); + + Float scFloat = wikittyProxy.getWikitty(sessionService).getFieldAsFloat("ouaf", "b"); + Float lcFloat = wikittyProxy.getWikitty(session).getFieldAsFloat("ouaf", "b"); + + String scString = wikittyProxy.getWikitty(sessionService).getFieldAsString("ouaf", "c"); + String lcString = wikittyProxy.getWikitty(session).getFieldAsString("ouaf", "c"); + + log.info("testPropagation result, local : " + session.getNum() + " serveur : " + sessionService.getNum()); + log.info("testPropagation result as int, local : " + lcInt + " serveur : " + scInt); + log.info("testPropagation result as float, local : " + lcFloat + " serveur : " + scFloat); + log.info("testPropagation result as String, local : " + lcString + " serveur : " + scString); + log.info("testPropagation result, local : " + session.getSessionDate() + " serveur : " + sessionService.getSessionDate()); + + Assert.assertEquals(session.getNum(), sessionService.getNum()); + Assert.assertEquals(lcInt, scInt); + Assert.assertEquals(lcFloat, scFloat); + Assert.assertEquals(lcString, scString); + Assert.assertEquals(session.getSessionDate(), sessionService.getSessionDate()); + } + + wikittyProxy.delete(session.getWikittyId()); + } + +} Property changes on: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/VradiHessianStorageTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java =================================================================== --- trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java (rev 0) +++ trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,105 @@ +/* + * #%L + * Vradi :: Services Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi.services.util; + +import com.caucho.hessian.client.HessianProxyFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Thesaurus; +import org.nuiton.util.StringUtil; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; +import org.nuiton.wikitty.search.operators.Element; + +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; + +/** + * Attention, cette class n'est pas un test, elle est utilisée + * pour faire une reindexation d'un service distant facilement. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ReindexService { + + static final String wikittyUrl = "http://dbdev/vradi/wikittyservice"; + + static final Log log = LogFactory.getLog(ReindexService.class); + + public static void main(String... args) throws MalformedURLException { + + HessianProxyFactory factory = new HessianProxyFactory(); + factory.setHessian2Request(true); + factory.setOverloadEnabled(true); + + WikittyService wikittyService = (WikittyService) factory.create(WikittyService.class, wikittyUrl); + WikittyProxy wikittyProxy = new WikittyProxy(wikittyService); + + //synEngin(wikittyProxy); + //deleteObseleteThesaurus(wikittyProxy); + } + + public static void syncSearchEngine(WikittyProxy wikittyProxy) throws MalformedURLException { + wikittyProxy.syncSearchEngine(); + System.out.println("syncEngin complete !"); + } + + public static void deleteObseleteThesaurus(WikittyProxy wikittyProxy) { + log.info("Starting deleting obselete thesaurus"); + + long startingTime = System.nanoTime(); + + Criteria criteria = Search.query().eq(Element.ELT_EXTENSION, Thesaurus.EXT_THESAURUS).criteria(); + List<Thesaurus> thesauruses = wikittyProxy.findAllByCriteria(Thesaurus.class, criteria).getAll(); + + List<String> thesaurusToDelete = new ArrayList<String>(); + for (Thesaurus thesaurus : thesauruses) { + String parentId = thesaurus.getParent(); + if (parentId == null) { + thesaurusToDelete.add(thesaurus.getWikittyId()); + + log.info("Found thesaurus '" + thesaurus.getName() + "' has no parentId, deleting this"); + } else { + Thesaurus parent = wikittyProxy.restore(Thesaurus.class, parentId); + if (parent == null) { + thesaurusToDelete.add(thesaurus.getWikittyId()); + log.info("Found thesaurus '" + thesaurus.getName() + "' has no parent with id '" + parentId + ", deleting this"); + } + } + } + + //wikittyProxy.delete(thesaurusToDelete); + + log.info("Deleting obselete thesaurus is finished in " + StringUtil.convertTime(startingTime, System.nanoTime())); + } +} Property changes on: trunk/vradi-services-web/src/test/java/org/chorem/vradi/services/util/ReindexService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/resources/log4j.properties =================================================================== --- trunk/vradi-services-web/src/test/resources/log4j.properties (rev 0) +++ trunk/vradi-services-web/src/test/resources/log4j.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,46 @@ +### +# #%L +# Vradi :: Services Web +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +# Global logging configuration +log4j.rootLogger=INFO, stdout + +# Console output +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%-5p %c - %m%n + +# vradi +log4j.logger.org.chorem.vradi=INFO + +# wikitty +log4j.logger.org.nuiton.wikitty=INFO +#log4j.logger.org.nuiton.wikitty.solr.WikittySearchEngineSolr=DEBUG +#log4j.logger.org.nuiton.wikitty.solr.SolrQParser=DEBUG +log4j.logger.org.nuiton.wikitty.jdbc.WikittyJDBCUtil=INFO + +# solr +log4j.logger.org.apache.solr=WARN +log4j.logger.org.apache.solr.core=WARN + Property changes on: trunk/vradi-services-web/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/resources/vradi-services.properties =================================================================== --- trunk/vradi-services-web/src/test/resources/vradi-services.properties (rev 0) +++ trunk/vradi-services-web/src/test/resources/vradi-services.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,74 @@ +### +# #%L +# Vradi :: Services +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +application.name=${project.name} +application.version=${project.version} +vradi.service.version=${project.version} + +vradi.objectStore.dir=${vradi.data.dir}/objectStore +vradi.data.dir=target/vradi +vradi.temp.dir=target/vradi/tmp +vradi.queryHistory.dir=target/vradi/queryHistory +vradi.embeddedFiles.dir=target/vradi/embeddedFiles +vradi.templates.dir=target/vradi/templates +vradi.pdf.dir=target/vradi/pdf +solr.data.dir=${wikitty.searchengine.solr.directory.data} + +wikitty.data.directory=${vradi.data.dir}/wikitty +oOo.exec.folder=/usr/bin + +wikitty.storage.jdbc.queryfile=wikitty-jdbc-query.properties +wikitty.storage.jdbc.driver=org.h2.Driver +wikitty.storage.jdbc.host=jdbc:h2:file:${wikitty.data.directory}/data/db +wikitty.storage.jdbc.login=sa +wikitty.storage.jdbc.password= +wikitty.storage.jdbc.xadatasource=org.h2.jdbcx.JdbcDataSource +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.URL=${wikitty.storage.jdbc.host} +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.user=${wikitty.storage.jdbc.login} +wikitty.storage.jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.password=${wikitty.storage.jdbc.password} +wikitty.searchengine.solr.directory.data=${wikitty.data.directory}/solr +wikitty.searchengine.solr.directory.factory=solr.StandardDirectoryFactory +wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceStorage,\ +org.nuiton.wikitty.services.WikittyServiceNotifier,\ +org.nuiton.wikitty.services.WikittyServiceCached,\ +org.nuiton.wikitty.services.WikittyServiceSecurity +wikitty.WikittyServiceStorage.components=org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC,\ +org.nuiton.wikitty.jdbc.WikittyStorageJDBC,\ +org.nuiton.wikitty.storage.solr.WikittySearchEngineSolr +wikitty.transaction.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceInMemory +wikitty.service.cache.allwaysRestoreCopies=false +wikitty.service.event.propagate=true +wikitty.service.event.listen=false +wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter +wikitty.service.event.transporter.xmpp.server=im.codelutin.com +wikitty.service.event.transporter.xmpp.room=slave@conference.im.codelutin.com +wikitty.service.slave.async.store=false +wikitty.service.slave.master.xmpp.server=im.codelutin.com +wikitty.service.slave.master.xmpp.room=test@conference.im.codelutin.com +wikitty.addon.export.threadnumber=1 +wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS +#wikitty.service.cache.priority.extensions=Thesaurus +jcs.default= +jcs.default.cacheattributes.MaxObjects=10000 +#jcs.priority.cacheattributes.MaxObjects=10000 Property changes on: trunk/vradi-services-web/src/test/resources/vradi-services.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/resources/vradi_services_web.place_holder =================================================================== --- trunk/vradi-services-web/src/test/resources/vradi_services_web.place_holder (rev 0) +++ trunk/vradi-services-web/src/test/resources/vradi_services_web.place_holder 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1 @@ +Place holder, do not remove, or adapt VradiHessianStorageTest. Property changes on: trunk/vradi-services-web/src/test/resources/vradi_services_web.place_holder ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-services-web/src/test/webapp/WEB-INF/web.xml =================================================================== --- trunk/vradi-services-web/src/test/webapp/WEB-INF/web.xml (rev 0) +++ trunk/vradi-services-web/src/test/webapp/WEB-INF/web.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Services Web + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + + <servlet> + <servlet-name>vradiStorageServlet</servlet-name> + <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class> + <init-param> + <param-name>home-api</param-name> + <param-value>org.chorem.vradi.services.VradiStorageService</param-value> + </init-param> + <init-param> + <param-name>home-class</param-name> + <param-value>org.chorem.vradi.services.VradiStorageServiceImpl + </param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet> + <servlet-name>wikittyServiceServlet</servlet-name> + <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class> + <init-param> + <param-name>home-api</param-name> + <param-value>org.nuiton.wikitty.WikittyService</param-value> + </init-param> + <init-param> + <param-name>home-class</param-name> + <param-value>org.chorem.vradi.services.VradiWikittyServiceDelegator + </param-value> + </init-param> + <load-on-startup>2</load-on-startup> + </servlet> + <servlet> + <servlet-name>fileServlet</servlet-name> + <servlet-class>org.chorem.vradi.services.FileServlet</servlet-class> + </servlet> + <servlet> + <servlet-name>clearService</servlet-name> + <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class> + <init-param> + <param-name>home-api</param-name> + <param-value>org.chorem.vradi.services.ClearService</param-value> + </init-param> + <init-param> + <param-name>home-class</param-name> + <param-value>org.chorem.vradi.services.ClearServiceImpl</param-value> + </init-param> + <load-on-startup>3</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>vradiStorageServlet</servlet-name> + <url-pattern>/vradiservice</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>wikittyServiceServlet</servlet-name> + <url-pattern>/wikittyservice</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>fileServlet</servlet-name> + <url-pattern>/file/*</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>clearService</servlet-name> + <url-pattern>/clearservice</url-pattern> + </servlet-mapping> +</web-app> Property changes on: trunk/vradi-services-web/src/test/webapp/WEB-INF/web.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/LICENSE.txt =================================================================== --- trunk/vradi-swing/LICENSE.txt (rev 0) +++ trunk/vradi-swing/LICENSE.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. Property changes on: trunk/vradi-swing/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-swing/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/vradi-swing/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/pom.xml =================================================================== --- trunk/vradi-swing/pom.xml (rev 0) +++ trunk/vradi-swing/pom.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,585 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>vradi</artifactId> + <version>0.6-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.vradi</groupId> + <artifactId>vradi-swing</artifactId> + + <name>Vradi :: Swing</name> + <description>Vradi Swing</description> + + <properties> + + <!--Vradi Main Class in JAR --> + <maven.jar.main.class> + org.chorem.vradi.VradiMain + </maven.jar.main.class> + + <!-- jaxx configuration --> + <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath> + <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath> + <jaxx.defaultErrorUIFQN> + jaxx.runtime.validator.swing.ui.ImageValidationUI + </jaxx.defaultErrorUIFQN> + <jaxx.useUIManagerForIcon>true</jaxx.useUIManagerForIcon> + + <jaxx.extraImportList> + org.chorem.vradi.entities.*, + org.chorem.vradi.VradiContext, + org.chorem.vradi.ui.helpers.UIHelper, + jaxx.runtime.swing.editor.*, + javax.swing.*, + java.awt.*, + java.awt.event.*, + static org.nuiton.i18n.I18n.n_ + </jaxx.extraImportList> + + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <!-- project dependencies --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-entities</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vradi-services</artifactId> + <version>${project.version}</version> + <!-- WARNING! check it works chemit 2010-10-28 : it comes from wikitty-solr-impl but conflits with stax --> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- jaxx dependencies --> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-runtime</artifactId> + </dependency> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-validator</artifactId> + </dependency> + <dependency> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>jaxx-widgets</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-hessian-client</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-widgets</artifactId> + </dependency> + + <dependency> + <groupId>com.caucho</groupId> + <artifactId>hessian</artifactId> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + <scope>runtime</scope> + </dependency> + + <!-- Must be compile (provided for current, runtime for service) --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>jxlayer</artifactId> + </dependency> + + <dependency> + <groupId>org.swinglabs</groupId> + <artifactId>swingx-core</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </dependency> + + <dependency> + <groupId>net.sourceforge.web-harvest</groupId> + <artifactId>web-harvest</artifactId> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + </dependency> + + <dependency> + <groupId>com.opensymphony</groupId> + <artifactId>xwork</artifactId> + </dependency> + + <dependency> + <groupId>net.sf.opencsv</groupId> + <artifactId>opencsv</artifactId> + </dependency> + + <dependency> + <groupId>com.fifesoft</groupId> + <artifactId>rsyntaxtextarea</artifactId> + </dependency> + + </dependencies> + + <build> + + <resources> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + + <plugins> + + <plugin> + <groupId>org.nuiton.jaxx</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <configuration> + <entries> + <entry> + <basedir>${maven.gen.dir}/java/</basedir> + </entry> + </entries> + </configuration> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>parserValidation</goal> + <goal>gen</goal> + <goal>bundle</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>target/lib</outputDirectory> + <silent>true</silent> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + + <pluginManagement> + <plugins> + + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>./lib/</classpathPrefix> + <useUniqueVersions>true</useUniqueVersions> + </manifest> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>license-maven-plugin</artifactId> + <configuration> + <generateBundle>true</generateBundle> + </configuration> + </plugin> + + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <configuration> + <libPath>lib</libPath> + <makeArchive>false</makeArchive> + <verbose>false</verbose> + + <jnlp> + <mainClass>${maven.jar.main.class}</mainClass> + <allPermissions>true</allPermissions> + <offlineAllowed>true</offlineAllowed> + <j2seVersion>1.6+</j2seVersion> + </jnlp> + + <!-- Add some extensions for the already signed libs --> + <jnlpExtensions> + <!--jnlpExtension> + <name>sun</name> + <title>Sun MicroSystems</title> + <vendor>Sun MicroSystems, Inc.</vendor> + <includes> + <include>javax.help:javahelp</include> + </includes> + </jnlpExtension--> + <jnlpExtension> + <name>jxlayer</name> + <title>Swing labs JXLayer</title> + <vendor>Swing Labs</vendor> + <includes> + <include>org.swinglabs:jxlayer</include> + </includes> + </jnlpExtension> + </jnlpExtensions> + + <sign> + <keystore>${keystorepath}</keystore> + <storepass>${keystorepass}</storepass> + <alias>${keyalias}</alias> + <keypass>${keypass}</keypass> + <verify>true</verify> + <keystoreConfig> + <delete>false</delete> + <gen>false</gen> + </keystoreConfig> + </sign> + + </configuration> + </plugin> + + </plugins> + </pluginManagement> + </build> + + <profiles> + <profile> + <id>assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>verify</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/bin.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + + <!-- just add to build the webstart --> + <profile> + <id>webstart-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <executions> + <execution> + <id>get-keystore</id> + <goals> + <goal>share-server-secret</goal> + </goals> + <phase>package</phase> + <configuration> + <serverId>codelutin-keystore</serverId> + <privateKeyOut>keystorepath</privateKeyOut> + <passwordOut>keystorepass</passwordOut> + <usernameOut>keyalias</usernameOut> + <passphraseOut>keypass</passphraseOut> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-jnlp</id> + <phase>package</phase> + <goals> + <goal>jnlp-inline</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <version>${webstartPluginVersion}</version> + </plugin> + </plugins> + </reporting> + </profile> + + <!-- just add to buil the local webstart (codebase will be in target/jnlp) --> + <profile> + <id>local-webstart-profile</id> + <activation> + <property> + <name>doLocalWebstart</name> + <value>true</value> + </property> + </activation> + <properties> + <jnlp.codebase>file://${project.build.directory}/jnlp</jnlp.codebase> + </properties> + <build> + <defaultGoal>package</defaultGoal> + <plugins> + + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <executions> + <execution> + <id>get-keystore</id> + <goals> + <goal>share-server-secret</goal> + </goals> + <phase>package</phase> + <configuration> + <serverId>codelutin-keystore</serverId> + <privateKeyOut>keystorepath</privateKeyOut> + <passwordOut>keystorepass</passwordOut> + <usernameOut>keyalias</usernameOut> + <passphraseOut>keypass</passphraseOut> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-jnlp-local</id> + <phase>package</phase> + <goals> + <goal>jnlp-inline</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <version>${webstartPluginVersion}</version> + </plugin> + </plugins> + </reporting> + </profile> + + <!-- Buil the vradi local server webstart (codebase will be in target/jnlp) --> + <profile> + <id>server-webstart-profile</id> + <activation> + <property> + <name>doServerWebstart</name> + <value>true</value> + </property> + </activation> + <properties> + <jnlp.codebase>http://vradi/</jnlp.codebase> + </properties> + <build> + <defaultGoal>package</defaultGoal> + <plugins> + + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <executions> + <execution> + <id>get-keystore</id> + <goals> + <goal>share-server-secret</goal> + </goals> + <phase>package</phase> + <configuration> + <serverId>codelutin-keystore</serverId> + <privateKeyOut>keystorepath</privateKeyOut> + <passwordOut>keystorepass</passwordOut> + <usernameOut>keyalias</usernameOut> + <passphraseOut>keypass</passphraseOut> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-jnlp-local</id> + <phase>package</phase> + <goals> + <goal>jnlp-inline</goal> + </goals> + <configuration> + <jnlp> + <inputTemplateResourcePath> + src/main/jnlp + </inputTemplateResourcePath> + <inputTemplate>vradi-server-jnlp.vm</inputTemplate> + </jnlp> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.nuiton.thirdparty</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <version>${webstartPluginVersion}</version> + </plugin> + </plugins> + </reporting> + </profile> + </profiles> +</project> Property changes on: trunk/vradi-swing/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/license/THIRD-PARTY.properties =================================================================== --- trunk/vradi-swing/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/vradi-swing/src/license/THIRD-PARTY.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,54 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache 2 +# - Apache License +# - Apache Software License - Version 2.0 +# - Apache Software License, version 1.1 +# - BSD / Apache +# - BSD License +# - BSD style +# - CDDL +# - Common Development and Distribution License (CDDL) v1.0 +# - Common Public License Version 1.0 +# - Eclipse Public License - Version 1.0 +# - GNU LESSER GENERAL PUBLIC LICENSE +# - GNU Lesser General Public License +# - GNU Lesser General Public License, Version 3 +# - GPLv2+CE +# - General Public License (GPL) v 3.0 +# - Indiana University Extreme! Lab Software License +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - LGPL 2.1 +# - LGPL 2.1 / Apache Software License - Version 2.0 +# - Lesser General Public License (LGPL) +# - Lesser General Public License (LGPL) v 3.0 +# - MIT License +# - Mozilla Public License +# - Mozilla Public License Version 1.0 +# - Public Domain +# - Public domain +# - TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +# - The Apache Software License, Version 1.1 +# - The Apache Software License, Version 2.0 +# - The H2 License, Version 1.0 +# - The OpenSymphony Software License 1.1 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 23 18:07:54 CET 2010 +commons-cli--commons-cli--1.2--jar=Apache License, Version 2.0 +commons-jxpath--commons-jxpath--1.3--jar=Apache License, Version 2.0 +commons-primitives--commons-primitives--1.0--jar=Apache License, Version 2.0 +concurrent--concurrent--1.0--jar=TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. +groovy--groovy-all--1.0-jsr-06--jar=BSD / Apache +javax.servlet--servlet-api--2.5--jar=Common Development and Distribution License (CDDL) v1.0 +javax.transaction--jta--1.1--jar=Common Development and Distribution License (CDDL) v1.0 +jboss--jnet--3.2.1--jar=GNU LESSER GENERAL PUBLIC LICENSE +opensymphony--ognl--2.6.11--jar=The OpenSymphony Software License 1.1 +org.apache.commons--commons-email--1.2--jar=Apache License, Version 2.0 +org.jdom--jdom--1.1--jar=Apache License +rome--rome--1.0--jar=Apache Software License - Version 2.0 +woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / Apache Software License - Version 2.0 +xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme\! Lab Software License Property changes on: trunk/vradi-swing/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/assembly/bin/go.bat =================================================================== --- trunk/vradi-swing/src/main/assembly/bin/go.bat (rev 0) +++ trunk/vradi-swing/src/main/assembly/bin/go.bat 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,2 @@ +set MX=768M +java -Xmx%MX% -jar ${project.build.finalName}.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 Property changes on: trunk/vradi-swing/src/main/assembly/bin/go.bat ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/assembly/bin/go.sh =================================================================== --- trunk/vradi-swing/src/main/assembly/bin/go.sh (rev 0) +++ trunk/vradi-swing/src/main/assembly/bin/go.sh 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,29 @@ +### +# #%L +# Vradi :: Swing +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +#!/bin/sh + +MX=768M +java -Xmx$MX -jar ${project.build.finalName}.jar $@ + Property changes on: trunk/vradi-swing/src/main/assembly/bin/go.sh ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/assembly/bin.xml =================================================================== --- trunk/vradi-swing/src/main/assembly/bin.xml (rev 0) +++ trunk/vradi-swing/src/main/assembly/bin.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> + <id>bin</id> + <formats> + <format>zip</format> + </formats> + <!-- <dependencySets> + <dependencySet> + <outputDirectory>lib</outputDirectory> + <scope>runtime</scope> + </dependencySet> + </dependencySets> --> + + <fileSets> + + <fileSet> + <directory>target/lib</directory> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + + <fileSet> + <directory>target</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>${project.build.finalName}.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>target/classes</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>THIRD-PARTY.txt</include> + </includes> + </fileSet> + <!--fileSet> + <directory>target/apidocs</directory> + <outputDirectory>/apidocs</outputDirectory> + </fileSet--> + <fileSet> + <outputDirectory>/</outputDirectory> + <includes> + <include>README*</include> + <include>LICENSE*</include> + </includes> + </fileSet> + + <fileSet> + <directory>src/main/assembly/bin</directory> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + <filtered>true</filtered> + <includes> + <include>go.sh</include> + <include>go.bat</include> + </includes> + </fileSet> + + </fileSets> +</assembly> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/assembly/bin.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiAction.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiAction.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiAction.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,106 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import jaxx.runtime.context.DefaultApplicationContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; + +import java.util.Arrays; + +@DefaultApplicationContext.AutoLoad +public class VradiAction { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiAction.class); + + /** La configuration de l'application. */ + protected VradiConfig config; + + public VradiAction() { + } + + public VradiAction(VradiConfig config) { + this.config = config; + } + + public void configure() { + disableMainUI(); +// VradiContext context = VradiContext.get(); +// VradiMainUIHandler handler = context.getContextValue(VradiMainUIHandler.class); +// handler.showConfig(context); + } + + public void help() { + disableMainUI(); + + log.debug(I18n._("vradi.message.help.usage", VradiConfigHelper.getVersion(getConfig()))); + log.debug("Options (set with --option <key> <value>:"); + for (VradiConfig.VradiSwingOption o : VradiConfig.VradiSwingOption.values()) { + log.debug("\t" + o.key + "(" + o.defaultValue + "):" + o.description); + } + + log.debug("Actions:"); + for (VradiConfig.VradiSwingAction a : VradiConfig.VradiSwingAction.values()) { + log.debug("\t" + Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description); + } + System.exit(0); + } +// +// public void helpUI() { +// VradiContext context = VradiContext.get(); +//// VradiMainUIHandler handler = context.getContextValue(VradiMainUIHandler.class); +// VradiHelpBroker helpBroker = context.getContextValue(VradiHelpBroker.class); +// +// log.debug("no mainUI, open in autonome frame"); +// // ouvrir dans une fenetre dedie +// JHelp ui = new JHelp(helpBroker.getHelpset()); +// JDialog frame = new JDialog((Frame) null, true); +// frame.setTitle(_("vradi.help.top.title")); +// frame.setSize(1024, 800); +// frame.add(ui); +// frame.setVisible(true); +// +// disableMainUI(); +// +// System.exit(0); +// } + + /** Désactiver la possiblite de lancer l'ui principale. */ + public void disableMainUI() { + if (log.isDebugEnabled()) { + log.debug(this); + } + } + + protected VradiConfig getConfig() { + if (config == null) { + VradiContext context = VradiContext.get(); + config = context.getContextValue(VradiConfig.class); + } + return config; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,344 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.DefaultApplicationContext.AutoLoad; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; +import org.nuiton.wikitty.WikittyConfig; + +import java.beans.PropertyChangeListener; +import java.io.File; +import java.util.Locale; + +import static org.nuiton.i18n.I18n._; + +/** + * Vradi UI configuration. + * <p/> + * Class is auto instanced by Jaxx when getting it from context. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +@AutoLoad +public class VradiConfig extends ApplicationConfig { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiConfig.class); + + /** Un drapeau pour savoir si on est en mode pleine écran. */ + protected boolean fullscreen; + + /** + * Constructor. + * <p/> + * Init default options and actions. + */ + public VradiConfig() { + + // Load default value for wikitty + loadDefaultOptions(WikittyConfig.WikittyOption.class); + + // init configuration with default options + loadDefaultOptions(VradiSwingOption.class); + + loadActions(VradiSwingAction.class); + + } + + @Override + protected void firePropertyChange(String propertyName, + Object oldValue, Object newValue) { + super.firePropertyChange(propertyName, oldValue, newValue); + } + + /** Overwrite to manage version after parsing. */ + @Override + public void parse(String[] args) throws ArgumentsParserException { + super.parse(args); + + // on supprime le stamp de snapshot s'il existe + String sVersion = VersionUtil.removeSnapshot(getOption("application.version")); + Version version = VersionUtil.valueOf(sVersion); + setDefaultOption(VradiSwingOption.VRADI_VERSION.key, version.getVersion()); + + // la version de la base est sans classifier (pas de alpha, ou rc,...) + Version dbVersion; + if (version.hasClassifier()) { + dbVersion = VersionUtil.removeClassifier(version); + } else { + dbVersion = VersionUtil.valueOf(version.toString()); + } + + setDefaultOption(VradiSwingOption.VRADI_DATABASE_VERSION.key, dbVersion.getVersion()); + } + + protected static final String[] DEFAULT_JAXX_PCS = { + "showNumberEditorButton", "autoPopupNumberEditor", "fullScreen", "locale" + }; + + /** TODO EC20100519 used by ? */ + public void removeJaxxPropertyChangeListener() { + PropertyChangeListener[] toRemove = SwingUtil.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners()); + if (toRemove == null || toRemove.length == 0) { + return; + } + if (log.isDebugEnabled()) { + log.debug("before remove : " + getPropertyChangeListeners().length); + log.debug("toRemove : " + toRemove.length); + } + for (PropertyChangeListener listener : toRemove) { + removePropertyChangeListener(listener); + } + if (log.isDebugEnabled()) { + log.debug("after remove : " + getPropertyChangeListeners().length); + } + } + + /** Vradi option enum. */ + public enum VradiSwingOption implements OptionDef { + + CONFIG_FILE( + CONFIG_FILE_NAME, + _("vradi.config.configFileName.description"), + "vradi.properties", String.class, true, true), + + VRADI_SWING_DEBUG( + "vradi.swing.debug", + _("vradi.config.swing.debug"), + "false", Boolean.class, true, true), + + SWING_CONFIG_FILE( + "vradi.swing.config", + _("vradi.config.swingConfigFileName.description"), + "${config.file}" + File.separator + "vradi-swing.properties", File.class, true, true), + + VRADI_VERSION( + "vradi.version", + _("vradi.config.version.description"), + null, String.class, true, true), + + VRADI_DATABASE_VERSION( + "vradi.database.version", + _("vradi.config.database.version.description"), + null, String.class, true, true), + + VRADI_LAST_VERSION( + "vradi.last.version", + _("vradi.config.last.version.description"), + null, String.class, true, true), + + // ui config + FULL_SCREEN( + "ui.fullscreen", + _("vradi.config.ui.fullscreen"), + "false", Boolean.class, false, false), + + LOCALE( + "ui.locale", + _("vradi.config.ui.locale"), + Locale.FRANCE.toString(), + Locale.class, false, false), + + // login and password + USERNAME( + "login", + _("vradi.config.login"), + "", String.class, true, true), + PASSWORD( + "password", + _("vradi.config.password"), + "", String.class, true, true), + + // achitecture client serveur + REMOTE_ENDPOINT( + "vradi.remote.endpoint", + _("vradi.config.remote.endpoint.description"), + "", String.class, false, false), + + // user datas + QUERIES( + "vradi.queries", + _("vradi.config.queries.description"), + "", String.class, false, false), + + XML_STREAMS( + "vradi.xmlStreams", + _("vradi.config.xmlStreams.description"), + "", String.class, false, false), + + CRITERIAS( + "vradi.xmlStreams", + _("vradi.config.criteria.description"), + "", String.class, false, false), + + ROOT_CRITERIAS( + "vradi.root.criteria", + _("vradi.config.root.criteria.description"), + "", String.class, false, false), + + THESAURUS( + "vradi.thesaurus", + _("vradi.config.thesaurus.description"), + "", String.class, false, false), + + ROOT_THESAURUS( + "vradi.rootThesaurus", + _("vradi.config.rootThesaurus.description"), + "", String.class, false, false), + + COLUMNS( + "vradi.columns", + _("vradi.config.columns.description"), + "", String.class, false, false), + + THESAURUS_COLORS( + "vradi.thesaurus.color", + _("vradi.config.thesaurus.color.description"), + "", String.class, false, false), + + STATUS_COLOR( + "vradi.status.color", + _("vradi.config.status.color.description"), + "", String.class, false, false), + + THESAURUS_EXPANDED( + "vradi.thesaurus.expanded", + _("vradi.config.thesaurus.expanded.description"), + "", Boolean.class, false, false); + + public String key; + + public String description; + + public String defaultValue; + + public Class<?> type; + + public boolean isTransient; + + public boolean isFinal; + + VradiSwingOption(String key, String description, String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + this.isTransient = isTransient; + this.isFinal = isFinal; + } + + @Override + public boolean isFinal() { + return isFinal; + } + + @Override + public boolean isTransient() { + return isTransient; + } + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getKey() { + return key; + } + + @Override + public Class<?> getType() { + return type; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public void setTransient(boolean isTransient) { + this.isTransient = isTransient; + } + + @Override + public void setFinal(boolean isFinal) { + this.isFinal = isFinal; + } + } + + /** Can't be used un @annotation. */ + @Deprecated + public enum Step { + AfterInit, BeforeExit + } + + public enum VradiSwingAction implements ActionDef { + + HELP(_("vradi.action.commandline.help"), VradiAction.class.getName() + "#help", "-h", "--help"), + HELP_UI(_("vradi.action.commandline.help.ui"), VradiAction.class.getName() + "#helpUI", "--help-ui"), + NO_MAIN_UI(_("vradi.action.commandline.disable.main.ui"), VradiAction.class.getName() + "#disableMainUI", "-n", "--no-main"), + CONFIGURE_UI(_("vradi.action.commandline.configure.ui"), VradiAction.class.getName() + "#configure", "--configure"); + + public String description; + + public String action; + + public String[] aliases; + + VradiSwingAction(String description, String action, String... aliases) { + this.description = description; + this.action = action; + this.aliases = aliases; + } + + @Override + public String getAction() { + return action; + } + + @Override + public String[] getAliases() { + return aliases; + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,378 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.StringUtil; +import org.nuiton.util.Version; +import org.nuiton.widget.SwingSession; + +import java.io.File; +import java.util.Locale; + +/** + * TODO poussin 20101207 il ne devrait y avoir aucune reference a VradiConfig + * dans les signatures des methodes sinon ca sert a rien de faire ce Helper :(. + * Remplacer VradiConfig par ApplicationConfig. Le mieux serait de sortir + * VradiSwingOption de VradiConfig en meme temps + * + * @author sletellier + */ +public class VradiConfigHelper extends VradiServiceConfigurationHelper { + + public static boolean isSwingDebug(ApplicationConfig config) { + boolean result = config.getOptionAsBoolean( + VradiConfig.VradiSwingOption.VRADI_SWING_DEBUG.getKey()); + return result; + } + + public static String getCopyrightText(ApplicationConfig config) { + return "Version " + getVersion(config) + " JurisMarches @ 2009 - 2010"; + } + + /** + * La version du logiciel. + * + * @param config vradi swing configuration + * @return la version de l'application. + */ + public static Version getVersion(ApplicationConfig config) { + Version option = config.getOption(Version.class, VradiConfig.VradiSwingOption.VRADI_VERSION.key); + return option; + } + + /** + * @param config vradi swing configuration + * @return la version de la base + */ + public static Version getDatabaseVersion(ApplicationConfig config) { + Version option = config.getOption(Version.class, VradiConfig.VradiSwingOption.VRADI_DATABASE_VERSION.key); + return option; + } + + /** + * La derniere version de lancement du logiciel. + * + * @param config vradi swing configuration + * @return la derniere version de lancement + */ + public static String getLastVersion(ApplicationConfig config) { + String lastVersion = config.getOption(VradiConfig.VradiSwingOption.VRADI_LAST_VERSION.key); + return lastVersion; + } + + /** + * Change last version. + * + * @param config vradi swing configuration + * @param lastVersion new last version + */ + public static void setLastVersion(ApplicationConfig config, String lastVersion) { + config.setOption(VradiConfig.VradiSwingOption.VRADI_LAST_VERSION.key, lastVersion); + } + + public static boolean isFullScreen(ApplicationConfig config) { + Boolean result = config.getOptionAsBoolean(VradiConfig.VradiSwingOption.FULL_SCREEN.key); + return result != null && result; + } + + public static Locale getLocale(ApplicationConfig config) { + Locale result = config.getOption(Locale.class, VradiConfig.VradiSwingOption.LOCALE.key); + return result; + } + + public static void setFullscreen(VradiConfig config, boolean fullscreen) { + boolean oldValue = isFullScreen(config); + config.setOption(VradiConfig.VradiSwingOption.FULL_SCREEN.key, fullscreen + ""); + config.saveForUser(); + config.firePropertyChange("fullscreen", oldValue, fullscreen); + } + + public static void setLocale(VradiConfig config, Locale newLocale) { + config.setOption(VradiConfig.VradiSwingOption.LOCALE.key, newLocale.toString()); + config.saveForUser(); + config.firePropertyChange("locale", null, newLocale); + } + + /** + * Get user login. + * + * @param config vradi swing configuration + * @return user login + */ + public static String getLogin(ApplicationConfig config) { + return config.getOption(VradiConfig.VradiSwingOption.USERNAME.key); + } + + /** + * Set user login. + * + * @param config vradi swing configuration + * @param login user login + */ + public static void setLogin(ApplicationConfig config, String login) { + config.setOption(VradiConfig.VradiSwingOption.USERNAME.key, login); + } + + /** + * Get user password. + * + * @param config vradi swing configuration + * @return user password + */ + public static String getPassword(ApplicationConfig config) { + return config.getOption(VradiConfig.VradiSwingOption.PASSWORD.key); + } + + /** + * Set user password. + * + * @param config vradi swing configuration + * @param password user password + */ + public static void setPassword(VradiConfig config, String password) { + config.setOption(VradiConfig.VradiSwingOption.PASSWORD.key, password); + } + + /** + * Get remote endpoint base url. + * <p/> + * If not valid url, embedded mode is used. + * + * @param config vradi swing configuration + * @return remote endpoint base url + */ + public static String getRemoteEndpoint(ApplicationConfig config) { + String endpoint = config.getOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT.key); + return endpoint; + } + + /** + * Get user queries (comma separated). + * <p/> + * Warning to inner comma in queries, use {@link StringUtil#split(String, String)} + * + * @param config vradi swing configuration + * @return user queries. + */ + public static String getQueries(ApplicationConfig config) { + String queries = config.getOption(VradiConfig.VradiSwingOption.QUERIES.key); + return queries; + } + + /** + * Set user queries and save user configuration. + * + * @param config vradi swing configuration + * @param queries user queries (comma separated) + */ + public static void setQueries(ApplicationConfig config, String queries) { + config.setOption(VradiConfig.VradiSwingOption.QUERIES.key, queries); + config.saveForUser(); + } + + /** + * Get user criteria (comma separated). + * + * @param config vradi swing configuration + * @return user criteria. + */ + public static String getCriterias(ApplicationConfig config) { + String criterias = config.getOption(VradiConfig.VradiSwingOption.CRITERIAS.key); + return criterias; + } + + /** + * Set user criterias and save user configuration. + * + * @param config vradi swing configuration + * @param criterias user criterias (comma separated) + */ + public static void setCriterias(ApplicationConfig config, String criterias) { + config.setOption(VradiConfig.VradiSwingOption.CRITERIAS.key, criterias); + config.saveForUser(); + } + + /** + * Get user root criteria (comma separated). + * + * @param config vradi swing configuration + * @return user root criteria. + */ + public static String getRootCriterias(ApplicationConfig config) { + String criterias = config.getOption(VradiConfig.VradiSwingOption.CRITERIAS.key); + return criterias; + } + + /** + * Set user root criterias and save user configuration. + * + * @param config vradi swing configuration + * @param criterias user root criterias (comma separated) + */ + public static void setRootCriterias(ApplicationConfig config, String criterias) { + config.setOption(VradiConfig.VradiSwingOption.CRITERIAS.key, criterias); + config.saveForUser(); + } + + /** + * Get user rootThesaurus (comma separated). + * + * @param config vradi swing configuration + * @return user thesaurus. + */ + public static String getRootThesaurus(ApplicationConfig config) { + String rootThesaurus = config.getOption(VradiConfig.VradiSwingOption.ROOT_THESAURUS.key); + return rootThesaurus; + } + + /** + * Set user rootThesaurus and save user configuration. + * + * @param config vradi swing configuration + * @param rootThesaurus user rootThesaurus (comma separated) + */ + public static void setRootThesaurus(ApplicationConfig config, String rootThesaurus) { + config.setOption(VradiConfig.VradiSwingOption.ROOT_THESAURUS.key, rootThesaurus); + config.saveForUser(); + } + + /** + * Get user thesaurus (comma separated). + * + * @param config vradi swing configuration + * @return user thesaurus. + */ + public static String getThesaurus(ApplicationConfig config) { + String thesaurus = config.getOption(VradiConfig.VradiSwingOption.THESAURUS.key); + return thesaurus; + } + + /** + * Set user thesaurus and save user configuration. + * + * @param config vradi swing configuration + * @param thesaurus user thesaurus (comma separated) + */ + public static void setThesaurus(ApplicationConfig config, String thesaurus) { + config.setOption(VradiConfig.VradiSwingOption.THESAURUS.key, thesaurus); + config.saveForUser(); + } + + /** + * Get user columns list : offer (comma separated). + * + * @param config vradi swing configuration + * @return user columns. + */ + public static String getOfferColumns(ApplicationConfig config) { + String columns = config.getOption(VradiConfig.VradiSwingOption.COLUMNS.key); + return columns; + } + + /** + * Set user columns and save user configuration. + * + * @param config vradi swing configuration + * @param columns user columns (comma separated) + */ + public static void setOfferColumns(ApplicationConfig config, String columns) { + config.setOption(VradiConfig.VradiSwingOption.COLUMNS.key, columns); + config.saveForUser(); + } + + /** + * Get thesaurus color and level. + * <p/> + * Storage is : 0=255,323,232;1=232,112,234;... + * + * @param config vradi swing configuration + * @return thesaurus level and color + */ + public static String getThesaurusColors(ApplicationConfig config) { + String columns = config.getOption(VradiConfig.VradiSwingOption.THESAURUS_COLORS.key); + return columns; + } + + /** + * Set user thesaurus color and level. + * <p/> + * Storage is : 0=255,323,232;1=232,112,234;... + * + * @param config vradi swing configuration + * @param levelAndColors user columns (; separated) + */ + public static void setThesaurusColors(ApplicationConfig config, String levelAndColors) { + config.setOption(VradiConfig.VradiSwingOption.THESAURUS_COLORS.key, levelAndColors); + config.saveForUser(); + } + + /** + * Get the swing vradi config file (used by {@link SwingSession}) + * + * @param config vradi swing configuration + * @return file concerned + */ + public static File getSwingConfigFile(ApplicationConfig config) { + return config.getOptionAsFile(VradiConfig.VradiSwingOption.SWING_CONFIG_FILE.key); + } + + public static void setSwingConfigFile(ApplicationConfig config, String path) { + config.setOption(VradiConfig.VradiSwingOption.SWING_CONFIG_FILE.key, path); + } + + /** + * Get thesaurus expanded state. + * + * @param config vradi swing configuration + * @return thesaurus expanded state + */ + public static boolean isOnClickThesaurusExpanded(ApplicationConfig config) { + boolean result = config.getOptionAsBoolean(VradiConfig.VradiSwingOption.THESAURUS_EXPANDED.key); + return result; + } + + /** + * Set thesaurus expanded state. + * + * @param config vradi swing configuration + * @param state thesaurus expanded state + */ + public static void setOnClickThesaurusExpanded(ApplicationConfig config, boolean state) { + config.setOption(VradiConfig.VradiSwingOption.THESAURUS_EXPANDED.key, String.valueOf(state)); + config.saveForUser(); + } + + /** + * Change remote endpoint url. + * + * @param config vradi swing configuration + * @param newEndpoint new base url + */ + public static void setRemoteEndPoint(ApplicationConfig config, String newEndpoint) { + config.setOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT.key, newEndpoint); + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiConfigHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiContext.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiContext.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiContext.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,178 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.vradi; + +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.DefaultApplicationContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.decorator.DecoratorProvider; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.ui.VradiMainUI; +import org.chorem.vradi.ui.admin.AdminPopupUI; +import org.chorem.vradi.ui.email.EmailPopupUI; +import org.chorem.vradi.ui.offer.OfferListUI; +import org.nuiton.widget.SwingSession; + +import java.util.List; +import java.util.Locale; + +public class VradiContext extends DefaultApplicationContext { + + static private Log log = LogFactory.getLog(VradiContext.class); + + public static final JAXXContextEntryDef<VradiMainUI> MAIN_UI_ENTRY_DEF = + SwingUtil.newContextEntryDef("mainui", VradiMainUI.class); + + public static final JAXXContextEntryDef<OfferListUI> OFFERT_LIST_UI_ENTRY_DEF = + SwingUtil.newContextEntryDef("offerList", OfferListUI.class); + + public static final JAXXContextEntryDef<AdminPopupUI> ADMIN_UI_ENTRY_DEF = + SwingUtil.newContextEntryDef("adminPopupUI", AdminPopupUI.class); + + public static final JAXXContextEntryDef<EmailPopupUI> EMAIL_UI_ENTRY_DEF = + SwingUtil.newContextEntryDef("emailViewUI", EmailPopupUI.class); + + public static final JAXXContextEntryDef<List<Locale>> LOCALES_AVAILABLES = + SwingUtil.newListContextEntryDef("localesAvailables"); + + /** Instance of SwingSession to save ui disposition */ + public static final JAXXContextEntryDef<SwingSession> SWING_SESSION_ENTRY_DEF = + SwingUtil.newContextEntryDef("swingSession", SwingSession.class); + + /** + * l'intance partagée accessible après un appel à la méthode + * {@link #init()} + */ + protected static VradiContext instance; + + /** + * @return <code>true</code> si le context a été initialisé via la méthode + * {@link #init()}, <ocde>false</code> autrement. + */ + public static boolean isInit() { + return instance != null; + } + + /** + * Permet l'initialisation du contexte applicatif et positionne + * l'instance partagée. + * <p/> + * Note : Cette méthode ne peut être appelée qu'une seule fois. + * + * @return l'instance partagée + * @throws IllegalStateException si un contexte applicatif a déja été positionné. + */ + public static synchronized VradiContext init() throws IllegalStateException { + if (isInit()) { + throw new IllegalStateException("there is an already application context registred."); + } + instance = new VradiContext(); + return instance; + } + + /** + * Récupération du contexte applicatif. + * + * @return l'instance partagé du contexte. + * @throws IllegalStateException si le contexte n'a pas été initialisé via + * la méthode {@link #init()} + */ + public static VradiContext get() throws IllegalStateException { + if (!isInit()) { + throw new IllegalStateException("no application context registred."); + } + return instance; + } + + /** Un objet pour bloquer le context */ + protected final Object lock = new Object(); + + protected VradiContext() { + super(); + } + + public void lock() throws InterruptedException { + synchronized (lock) { + lock.wait(); + } + } + + public void releaseLock() { + synchronized (lock) { + lock.notify(); + } + } + + /** + * close the application's context. + * + * @throws Exception if any pb while closing + */ + public void close() throws Exception { + if (log.isDebugEnabled()) { + log.debug("closing context " + this); + } + + // fermeture du context principal + clear(); + } + + public VradiConfig getVradiConfig() { + return getContextValue(VradiConfig.class); + } + + /** + * TODO EC20100515 : explain this code ! + * + * @return + */ + public DecoratorProvider getDecoratorProvider() { + return getContextValue(DecoratorProvider.class); + } + + /** + * TODO EC20100515 : explain this code ! + * + * @return + */ + public DecoratorProviderListCellRenderer getDecoratorProviderListCellRenderer() { + return getContextValue(DecoratorProviderListCellRenderer.class); + } + + public VradiNotifier getVradiNotifier() { + return getContextValue(VradiNotifier.class); + } + + public List<Locale> getLocalesAvailables() { + return LOCALES_AVAILABLES.getContextValue(this); + } + + public void setLocalesAvailables(List<Locale> localesAvailables) { + LOCALES_AVAILABLES.setContextValue(this, localesAvailables); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiEntitiesListener.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiEntitiesListener.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiEntitiesListener.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,38 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.Set; + +/** @author sletellier */ +public interface VradiEntitiesListener<C extends BusinessEntity> { + + void entitiesAdded(Set<C> added); + + void entitiesRemoved(Set<String> removedIds); + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiEntitiesListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiExtensionsListener.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiExtensionsListener.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiExtensionsListener.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,37 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.Set; + +/** @author sletellier */ +public interface VradiExtensionsListener { + + void extensionsAdded(Set<WikittyExtension> added); + + void extensionsRemoved(Set<String> removedNames); +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiExtensionsListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,868 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.nuiton.util.StringUtil; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.addons.WikittyI18nUtil; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyI18n; + +import java.awt.Color; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class VradiHelper { + + private static final Log log = LogFactory.getLog(VradiHelper.class); + + //public final static String QUERIES = "vradi.queries"; + //public final static String XML_STREAMS = "vradi.xmlStreams"; + //public final static String CRITERIAS = "vradi.criterias"; + //public final static String THESAURUS = "vradi.thesaurus"; + //public final static String COLUMNS = "vradi.columns"; + //public final static String THESAURUS_COLORS = "vradi.thesaurus.color"; + //public final static String STATUS_COLOR = "vradi.status.color"; + //public final static String COLOR_REGEX = "\\.\\d+"; + public final static String TYPE_DESCRIPTION = "description"; + + public final static String TYPE_RANK = "rank"; + + public final static String TYPE_LAST_MODIFIED_DATE = "lastModifiedDate"; + + public final static String TYPE_LAST_MODIFIED_TIME = "lastModifiedTime"; + + public final static String TYPE_LAST_MODIFIED_BY = "lastModifiedBy"; + + public static final String INFOGENE_KEY_PREFIX = "vradi.infogene."; + + public static final String FORM_KEY_PREFIX = "vradi.form."; + + public static final String MODIFICATION_TAG_KEY_PREFIX = "vradi.modificationTag."; + + //public final static String EXPEND_SELECTED = "vradi.expend.selected"; + + // Singleton sur les proprietes + //public static Properties userProperties = null; + + public static VradiConfig getVradiConfig() { + return VradiContext.get().getVradiConfig(); + } + + public static Status getSelectionneStatus() { + + VradiConstants.FormStatus type = VradiConstants.FormStatus.SELECTIONNE; + + if (log.isDebugEnabled()) { + log.debug("getOrCreateStatus(" + type.getName() + ")"); + } + + try { + return VradiService.getVradiDataService().getStatus(type.getName()); + } catch (VradiException eee) { + log.error(eee); + ErrorDialogUI.showError(eee); + return null; + } + } + + /*protected static Properties getUserProperties() { + if (userProperties == null) { + userProperties = getProperties(getVradiConfig().getUserFile()); + } + return userProperties; + }*/ + + /*protected static Properties getProperties(File propertyFile) { + Properties properties; + try { + properties = new Properties(); + if (getVradiConfig().getVersion().getVersion() != null + && !getVradiConfig().getVersion().getVersion().isEmpty()) { + if (!propertyFile.exists()) { + if (!propertyFile.createNewFile()) { + log.error("Failled to create new property file : " + propertyFile.getName()); + } + } + InputStream input = new FileInputStream(propertyFile); + properties.load(input); + } + } catch (IOException ioe) { + + throw new IllegalStateException("could not get " + + propertyFile.getName() + " caused by : " + + ioe.getMessage(), ioe); + } + return properties; + }*/ + + /*protected static Properties store(Properties property, File file) { + try { + Writer fileOutputStream = new OutputStreamWriter( + new FileOutputStream(file), "ISO-8859-1"); + property.store(fileOutputStream, ""); + } catch (IOException e) { + log.error("Cant save request property caused by : ", e); + ErrorDialogUI.showError(e); + } + + return property; + }*/ + + /*protected static void storeUserProperties(Properties properties) { + + File userFile = getVradiConfig().getUserFile(); + if (userFile != null) { + store(properties, userFile); + } + }*/ + + /*protected static List<String> getUserListOfStringFromProperties( + String propertyName) { + Properties properties = getUserProperties(); + List<String> result = new ArrayList<String>(); + // Recuperation des propriete + if (properties != null) { + String resultNames = properties.getProperty(propertyName); + if (resultNames != null) { + for (String resultName : resultNames.split(",")) { + String utf8ResultName; + try { + utf8ResultName = new String( + resultName.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException eee) { + utf8ResultName = resultName; + } + result.add(utf8ResultName); + } + } else { + log.warn("Cant find property : " + propertyName); + } + } + return result; + }*/ + + /*protected static void storeUserListProperties(String propertyName, + List<String> values) { + Properties properties = getUserProperties(); + if (properties != null) { + StringBuffer store = new StringBuffer(); + for (String value : values) { + store.append(value).append(","); + } + + // Removing last "," + int length = store.length() - 1; + if (length > 0) { + store.deleteCharAt(length); + } + properties.setProperty(propertyName, store.toString()); + storeUserProperties(properties); + } + }*/ + + /*protected static void addToUserListProperties(String propertyName, + String value) { + addToUserListProperties(propertyName, value, false); + }*/ + + /*protected static void addToUserListProperties(String propertyName, + String value, + boolean replace) { + addToUserListProperties(propertyName, value, replace, false, false); + }*/ + + /*protected static void addToUserListProperties(String propertyName, + String value, boolean replace, + boolean inverse, + boolean uniqueValues) { + List<String> result = replace ? new ArrayList<String>() : + getUserListOfStringFromProperties(propertyName); + if (value != null) { + String isoValue; + try { + isoValue = new String(value.getBytes("UTF-8"), "ISO-8859-1"); + } catch (UnsupportedEncodingException eee) { + isoValue = value; + } + if (uniqueValues && result.contains(isoValue)) { + result.remove(isoValue); + if (inverse) { + result.add(0, isoValue); + } else { + result.add(isoValue); + } + } else { + if (inverse) { + result.add(0, isoValue); + } else { + result.add(isoValue); + } + } + } + storeUserListProperties(propertyName, result); + }*/ + + /** + * Return a non null list from a comma separated string + * + * @param string to convert + * @return list created + */ + protected static List<String> stringToList(String string) { + List<String> resultList = new ArrayList<String>(); + if (StringUtils.isNotEmpty(string)) { + // use StringUtil.split because of inner separator in "" + String[] items = StringUtil.split(string, ","); + resultList.addAll(Arrays.asList(items)); + } + return resultList; + } + + /*protected static List<String> removeToUserListProperties( + String propertyName, String value) { + List<String> result = getUserListOfStringFromProperties(propertyName); + result.remove(value); + storeUserListProperties(propertyName, result); + + return result; + }*/ + + /** + * Save query in configuration. + * + * @param query query to save + */ + public static void addRequestToProperties(String query) { + List<String> result = loadRequests(); + if (!result.contains(query)) { + result.add(0, query); + String queries = StringUtils.join(result, ","); + VradiConfigHelper.setQueries(getVradiConfig(), queries); + } + } + + /** + * Get queries from configuration as set. + * (used in SearchUI). + * + * @return queries + */ + public static List<String> loadRequests() { + String queries = VradiConfigHelper.getQueries(getVradiConfig()); + List<String> result = stringToList(queries); + return result; + } + + /** + * Get configuration criterias as list. + * (used in SearchUI) + * + * @return criterias + */ + public static List<String> getVradiListCriteria() { + String criterias = VradiConfigHelper.getCriterias(getVradiConfig()); + List<String> result = stringToList(criterias); + return result; + } + + /** + * Add criteria. + * + * @param value criteria to add + */ + public static void addVradiListCriteria(Thesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListCriteria(); + result.add(value.getWikittyId()); + String criterias = StringUtils.join(result, ','); + VradiConfigHelper.setCriterias(getVradiConfig(), criterias); + } + + /** + * Remove a criteria. + * + * @param value criteria to remove + */ + public static void removeVradiListCriteria(Thesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListCriteria(); + result.remove(value.getWikittyId()); + String criterias = StringUtils.join(result, ','); + VradiConfigHelper.setCriterias(getVradiConfig(), criterias); + } + + /** + * Get configuration root criterias as list. + * (used in SearchUI) + * + * @return root criterias + */ + public static List<String> getVradiListRootCriteria() { + String criterias = VradiConfigHelper.getRootCriterias(getVradiConfig()); + List<String> result = stringToList(criterias); + return result; + } + + /** + * Add root criteria. + * + * @param value root criteria to add + */ + public static void addVradiListRootCriteria(RootThesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListRootCriteria(); + result.add(value.getWikittyId()); + String criterias = StringUtils.join(result, ','); + VradiConfigHelper.setRootCriterias(getVradiConfig(), criterias); + } + + /** + * Remove a root criteria. + * + * @param value root criteria to remove + */ + public static void removeVradiListRootCriteria(RootThesaurus value) { + List<String> result = getVradiListRootCriteria(); + result.remove(value.getWikittyId()); + String criterias = StringUtils.join(result, ','); + VradiConfigHelper.setRootCriterias(getVradiConfig(), criterias); + } + + /** + * Get configuration RootThesaurus as list. + * + * @return thesaurus list + */ + public static List<String> getVradiListRootThesaurus() { + String rootThesaurus = VradiConfigHelper.getRootThesaurus(getVradiConfig()); + List<String> result = stringToList(rootThesaurus); + return result; + } + + /** + * Remove a RootThesaurus and save list. + * + * @param value thesaurus to remove + */ + public static void removeVradiListRootThesaurus(RootThesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListRootThesaurus(); + result.remove(value.getWikittyId()); + String rootThesaurus = StringUtils.join(result, ','); + VradiConfigHelper.setRootThesaurus(getVradiConfig(), rootThesaurus); + } + + /** + * Add thesaurus. + * + * @param value RootThesaurus to add + */ + public static void addVradiListRootThesaurus(RootThesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListRootThesaurus(); + result.add(value.getWikittyId()); + String rootThesaurus = StringUtils.join(result, ','); + VradiConfigHelper.setRootThesaurus(getVradiConfig(), rootThesaurus); + } + + /** + * Get configuration thesaurus as list. + * + * @return thesaurus list + */ + public static List<String> getVradiListThesaurus() { + String rootThesaurus = VradiConfigHelper.getThesaurus(getVradiConfig()); + List<String> result = stringToList(rootThesaurus); + return result; + } + + /** + * Remove a thesaurus and save list. + * + * @param value thesaurus to remove + */ + public static void removeVradiListThesaurus(Thesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListThesaurus(); + result.remove(value.getWikittyId()); + String thesaurus = StringUtils.join(result, ','); + VradiConfigHelper.setThesaurus(getVradiConfig(), thesaurus); + } + + /** + * Add thesaurus. + * + * @param value thesaurus to add + */ + public static void addVradiListThesaurus(Thesaurus value) { + if (value == null) { + return; + } + List<String> result = getVradiListThesaurus(); + result.add(value.getWikittyId()); + String thesaurus = StringUtils.join(result, ','); + VradiConfigHelper.setThesaurus(getVradiConfig(), thesaurus); + } + + /** + * Get configuration offer list columns. + * + * @return offer list columns + */ + public static List<String> getVradiListColumns() { + String columns = VradiConfigHelper.getOfferColumns(getVradiConfig()); + List<String> result = stringToList(columns); + return result; + } + + /** + * Remove offer column. + * + * @param columnName column name + */ + public static void removeVradiListColumns(String columnName) { + List<String> result = getVradiListColumns(); + result.remove(columnName); + String columns = StringUtils.join(result, ','); + VradiConfigHelper.setOfferColumns(getVradiConfig(), columns); + } + + /** + * Add offer column. + * + * @param columnName column name + */ + public static void addVradiListColumns(String columnName) { + List<String> result = getVradiListColumns(); + result.add(columnName); + String columns = StringUtils.join(result, ','); + VradiConfigHelper.setOfferColumns(getVradiConfig(), columns); + } + + /** + * Get configuration color as map. + * + * @return map for color at levels + */ + public static Map<Integer, Color> getColorsThesaurus() { + Map<Integer, Color> levelsAndColors = new HashMap<Integer, Color>(); + + // try to get it from config + String thesaurusColors = VradiConfigHelper.getThesaurusColors(getVradiConfig()); + if (StringUtils.isNotEmpty(thesaurusColors)) { + String[] thesaurusColorsItems = StringUtil.split(thesaurusColors, ","); + for (String thesaurusColorsItem : thesaurusColorsItems) { + if (thesaurusColorsItem.indexOf('=') > 0) { + String[] levelAndColor = thesaurusColorsItem.split("=|;"); + Integer level = Integer.parseInt(levelAndColor[0]); + Color color = new Color(Integer.parseInt(levelAndColor[1]), + Integer.parseInt(levelAndColor[2]), + Integer.parseInt(levelAndColor[3])); + levelsAndColors.put(level, color); + } + } + } + + // none found, load default + if (levelsAndColors.isEmpty()) { + Color[] colors = new Color[]{Color.BLACK, Color.BLUE, + Color.CYAN, Color.DARK_GRAY, Color.GRAY, Color.GREEN, + Color.LIGHT_GRAY, Color.MAGENTA, Color.ORANGE, + Color.PINK, Color.RED, Color.YELLOW}; + + for (int level = 0; level < colors.length; level++) { + levelsAndColors.put(level, colors[level]); + } + } + + return levelsAndColors; + } + + /** + * Set thesaurus color at specified level. + * + * @param level level + * @param color color to store + */ + public static void storeThesaurusColor(int level, Color color) { + Map<Integer, Color> levelsAndColors = getColorsThesaurus(); + levelsAndColors.put(level, color); + + StringBuilder levelAndColorConf = new StringBuilder(""); + + for (Entry<Integer, Color> entry : levelsAndColors.entrySet()) { + + String stringLevel = entry.getKey().toString(); + + String stringColor = entry.getValue().getRed() + ";" + + entry.getValue().getGreen() + ";" + + entry.getValue().getBlue(); + + levelAndColorConf.append(stringLevel); + levelAndColorConf.append("="); + levelAndColorConf.append(stringColor); + levelAndColorConf.append(","); + } + + VradiConfigHelper.setThesaurusColors(getVradiConfig(), levelAndColorConf.toString()); + } + + public static boolean isOnClickThesaurusExpanded() { + boolean result = VradiConfigHelper.isOnClickThesaurusExpanded(getVradiConfig()); + return result; + } + + public static void storeOnClickThesaurusExpanded(boolean expendSelected) { + VradiConfigHelper.setOnClickThesaurusExpanded(getVradiConfig(), expendSelected); + } + + /** + * Introspect object to look for a getName() method. + * + * @param o object to inspect + * @return getName() result or "" if object can't be inspected or is null + */ + public static String getEntityName(Object o) { + if (o == null) { + return ""; + } + PropertyDescriptor descriptor; + try { + descriptor = PropertyUtils.getPropertyDescriptor(o, "name"); + + if (descriptor == null) { + return ""; + } + Method getter = descriptor.getReadMethod(); + + Object invoke = getter.invoke(o); + if (invoke == null) { + return ""; + } + String result = (String) invoke; + return result; + } catch (IllegalAccessException e) { + log.error(e); + ErrorDialogUI.showError(e); + } catch (InvocationTargetException e) { + log.error(e); + ErrorDialogUI.showError(e); + } catch (NoSuchMethodException e) { + log.error(e); + ErrorDialogUI.showError(e); + } + return ""; + } + + /** + * Execute query. + * + * @param queryParameters query parameters + * @param formPagedResult pagination and sort bean + * @return formPagedResult + */ + public static FormPagedResult executeQuery(QueryParameters queryParameters, + FormPagedResult formPagedResult) { + try { + + formPagedResult.setTotalFoundFormNb(0); + + if (formPagedResult.getNbFormsToShow() == 0) { + formPagedResult.setNbFormsToShow(10); + } + + if (formPagedResult.getPageToShow() == 0) { + formPagedResult.setPageToShow(1); + } + + formPagedResult = VradiService.getVradiDataService().findForms(queryParameters, formPagedResult); + + if (log.isDebugEnabled()) { + log.debug(formPagedResult.getTotalFoundFormNb() + " forms found"); + List<String> formsIds = formPagedResult.getFormsIdsToShow(); + List<Form> forms = VradiService.getWikittyProxy().restore(Form.class, formsIds); + for (Form form : forms) { + log.debug(form.getWikittyId() + " : " + form.getObjet()); + } + } + + } catch (VradiException eee) { + log.error("Cant execute query : ", eee); + ErrorDialogUI.showError(eee); + formPagedResult = new FormPagedResult(); + + } catch (UnsupportedQueryException e) { + log.error(e.getMessage()); + ErrorDialogUI.showError(e); + formPagedResult = new FormPagedResult(); + } + + return formPagedResult; + } + + public static String getFieldTypeDescription(FieldType fieldType) { + return fieldType == null ? + null : fieldType.getTagValue(TYPE_DESCRIPTION); + } + + public static int getFieldTypeRank(FieldType fieldType) { + int result; + try { + result = Integer.valueOf(fieldType.getTagValue(TYPE_RANK)); + } catch (NumberFormatException eee) { + if (log.isDebugEnabled()) { + log.debug("no tag value for rank"); + } + result = -1; + } + return result; + } + + /*public static String getLastVersion() { + Properties userProperties = getUserProperties(); + return userProperties.getProperty(LAST_VERSION); + }*/ + + /*public static void setLastVersion(String lastVersion) { + Properties userProperties = getUserProperties(); + userProperties.setProperty(LAST_VERSION, lastVersion); + storeUserProperties(userProperties); + }*/ + + public static boolean isVersionNewer(String version) { + String lastVersion = VradiConfigHelper.getLastVersion(getVradiConfig()); + if (StringUtils.isEmpty(lastVersion)) { + return true; + } + String[] versionToken = version.split("\\."); + String[] lastVersionToken = lastVersion.split("\\."); + int i = 0; + while (i < versionToken.length && i < lastVersionToken.length) { + if (Integer.valueOf(versionToken[i]) + > Integer.valueOf(lastVersionToken[i])) { + return true; + } else if (Integer.valueOf(versionToken[i]) + < Integer.valueOf(lastVersionToken[i])) { + return false; + } + i++; + } + return false; + } + + public static List<String> extractIds(Collection<? extends BusinessEntity> beans) { + List<String> ids = new ArrayList<String>(); + for (BusinessEntity bean : beans) { + ids.add(bean.getWikittyId()); + } + return ids; + } + + public static Form initForm(Form form) { + String newId = VradiConstants.FORM_ID_DATE_FORMAT + .format(new GregorianCalendar().getTime()) + + form.getWikittyId(); + + form.setId(newId); + + // Init creation date + form.setCreationDate(new Date()); + + return form; + } + + public static String getTraduction(String fieldName) { + return getTraduction((WikittyI18n) null, fieldName); + } + + public static String getTraduction(WikittyExtension extension, String fieldName) { + + WikittyI18n wikittyI18n = null; + if (extension != null) { + wikittyI18n = WikittyI18nUtil.getI18n(VradiService.getWikittyProxy(), extension); + } + + return getTraduction(wikittyI18n, fieldName); + } + + public static String getTraduction(WikittyI18n wikittyI18n, String fqFieldNames) { + + if (fqFieldNames == null) { + return null; + } + + String result = null; + + String fieldName = fqFieldNames; + + // Remove fuly qualified name + int i = fieldName.indexOf('.'); + if (i != -1) { + fieldName = WikittyUtil.getFieldNameFromFQFieldName(fqFieldNames); + } + + // Try to get translation + if (wikittyI18n != null) { + result = wikittyI18n.getTranslation(getCurrentLocale().getLanguage(), fieldName); + } + + if (result == null || result.equals(fieldName) || "".equals(result)) { + // Try to get i18n traduction (normal use, not wikitty) + if (fqFieldNames.matches(Infogene.EXT_INFOGENE + "\\..*")) { + result = getInfogeneTraduction(fqFieldNames); + } else if (fqFieldNames.matches(Form.EXT_FORM + "\\..*")) { + result = getFormTraduction(fqFieldNames); + } else if (fqFieldNames.matches(ModificationTag.EXT_MODIFICATIONTAG + "\\..*")) { + result = getModificationTagTraduction(fqFieldNames); + } else { + result = fieldName; + } + } + + return _(result); + } + + /** + * Return traduction of infogene field pass in param + * + * @param key to traduct + * @return traducted + */ + public static String getInfogeneTraduction(String key) { + key = WikittyUtil.getFieldNameFromFQFieldName(key); + return _(INFOGENE_KEY_PREFIX + key); + } + + /** + * Return traduction of form field pass in param + * + * @param key to traduct + * @return traducted + */ + public static String getFormTraduction(String key) { + key = WikittyUtil.getFieldNameFromFQFieldName(key); + return _(FORM_KEY_PREFIX + key); + } + + /** + * Return traduction of modification tag field pass in param + * + * @param key to traduct + * @return traducted + */ + public static String getModificationTagTraduction(String key) { + key = WikittyUtil.getFieldNameFromFQFieldName(key); + return _(MODIFICATION_TAG_KEY_PREFIX + key); + } + + public static Locale getCurrentLocale() { + VradiConfig config = VradiContext.get().getVradiConfig(); + return VradiConfigHelper.getLocale(config); + } + + /** + * TODO sletellier 10/01/11 : Document it and put on nuiton-utils + * + * @param collection to join + * @param separator of join + * @param endOfLine char used for end of line + * @param prefferedSize preffered size + * @return joined + */ + public static String join(Collection collection, String separator, char endOfLine, int prefferedSize) { + String joined = StringUtils.join(collection, separator); + StringBuilder result = new StringBuilder(); + while (joined.length() > prefferedSize) { + + String part = joined.substring(0, prefferedSize); + int separatorIndex = part.lastIndexOf(separator); + + // If not found in part, it seems thats words is bigger that maxSize, so we search first separator to split + if (separatorIndex == -1) { + int i = joined.indexOf(separator); + + if (i == -1) { + part = joined; + } else { + separatorIndex = i + separator.length(); + + part = joined.substring(0, separatorIndex) + endOfLine; + } + } else { + separatorIndex = separatorIndex + separator.length(); + part = part.substring(0, separatorIndex) + endOfLine; + } + result.append(part); + joined = joined.substring(separatorIndex, joined.length()); + } + result.append(joined); + return result.toString(); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiMain.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiMain.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiMain.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,344 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import jaxx.runtime.SwingUtil; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorProvider; +import jaxx.runtime.swing.ErrorDialogUI; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.beanutils.converters.DateConverter; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.ChangeLogHandler; +import org.chorem.vradi.ui.ChangeLogUI; +import org.chorem.vradi.ui.VradiMainUI; +import org.chorem.vradi.ui.VradiMainUIHandler; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.login.LoginHandler; +import org.chorem.vradi.ui.login.LoginUI; +import org.chorem.vradi.ui.renderers.NumberListCellRenderer; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.bundle.I18nBundle; +import org.nuiton.i18n.bundle.I18nBundleEntry; +import org.nuiton.i18n.init.DefaultI18nInitializer; +import org.nuiton.util.StringUtil; +import org.nuiton.util.converter.ConverterUtil; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import static org.nuiton.i18n.I18n._; + +public class VradiMain { + + /** Logger */ + private static Log log = LogFactory.getLog(VradiMain.class); + + public static void main(String[] args) { + final long startingTime = System.nanoTime(); + log.info("Vradi start at " + new Date() + " args: " + Arrays.toString(args)); + + try { + // init root context + final VradiContext context = init(args); + log.info(_("vradi.init.context.done", StringUtil.convertTime(startingTime, System.nanoTime()))); + + SwingUtil.checkJAXXContextEntry(context, SwingUtil.newContextEntryDef(VradiConfig.class)); + SwingUtil.checkJAXXContextEntry(context, SwingUtil.newContextEntryDef(VradiAction.class)); + + final VradiConfig config = context.getContextValue(VradiConfig.class); + config.doAction(VradiConfig.Step.AfterInit.ordinal()); + + final LoginHandler handler = UIHelper.getHandler(context, LoginHandler.class); + final LoginUI loginUI = new LoginUI(context); + + loginUI.addPropertyChangeListener("bean", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() != null) { + // on affiche l'ui principale + context.setContextValue(evt.getNewValue()); + + // dispose loginUI + loginUI.removePropertyChangeListener(this); + loginUI.dispose(); + + try { + + ChangeLogHandler changeLogHandler = UIHelper.getHandler(context, ChangeLogHandler.class); + String changeLog = changeLogHandler.getChangeLog(); + if (!changeLog.isEmpty()) { + ChangeLogUI clUI = new ChangeLogUI(context); + clUI.getContent().setText(changeLog); + clUI.setLocationRelativeTo(null); + clUI.setVisible(true); + } + } catch (Exception eee) { + log.error("Can't open change log ui : ", eee); + ErrorDialogUI.showError(eee); + } + + // show mainUI + VradiMainUIHandler uiHandler = UIHelper.getHandler(context, VradiMainUIHandler.class); + VradiMainUI mainUI = uiHandler.initUI(context, VradiConfigHelper.isFullScreen(config)); + mainUI.setCursor(null); + mainUI.setLocationRelativeTo(null); + mainUI.setVisible(true); + + log.info(_("vradi.init.ui.done", StringUtil.convertTime(startingTime, System.nanoTime()))); + } + } + }); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + String login = VradiConfigHelper.getLogin(config); + // password here is md5 encoded + String password = VradiConfigHelper.getPassword(config); + VradiUser vradiUser = null; + + if (StringUtils.isNotBlank(login) && StringUtils.isNotBlank(password)) { + try { + vradiUser = handler.getVradiStorageService().loginUser(login, password); + } catch (VradiException e) { + log.error(e.getMessage()); + } + } + + if (vradiUser != null) { + loginUI.setBean(vradiUser); + } else { + loginUI.setLocationRelativeTo(null); + loginUI.setVisible(true); + } + } + }); + + } catch (Exception e) { + log.error(e.getMessage(), e); + ErrorDialogUI.showError(e); + System.exit(1); + } + } + + public static VradiContext init(String... args) throws Exception { + // to enable javassist on webstart, must remove any securityManager, + // see if this can be dangerous (should not be since jnlp is signed ?) + // moreover it speeds up the loading :) + System.setSecurityManager(null); + + long t0 = System.nanoTime(); + + DefaultI18nInitializer initializer = new DefaultI18nInitializer("vradi-swing-i18n"); + + I18n.init(initializer, null); + + Runtime.getRuntime().addShutdownHook(new ShutdownHook()); + + // init root context + VradiContext context = VradiContext.init(); + + // Init available locale + initLocalesAvailables(initializer); + + // register decorator one for all + DecoratorProvider decoratorProvider = new DecoratorProvider() { + @Override + protected void loadDecorators() { + + // FIXME EC-20100420 all ${name} are hard coded and non refectorable + registerMultiJXPathDecorator(Client.class, "${name}$s", "", ""); + registerMultiJXPathDecorator(User.class, VradiConstants.USER_ONLY_DECORATOR, "${name}$s", "", ""); + registerMultiJXPathDecorator(Group.class, "${name}$s", "", ""); + registerMultiJXPathDecorator(Status.class, "${name}$s", "", ""); + registerMultiJXPathDecorator(WikittyExtension.class, "${name}$s", "", ""); + registerMultiJXPathDecorator(XmlStream.class, "${name}$s", "", ""); + registerMultiJXPathDecorator(Thesaurus.class, "${name}$s", "", ""); + // ${tagsAsString}## + registerMultiJXPathDecorator(File.class, "${name}$s", "", ""); + //format:date($today, 'MM/dd/yyyy') + registerMultiJXPathDecorator(Form.class, "${objet}$s", "", ""); + registerMultiJXPathDecorator(FormLink.class, "${name}$s", "", ""); + registerDecorator(new Decorator<User>(User.class) { + + private static final long serialVersionUID = 1L; + + @Override + public String toString(Object bean) { + User user = (User) bean; + Client client = VradiService.getWikittyProxy().restore(Client.class, user.getClient()); + String clientString = ""; + if (client != null) { + clientString = client.getName() + " - "; + } + return clientString + user.getName(); + } + }); + } + }; + context.setContextValue(decoratorProvider); + context.setContextValue(new DecoratorProviderListCellRenderer(decoratorProvider)); + + context.setContextValue(new NumberListCellRenderer()); + + // init config + VradiConfig config = context.getContextValue(VradiConfig.class); + config.parse(args); + + long t00 = System.nanoTime(); + + // init i18n + Locale locale = VradiConfigHelper.getLocale(config); + I18n.setDefaultLocale(locale); + log.info("language : " + locale); + + if (log.isDebugEnabled()) { + log.debug("i18n loading time : " + StringUtil.convertTime(t00, System.nanoTime())); + } + + log.info(_("vradi.message.config.loaded", VradiConfigHelper.getVersion(config))); + + // prepare ui look&feel and load ui properties + try { + SwingUtil.initNimbusLoookAndFeel(); + + // set dismiss delay for one hour + ToolTipManager.sharedInstance().setDismissDelay(1000 * 60 * 60); + + // Show big button on splitPane + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + defaults.put("SplitPane.oneTouchButtonSize", 10); + + // Display verticals line on JTree + defaults.put("Tree.drawHorizontalLines", Boolean.TRUE); + defaults.put("Tree.drawVerticalLines", Boolean.TRUE); + defaults.put("Tree.showRootHandles", Boolean.TRUE); + defaults.put("Tree.leftChildIndent", 12); + defaults.put("Tree.rightChildIndent", 12); + defaults.put("Tree.scrollsOnExpand", Boolean.TRUE); + + } catch (Exception e) { + // could not find nimbus look-and-feel + log.warn(_("vradi.warning.nimbus.landf")); + } catch (Throwable e) { + log.warn(_("vradi.warning.no.ui")); + } + + // init date converters + Converter converter = ConverterUtil.getConverter(Date.class); + if (converter != null) { + ConvertUtils.deregister(Date.class); + + DateConverter dateConverter = new DateConverter(); + dateConverter.setUseLocaleFormat(true); + ConvertUtils.register(dateConverter, Date.class); + } + + // chargement de la configuration des uis + SwingUtil.loadUIConfig("/" + config.getConfigFileName(), null); + + // init service proxies + VradiService.initServiceProxies(config); + + // Init notifier + context.setContextValue(new VradiNotifier()); + + if (log.isDebugEnabled()) { + log.debug("init done in " + StringUtil.convertTime(t0, System.nanoTime())); + } + + return context; + } + + public static void initLocalesAvailables(DefaultI18nInitializer initializer) { + List<Locale> localesAvailables = new ArrayList<Locale>(); + try { + I18nBundle[] i18nBundles = initializer.resolvBundles(); + for (I18nBundle bundle : i18nBundles) { + for (Object aBundle : bundle) { + I18nBundleEntry entry = (I18nBundleEntry) aBundle; + Locale locale = entry.getLocale(); + localesAvailables.add(locale); + + log.info("Language found : " + locale.getLanguage()); + } + } + } catch (Exception e) { + log.error("failled to resolve i18n bundles"); + } + VradiContext.get().setLocalesAvailables(localesAvailables); + } + + public static class ShutdownHook extends Thread { + + public ShutdownHook() { + super("shutdown vradi"); + } + + @Override + public void run() { + try { + super.run(); + VradiContext.get().close(); + // force to kill main thread + + log.info(_("vradi.init.closed", new Date())); + Runtime.getRuntime().halt(0); + } catch (Exception ex) { + log.error("error while closing " + ex.getMessage(), ex); + ErrorDialogUI.showError(ex); + Runtime.getRuntime().halt(1); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiMain.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiNotifier.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiNotifier.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiNotifier.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,378 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.GroupFormsImpl; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.InfogeneImpl; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.RootThesaurusImpl; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.SendingImpl; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.SessionImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.StatusImpl; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.UserImpl; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.WebHarvestStreamImpl; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.entities.XmlStreamImpl; +import org.chorem.vradi.services.VradiService; +import org.nuiton.util.ListenerSet; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.BusinessEntityImpl; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.services.WikittyEvent; +import org.nuiton.wikitty.services.WikittyListener; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** @author sletellier */ +public class VradiNotifier implements WikittyListener { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiNotifier.class); + + protected enum BusinessEntitiesEnum { + CLIENT(Client.class, ClientImpl.class, Client.EXT_CLIENT), + GROUP(Group.class, GroupImpl.class, Group.EXT_GROUP), + USER(User.class, UserImpl.class, User.EXT_USER), + STATUS(Status.class, StatusImpl.class, Status.EXT_STATUS), + WEB_HARVEST_STREAM(WebHarvestStream.class, WebHarvestStreamImpl.class, WebHarvestStream.EXT_WEBHARVESTSTREAM), + XML_STREAM(XmlStream.class, XmlStreamImpl.class, XmlStream.EXT_XMLSTREAM), + FORM(Form.class, FormImpl.class, Form.EXT_FORM), + INFOGENE(Infogene.class, InfogeneImpl.class, Infogene.EXT_INFOGENE), + THESAURUS(Thesaurus.class, ThesaurusImpl.class, Thesaurus.EXT_THESAURUS), + ROOT_THESAURUS(RootThesaurus.class, RootThesaurusImpl.class, RootThesaurus.EXT_ROOTTHESAURUS), + SESSION(Session.class, SessionImpl.class, Session.EXT_SESSION), + SENDING(Sending.class, SendingImpl.class, Sending.EXT_SENDING), + GROUP_FORMS(GroupForms.class, GroupFormsImpl.class, GroupForms.EXT_GROUPFORMS); + + private Class<? extends BusinessEntity> beanClass; + + private Class<? extends BusinessEntityImpl> beanImplClass; + + private String ext; + + private BusinessEntitiesEnum(Class<? extends BusinessEntity> beanClass, Class<? extends BusinessEntityImpl> beanImplClass, String ext) { + this.ext = ext; + this.beanClass = beanClass; + this.beanImplClass = beanImplClass; + } + + public Class<? extends BusinessEntity> getBeanClass() { + return beanClass; + } + + private Class<? extends BusinessEntityImpl> getBeanImplClass() { + return beanImplClass; + } + + public String getExt() { + return ext; + } + + public static BusinessEntitiesEnum getValue(Class<? extends BusinessEntity> beanClass) { + for (BusinessEntitiesEnum constant : values()) { + if (beanClass.equals(constant.getBeanClass())) { + return constant; + } + } + return null; + } + + public static BusinessEntitiesEnum getValue(Wikitty wikitty) { + for (BusinessEntitiesEnum constant : values()) { + if (wikitty.hasExtension(constant.getExt())) { + return constant; + } + } + return null; + } + + public <C extends BusinessEntity> C getBusinessEntity(Class<C> classToConvert, Wikitty wikitty) { + + // try to find constructor with wikitty argument + Class<? extends BusinessEntityImpl> beanClass = getBeanImplClass(); + + C result = null; + try { + Constructor<?> cons = beanClass + .getConstructor(Wikitty.class); + result = (C) cons.newInstance(wikitty); + } catch (NoSuchMethodException eee) { + log.error("Failed to find constructor of '" + beanClass + "' : ", eee); + } catch (InstantiationException eee) { + log.error("Failed to instanciate '" + beanClass + "' : ", eee); + } catch (IllegalAccessException eee) { + log.error(eee); + } catch (InvocationTargetException eee) { + log.error(eee); + } + return result; + } + + public <C extends BusinessEntity> void addToMap( + Class<C> classToConvert, Map<BusinessEntitiesEnum, + Set<? extends BusinessEntity>> mapToAdd, Wikitty wikitty) { + + Set<C> listToAdd = (Set<C>) mapToAdd.get(this); + if (listToAdd == null) { + listToAdd = new HashSet<C>(); + mapToAdd.put(this, listToAdd); + } + + listToAdd.add(getBusinessEntity(classToConvert, wikitty)); + } + + } + + protected Map<BusinessEntitiesEnum, + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>>> entitiesListeners; + + protected ListenerSet<VradiExtensionsListener> extentionsListeners; + + public VradiNotifier() { + + entitiesListeners = new HashMap<BusinessEntitiesEnum, + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>>>(); + extentionsListeners = new ListenerSet<VradiExtensionsListener>(); + + // register each tree on wikitty service + VradiService.getWikittyService().addWikittyServiceListener(this, + WikittyService.ServiceListenerType.REMOTE); + } + + public <C extends BusinessEntity> void addVradiListener(Class<C> beanClass, VradiEntitiesListener<C> listener) { + BusinessEntitiesEnum businessEntitiesEnum = BusinessEntitiesEnum.getValue(beanClass); + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>> listenerList = entitiesListeners.get(businessEntitiesEnum); + if (listenerList == null) { + listenerList = new ListenerSet<VradiEntitiesListener<? extends BusinessEntity>>(); + + log.info("Add listener for enties " + businessEntitiesEnum + " class " + beanClass); + entitiesListeners.put(businessEntitiesEnum, listenerList); + } + listenerList.add(listener); + } + + public void addVradiListener(VradiExtensionsListener listener) { + extentionsListeners.add(listener); + } + + public <C extends BusinessEntity> void removeVradiEntitiesListener(Class<C> beanClass, VradiEntitiesListener<C> listener) { + BusinessEntitiesEnum businessEntitiesEnum = BusinessEntitiesEnum.getValue(beanClass); + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>> listenerList = entitiesListeners.get(businessEntitiesEnum); + if (listenerList == null) { + return; + } + listenerList.remove(listener); + } + + public void removeVradiExtensionsListener(VradiExtensionsListener listener) { + extentionsListeners.remove(listener); + } + + protected Map<BusinessEntitiesEnum, Set<? extends BusinessEntity>> extractEntities(WikittyEvent event) { + + Map<BusinessEntitiesEnum, Set<? extends BusinessEntity>> toNotify = + new HashMap<BusinessEntitiesEnum, Set<? extends BusinessEntity>>(); + + Map<String, Wikitty> wikittiesMap = event.getWikitties(); + + // Extract entities + if (wikittiesMap != null) { + for (Wikitty w : wikittiesMap.values()) { + BusinessEntitiesEnum businessEntitiesEnum = BusinessEntitiesEnum.getValue(w); + if (businessEntitiesEnum != null) { + businessEntitiesEnum.addToMap(businessEntitiesEnum.getBeanClass(), toNotify, w); + } + } + } + return toNotify; + } + + protected Set<WikittyExtension> extractExtensions(Map<String, WikittyExtension> extensionsMap) { + Set<WikittyExtension> extensions = new HashSet<WikittyExtension>(); + if (extensionsMap != null) { + for (WikittyExtension extension : extensionsMap.values()) { + if (extension.getFieldNames().contains(Form.EXT_FORM)) { + extensions.add(extension); + } + } + } + return extensions; + } + + + protected Set<String> extractDeletedIds(WikittyEvent event) { + Map<String, Date> removeDate = event.getRemoveDate(); + if (removeDate != null) { + return removeDate.keySet(); + } + return Collections.emptySet(); + } + + public void notifyAllAddEntities( + Map<BusinessEntitiesEnum, ListenerSet<VradiEntitiesListener<? extends BusinessEntity>>> listeners, + Map<BusinessEntitiesEnum, Set<? extends BusinessEntity>> toNotify) { + + for (BusinessEntitiesEnum businessEntitiesEnum : toNotify.keySet()) { + + Set<? extends BusinessEntity> entitiesToNotify = toNotify.get(businessEntitiesEnum); + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>> listernersToNotify = listeners.get(businessEntitiesEnum); + + notifyAllAddEntities(businessEntitiesEnum.getBeanClass(), listernersToNotify, entitiesToNotify); + + } + } + + protected <C extends BusinessEntity> void notifyAllAddEntities(Class<C> beanClass, + ListenerSet<VradiEntitiesListener<? extends BusinessEntity>> listernersToNotify, + Set<? extends BusinessEntity> entitiesToNotify) { + + if (log.isDebugEnabled()) { + log.debug("[VradiNotifier] notifyAllAddEntities of type : " + beanClass.getName()); + } + + if (listernersToNotify != null) { + for (VradiEntitiesListener<? extends BusinessEntity> listener : listernersToNotify) { + notifyAddEntities((VradiEntitiesListener<C>) listener, (Set<C>) entitiesToNotify); + } + } + } + + protected <C extends BusinessEntity> void notifyAddEntities(VradiEntitiesListener<C> listener, Set<C> entities) { + listener.entitiesAdded(entities); + } + + public void notifyAllRemoveEntities( + Map<BusinessEntitiesEnum, ListenerSet<VradiEntitiesListener<? extends BusinessEntity>>> listeners, + Set<String> toNotify) { + + for (ListenerSet<VradiEntitiesListener<? extends BusinessEntity>> listenerSet : listeners.values()) { + + for (VradiEntitiesListener<? extends BusinessEntity> listener : listenerSet) { + notifyRemoveEntities(listener, toNotify); + } + + } + } + + protected <C extends BusinessEntity> void notifyRemoveEntities(VradiEntitiesListener<C> listener, Set<String> removedIds) { + listener.entitiesRemoved(removedIds); + } + + public void notifyAllAddExtensions(ListenerSet<VradiExtensionsListener> listernersToNotify, Set<WikittyExtension> extensions) { + if (listernersToNotify != null) { + for (VradiExtensionsListener listener : listernersToNotify) { + notifyAddExtensions(listener, extensions); + } + } + } + + protected void notifyAddExtensions(VradiExtensionsListener listener, Set<WikittyExtension> extensions) { + listener.extensionsAdded(extensions); + } + + public void notifyAllRemoveExtensions(ListenerSet<VradiExtensionsListener> listernersToNotify, Set<String> extensionsIds) { + if (listernersToNotify != null) { + for (VradiExtensionsListener listener : listernersToNotify) { + notifyRemoveExtensions(listener, extensionsIds); + } + } + } + + protected void notifyRemoveExtensions(VradiExtensionsListener listener, Set<String> extensionsIds) { + listener.extensionsRemoved(extensionsIds); + } + + @Override + public void putWikitty(WikittyEvent event) { + + if (log.isDebugEnabled()) { + log.debug("[VradiNotifier] Put wikitty"); + } + + Map<BusinessEntitiesEnum, Set<? extends BusinessEntity>> toNotify = extractEntities(event); + + notifyAllAddEntities(entitiesListeners, toNotify); + } + + @Override + public void removeWikitty(WikittyEvent event) { + + if (log.isDebugEnabled()) { + log.debug("[VradiNotifier] Remove wikitty"); + } + + Set<String> toNotify = extractDeletedIds(event); + + notifyAllRemoveEntities(entitiesListeners, toNotify); + } + + @Override + public void clearWikitty(WikittyEvent event) { + // Never append in vradi + } + + @Override + public void putExtension(WikittyEvent event) { + Set<WikittyExtension> extensions = extractExtensions(event.getExtensions()); + notifyAllAddExtensions(extentionsListeners, extensions); + } + + @Override + public void removeExtension(WikittyEvent event) { + Set<String> extensionsIds = event.getDeletedExtensions(); + notifyAllRemoveExtensions(extentionsListeners, extensionsIds); + } + + @Override + public void clearExtension(WikittyEvent event) { + // Never append in vradi + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/VradiNotifier.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,207 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import com.caucho.hessian.client.HessianProxyFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConfig; +import org.chorem.vradi.VradiConfigHelper; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyServiceFactory; + +import java.net.MalformedURLException; + +/** + * Vradi service management. + * <p/> + * Can handle embedded server or remote hessian service. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 18 févr. 2010 17:33:03 + */ +public class VradiService { + + /** log. */ + private static final Log log = LogFactory.getLog(VradiService.class); + + /** Wikitty service, used to add cache listener. */ + protected static WikittyService wikittyService; + + /** Wikitty proxy on cached service. */ + protected static WikittyProxy wikittyProxy; + + /** Vradi management service. */ + protected static VradiStorageService vradiStorageService; + + /** Local version to use local {{@link #wikittyProxy}. */ + protected static VradiDataService vradiDataService; + + /** File service. */ + protected static FileService fileService; + + /** + * Init all service proxies. + * + * @param configuration configuration + */ + public static void initServiceProxies(VradiConfig configuration) { + + String serviceEndpoint = VradiConfigHelper.getRemoteEndpoint(configuration); + + // check is it's valid url + if (serviceEndpoint != null && serviceEndpoint.startsWith("http://")) { + if (log.isInfoEnabled()) { + log.info("Use remote mode with url : " + serviceEndpoint); + } + + HessianProxyFactory factory = new HessianProxyFactory(); + // Fix : com.caucho.hessian.io.HessianProtocolException: '���' is an unknown code + factory.setHessian2Request(true); + // pour que les méthodes aux noms dupliquées fonctionnent (arguments different) + factory.setOverloadEnabled(true); + + try { + + // vradi service + vradiStorageService = (VradiStorageService) factory.create(VradiStorageService.class, + getServiceURL(serviceEndpoint, "vradiservice")); + + wikittyService = initLocalWikittyService(configuration); + + // file service + fileService = new FileServiceProxy(getServiceURL(serviceEndpoint, "file")); + + } catch (MalformedURLException eee) { + if (log.isErrorEnabled()) { + log.error("Can't init remote proxy", eee); + } + } + } else { + if (log.isWarnEnabled()) { + log.warn("Can't parse remote serveur endpoint as valid url (" + serviceEndpoint + ")"); + log.warn("Use local embedded mode"); + } + + vradiStorageService = new VradiStorageServiceImpl(); + wikittyService = ServiceFactory.getWikittyService(configuration); + fileService = new FileServiceImpl(); + } + + // wrap service local/remote to a proxy + wikittyProxy = new WikittyProxy(); + wikittyProxy.setWikittyService(wikittyService); + + // init data service on local cached wikitty proxy + vradiDataService = new VradiDataServiceImpl(wikittyProxy); + } + + /** + * Create a new wikitty service with cache support that use + * provided WikittyService for non cached data. + * + * @param wikittyServiceRemote remote wikitty service + * @param configuration vradi server configuration + * @return local wikitty service + */ + protected static WikittyService initLocalWikittyService(ApplicationConfig configuration) { + + log.info("Propagation event is set to : " + VradiConfigHelper.getWikittyEventPropagate(configuration)); + log.info("XMPP server is set to : " + VradiConfigHelper.getWikittyEventTransporterXMPPServer(configuration)); + log.info("XMPP room is set to : " + VradiConfigHelper.getWikittyEventTransporterXMPPRoom(configuration)); + + WikittyService wikittyServiceLocal = WikittyServiceFactory.buildWikittyService(configuration); + return wikittyServiceLocal; + } + + /** + * Get service full url. + * + * @param serviceEndpoint end point (can't be null) + * @param serviceEndUrl service small name + * @return service full url + */ + protected static String getServiceURL(String serviceEndpoint, String serviceEndUrl) { + String fullUrl = serviceEndpoint; + + // Warn hessian won't work with double / + if (!fullUrl.endsWith("/")) { + fullUrl += "/"; + } + fullUrl += serviceEndUrl; + return fullUrl; + } + + /** + * Get remote vradi service (execute code on server).s + * + * @return vradi storage service proxy + */ + public static VradiStorageService getVradiStorageService() { + return vradiStorageService; + } + + /** + * Get local vradi service (use local chached wikitty proxy). + * + * @return local vradi data service proxy + */ + public static VradiDataService getVradiDataService() { + return vradiDataService; + } + + /** + * Get wikitty service proxy. + * <p/> + * This wikitty service instance is cached and use a remote + * wikitty service (also cached) for non available data. + * + * @return wikitty service proxy + */ + public static WikittyProxy getWikittyProxy() { + return wikittyProxy; + } + + /** + * Get wikitty service (only use it to add listener on cache). + * + * @return wikitty service + */ + public static WikittyService getWikittyService() { + return wikittyService; + } + + /** + * Get file service proxy. + * + * @return file service + */ + public static FileService getFileService() { + return fileService; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/VradiService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/package-info.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/services/package-info.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/services/package-info.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,28 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +/** + * Vradi service helper and proxies. + */ +package org.chorem.vradi.services; \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/services/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,120 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConfig; +import org.chorem.vradi.VradiConfigHelper; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +public class ChangeLogHandler { + + private static Log log = LogFactory.getLog(ChangeLogHandler.class); + + public static final String CHANGELOG_FILE = "/changelog.txt"; + + public static final String CHANGELOG_VERSION_SEPARATOR = "---- "; + + public String getLatestChangeLog() { + String content = loadSource(); + String[] versionChangeLogs = content.split(CHANGELOG_VERSION_SEPARATOR); + String lastVersion = ""; + if (versionChangeLogs.length > 0) { + lastVersion = versionChangeLogs[0]; + if (log.isDebugEnabled()) { + log.debug(lastVersion); + } + lastVersion = lastVersion.replace(CHANGELOG_VERSION_SEPARATOR.substring(1), ""); + String[] lastVersionArray = lastVersion.split("\\s"); + if (lastVersionArray.length > 0) { + lastVersion = lastVersionArray[0].trim(); + } else { + lastVersion = ""; + } + } + log.debug(lastVersion); + return versionChangeLogs[0]; + } + + public String getChangeLog() { + StringBuffer result = new StringBuffer(); + String content = loadSource(); + if (content != null) { + String[] versionChangeLogs = content.split(CHANGELOG_VERSION_SEPARATOR); + + versionChangeLogs = removeFirstEmptyLines(versionChangeLogs); + + String lastVersion = versionChangeLogs[0] + .replace(CHANGELOG_VERSION_SEPARATOR.substring(1), "") + .split("\\s")[0].trim(); + if (VradiHelper.isVersionNewer(lastVersion)) { + result.append(versionChangeLogs[0]); + for (int i = 1; i < versionChangeLogs.length; i++) { + log.debug(versionChangeLogs[i]); + String version = versionChangeLogs[i].split("\\s")[0].trim(); + if (VradiHelper.isVersionNewer(version)) { + result.append(CHANGELOG_VERSION_SEPARATOR) + .append(versionChangeLogs[i]); + } else { + break; + } + } + } + VradiConfig config = VradiContext.get().getVradiConfig(); + VradiConfigHelper.setLastVersion(config, lastVersion); + config.saveForUser(); + } + + return result.toString(); + } + + protected String[] removeFirstEmptyLines(String[] versionChangeLogs) { + for (String versionChangeLog : Arrays.asList(versionChangeLogs)) { + if (StringUtils.isBlank(versionChangeLog)) { + versionChangeLogs = Arrays.copyOfRange(versionChangeLogs, 1, versionChangeLogs.length); + } + } + return versionChangeLogs; + } + + public String loadSource() { + try { + InputStream changelogFile = getClass().getResourceAsStream(CHANGELOG_FILE); + String result = IOUtils.toString(changelogFile); + return result; + } catch (IOException ex) { + log.error("could not load file " + CHANGELOG_FILE, ex); + return null; + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,50 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='changeLogUI' + title='vradi.changelog.title' + modal='true' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='dispose()' + width='800' + height='600'> + + <import> + java.awt.Font + </import> + + <JScrollPane id='changeLogPanel' + constructorParams='JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED' + border='{null}'> + + <JTextArea id='content' + font='{new Font(Font.MONOSPACED, Font.PLAIN, 11)}' + editable='false' + wrapStyleWord='false' + columns='60' + lineWrap='true' + caretPosition='0'/> + </JScrollPane> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/ChangeLogUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.css =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.css (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.css 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,507 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +JToolBar { + borderPainted: false; + floatable: false; + opaque: false; +} + +JSplitPane { + oneTouchExpandable: true; + continuousLayout: true; + dividerSize: 12; +} + +JLabel.title { + +horizontalTextPosition: { + JLabel . CENTER +} + +; +horizontalAlignment: { + javax . swing . SwingConstants . CENTER +} + +; +font-size: + +20 +; +font-weight:bold + +; +/*font: {new Font("Serif", Font.BOLD, 26)};*/ + } + +JLabel.titleLeft { + +horizontalTextPosition: { + JLabel . LEFT +} + +; +horizontalAlignment: { + javax . swing . SwingConstants . LEFT +} + +; +font-size: + +20 +; +font-weight:bold + +; +/*font: {new Font("Serif", Font.BOLD, 26)};*/ + } + +JLabel.titleRight { + +horizontalTextPosition: { + JLabel . RIGHT +} + +; +horizontalAlignment: { + javax . swing . SwingConstants . RIGHT +} + +; +font-size: + +20 +; +font-weight:bold + +; +/*font: {new Font("Serif", Font.BOLD, 26)};*/ + } + +#mainFrame { + title: "vradi.title.welcome"; + defaultCloseOperation: "do_nothing_on_close"; /*iconImage:{createImageIcon("logo-OT_web.png").getImage()};*/ +} + +#menu { + +_help: { +"ui.main.menu" +} + +; + } + +#menuFile { + text: "vradi.menu.file"; + mnemonic: F; + +_help: { +"ui.main.menu.file" +} + +; + } + +#menuShowOfferListUI { + text: "vradi.menu.file.offerList"; + mnemonic: O; + +_help: { +"ui.main.menu.file.offerList" +} + +; + } + +#menuFileConfiguration { + text: "vradi.action.configuration"; + toolTipText: "vradi.action.configuration.tip"; + actionIcon: "config"; + mnemonic: C; + +_help: { +"ui.main.menu.file.configuration" +} + +; + } + +#menuFileLanguage { + text: "vradi.menu.file.locale"; + toolTipText: "vradi.menu.file.locale"; + actionIcon: "translate"; + mnemonic: C; + +_help: { +"ui.main.menu.file.locale" +} + +; + } + +#menuFileLanguageFR { + text: "vradi.action.locale.fr"; + toolTipText: "vradi.action.locale.fr.tip"; + actionIcon: "i18n-fr"; + +enabled: { + ! acceptLocale(VradiConfigHelper.getLocale(getConfig()), "fr_FR") +} + +; +_help: { +"ui.main.menu.file.locale.fr" +} + +; + } + +#menuFileLanguageUK { + text: "vradi.action.locale.uk"; + toolTipText: "vradi.action.locale.uk.tip"; + actionIcon: "i18n-uk"; + +enabled: { + ! acceptLocale(VradiConfigHelper.getLocale(getConfig()), "en_GB") +} + +; +mnemonic:U + +; +_help: { +"ui.main.menu.file.locale.uk" +} + +; + } + +#menuFileFullscreen { + text: "vradi.action.fullscreen"; + toolTipText: "vradi.action.fullscreen.tip"; + actionIcon: "fullscreen"; + mnemonic: P; + +visible: { + ! isUndecorated() +} + +; +_help: { +"ui.main.menu.file.fullscreen" +} + +; + } + +#menuFileNormalscreen { + text: "vradi.action.normalscreen"; + toolTipText: "vradi.action.normalscreen.tip"; + actionIcon: "leave-fullscreen"; + mnemonic: N; + +visible: { +isUndecorated ( ) +} + +; +_help: { +"ui.main.menu.file.leave-fullscreen" +} + +; + } + +#menuFileExit { + text: "vradi.action.exit"; + toolTipText: "vradi.action.exit.tip"; + actionIcon: "exit"; + mnemonic: X; + +_help: { +"ui.main.menu.file.exit" +} + +; + } + +#menuForm { + text: "vradi.menu.form"; + mnemonic: M; + +_help: { +"ui.main.menu.form" +} + +; + } + +#menuActions { + text: "vradi.menu.actions"; + mnemonic: A; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdmin { + text: "vradi.menu.admin"; + mnemonic: A; + +_help: { +"ui.main.menu.file" +} + +; + } + +#menuAdminClient { + text: "vradi.menu.client"; + mnemonic: C; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdminGroup { + text: "vradi.menu.group"; + mnemonic: G; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdminForm { + text: "vradi.menu.formType"; + mnemonic: F; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdminXmlStream { + text: "vradi.menu.xmlStream"; + mnemonic: X; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdminStatus { + text: "vradi.menu.status"; + mnemonic: S; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuAdminThesaurus { + text: "vradi.menu.thesaurus"; + mnemonic: T; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuEmail { + text: "vradi.menu.email"; + mnemonic: E; + +_help: { +"ui.main.menu.file" +} + +; + } + +#menuAdminEmail { + text: "vradi.menu.email.admin"; + mnemonic: C; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuImportExport { + text: "vradi.menu.importExport"; + mnemonic: I; + +_help: { +"ui.main.menu.file" +} + +; + } + +#menuExport { + text: "vradi.menu.importExport.export"; + mnemonic: E; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuImport { + text: "vradi.menu.importExport.import"; + mnemonic: I; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuReindex { + text: "vradi.menu.importExport.reindex"; + mnemonic: R; + +_help: { +"ui.main.menu.action" +} + +; + } + +#menuHelp { + text: "vradi.menu.help"; + mnemonic: e; + +_help: { +"ui.main.menu.help" +} + +; + } + +#menuHelpHelp { + text: "vradi.action.help"; + toolTipText: "vradi.action.help.tip"; + actionIcon: "help"; + mnemonic: e; + +_help: { +"ui.main.menu.help.help" +} + +; + } + +#menuHelpSite { + text: "vradi.action.site"; + toolTipText: "vradi.action.site.tip"; + actionIcon: "site"; + mnemonic: s; + +_help: { +"ui.main.menu.help.site" +} + +; + } + +#menuHelpAbout { + text: "vradi.action.about"; + toolTipText: "vradi.action.about.tip"; + actionIcon: "about"; + mnemonic: A; + +_help: { +"ui.main.menu.help.about" +} + +; + } + +#menuDebug { + text: "vradi.menu.debug"; +} + +#menuDebugStat { + text: "vradi.action.stat"; +} + +#closeTab { + actionIcon: "closeTab"; + borderPainted: false; + rolloverEnabled: false; + focusable: false; + toolTipText: "vradi.action.quitHelp.tip"; + +_help: { +"ui.main.body.help.closeTab" +} + +; + } + +/* FIXME : ne fonctionne pas avec la statusMessagePanel... +#status { + _help:{"ui.main.statusBar"}; +}*/ + +#toolbar { + +layout: { + new BoxLayout(toolbar, 0) +} + +; +_help: { +"ui.main.toolbar" +} + +; + } + + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,162 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JFrame id='mainFrame' + decorator='help' + undecorated='{VradiConfigHelper.isFullScreen(getConfig())}'> + + <style source='VradiMainUI.css'/> + + <import> + java.util.Locale + org.chorem.vradi.ui.models.FormMenu + org.chorem.vradi.VradiConfigHelper + org.chorem.vradi.VradiConfig + </import> + + <script><![CDATA[ +VradiConfig getConfig() { + return getContextValue(VradiConfig.class); +} + +public VradiMainUIHandler getHandler() { + return getContextValue(VradiMainUIHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public boolean acceptLocale(Locale l, String expected) { + return l != null && l.toString().equals(expected); +} + +void $afterCompleteSetup() { + //getBroker().setHandler(getHandler()); + getMenuDebug().setVisible(VradiConfigHelper.isSwingDebug(getConfig())); +} +]]> + </script> + + <!-- menu --> + <JMenuBar id='menu'> + + <JMenu id='menuFile'> + <JMenuItem id='menuShowOfferListUI' + onActionPerformed="getHandler().showOfferListUI(this)"/> + <JSeparator/> + <JMenuItem id='menuFileConfiguration' + onActionPerformed="getHandler().showConfig(this)"/> + <JMenu id='menuFileLanguage'> + <!--JMenuItem id='menuFileLanguageFR' + onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/> +<JMenuItem id='menuFileLanguageUK' + onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/--> + + </JMenu> + <JSeparator/> + <JMenuItem id='menuFileFullscreen' + onActionPerformed="getHandler().changeScreen(this, true)"/> + <JMenuItem id='menuFileNormalscreen' + onActionPerformed="getHandler().changeScreen(this, false)"/> + <JSeparator/> + <JMenuItem id='menuFileExit' + onActionPerformed="getHandler().close(mainFrame)"/> + </JMenu> + + <FormMenu id='menuForm' constructorParams='getHandler()'/> + + <JMenu id='menuAdmin'> + <JMenuItem id='menuAdminClient' + onActionPerformed="getHandler().showAdminClient(this)"/> + <JMenuItem id='menuAdminGroup' + onActionPerformed="getHandler().showAdminGroup(this)"/> + <JMenuItem id='menuAdminForm' + onActionPerformed="getHandler().showAdminForm(this)"/> + <JMenuItem id='menuAdminXmlStream' + onActionPerformed="getHandler().showAdminXmlStream(this)"/> + <JMenuItem id='menuAdminStatus' + onActionPerformed="getHandler().showAdminStatus(this)"/> + <JMenuItem id='menuAdminThesaurus' + onActionPerformed="getHandler().showAdminThesaurus(this)"/> + </JMenu> + + <JMenu id='menuEmail'> + <JMenuItem id='menuAdminEmail' + onActionPerformed="getHandler().showEmail(this)"/> + </JMenu> + + <!-- + <JMenu id='menuImportExport'> + <JMenuItem id='menuExport' + onActionPerformed="getHandler().showExport(this)"/> + <JMenuItem id='menuImport' + onActionPerformed="getHandler().showImport(this)"/> + <JMenuItem id='menuReindex' + onActionPerformed="getHandler().showReindex(this)"/> + </JMenu> + --> + + <JMenu id='menuHelp'> + <JMenuItem id='menuHelpHelp' + onActionPerformed="getHandler().showHelp(this, null)"/> + <JMenuItem id='menuHelpSite' + onActionPerformed="getHandler().gotoSite(this)"/> + <JMenuItem id='menuHelpAbout' + onActionPerformed="getHandler().showAbout(this)"/> + </JMenu> + + + <JMenu id='menuDebug'> + <JMenuItem id='menuDebugStat' + onActionPerformed="getHandler().showStat(this)"/> + </JMenu> + + <!--<JToolBar id='toolbar' + _help='"ui.main.toolbar"'> + + pour afficher l'aide contextuelle + <JButton id='showHelp'/> + + <javax.swing.Box.Filler constructorParams='UIHelper.newMinDimension(), UIHelper.newMinDimension(), UIHelper.newMaxXDimension()'/> + </JToolBar>--> + + </JMenuBar> + + <!-- contenu principal --> + + <!--JPanel id='body' constraints="BorderLayout.CENTER" layout='{new BorderLayout()}'> + + <JLabel text='vradi.hello' horizontalAlignment='center' + verticalAlignment='center' constraints="BorderLayout.CENTER"/> + + </JPanel--> + + <JPanel id="content"/> + + <!-- status message bar --> + <jaxx.runtime.swing.StatusMessagePanel id='status' + _help='"ui.main.statusBar"' + constraints="BorderLayout.SOUTH"/> +</JFrame> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,577 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.DefaultApplicationContext.AutoLoad; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.AboutPanel; +import jaxx.runtime.swing.ErrorDialogUI; +import jaxx.runtime.swing.editor.config.ConfigUIHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConfig; +import org.chorem.vradi.VradiConfigHelper; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.admin.AdminPopupUI; +import org.chorem.vradi.ui.email.EmailHandler; +import org.chorem.vradi.ui.email.EmailPopupUI; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.OfferEditHandler; +import org.chorem.vradi.ui.offer.OfferListHandler; +import org.chorem.vradi.ui.offer.OfferListUI; +import org.chorem.vradi.ui.task.VradiTask; +import org.nuiton.i18n.I18n; +import org.nuiton.util.TimeLog; +import org.nuiton.widget.SwingSession; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.net.URL; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * Le handler de l'ui principale. + * + * @author chemit + * @see VradiMainUI + */ +@AutoLoad +public class VradiMainUIHandler { //implements JAXXHelp { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(VradiMainUIHandler.class); + + static public final String XML_FILE_EXTENSION = ".xml"; + + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param rootContext le context applicatif + * @param fullscreen flag pour indiquer si on doit ouvrir l'ui en model console (pleine ecran). + * @return l'ui instancie et initialisee mais non visible encore + */ + public VradiMainUI initUI(JAXXContext rootContext, boolean fullscreen) { + + JAXXInitialContext context = new JAXXInitialContext().add(rootContext); + + // Init swingSession + VradiConfig config = VradiContext.get().getVradiConfig(); + SwingSession swingSession = new SwingSession(VradiConfigHelper.getSwingConfigFile(config), false); + VradiContext.SWING_SESSION_ENTRY_DEF.setContextValue(VradiContext.get(), swingSession); + + // show main ui + VradiMainUI ui = new VradiMainUI(context); + + // Init locales selections in main ui + initLocalesMenu(ui); + + VradiContext.MAIN_UI_ENTRY_DEF.setContextValue(VradiContext.get(), ui); + + ErrorDialogUI.init(ui); + + // set fullscreen propery on main ui + if (fullscreen) { + ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(ui); + } + + // init home screen + OfferListHandler handler = UIHelper.getHandler(context, OfferListHandler.class); + + OfferListUI content = handler.initUI(ui); + + ui.setContentPane(content); + + ui.pack(); + + ui.setVisible(true); + + // Add this frame + swingSession.add(ui); + swingSession.save(); + + // Saved in context + VradiContext.OFFERT_LIST_UI_ENTRY_DEF.setContextValue(VradiContext.get(), content); + + // Must be always hide on init + content.setDividerLocation(Integer.MAX_VALUE); + content.setDividerSize(0); + + return ui; + } + + public void initLocalesMenu(final VradiMainUI ui) { + JMenu menuFileLanguages = ui.getMenuFileLanguage(); + List<Locale> localesAvailables = VradiContext.get().getLocalesAvailables(); + for (final Locale locale : localesAvailables) { + String language = locale.getLanguage(); + Icon menuFileLanguageIcon = SwingUtil.getUIManagerActionIcon("i18n-" + language); + JMenuItem menuFileLanguage = new JMenuItem(_("vradi.action.locale." + language), menuFileLanguageIcon); + menuFileLanguage.setToolTipText(_("vradi.action.locale." + language + ".tip")); + VradiConfig config = VradiContext.get().getVradiConfig(); + menuFileLanguage.setEnabled(!acceptLocale(VradiConfigHelper.getLocale(config), "fr_FR")); + menuFileLanguage.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + changeLanguage(ui, locale); + } + }); + menuFileLanguages.add(menuFileLanguage); + } + } + + public boolean acceptLocale(Locale l, String expected) { + return l != null && l.toString().equals(expected); + } + + public void changeContent(JAXXContext context, JComponent content) { + VradiMainUI ui = getUI(context); + ui.setContentPane(content); + ui.setVisible(true); + } + + public void edit(JAXXContext context, Form data) { + OfferEditHandler handler = UIHelper.getHandler(context, OfferEditHandler.class); + changeContent(VradiContext.get(), handler.initUI(context, data.getWikittyId())); + } + + public void goToHome(JAXXContext context) { + OfferListHandler handler = UIHelper.getHandler(context, OfferListHandler.class); + changeContent(context, handler.initUI(context)); + } + + public void changeLanguage(VradiMainUI mainUI, Locale newLocale) { + VradiConfig config = mainUI.getConfig(); + // sauvegarde de la nouvelle locale + VradiConfigHelper.setLocale(config, newLocale); + // chargement de la nouvelle locale dans le système i18n + I18n.setDefaultLocale(newLocale); + // on recharge les decorateurs + //DecoratorProvider decoratorProvider = mainUI.getContextValue(DecoratorProvider.class); + //decoratorProvider.reloadCache(); + // on recharge l'ui + reloadUI(VradiContext.get(), VradiConfigHelper.isFullScreen(config)); + } + + /** + * Ferme l'application. + * + * @param ui l'ui principale de l'application + */ + public void close(VradiMainUI ui) { + log.info("Vradi quitting..."); + + // Close all tabs before save + UIHelper.getHandler(ui, OfferListHandler.class).closeAllTabs(); + + // Store session configuration + UIHelper.saveComponentDispositionConfig(); + + boolean canContinue = ensureModification(ui); + if (!canContinue) { + return; + } + try { + ui.dispose(); + } finally { + System.exit(0); + } + } + + /** + * Méthode pour changer de mode d'affichage. + * <p/> + * Si <code>fullscreen</code> est à <code>true</code> alors on passe en + * mode console (c'est à dire en mode plein écran exclusif), sinon on + * passe en mode fenetré normal. + * + * @param ui l'ui principale de l'application + * @param fullscreen le nouvel état requis. + */ + public void changeScreen(VradiMainUI ui, boolean fullscreen) { + boolean canContinue = ensureModification(ui); + if (!canContinue) { + return; + } + VradiConfigHelper.setFullscreen(ui.getConfig(), fullscreen); + + reloadUI(VradiContext.get(), fullscreen); + } + + /** + * Open admin popups and set specified selected tab index. + * + * @param rootContext + * @param tabIndex selected tab index + */ + protected void openAdminPopup(VradiMainUI rootContext, int tabIndex) { + AdminHandler handler = UIHelper.getHandler(rootContext, AdminHandler.class); + AdminPopupUI ui = handler.init(rootContext); + + ui.showTab(tabIndex); + ui.setLocationRelativeTo(rootContext); + ui.setVisible(true); + } + + protected void openEmailPopup(VradiMainUI rootContext) { + EmailPopupUI ui = UIHelper.getHandler(rootContext, EmailHandler.class).init(rootContext); + ui.setLocationRelativeTo(rootContext); + ui.setVisible(true); + } + + public void showAdminClient(VradiMainUI context) { + openAdminPopup(context, 0); + } + + public void showAdminGroup(VradiMainUI context) { + openAdminPopup(context, 1); + } + + public void showAdminForm(VradiMainUI context) { + openAdminPopup(context, 2); + } + + public void showAdminXmlStream(VradiMainUI context) { + openAdminPopup(context, 3); + } + + public void showAdminThesaurus(VradiMainUI context) { + openAdminPopup(context, 5); + } + + public void showAdminStatus(VradiMainUI context) { + openAdminPopup(context, 4); + } + + public void showEmail(VradiMainUI context) { + openEmailPopup(context); + } + + /*public void showExport(JAXXContext rootContext) { + final VradiMainUI mainUI = getUI(rootContext); + final File file = UIHelper.openFileChooser(XML_FILE_EXTENSION, "vradi.export.filter.xml", mainUI, "vradi.export.validate.label"); + + if (file != null) { + VradiTask<Void> task = new VradiTask<Void>(mainUI) { + + @Override + public Void doAction() throws Exception { + String s = VradiService.getVradiStorageService().exportData(); + FileUtil.writeString(file, s, "UTF-8"); + return null; + } + }; + task.execute(); + } + } + + public void showImport(JAXXContext rootContext) { + final VradiMainUI mainUI = getUI(rootContext); + final File file = UIHelper.openFileChooser(XML_FILE_EXTENSION, "vradi.export.filter.xml", mainUI, "vradi.import.validate.label"); + if (file != null) { + VradiTask<Void> task = new VradiTask<Void>(mainUI) { + + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().importData(file); + return null; + } + }; + task.execute(); + } + + }*/ + + public void showReindex(JAXXContext rootContext) { + final VradiMainUI mainUI = getUI(rootContext); + mainUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + int answer = JOptionPane.showConfirmDialog(mainUI, _("vradi.reindex.message"), _("vradi.reindex.title"), + JOptionPane.YES_NO_OPTION); + if (answer == JOptionPane.YES_OPTION) { + VradiTask<Void> task = new VradiTask<Void>(mainUI) { + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().reindexData(); + return null; + } + }; + task.execute(); + } + } + + public void showOfferListUI(JAXXContext context) { + final JFrame offerListFrame = new JFrame(_("vradi.title.welcome")); + + offerListFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + offerListFrame.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosing(WindowEvent e) { + UIHelper.saveComponentDispositionConfig(); + offerListFrame.dispose(); + } + }); + UIHelper.registerComponentToSaveDispositionConfig(offerListFrame); + + // init home screen + OfferListHandler handler = UIHelper.getHandler(context, OfferListHandler.class); + OfferListUI ui = handler.initUI(context); + offerListFrame.setContentPane(ui); + offerListFrame.pack(); + offerListFrame.setVisible(true); + } + + public void showConfig(JAXXContext context) { + VradiMainUI ui = getUI(context); + VradiConfig config = context.getContextValue(VradiConfig.class); + + // categorie repertoires + ConfigUIHelper modelBuilder = new ConfigUIHelper(config); + + // category 1 + modelBuilder.addCategory(n_("vradi.config.category.directories"), + n_("vradi.config.category.directories.description")); + modelBuilder.addOption(VradiConfig.VradiSwingOption.CONFIG_FILE); + + // category 2 + modelBuilder.addCategory(n_("vradi.config.category.other"), + n_("vradi.config.category.other.description")); + modelBuilder.addOption(VradiConfig.VradiSwingOption.FULL_SCREEN); + modelBuilder.addOption(VradiConfig.VradiSwingOption.LOCALE); + + // category 3 + modelBuilder.addCategory(n_("vradi.config.category.remote"), + n_("vradi.config.category.remote.description")); + modelBuilder.addOption(VradiConfig.VradiSwingOption.REMOTE_ENDPOINT); + + modelBuilder.buildUI(context, "vradi.config.category.directories"); + + modelBuilder.displayUI(ui, false); + } + + // @Override + public void showHelp(JAXXContext context, String helpId) { +// VradiMainUI mainUI = getUI(context); +// +// ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class); +// +// if (helpId == null) { +// helpId = helpBroker.getDefaultID(); +// } +// log.debug("show help " + helpId); +// mainUI.getHelp().setCurrentID(helpId); +// +// mainUI.setContextValue(mainUI.getMode(), "oldMode"); +// mainUI.setMode(ObserveUIMode.HELP); + } + + public void closeHelp(JAXXContext context) { +// VradiMainUI mainUI = getUI(context); +// ObserveUIMode oldMode = mainUI.getContextValue(ObserveUIMode.class, "oldMode"); +// if (oldMode == null) { +// // on regarde si une base est chargee +// ObserveDataContext dataContext = context.getContextValue(ObserveDataContext.class); +// StorageService<?> mainStorage = dataContext.getStorage(); +// +// if (mainStorage == null) { +// oldMode = ObserveUIMode.NO_DB; +// } else { +// oldMode = ObserveUIMode.DB; +// } +// } +// mainUI.setMode(oldMode); + } + + public void gotoSite(JAXXContext rootContext) { + + VradiConfig config = rootContext.getContextValue(VradiConfig.class); + + URL siteURL = config.getOptionAsURL("application.site.url"); + +// UIHelper.displayInfo(rootContext, _("vradi.message.goto.site", siteURL)); + + log.debug("goto " + siteURL); + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { + try { + Desktop.getDesktop().browse(siteURL.toURI()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + ErrorDialogUI.showError(ex); + } + } + } + + public void showAbout(VradiMainUI ui) { + AboutPanel about = new AboutPanel() { + + private static final long serialVersionUID = 1L; + +// @Override +// public void buildTopPanel() { +// topPanel.setLayout(new BorderLayout()); +// JLabel labelIcon; +// Icon logoIcon; +// logoIcon = Resource.getIcon("/icons/logo-OT_web.png"); +// labelIcon = new JLabel(logoIcon); +// topPanel.add(labelIcon, BorderLayout.WEST); +// +// logoIcon = Resource.getIcon("/icons/logo_ird.png"); +// labelIcon = new JLabel(logoIcon); +// topPanel.add(labelIcon, BorderLayout.EAST); +// } + }; + + about.setTitle(_("vradi.title.about")); + ChangeLogHandler clh = UIHelper.getHandler(ui, ChangeLogHandler.class); + about.setAboutText(clh.getLatestChangeLog()); + + String copyright = VradiConfigHelper.getCopyrightText(ui.getConfig()); + about.setBottomText(copyright); +// about.setIconPath("/icons/logo-OT_web.png"); + about.setLicenseFile("META-INF/vradi-swing-LICENSE.txt"); + about.setThirdpartyFile("META-INF/vradi-swing-THIRD-PARTY.txt"); + about.init(); + about.showInDialog(ui, true); + } + + public void showStat(VradiMainUI ui) { + String msg = "Proxy call statistics\n"; + for (Map.Entry<String, TimeLog.CallStat> e : WikittyProxy.getCallCount().entrySet()) { + msg += "\n\t" + e.getKey() + " = " + e.getValue(); + } + if (log.isInfoEnabled()) { + log.info(msg); + } + JOptionPane.showMessageDialog(ui, msg); + } + + /** + * Permet de recharger l'ui principale et de changer de le mode d'affichage. + * + * @param rootContext le contexte applicatif + * @param fullscreen le type de fenetre à reouvrir + */ + protected void reloadUI(VradiContext rootContext, boolean fullscreen) { + + // must remove all properties listener on config + rootContext.getContextValue(VradiConfig.class).removeJaxxPropertyChangeListener(); + + // scan main ui + VradiMainUI ui = getUI(rootContext); + + if (ui != null) { + + ErrorDialogUI.init(null); + + VradiContext.MAIN_UI_ENTRY_DEF.removeContextValue(rootContext); + VradiContext.ADMIN_UI_ENTRY_DEF.removeContextValue(rootContext); + + ui.dispose(); + + ui.setVisible(false); + } + + ui = initUI(rootContext, fullscreen); + + // show ui + ui.setVisible(true); + } + + /** + * Test if there is some modification on screen, + * + * @param rootContext the context + * @return <code>true</code> if no more modification is detected + * @throws IllegalArgumentException if rootContext is null + */ + protected boolean ensureModification(JAXXContext rootContext) throws IllegalArgumentException { + if (rootContext == null) { + throw new IllegalArgumentException("rootContext can not be null"); + } + VradiMainUI ui = getUI(rootContext); + if (ui == null) { + // no ui, so no modification + return true; + } + // check ui is not modified + return true; + } + + VradiMainUI getUI(JAXXContext context) { + if (context instanceof VradiMainUI) { + return (VradiMainUI) context; + } + VradiMainUI ui = VradiContext.MAIN_UI_ENTRY_DEF.getContextValue(context); + return ui; + } + + + public void createForm(WikittyExtension extension) { + OfferListUI ui = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + + if (ui != null) { + log.debug("FormType selected : " + extension); + + // If is canceled + if (extension == null) { + return; + } + FormImpl formImpl = new FormImpl(); + formImpl.getWikitty().addExtension(extension); + + Form form = VradiHelper.initForm(formImpl); + + if (log.isDebugEnabled()) { + log.debug("Creating form with id : " + form.getWikittyId()); + } + + ui.getHandler().addEditPane(ui.getDelegateContext(), form); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/VradiMainUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminContentUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminContentUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminContentUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,264 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel abstract='true' + layout='{new BorderLayout()}' + genericType='B' + _collapseIcon='{SwingUtil.createActionIcon("collapse")}' + _expandIcon='{SwingUtil.createActionIcon("expand")}'> + + <import> + javax.swing.Icon + java.awt.Component + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.util.Date + + javax.swing.Icon + javax.swing.JLabel + javax.swing.UIManager + + org.nuiton.wikitty.entities.BusinessEntity + org.nuiton.wikitty.entities.WikittyExtension + + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + jaxx.runtime.swing.BlockingLayerUI + + org.chorem.vradi.entities.ModificationTag + org.chorem.vradi.services.VradiService + org.chorem.vradi.ui.tree.VradiTreeNode + org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper + </import> + + <!-- bean property to say ui was modified --> + <Boolean id='modified' javaBean='false'/> + + <!-- bean property to say if ui is creation one --> + <Boolean id='creation' javaBean='false'/> + + <!-- bean property to say ui is valid --> + <Boolean id='valide' javaBean='true'/> + + <!-- ui blocker : apply a layer when ui is not enabled (this is a really better idea than disable all editors...) --> + <BlockingLayerUI id='blockLayerUI' + useIcon='false' + blockingColor='{UIManager.getColor("BlockingLayerUI.blockingColor")}' + block='{!isEnabled()}'/> + + <!-- errors model --> + <SwingValidatorMessageTableModel id='errorTable' + onTableChanged='setValide(errorTable.getRowCount()==0);'/> + + <script><![CDATA[ + +/** + * @return the editing bean of the content + */ +public abstract B getBean(); + +/** + * @param bean selected + */ +public abstract void setBean(B bean); + +/** + * Call after set bean + */ +protected abstract void postLoadBean(); + +/** + * Save the editing bean + */ +public abstract void save(); + +/** + * Save the editing bean and unmodify the form + */ +public void postSave() { + setModified(false); + save(); +} + +public void cancel() { + getHandler().cancel(this, getHelper().getSelectedNode(), true); +} + +protected AdminNavigationTreeHelper getHelper() { + return getContextValue(AdminNavigationTreeHelper.class); +} + +public AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +protected Icon updateCollapseIcon(boolean c) { + String key = c ? "collapseIcon" : "expandIcon"; + Icon i = (Icon) getClientProperty(key); + return i; +} + +protected void addBusinessEntityModifiedPCS(BusinessEntity bean) { + if (bean != null) { + bean.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (isEnabled()) { + setModified(true); + } + } + }); + } +} + +protected void addBusinessEntityPCSLogger(BusinessEntity bean) { + if (bean != null) { + bean.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug("bean." + evt.getPropertyName() + " <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); + } + } + }); + } +} + +protected void addPCSLogger() { + addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug("ui." + evt.getPropertyName() + " <" + evt.getOldValue() + ":" + evt.getNewValue() + ">"); + } + } + }); +} + +void $afterCompleteSetup() { + addPropertyChangeListener("bean", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (getBean() != null) { + if (getBean() instanceof WikittyExtension) { + ((WikittyExtension)getBean()).addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (isEnabled()) { + setModified(true); + } + } + }); + } + if (getBean() != null && getBean() instanceof BusinessEntity) { + BusinessEntity entity = (BusinessEntity)getBean(); + lastModifiedPanel.removeAll(); + + // FIXME EC20100915 pour l'instant le test est fait car + // c'est la condition (hack) d'affichage des buttons + // sinon le cast rajoute l'extension est la condition est fausse + if (!isInCreation()) { + ModificationTag beanTag = VradiService.getWikittyProxy().cast(entity, ModificationTag.class); + Date lastModified = beanTag.getLastModified(); + String lastModifier = beanTag.getLastModifier(); + + if (lastModified != null && lastModifier != null) { + String labelText = String.format(_("vradi.entity.lastModified.date.user"), lastModified, lastModifier); + lastModifiedPanel.add(new JLabel(labelText)); + } + lastModifiedPanel.validate(); + } else { + setModified(true); + } + addBusinessEntityModifiedPCS((BusinessEntity)getBean()); + } + } else { + clearUI(); + } + postLoadBean(); + } + }); + setContextValue(errorTable, "errorTable"); + SwingUtil.getLayer(body).setUI(blockLayerUI); +} + +/** + * Renvoi vrai si le bean est en phase de creation. + * + * @return {@code true} si le bean est en phase de creation + */ +protected boolean isInCreation() { + B bean = getBean(); + if (bean == null || !(bean instanceof BusinessEntity)) { + return false; + } + BusinessEntity entity = (BusinessEntity)bean; + return !entity.getExtensionNames().contains(ModificationTag.EXT_MODIFICATIONTAG); +} + +protected abstract void clearUI(); + ]]> + </script> + + <Table constraints='BorderLayout.NORTH' id='toolbar'/> + + <JPanel constraints='BorderLayout.CENTER' id='body' + layout="{new BorderLayout()}" decorator="boxed"/> + + <Table constraints='BorderLayout.SOUTH' id='commonActions' + visible='{isEnabled()}'> + <row> + <cell fill='horizontal' weightx='1.0'> + <JPanel/> + </cell> + <cell columns='2'> + <HBox id='lastModifiedPanel' horizontalAlignment='right'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <!--<JButton id='cancel' actionIcon='cancel' text='vradi.common.cancel' enabled='{isEnabled()}'--> + <JButton id='cancel' actionIcon='cancel' text='vradi.common.cancel' + enabled='{isModified()}' + onActionPerformed='cancel()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='save' actionIcon='save' text='vradi.common.save' + enabled='{isModified() && isValide()}' + onActionPerformed='postSave()' + visible='{!isCreation()}'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='create' actionIcon='create' text='vradi.common.create' + enabled='{isModified() && isValide()}' + onActionPerformed='postSave()' + visible='{isCreation()}'/> + </cell> + </row> + </Table> +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminContentUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,1930 @@ +/* + * #%L + * Vradi :: Swing + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2011 JurisMarches, Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.CardLayout2; +import jaxx.runtime.swing.ErrorDialogUI; +import jaxx.runtime.swing.VBox; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.beans.XmlStreamImportResult; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.XmlFieldBinding; +import org.chorem.vradi.entities.XmlFieldBindingImpl; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.VradiMainUI; +import org.chorem.vradi.ui.admin.content.AdminClientUI; +import org.chorem.vradi.ui.admin.content.AdminFormTypeUI; +import org.chorem.vradi.ui.admin.content.AdminGroupUI; +import org.chorem.vradi.ui.admin.content.AdminStatusUI; +import org.chorem.vradi.ui.admin.content.AdminXmlStreamUI; +import org.chorem.vradi.ui.admin.content.RequestSelectUI; +import org.chorem.vradi.ui.admin.helpers.AdminBeanConstant; +import org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper; +import org.chorem.vradi.ui.admin.models.FieldSelectModel; +import org.chorem.vradi.ui.admin.models.FieldTypeModel; +import org.chorem.vradi.ui.admin.models.TemplateFieldTableModel; +import org.chorem.vradi.ui.admin.models.XmlStreamFieldTableModel; +import org.chorem.vradi.ui.admin.popups.AdminRequestUI; +import org.chorem.vradi.ui.admin.popups.TemplateFieldBindingUI; +import org.chorem.vradi.ui.admin.renderers.JListCellRenderer; +import org.chorem.vradi.ui.admin.widget.FieldSelectUI; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.helpers.XmlStreamHelper; +import org.chorem.vradi.ui.offer.OfferListColumnFactory; +import org.chorem.vradi.ui.offer.OfferListHandler; +import org.chorem.vradi.ui.offer.editors.JListCellEditor; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.search.SearchHandler; +import org.chorem.vradi.ui.search.SearchUI; +import org.chorem.vradi.ui.task.VradiTask; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdom.Element; +import org.nuiton.util.FileUtil; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyI18n; +import org.webharvest.gui.Ide; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import javax.swing.SwingUtilities; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.filechooser.FileFilter; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.event.MouseListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class AdminHandler { + + static private final Log log = LogFactory.getLog(AdminHandler.class); + + /** Max element in xml stream sample tooltip. */ + static public final int TOOLTIP_ELEMENT_MAX_CHAR_NB = 500; + + public AdminPopupUI init(JAXXContext rootContext) { + AdminPopupUI adminPopupUI = VradiContext.ADMIN_UI_ENTRY_DEF + .getContextValue(rootContext); + + if (adminPopupUI == null) { + JAXXInitialContext context = new JAXXInitialContext() + .add(rootContext).add(this); + + VradiMainUI mainUI = VradiContext.MAIN_UI_ENTRY_DEF + .getContextValue(context); + + adminPopupUI = new AdminPopupUI(context, mainUI); + + VradiContext.ADMIN_UI_ENTRY_DEF.setContextValue(rootContext, + adminPopupUI); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(adminPopupUI); + } + + return adminPopupUI; + } + + protected AdminPopupUI getUI(JAXXContext context) { + if (context instanceof AdminPopupUI) { + return (AdminPopupUI) context; + } + AdminPopupUI ui = VradiContext.ADMIN_UI_ENTRY_DEF + .getContextValue(context); + return ui; + } + + /** + * Close ui (release resources). + * + * @param context context + */ + protected void close(JAXXContext context) { + AdminPopupUI ui = getUI(context); + ui.setVisible(false); + ui.dispose(); + } + + /** + * Open UI depending on node type. + * + * @param ui + * @param node + */ + public void openUI(AdminNavUI ui, + VradiTreeNode node) { + + // Get node type + Class<?> editType = node.getInternalClass(); + String id = node.getId(); + + openUI(ui, id, editType); + } + + /** + * Open UI depending on node type. + * + * @param ui + * @param id + * @param editType + */ + public void openUI(AdminNavUI ui, + String id, + Class editType) { + + // If it's category node + if (editType.equals(String.class)) { + Class uiClass = AdminBeanConstant.getUIClass(id); + showUI(ui, null, uiClass); + } else { + // If it's entity node + Class uiClass = AdminBeanConstant.getUIClass(editType); + Object bean = AdminBeanConstant.getConstantByBeanClass(editType) + .getBean(VradiService.getWikittyProxy(), id); + + showUI(ui, bean, uiClass); + } + } + + /** + * Create by introspection content ui. + * + * @param <B> + * @param navUI + * @param bean + * @param uiClass + */ + protected <B> void showUI(AdminNavUI navUI, B bean, + Class<? extends AdminContentUI> uiClass) { + + if (uiClass == null) { + return; + } + + CardLayout2 contentLayout = navUI.getContentLayout(); + JPanel content = navUI.getContent(); + + // Verify if instance is existing + AdminContentUI ui = UIHelper.getContentIfExist(contentLayout, content, + uiClass); + + // Get layout identifier + String contentName = uiClass.getName(); + + if (ui == null) { + try { + // Get constructor + Constructor<? extends AdminContentUI> constructor = + uiClass.getConstructor(JAXXContext.class); + + // Invoke instance creation + ui = constructor.newInstance(navUI); + } catch (Exception eee) { + log.error(eee); + ErrorDialogUI.showError(eee); + } + + // Add to content panel + content.add(ui, contentName); + } + + // Attach bean + //FIXME JC 27/08/2010 set bean to null to fire property change. If not, save button does not enable. + ui.setModified(false); + ui.setBean(null); + ui.setBean(bean); + + // show ui + contentLayout.show(content, contentName); + } + + /** + * Save group in wikitty. + * + * @param parentUI parent ui reference + * @param group group to save + * @return saved group + */ + public Group saveGroup(JAXXContext parentUI, AdminNavigationTreeHelper helper, Group group) { + + // add modification info + String login = parentUI.getContextValue(VradiUser.class).getLogin(); + ModificationTag clientTag = VradiService.getWikittyProxy().cast(group, ModificationTag.class); + clientTag.setLastModified(new Date()); + clientTag.setLastModifier(login); + + try { + VradiService.getVradiStorageService().archiveQueries(group); + } catch (VradiException eee) { + log.error("Cant archive query : ", eee); + ErrorDialogUI.showError(eee); + } + + if (log.isDebugEnabled()) { + log.debug("Save group '" + group.getName() + "'"); + if (group.getQueries() != null) { + for (String query : group.getQueries()) { + log.debug("Save group '" + group.getName() + + "' with query : " + query); + } + } + Set<String> users = group.getUser(); + if (users != null) { + for (String user : users) { + log.debug("Saving group " + group.getName() + + " with user : " + user); + } + } + } + + // save group + Group newGroup = VradiService.getWikittyProxy().store(group); + helper.createAndSelectGroupNode(group.getWikittyId()); + + return newGroup; + } + + /** + * Save groups in wikitty. + * + * @param groups groups + * @return groups + */ + protected Collection<Group> saveGroups(JAXXContext parentUI, AdminNavigationTreeHelper helper, List<Group> groups) { + + List<Group> newGroups = new ArrayList<Group>(); + + for (Group group : groups) { + Group savedGroup = saveGroup(parentUI, helper, group); + newGroups.add(savedGroup); + } + + return newGroups; + } + + /** + * Save stream in wikitty. + * + * @param <E> + * @param xmlStream + * @param bindings + * @return + */ + protected <E extends XmlStream> E saveStream(E xmlStream, + List<XmlFieldBinding> bindings) { + + try { + + // save xmlStream + List<XmlFieldBinding> newXmlFieldBinding = + VradiService.getWikittyProxy().store(bindings); + + xmlStream.clearXmlFieldBinding(); + for (XmlFieldBinding binding : newXmlFieldBinding) { + xmlStream.addXmlFieldBinding(binding.getWikittyId()); + } + + xmlStream = VradiService.getWikittyProxy().store(xmlStream); + } catch (Exception eee) { + log.error("Failled to store stream '" + xmlStream.getName(), eee); + ErrorDialogUI.showError(eee); + } + + return xmlStream; + } + + public Client saveClient(JAXXContext parentUI, AdminNavigationTreeHelper helper, Client client, Collection<Group> groups) { + + try { + + // add modification info + String login = parentUI.getContextValue(VradiUser.class).getLogin(); + ModificationTag clientTag = VradiService.getWikittyProxy().cast(client, ModificationTag.class); + clientTag.setLastModified(new Date()); + clientTag.setLastModifier(login); + + // save client + client = VradiService.getWikittyProxy().store(client); + + // save associated groups + if (groups != null && !groups.isEmpty()) { + saveGroups(parentUI, helper, new ArrayList<Group>(groups)); + } + + helper.createAndSelectClientNode(client.getWikittyId()); + + } catch (Exception e) { + log.error("Cant save client : ", e); + } + + return client; + } + + public User saveUser(JAXXContext parentUI, AdminNavigationTreeHelper helper, User user, Collection<Group> groups) { + try { + helper.createAndSelectUserNode(user.getWikittyId(), user.getClient()); + + // add modification info + String login = parentUI.getContextValue(VradiUser.class).getLogin(); + ModificationTag userTag = VradiService.getWikittyProxy().cast(user, ModificationTag.class); + userTag.setLastModified(new Date()); + userTag.setLastModifier(login); + + WikittyProxy proxy = VradiService.getWikittyProxy(); + + // save user + user = proxy.store(user); + + // save associated groups + if (groups != null && !groups.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Save groups"); + } + saveGroups(parentUI, helper, new ArrayList<Group>(groups)); + } + + } catch (Exception e) { + log.error("Cant save user : ", e); + } + + return user; + } + + /** + * Export all clients database (with groups, users, clients) as CSV. + * <p/> + * Used in {@link org.chorem.vradi.ui.admin.AdminClientNavUI}. + * + * @param adminNavUI parent ui + */ + public void exportClientUsersDBCSV(AdminNavUI adminNavUI) { + + try { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle(_("vradi.admin.exportTitle")); + chooser.setApproveButtonText(_("vradi.admin.exportButtonText")); + int returnVal = chooser.showOpenDialog(adminNavUI); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File selectedFile = chooser.getSelectedFile(); + + if (log.isDebugEnabled()) { + log.debug("Exporting groups to : " + selectedFile.getAbsolutePath()); + } + + // export + VradiStorageService vradiStorageService = VradiService.getVradiStorageService(); + String vscContent = vradiStorageService.exportClientDB(); + + // write content into file + FileUtils.writeStringToFile(selectedFile, vscContent); + } + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't export groups", eee); + } + ErrorDialogUI.showError(eee); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't export groups", eee); + } + } + } + + /** + * Import CSV file. + * <p/> + * Can be used to import clients, groups or thesaurus. + * + * @param adminNavUI parent ui + */ + public void importClientUsersDBCSV(AdminNavUI adminNavUI) { + try { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle(_("vradi.admin.importTitle")); + chooser.setApproveButtonText(_("vradi.admin.importButtonText")); + int returnVal = chooser.showOpenDialog(adminNavUI); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File selectedFile = chooser.getSelectedFile(); + + if (log.isDebugEnabled()) { + log.debug("Importing file : " + selectedFile.getAbsolutePath()); + } + + //upload file on server + String uri = VradiService.getFileService().uploadTempFile(selectedFile); + // import from file on server + VradiService.getVradiStorageService().importAsCSV(uri); + } + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't import file", eee); + } + ErrorDialogUI.showError(eee); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't import file", eee); + } + } + } + + public boolean answerToSave(AdminContentUI<?> content) { + if (content == null) { + return true; + } + VradiTreeNode selected = null; + if (content.getHelper() != null && content.getHelper().getSelectedNode() != null) { + selected = (VradiTreeNode) content.getHelper().getSelectedNode(); + } + return answerToSave(content, selected); + } + + public boolean answerToSave(AdminContentUI<?> content, VradiTreeNode oldNode) { + if (content == null) { + return true; + } + if (content.isModified()) { + int n = JOptionPane.showConfirmDialog(content, + _("vradi.admin.saveAnswer") + + VradiHelper.getEntityName(content.getBean()) + + " ?", _("vradi.admin.saveTitle"), + JOptionPane.YES_NO_CANCEL_OPTION); + + switch (n) { + case JOptionPane.NO_OPTION: + // annule les modifications + cancel(content, oldNode, false); + break; + case JOptionPane.OK_OPTION: + // sauvegarde les modifications + content.setModified(false); + content.save(); + break; + case JOptionPane.CANCEL_OPTION: + // annule le changement d'onglet + return false; + } + } + return true; + } + + public boolean confirmDeletion(AdminContentUI<?> content) { + int confirm = JOptionPane.showConfirmDialog(content, + _("vradi.admin.confirmDelete", VradiHelper.getEntityName(content.getBean())), + _("vradi.admin.deleteTitle"), JOptionPane.YES_NO_OPTION); + + return confirm != JOptionPane.NO_OPTION; + } + + public <B> void delete(AdminContentUI<B> content, AdminNavigationTreeHelper helper, + B bean) { + if (!confirmDeletion(content)) { + return; + } + + // deleteEntity is too generic to apply business rules on service layer + try { + + // Get id + String id; + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + if (bean instanceof BusinessEntity) { + BusinessEntity entity = (BusinessEntity) bean; + id = entity.getWikittyId(); + } else { + + // Its name for formType + WikittyExtension formType = (WikittyExtension) bean; + id = formType.getName(); + + // Search if is used + try { + // Delete + VradiService.getWikittyService().deleteExtension(wikittyProxy.getSecurityToken(), Collections.singleton(formType.getName())); + } catch (Exception eee) { + JOptionPane.showMessageDialog(content, _("vradi.error.formTypeDeletionUsed", formType.getName()), + _("vradi.error.formTypeDeletionUsed.title"), JOptionPane.ERROR_MESSAGE); + + return; + } + } + + VradiTreeNode selectedNode = helper.getSelectedNode(); + + // select parent node + helper.selectNode(selectedNode.getParent()); + + //Clear the bean that was editing as it does not exist anymore + content.setModified(false); + content.setBean(null); + + // check if the entity is to be delete or if it is a newly created one + // which have never been saved. modified is null if newly created + Object modified = wikittyProxy.restore(id); + if (modified == null) { + //Remove from tree by hand when not in database + helper.removeNode(selectedNode); + return; + } + + // Deleting client + if (bean instanceof Client) { + VradiService.getVradiDataService().deleteClient(id); + } + + // Deleteing user + if (bean instanceof User) { + VradiService.getVradiDataService().deleteUser(id); + } + + // Deleting group + if (bean instanceof Group) { + VradiService.getVradiDataService().deleteGroup(id); + } + + // Deleting xmlStream + if (bean instanceof XmlStream) { + VradiService.getVradiDataService().deleteXmlStream(id); + } + } catch (Exception eee) { + log.error(eee.getMessage(), eee); + ErrorDialogUI.showError(eee); + } + } + + protected <B> void cancel(AdminContentUI<B> content, + VradiTreeNode oldNode, + boolean trigerredByCancelButton) { + int confirm = -1; + if (trigerredByCancelButton) { + confirm = JOptionPane.showConfirmDialog(content, + _("vradi.admin.cancel.message"), + _("vradi.admin.cancel.title"), + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + } + + if (!trigerredByCancelButton || confirm == JOptionPane.YES_OPTION) { + try { + + // Retrieve bean concerned + B bean = content.getBean(); + + // Get id + String id = null; + + // Prepare data for restoring bean + Class<? extends AdminContentUI> uiClass = content.getClass(); + AdminBeanConstant beanClass = AdminBeanConstant.getConstantByUIClass(uiClass); + + content.setModified(false); + + if (bean instanceof BusinessEntity) { + cancelIfCreation(content, oldNode, (BusinessEntity) bean); + } else if (bean instanceof WikittyExtension) { + id = ((WikittyExtension) bean).getId(); + } + + if (id != null) { + Object beanCanceled = beanClass.getBean(VradiService.getWikittyProxy(), id); + + // Push it in UI + //FIXME JC 25/08/2010 bean is the same (because of cache ?) so no property change fired. Set bean to null before to force fire. + content.setBean(null); + content.setBean((B) beanCanceled); + } + AdminNavigationTreeHelper helper = content.getHelper(); + if (helper != null) { + if (oldNode != null) { + VradiTreeNode parent = oldNode.getParent(); + helper.refresh(parent); + helper.selectNode(oldNode); + } + } + + } catch (Exception eee) { + log.error("Cant cancel editing", eee); + ErrorDialogUI.showError(eee); + } + } + } + + protected <B> void cancelIfCreation(AdminContentUI<B> content, VradiTreeNode oldNode, BusinessEntity bean) { + + Class<? extends AdminContentUI> uiClass = content.getClass(); + AdminBeanConstant beanClass = AdminBeanConstant.getConstantByUIClass(uiClass); + + String id = bean.getWikittyId(); + + // Creation if beanCanceled is null (not yet in base) + Object beanCanceled = beanClass.getBean(VradiService.getWikittyProxy(), id); + if (beanCanceled == null) { + + // Get helper + AdminNavigationTreeHelper helper = content.getHelper(); + + if (oldNode != null) { + // Select parent + VradiTreeNode parent = oldNode.getParent(); + helper.refresh(parent); + helper.selectNode(parent); + } + + // Remove creation node +// helper.removeNode(oldNode); + content.setModified(false); + } + } + + public ComboBoxModel getTypesModel() { + ComboBoxModel model = new FieldTypeModel(); + return model; + } + + // REQUEST + + // From show imply + public void openRequest(JAXXContext rootContext, Thesaurus thesaurus) { + + // Creating request bean + String request = ThesaurusDataHelper.getRequestName(thesaurus); + QueryBean requestBean = null; + try { + // FIXME EC20100930 a voir pourquoi il faut la quoter pour opencsv + requestBean = new QueryBean("\"" + request + "\""); + } catch (IOException eee) { + log.error("Cant parse query : " + request, eee); + } + + // Open request ui + openRequest(rootContext, requestBean, thesaurus, true); + } + + public void openRequest(JAXXContext rootContext, QueryBean request) { + openRequest(rootContext, request, null, false); + } + + public void openRequest(final JAXXContext rootContext, QueryBean request, Thesaurus thesaurus, boolean isShowImply) { + AdminRequestUI requestUI = createAdminRequestUI(rootContext, request, thesaurus); + + SearchHandler searchHandler = requestUI.getContextValue(SearchHandler.class); + SearchUI searchUI = requestUI.getSearchUI(); + OfferListTableModel offerListTableModel = requestUI.getContextValue(OfferListTableModel.class); + String query = requestUI.getRequest(); + + // execute search + FormPagedResult formPagedResult = new FormPagedResult(); +// formPagedResult = searchHandler.executeQuery(searchUI, searchUI.getCriterias(), formPagedResult, null, query); + offerListTableModel.setFormPagedResult(formPagedResult); + + // Save request only if parent is request select ui + if (rootContext instanceof RequestSelectUI) { + requestUI.addPropertyChangeListener(AdminRequestUI.PROPERTY_REQUEST, + new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + String newValue = (String) evt.getNewValue(); + RequestSelectUI ui = (RequestSelectUI) rootContext; + QueryBean bean = ui.getBean(); + ui.setBean(bean.setQuery(newValue)); + } + }); + } + + if (isShowImply) { + requestUI.setModal(true); + requestUI.getSearchUI().getCriterias().setVisible(false); + requestUI.getSearchPanel().setVisible(false); + requestUI.getSearchUI().executeQuery(); + requestUI.setCanSave(false); + } + + requestUI.setVisible(true); + } + + public AdminRequestUI createAdminRequestUI(JAXXContext rootContext, QueryBean request, Thesaurus thesaurus) { + JAXXInitialContext context = new JAXXInitialContext().add(rootContext); + + SearchHandler searchHandler = new SearchHandler(); + OfferListTableModel offerListTableModel = new OfferListTableModel(); + OfferListColumnFactory offerListColumnFactory = new OfferListColumnFactory(); + + context.add(searchHandler); + context.add(offerListTableModel); + context.add(offerListColumnFactory); + + AdminRequestUI requestUI = new AdminRequestUI(context); + + // add listeners + JXTable listTable = requestUI.getResultTable(); + + // Add listener to open AO + MouseListener offerListTableMouseListener = + UIHelper.getHandler(context, OfferListHandler.class).getOfferListTableMouseListener(); + listTable.addMouseListener(offerListTableMouseListener); + + TableModelListener offerListTableModelListener = + getOfferListTableModelListener(listTable); + offerListTableModel.addTableModelListener(offerListTableModelListener); + + // listTable cellRenderer + // TODO SLE 30/09/2010 : Refactor it ! + OfferListTableModel.OfferListTableCellRenderer renderer = + new OfferListTableModel.OfferListTableCellRenderer(); + listTable.setDefaultRenderer(Boolean.class, renderer); + listTable.setDefaultRenderer(Date.class, renderer); + listTable.setDefaultRenderer(Double.class, renderer); + listTable.setDefaultRenderer(String.class, renderer); + listTable.setDefaultRenderer(XmlStream.class, renderer); + listTable.setDefaultRenderer(Status.class, renderer); + + // listTable highlighter + Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + listTable.addHighlighter(highlighter); + + // search ui + SearchUI searchUI = searchHandler.initCloneUI(context, offerListTableModel, thesaurus); + String query; + + if (request != null) { + query = request.getQuery(); + searchUI.setRequest(query); + + } else { + // If it's for visualisation + if (thesaurus != null) { + requestUI.setCanSave(false); + searchUI.setHidable(false); + } + } + requestUI.getSearchPanel().add(searchUI, BorderLayout.CENTER); + return requestUI; + } + +// private MouseListener getOfferListTableMouseListener( +// final AdminRequestUI requestUI, +// final JTable resultTable, +// final OfferListTableModel offerListTableModel) { +// +// // double click on resultTable shows selected offer +// return new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent e) { +// if (e.getClickCount() == 2) { +// requestUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); +// +// int row = resultTable.getSelectedRow(); +// Form form = offerListTableModel.getFormPageDTO().getFormsToShow().get(row); +// UIHelper.openFormPopup(requestUI, form); +// +// requestUI.setCursor(null); +// } +// } +// }; +// } + + private TableModelListener getOfferListTableModelListener(final JXTable listTable) { + return new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + listTable.packAll(); + } + }; + } + + // STATUS + public static List<Status> getAllStatuses() { + try { + + List<Status> all = new ArrayList<Status>(VradiService.getVradiDataService().findAllStatus()); + + // If no found, creating all + if (all.isEmpty()) { + log.info("No status found, creating default one"); + all = new ArrayList<Status>(VradiService.getVradiDataService().createDefaultStatuses()); + } + + // Sort by value + Collections.sort(all, VradiComparators.STATUSES_COMPARATOR); + + return all; + } catch (Exception eee) { + log.error("Cant get all status : ", eee); + ErrorDialogUI.showError(eee); + } + return new ArrayList<Status>(); + } + + public void saveStatuses(AdminStatusUI adminStatusUI) { + List<Status> statuses = adminStatusUI.getStatuses(); + List<Status> toSave = new ArrayList<Status>(); + List<Status> deleted = adminStatusUI.getDeleted(); + + // Keep order + int i = 0; + for (Status status : statuses) { + i++; + status.setValue(i); + toSave.add(status); + } + + // extract ids + List<String> idsToDelete = new ArrayList<String>(); + for (Status toDelete : deleted) { + log.info("Delete status " + toDelete.getName()); + idsToDelete.add(toDelete.getWikittyId()); + } + try { + // Check if status is in use before delete, else display message + if (!VradiService.getVradiDataService().deleteStatus(idsToDelete)) { + + // Restore not deleted status + List<Status> statusesNotDeleted = VradiService.getWikittyProxy().restore(Status.class, idsToDelete); + + // Show display message + for (Status s : statusesNotDeleted) { + String name = s.getName(); + log.error("Abord delete status, status " + name + " is in use"); + JOptionPane.showMessageDialog(adminStatusUI, _("vradi.admin.isInUse", name), _("vradi.admin.isInUse.title"), JOptionPane.INFORMATION_MESSAGE); + } + } + VradiService.getWikittyProxy().store(toSave); + } catch (VradiException eee) { + log.error("Cant save status : ", eee); + + } finally { + adminStatusUI.createStatuses(false); + } + } + + protected void createEntity(AdminNavUI ui, Class clazz) { + ui.resetFilter(); + + Class uiClass = AdminBeanConstant.getUIClass(clazz); + Object bean = AdminBeanConstant.getConstantByBeanClass(clazz) + .getBean(VradiService.getWikittyProxy(), null); + + // Create open ui with new client bean + showUI(ui, bean, uiClass); + } + + public void createClient(AdminClientUI context) { + // reset tree filter + // cause NPE when saving client + AdminNavUI ui = getUI(context).getClientAdminNavUI(); + + createEntity(ui, Client.class); + } + + // USER + public void createUser(JAXXContext context, + Client clientConcerned) { + + if (clientConcerned == null) { + return; + } + + // reset tree filter + // cause NPE when saving client + AdminNavUI ui = getUI(context).getClientAdminNavUI(); + ui.resetFilter(); + + // If it's entity node + Class uiClass = AdminBeanConstant.getUIClass(User.class); + Object bean = AdminBeanConstant.getConstantByBeanClass(User.class) + .getBean(VradiService.getWikittyProxy(), null); + + User user = (User) bean; + + user.setClient(clientConcerned.getWikittyId()); + + // Create open ui with new client bean + showUI(ui, bean, uiClass); + } + + public void createGroup(AdminGroupUI context) { + // reset tree filter + // cause NPE when saving client + AdminNavUI ui = getUI(context).getGroupAdminNavUI(); + + createEntity(ui, Group.class); + } + + /** + * Get all clients. + * + * @return all clients + */ + public List<Client> getAllClients() { + List<Client> values = VradiService.getVradiDataService().findAllClients(); +// Collections.sort(values, VradiComparators.CLIENT_COMPARATOR); + return values; + } + + /** + * Get all groups. + * + * @return all groups + */ + public List<Group> getAllGroups() { + List<Group> values = VradiService.getVradiDataService().findAllGroups(); +// Collections.sort(values, VradiComparators.GROUP_COMPARATOR); + return values; + } + + /** + * Get all users. + * + * @return all users + */ + public List<User> getAllUsers() { + List<User> values = VradiService.getVradiDataService().findAllUsers(); + Collections.sort(values, new VradiComparators.UserComparator(getAllClients())); + return values; + } + + /** + * Create new form type (name checked). + * + * @param context parent ui + * @param helper tree helper + */ + public void createFormType(AdminFormTypeUI context, + AdminNavigationTreeHelper helper) { + String formTypeName = JOptionPane + .showInputDialog(getUI(context), _("vradi.adminFormType.askName"), + _("vradi.adminFormType.askNameTitle"), JOptionPane.QUESTION_MESSAGE); + + try { + if (formTypeName != null) { + + if (!formTypeName.matches("\\w+")) { + JOptionPane.showMessageDialog(getUI(context), _("vradi.adminFormType.askNameInvalid"), + _("vradi.adminFormType.askNameTitle"), JOptionPane.ERROR_MESSAGE); + } else { + // TODO EC20100914 check form type already exists name + + // reset tree filter + // cause NPE when saving form + getUI(context).getFormAdminNavUI().resetFilter(); + + WikittyExtension extension = VradiService.getVradiDataService().createFormType(formTypeName); + + helper.createAndSelectFormTypeNode(extension.getName()); + } + } + } catch (VradiException ex) { + if (log.isErrorEnabled()) { + log.error("Can't create new form type", ex); + } + throw new RuntimeException("Can't create new form type", ex); + } + + } + + public String getFormTypeTemplateName(WikittyExtension ext) { + return VradiService.getVradiDataService().getFormTypeTemplateName(ext); + } + + public void createForms(JAXXContext context) { + final AdminXmlStreamUI xmlStreamUI = getXmlStreamUI(context); + + final XmlStream xmlStream = xmlStreamUI.getBean(); + if (xmlStream == null || xmlStream.getFormTypeName() == null) { + JOptionPane.showMessageDialog(xmlStreamUI, _("vradi.admin.formsCreated.missingFormType"), + _("vradi.admin.formsCreated.title"), JOptionPane.WARNING_MESSAGE); + return; + } + + //final VradiUser vradiUser = xmlStreamUI.getContextValue(VradiUser.class); + + VradiTask<XmlStreamImportResult> task = new VradiTask<XmlStreamImportResult>(context) { + + @Override + public XmlStreamImportResult doAction() throws Exception { + return createForms(xmlStream); + } + + @Override + public void doWhenDone() throws Exception { + xmlStreamUI.getCreateForms().setEnabled(true); + XmlStreamImportResult xmlStreamImportResult = get(); + showFormCreationResults(xmlStreamUI, xmlStreamImportResult); + } + + @Override + public void doWhenError(Exception eee) { + throw new RuntimeException("Can't import forms", eee); + } + }; + + xmlStreamUI.getCreateForms().setEnabled(false); + + task.execute(); + } + + public XmlStreamImportResult createForms(XmlStream xmlStream) throws VradiException { + VradiStorageService service = VradiService.getVradiStorageService(); + if (xmlStream instanceof WebHarvestStream) { + return service.importFormsFromWebHarvestStream((WebHarvestStream) xmlStream); + } + return service.importFormsFromXmlStream(xmlStream); + } + + protected void showFormCreationResults(AdminXmlStreamUI xmlStreamUI, XmlStreamImportResult xmlStreamImportResult) { + + int nbFormCreated = xmlStreamImportResult.getCreatedFormCount(); + int alreadyExisting = xmlStreamImportResult.getAlreadyExistsFormCount(); + int dateErrorParsing = xmlStreamImportResult.getDateParsingError(); + int numberErrorParsing = xmlStreamImportResult.getNumberParsingError(); + + String optionMessage = _("vradi.admin.formsCreated.message.allWarning", + nbFormCreated, alreadyExisting, dateErrorParsing, numberErrorParsing); + int messageType = JOptionPane.INFORMATION_MESSAGE; + if (dateErrorParsing > 0 || numberErrorParsing > 0) { + messageType = JOptionPane.WARNING_MESSAGE; + } + + JOptionPane.showMessageDialog(xmlStreamUI, + _("vradi.admin.formsCreated.message") + optionMessage, + _("vradi.admin.formsCreated.title"), messageType); + } + + public void saveFormType(AdminFormTypeUI context, AdminNavigationTreeHelper helper) { + if (log.isDebugEnabled()) { + log.debug("Saving formType"); + } + try { + List<FieldSelectModel> fields = new ArrayList<FieldSelectModel>(); + + VBox contentPanel = context.getContent(); + for (Component component : contentPanel.getComponents()) { + fields.add(((FieldSelectUI) component).getBean()); + } + + WikittyExtension uiExtension = context.getBean(); + String extensionName = uiExtension.getName(); + WikittyExtension newFormType = new WikittyExtension(extensionName, + uiExtension.getVersion(), uiExtension.getRequires(), null); + + // Keep all field names + List<String> fieldsNames = new ArrayList<String>(); + + for (int i = 0; i < fields.size(); i++) { + FieldSelectModel model = fields.get(i); + String name = model.getNameValue(); + + // Keep name + fieldsNames.add(name); + + if (name != null && model.getType() != null) { + FieldType fieldType = model.getType().getFieldType(); + + if (model.getDescValue() != null && !model.getDescValue().isEmpty()) { + fieldType.addTagValue(VradiHelper.TYPE_DESCRIPTION, model.getDescValue()); + } + + fieldType.addTagValue(VradiHelper.TYPE_RANK, String.valueOf(i)); + newFormType.addField(name, fieldType); + } + } + + Date now = new Date(); + newFormType.addTagValue(VradiHelper.TYPE_LAST_MODIFIED_DATE, + String.format("%1$td/%1$tm/%1$ty", now)); + newFormType.addTagValue(VradiHelper.TYPE_LAST_MODIFIED_TIME, + String.format("%1$tk:%1$tM:%1$tS", now)); + newFormType.addTagValue(VradiHelper.TYPE_LAST_MODIFIED_BY, + context.getContextValue(VradiUser.class).getLogin()); + + String templateName = (String) context.getTemplateChoice().getSelectedItem(); + + // save extension + WikittyExtension extension = VradiService.getVradiDataService().updateFormType(newFormType, templateName); + + // Save traductions + WikittyI18n wikittyI18n = context.getWikittyI18n(); + wikittyI18n = VradiService.getWikittyProxy().store(wikittyI18n); + context.setWikittyI18n(wikittyI18n); + + helper.createAndSelectFormTypeNode(extension.getName()); + + // Save associations + TemplateFieldTableModel model = context.getFieldsModel(); + + if (model != null) { + + // Save association + VradiService.getVradiStorageService().setAssociatedFields(extensionName, + templateName, model.getData()); + } + } catch (Exception e) { + log.error("Error on save form type ", e); + ErrorDialogUI.showError(e); + + } + } + + public boolean checkAssociation(TemplateFieldBindingUI ui, WikittyExtension ext, TemplateFieldTableModel model) { + List<String> fieldsNames = new ArrayList<String>(ext.getFieldNames()); + Map<String, String> fieldMap = model.getData(); + + // Store all field existing in template not binded + List<String> errors = new ArrayList<String>(); + + // Store all field existing in form type not binded + List<String> warns = new ArrayList<String>(); + + // Check if all template fields are binded + for (String key : fieldMap.keySet()) { + String fieldName = fieldMap.get(key); + if (fieldName == null) { + errors.add(key); + } else { + fieldsNames.remove(fieldName); + } + } + + // Add infogene fields names + // TODO sletellier 29/12/10 : refactor it with help method to do this + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_OBJET); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_DESCRIPTION); + fieldsNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fieldsNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_ENTITY); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCETEXT); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCEURL); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_COUNTRY); + fieldsNames.add(Infogene.FQ_FIELD_INFOGENE_DEPARTMENT); + + // Check if all template fields are binded + for (String fieldName : fieldsNames) { + warns.add(fieldName); + } + + // Ask if save if errors + boolean ok = true; + + if (!errors.isEmpty() || !warns.isEmpty()) { + String msg = _("vradi.error.fieldsBinding.msg"); + msg += errors.isEmpty() ? "" : _("vradi.error.fieldsBinding.errors", VradiHelper.join(errors, ", ", '\n', 100)); + msg += warns.isEmpty() ? "" : _("vradi.error.fieldsBinding.warns", VradiHelper.join(warns, ", ", '\n', 100)); + + int responce = JOptionPane.showConfirmDialog(ui, msg, + _("vradi.error.fieldsBinding.title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.ERROR_MESSAGE); + + ok = responce == JOptionPane.YES_OPTION; + } + return ok; + } + + public WikittyExtension getExtension(String extensionName) { + try { + return VradiService.getVradiDataService().getFormType(extensionName); + } catch (Exception e) { + return null; + } + } + + // RSS + + /** Cache of the already loaded urls : keeps only the first Element parsed */ + public static final Map<String, Element> XML_STREAM_FIELDS_CACHE + = new HashMap<String, Element>(); + + public void createWebHarvestStream(AdminXmlStreamUI context) { + + // reset tree filter + // cause NPE when saving XmlStream + AdminNavUI ui = getUI(context).getXmlStreamAdminNavUI(); + ui.resetFilter(); + + createEntity(ui, WebHarvestStream.class); + } + + public void createXmlStream(AdminXmlStreamUI context) { + // reset tree filter + // cause NPE when saving XmlStream + AdminNavUI ui = getUI(context).getXmlStreamAdminNavUI(); + ui.resetFilter(); + + createEntity(ui, XmlStream.class); + } + + public void openWebHarvestEditor(JAXXContext context) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new Ide().createAndShowGUI(); + } + }); + } + + public void addWebHarvestScript(JAXXContext context, WebHarvestStream stream) { + JFileChooser chooser = new JFileChooser(); + + int returnVal = chooser.showOpenDialog(getXmlStreamUI(context)); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + String url = null; + try { + url = VradiService.getFileService().uploadWebHarvestScript(chooser.getSelectedFile()); + + } catch (VradiException eee) { + log.error("Cant upload script : ", eee); + } + log.info("Script uploaded to " + url); + + stream.setScriptUrl(url); + + } + } + + public void initScriptComboBox(JComboBox combo, WebHarvestStream bean) { + + VradiDataService service = VradiService.getVradiDataService(); + + List<String> webHarvestScripts = service.getAllWebHarvestScripts(); + + combo.setModel(new DefaultComboBoxModel(webHarvestScripts.toArray())); + combo.setRenderer(new ListCellRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + if (value == null) { + return new JLabel(""); + } + String fileName = (String) value; + return new JLabel(fileName); + } + }); + + if (bean != null) { + String fileToSelect = bean.getScriptUrl(); + combo.setSelectedItem(fileToSelect); + } + + } + + public <E extends XmlStream> E saveStream(AdminXmlStreamUI ui, + AdminNavigationTreeHelper helper, E xmlStream, + List<XmlFieldBinding> bindings) { + + try { + // save xmlStream + xmlStream = saveStream(xmlStream, bindings); + + } catch (Exception eee) { + log.error(eee.getMessage(), eee); + } + + ui.setModified(false); + helper.createAndSelectStreamNode(xmlStream.getWikittyId()); + + return xmlStream; + } + + /** + * Find all XmlFieldBinding for XmlStream. + * + * @param xmlStream XmlStream to find XmlFieldBinding + * @return found XmlFieldBinding + */ + public List<XmlFieldBinding> getXmlStreamFields(XmlStream xmlStream) { + try { + List<String> xmlFieldBindingIds = new ArrayList<String>(); + if (xmlStream.getXmlFieldBinding() != null) { + xmlFieldBindingIds.addAll(xmlStream.getXmlFieldBinding()); + } + List<XmlFieldBinding> result = VradiService.getWikittyProxy().restore(XmlFieldBinding.class, xmlFieldBindingIds); + return result; + } catch (WikittyException e) { + log.warn(e.getMessage(), e); + return new ArrayList<XmlFieldBinding>(); + } + } + + private <E extends XmlStream> WikittyExtension getFormType(E xmlStream) { + if (xmlStream == null) { + return null; + } + + String formTypeName = xmlStream.getFormTypeName(); + if (formTypeName == null) { + return null; + } + + WikittyExtension formType = getExtension(formTypeName); + + return formType; + } + + public void openAdminXmlStreamUI(final AdminXmlStreamUI xmlStreamUI) { + if (log.isDebugEnabled()) { + log.debug("openAdminXmlStreamUI(xmlStreamUI)"); + } + + VradiTask<Void> task = new VradiTask<Void>(xmlStreamUI) { + + @Override + public Void doAction() throws Exception { + updateXmlStreamFieldModel(xmlStreamUI); + return null; + } + + @Override + public void doWhenDone() throws Exception { + xmlStreamUI.setModified(false); + xmlStreamUI.setCursor(null); + xmlStreamUI.validate(); + } + }; + + task.execute(); + } + + public void updateXmlStreamFieldModel(JAXXContext context) { + if (log.isDebugEnabled()) { + log.debug("updateXmlStreamFieldModel(context)"); + } + + AdminXmlStreamUI xmlStreamUI = (AdminXmlStreamUI) context; + XmlStreamFieldTableModel fieldsModel = xmlStreamUI.getFieldsModel(); + fieldsModel.setValueIsAdjusting(true); + fieldsModel.clear(); + + try { + XmlStream bean = xmlStreamUI.getBean(); + + if (bean == null) { + return; + } + + String url = bean.getUrl(); + if (bean instanceof WebHarvestStream) { + final WebHarvestStream webHarvest = (WebHarvestStream) bean; + if (webHarvest.getScriptUrl() == null) { + // Pas de script + return; + } + VradiTask<String> createPreview = new VradiTask<String>(context) { + + @Override + public String doAction() throws Exception { + return VradiService.getVradiDataService().getWebHarvestPreviewURL(webHarvest); + } + }; + createPreview.execute(); + + url = createPreview.get(); + } + + if (url == null || url.trim().isEmpty()) { + // pas d'url + return; + } + + WikittyExtension formType = getFormType(bean); + if (formType == null) { + // pas de type de formulaire + return; + } + + // liste des champs xml disponibles + Set<String> xmlFieldNames = getXmlFieldNames(url); + + // liste des bindings existants + List<XmlFieldBinding> bindings = getXmlStreamFields(bean); + + // map des bindings formfield/xmlfields indexée par formfield + LinkedHashMap<String, XmlFieldBinding> fieldNames = + getAllBindingFields(formType); + + if (bindings != null && !bindings.isEmpty()) { + // si la liste des champs xml est vide (pas de resau ou flux invalide), + // on la recupère depuis la liste des champs déjà enregistrées. + boolean empty = xmlFieldNames.isEmpty(); + + for (XmlFieldBinding binding : bindings) { + String formField = binding.getFormField(); + + if (!fieldNames.containsKey(formField)) { + // ce champ était présent lors du precedent enregistrement des bindings + // mais il n'existe plus dans l'extension formType + continue; + } + + fieldNames.put(formField, binding); + + if (empty) { + Set<String> xmlFields = binding.getXmlField(); + if (xmlFields != null) { + xmlFieldNames.addAll(xmlFields); + } + } + } + } + + // mise a jour de l'univers des valeurs selectionnables + ArrayList<String> xmlFieldList = new ArrayList<String>(xmlFieldNames); + xmlStreamUI.getContextValue(JListCellEditor.class).updateUniverse(xmlFieldList); + xmlStreamUI.getContextValue(JListCellRenderer.class).updateUniverse(xmlFieldList); + + // ajout des bindings au model + Collection<XmlFieldBinding> bindingCollection = fieldNames.values(); + fieldsModel.setBindings(bindingCollection); + + JXTable fieldsTable = xmlStreamUI.getFieldsTable(); + if (!xmlFieldNames.isEmpty()) { + fieldsTable.setRowHeight(19 * xmlFieldNames.size()); + } else { + fieldsTable.setRowHeight(19); + } + + } catch (VradiException e) { + log.error(e.getMessage(), e); + ErrorDialogUI.showError(e); + + } catch (Exception e) { + log.error(e.getMessage(), e); + + } finally { + fieldsModel.fireTableDataChanged(); + fieldsModel.setValueIsAdjusting(false); + } + } + + /** + * Crée une map de tous les bindings formfield/xmlfields indexée par nom de formfield. + * + * @param formType liste de fields d'un type de formulaire. + * @return une map de bindings ordonnée. + */ + private LinkedHashMap<String, XmlFieldBinding> getAllBindingFields(WikittyExtension formType) { + LinkedHashMap<String, XmlFieldBinding> fieldMap + = new LinkedHashMap<String, XmlFieldBinding>(); + + // form fields + fieldMap.put(Form.FQ_FIELD_INFOGENE_OBJET, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_DESCRIPTION, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_FORM_DATEPUB, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_FORM_DATEPEREMPTION, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_ENTITY, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_SOURCETEXT, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_SOURCEURL, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_COUNTRY, new XmlFieldBindingImpl()); + fieldMap.put(Form.FQ_FIELD_INFOGENE_DEPARTMENT, new XmlFieldBindingImpl()); + + // formtype's bindings fields + Collection<String> fieldNames = formType.getFieldNames(); + for (String fieldName : fieldNames) { + fieldMap.put(formType.getName() + "." + fieldName, new XmlFieldBindingImpl()); + } + + for (Map.Entry<String, XmlFieldBinding> entry : fieldMap.entrySet()) { + XmlFieldBinding value = entry.getValue(); + value.setFormField(entry.getKey()); + } + + return fieldMap; + } + + /** + * Recherche les noms des elements fils d'un item rss. + * + * @param url url du flux rss + * @return liste de noms d'elements (les noms sont uniques) + * @throws VradiException + */ + private Set<String> getXmlFieldNames(String url) throws VradiException { + Set<String> xmlFieldNames = new LinkedHashSet<String>(); + Map<String, Element> xmlStreamFields = XML_STREAM_FIELDS_CACHE; + + Element element = xmlStreamFields.get(url); + if (element == null) { + try { + Element firstElement = XmlStreamHelper.getFirstElement(url); + xmlFieldNames = XmlStreamHelper.getRSSFields(firstElement); + xmlStreamFields.put(url, firstElement); + + } catch (Exception e) { + log.warn(e.getMessage(), e); + } + } else { + xmlFieldNames = XmlStreamHelper.getRSSFields(element); + } + + return xmlFieldNames; + } + + public void updateTemplateFieldTableModel(TemplateFieldBindingUI context, + WikittyExtension extension, String templateName) { + + context.setTemplate(templateName); + context.setExtension(extension); + TemplateFieldTableModel model = context.getFieldsModel(); + + model.setValueIsAdjusting(true); + model.clear(); + + // mise a jour de l'univers des valeurs selectionnables + List<String> fieldNames = new LinkedList<String>(); + fieldNames.add(Form.FQ_FIELD_INFOGENE_ID); + fieldNames.add(Form.FQ_FIELD_INFOGENE_OBJET); + fieldNames.add(Form.FQ_FIELD_INFOGENE_DESCRIPTION); + fieldNames.add(Form.FQ_FIELD_INFOGENE_CREATIONDATE); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fieldNames.add(Form.FQ_FIELD_INFOGENE_ENTITY); + fieldNames.add(Form.FQ_FIELD_INFOGENE_SOURCETEXT); + fieldNames.add(Form.FQ_FIELD_INFOGENE_SOURCEURL); + fieldNames.add(Form.FQ_FIELD_INFOGENE_COUNTRY); + fieldNames.add(Form.FQ_FIELD_INFOGENE_DEPARTMENT); + + for (String fieldName : extension.getFieldNames()) { + fieldNames.add(extension.getName() + "." + fieldName); + } + + context.getContextValue(JListCellEditor.class).updateUniverse(fieldNames); + context.getContextValue(JListCellRenderer.class).updateUniverse(fieldNames); + if (fieldNames.size() > 0) { + context.getFieldsTable().setRowHeight(19 * fieldNames.size()); + } + + try { + Map<String, String> fieldMap = VradiService.getVradiStorageService().getAssociatedFields( + extension.getName(), templateName); + + // null = no save found, empty configuration + if (fieldMap == null || fieldMap.isEmpty()) { + fieldMap = new HashMap<String, String>(); + + List<String> templateFields = VradiService.getVradiStorageService().getDocumentFields(extension, templateName); + for (String field : templateFields) { + fieldMap.put(field, null); + } + } + model.setData(fieldMap); + + } catch (Exception eee) { + log.error("Cant update template", eee); + ErrorDialogUI.showError(eee); + + } finally { + model.fireTableDataChanged(); + model.setValueIsAdjusting(false); + } + } + + private AdminXmlStreamUI getXmlStreamUI(JAXXContext context) { + if (context instanceof AdminXmlStreamUI) { + return (AdminXmlStreamUI) context; + } + return null; + } + + public String getFirstElementPreview(JAXXContext context, XmlStream bean) { + if (bean == null || bean instanceof WebHarvestStream) { + return ""; + } + + String url = bean.getUrl(); + if (url == null || url.trim().isEmpty()) { + return ""; + } + + Element firstElement = null; + Map<String, Element> xmlStreamFields = XML_STREAM_FIELDS_CACHE; + + if (xmlStreamFields.get(url) == null) { + AdminXmlStreamUI ui = getXmlStreamUI(context); + try { + ui.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + firstElement = XmlStreamHelper.getFirstElement(url); + xmlStreamFields.put(url, firstElement); + } catch (Exception eee) { + log.error("Can't get preview", eee); + return null; + } finally { + ui.setCursor(null); + } + + } else { + firstElement = xmlStreamFields.get(url); + } + + if (firstElement == null) { + return ""; + } + + Map<String, String> elementValues = XmlStreamHelper.getFirstElementValues(firstElement); + + StringBuffer result = new StringBuffer(); + result.append("<html>"); + + for (Map.Entry<String, String> entry : elementValues.entrySet()) { + result.append("<strong>").append(entry.getKey()) + .append("</strong>").append(" : "); + + String value = entry.getValue(); + if (value.length() > TOOLTIP_ELEMENT_MAX_CHAR_NB) { + value = StringUtils.replace(value, "\r", ""); + value = StringUtils.replace(value, "\n\n", "\n"); + value = StringUtils.abbreviate(value, TOOLTIP_ELEMENT_MAX_CHAR_NB); + value = StringUtils.replace(value, "\n", "<br/>"); + } + result.append(value).append("<br/>"); + } + + result.append("</html>"); + return result.toString(); + } + + /** + * Get combo box model with all template registred for specified extension. + * + * @param extension extension to get template list (can be null) + * @return combo box model + */ + public ComboBoxModel getTemplateComboBoxModel(WikittyExtension extension) { + /*File[] files = getVradiStorageService().getTemplates(extension); + if(files != null) { + return new DefaultComboBoxModel(files) { + @Override + public void setSelectedItem(Object item) { + if (item == null || !String.class.equals(item.getClass())) { + super.setSelectedItem(item); + } else { + for (int i = 0; i < this.getSize(); i++) { + File f = (File) this.getElementAt(i); + if (f.getName().equals(item)) { + super.setSelectedItem(f); + break; + } + } + } + } + }; + } else { + return new DefaultComboBoxModel(); + }*/ + + ComboBoxModel result = null; + if (extension != null) { + Collection<String> fileNames = VradiService.getVradiStorageService().getTemplateFilenames(extension); + if (CollectionUtils.isNotEmpty(fileNames)) { + result = new DefaultComboBoxModel(fileNames.toArray(new String[fileNames.size()])); + // ca marche a suposer que ce que appele ce code + // fait un ComboBoxModel.setSelectedItem(String) + // avec en argument le nom du template selectionne + } + } + + if (result == null) { + result = new DefaultComboBoxModel(); + } + + return result; + } + + public void showTemplateExample(AdminFormTypeUI context) { + WikittyExtension extension = context.getBean(); + + FormPagedResult formPage = new FormPagedResult(); + QueryParameters queryParameters = new QueryParameters(); + queryParameters.setExtension(extension); + formPage = VradiHelper.executeQuery(queryParameters, formPage); + + if (formPage.getTotalFoundFormNb() > 0) { + String formId = formPage.getFormsIdsToShow().get(0); + try { + context.setCursor(new Cursor(Cursor.WAIT_CURSOR)); + + //File file = VradiHelper.generatePDF(form); + String uri = VradiService.getVradiStorageService().generatePDF(formId, false); + File exampleFile = VradiService.getFileService().downloadPDF(uri); + Desktop.getDesktop().open(exampleFile); + + } catch (VradiException e) { + log.error(e.getMessage(), e); + ErrorDialogUI.showError(e); + + } catch (Exception e) { + log.error(e.getMessage(), e); + + } finally { + context.setCursor(null); + } + } else { + JOptionPane.showMessageDialog(context, + _("vradi.adminFormType.template.showExample.error.message"), + _("vradi.adminFormType.template.showExample.error.title"), + JOptionPane.ERROR_MESSAGE); + } + } + + /** + * Upload local file on server and refresh template list combo box. + * + * @param adminFormTypeUI parent ui + * @return {@code true} if file has been uploaded + */ + public boolean uploadNewTemplate(AdminFormTypeUI adminFormTypeUI) { + + boolean result = false; + + try { + File template = FileUtil.getFile(adminFormTypeUI, new FileFilter() { + @Override + public boolean accept(File file) { + + return file.isDirectory() || file.getName().endsWith(".odt") || file.getName().endsWith(".ott"); + } + + @Override + public String getDescription() { + return _("vradi.file.template.description"); + } + }); + + if (template != null) { + + // interdiction des characteres spéciaux dans les noms de fichier + // bug hessian et pas top d'avoir des accents + String filename = template.getName(); + if (!filename.matches("[a-zA-Z0-9_]+")) { + JOptionPane.showMessageDialog(adminFormTypeUI, _("vradi.file.template.wrongFileNamePattern")); + } else { + String extensionName = adminFormTypeUI.getBean().getName(); + String uri = VradiService.getFileService().uploadTemplate(template, extensionName); + + JComboBox templates = adminFormTypeUI.getTemplateChoice(); + templates.addItem(uri); + templates.setSelectedItem(uri); + + result = true; + } + } + + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error(_("Can't upload file"), ex); + } + ErrorDialogUI.showError(ex); + } + + return result; + } + + /** + * Ask for user where to save template and download it. + * + * @param adminFormTypeUI parent ui + */ + public void downloadTemplate(AdminFormTypeUI adminFormTypeUI) { + try { + + String selectedTemplate = (String) adminFormTypeUI.getTemplateChoice().getSelectedItem(); + // bindings has not been done (can be called with empty selection) + if (StringUtils.isEmpty(selectedTemplate)) { + return; + } + + File savedTemplate = FileUtil.getFile(adminFormTypeUI, new FileFilter[0]); + + if (savedTemplate != null) { + + String extensionName = adminFormTypeUI.getBean().getName(); + + File downloadedFile = VradiService.getFileService().downloadTemplate(extensionName, selectedTemplate); + + // copy is mandatory (in local mode original file is returned) + FileUtils.copyFile(downloadedFile, savedTemplate); + } + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error(_("Can't download file"), eee); + } + ErrorDialogUI.showError(eee); + } + } + + /** + * Open rss representing group request historique in web broser + * + * @param id of group with request + */ + public void showHistory(String id) { + + try { + String url = VradiService.getFileService().getRequestHistoryURL(id + ".rss"); + + if (log.isDebugEnabled()) { + log.debug("Opening request history : " + url); + } + + try { + UIHelper.browseURI(url); + } catch (IOException eee) { + log.error("Cannot display history for group : " + id); + JOptionPane.showMessageDialog(null, + _("vradi.message.cannot.display.history")); + + } + + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.warn(_("Can't download file"), eee); + } + JOptionPane.showConfirmDialog(new JFrame(), + _("vradi.error.cantOpenHistory"), + _("vradi.error.cantOpenHistory.title"), + JOptionPane.ERROR_MESSAGE); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavTreeFilter.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavTreeFilter.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavTreeFilter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,177 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.widget.tree.TreeFilter; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.tree.TreeModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Implementation of admin navigation tree filter. + * <p/> + * Pour l'instant, le filter regarde principalement si le getName de l'intité + * en question "contient" le {@link #filterString}. + * <p/> + * Mais on pourrait matcher sur autre chose, description ... + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class AdminNavTreeFilter implements TreeFilter { + + static private final Log log = LogFactory.getLog(AdminNavTreeFilter.class); + + protected String filterString; + + public AdminNavTreeFilter(String filterString) { + this.filterString = filterString.toLowerCase(); + } + + /* + * @see org.nuiton.widget.tree.TreeFilter#include(javax.swing.tree.TreeModel, java.lang.Object) + */ + @Override + public boolean include(TreeModel model, Object node) { + + // empty filter, no filtering + if (StringUtils.isEmpty(filterString)) { + return true; + } + + // filter real user object + if (log.isDebugEnabled()) { + log.debug("Todo filter string : " + filterString + " on " + node); + } + + VradiTreeNode vradiNode = (VradiTreeNode) node; + String id = vradiNode.getId(); + Class<?> nodeType = vradiNode.getInternalClass(); + + // si c'est un noeaud intermediaire, on l'affiche tout le temps + if (vradiNode.isStringNode()) { + return true; + } + + // un client (si son nom match ou ses users) + else if (nodeType.equals(Client.class)) { + Client client = VradiService.getWikittyProxy().restore(Client.class, id); + if (client.getName().toLowerCase().contains(filterString)) { + return true; + } + + // Get user category node + List<User> users = VradiService.getVradiDataService().findClientUsers(id); + if (users != null) { + for (User user : users) { + if (user.getName().toLowerCase().contains(filterString)) { + return true; + } + } + } + } + + // un utilisateur (filtre s'il match ou son client/group match) + else if (nodeType.equals(User.class)) { + User user = VradiService.getWikittyProxy().restore(User.class, id); + if (user.getName().toLowerCase().contains(filterString)) { + return true; + } + + VradiTreeNode clientNode = AdminNavigationTreeHelper.getParentNode(vradiNode, Client.class); + + // cas ou le parent est un client + if (clientNode != null) { + Client client = VradiService.getWikittyProxy().restore(Client.class, clientNode.getId()); + if (client.getName().toLowerCase().contains(filterString)) { + return true; + } + } + // cas ou le parent est un group + else { + VradiTreeNode groupNode = AdminNavigationTreeHelper.getParentNode(vradiNode, Group.class); + Group group = VradiService.getWikittyProxy().restore(Group.class, groupNode.getId()); + if (group.getName().toLowerCase().contains(filterString)) { + return true; + } + } + } + + // group + else if (nodeType.equals(Group.class)) { + Group group = VradiService.getWikittyProxy().restore(Group.class, id); + if (group.getName().toLowerCase().contains(filterString)) { + return true; + } + Set<String> userIds = group.getUser(); + if (userIds != null) { + List<User> users = VradiService.getWikittyProxy().restore(User.class, new ArrayList<String>(userIds)); + for (User user : users) { + if (user.getName().toLowerCase().contains(filterString)) { + return true; + } + } + } + } + + // un formulaire (filtre sur son nom seulement) + else if (nodeType.equals(WikittyExtension.class)) { + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + WikittyExtension formType = wikittyProxy.restoreExtension(id); + if (formType.getName().toLowerCase().contains(filterString)) { + return true; + } + } + + // flux xml + else if (nodeType.equals(XmlStream.class)) { + XmlStream xmlStream = VradiService.getWikittyProxy().restore(XmlStream.class, id); + + if (xmlStream.getName().toLowerCase().contains(filterString)) { + return true; + } + } + + return false; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavTreeFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,185 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JSplitPane id='adminNavUI' + resizeWeight='{0.1}' + oneTouchExpandable='true' + dividerLocation='{200}'> + + <style source='../VradiMainUI.css'/> + + <import> + javax.swing.tree.TreePath + javax.swing.tree.TreeSelectionModel + javax.swing.tree.TreeNode + jaxx.runtime.swing.CardLayout2 + jaxx.runtime.JAXXContext + org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper + javax.swing.tree.TreeModel + org.nuiton.widget.datatips.DataTipManager + org.apache.commons.lang.StringUtils + org.chorem.vradi.ui.tree.VradiDataProvider + org.chorem.vradi.ui.tree.VradiTreeNode + jaxx.runtime.decorator.DecoratorProvider + org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper + org.chorem.vradi.ui.admin.renderers.AdminCellRenderer + org.chorem.vradi.VradiHelper + org.chorem.vradi.ui.admin.helpers.AdminBeanConstant + org.nuiton.wikitty.entities.BusinessEntity + org.chorem.vradi.ui.admin.models.AdminTreeSelectionModel + </import> + + <CardLayout2 id='contentLayout' useOnlyVisibleComponentDimension='true'/> + + <!-- Cause java.lang.ClassCastException: org.nuiton.widget.tree.FilterTreeModel +cannot be cast to javax.swing.tree.DefaultTreeModel --> + <org.nuiton.widget.tree.FilterTreeModel id="filterTreeModel" + javaBean="new org.nuiton.widget.tree.FilterTreeModel(getHelper().createTreeModel())"/> + + <Boolean id='showImportExport' javaBean='false'/> + + <script><![CDATA[ + +public static final String NONE = "none"; + +// FIXME add doc about this code !!! Useless now, keep it if commenting it created some bug +//protected boolean contextInitialized = false; + +public AdminNavUI(JAXXContext parentContext, AdminNavigationTreeHelper helper) { + SwingUtil.initContext(this, parentContext); + setContextValue(helper); + // FIXME add doc about this code !!! Useless now, keep it if commenting it created some bug + //contextInitialized = true; +} + +public AdminContentUI getCurrentContent() { + Component visibleComponent = contentLayout.getVisibleComponent(content); + if (visibleComponent instanceof AdminContentUI) { + return (AdminContentUI) visibleComponent; + } + return null; +} + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +protected AdminNavigationTreeHelper getHelper() { + return getContextValue(AdminNavigationTreeHelper.class); +} + +protected void $afterCompleteSetup() { + + SwingUtil.addExpandOnClickListener(nav); + + // extended tooltip for hidden content + DataTipManager.get().register(nav); + + VradiDataProvider dataProvider = getHelper().getDataProvider(); + + // Register decorator + DecoratorProvider decoratorProvider = VradiContext.get().getDecoratorProvider(); + + // Attach renderer + nav.setCellRenderer(new AdminCellRenderer(decoratorProvider, dataProvider)); + nav.setSelectionModel(new AdminTreeSelectionModel(this, getHandler())); + + // Register tree + getHelper().setUI(nav, true); + + // Single selection mode + nav.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); +} + +/** + * Update tree filter on filter model and expand all tree. + */ +protected void updateFilter() { + String filterString = filterField.getText(); + AdminNavTreeFilter treeFilter = new AdminNavTreeFilter(filterString); + filterTreeModel.setFilter(treeFilter); + + // si le filtre n'est pas vide, on etend completement l'arbre + if (StringUtils.isNotEmpty(filterString)) { + + // expand the tree + SwingUtil.expandTree(nav); + } +} + +/** + * Reset filter (clear filter text). + */ +public void resetFilter() { + getFilterField().setText(""); +} + +protected void sort() { + resetFilter(); + nav.setModel(getHelper().createTreeModel()); +} +]]> + </script> + + <JPanel id='navPanel' layout='{new BorderLayout()}'> + + <JScrollPane constraints='BorderLayout.CENTER' + columnHeaderView='{headerPanel}'> + + <JTree id="nav" + font-size='11' + rootVisible='false' + showsRootHandles='false' + model='{filterTreeModel}'/> + + <JToolBar floatable='false' id='headerPanel' + layout='{new BorderLayout()}'> + <JTextField id='filterField' constraints='BorderLayout.CENTER'/> + <JButton id='sortButton' actionIcon='sort' + constraints='BorderLayout.EAST' onActionPerformed='sort()'/> + </JToolBar> + + </JScrollPane> + + <javax.swing.text.Document javaBean="filterField.getDocument()" + onInsertUpdate='updateFilter()' + onRemoveUpdate='updateFilter()'/> + + <JToolBar floatable='false' id='importPanel' + visible='{isShowImportExport()}' + layout='{new GridLayout(1, 2)}' constraints='BorderLayout.SOUTH'> + + <JButton text="vradi.admin.importCSV" actionIcon='import' + onActionPerformed="getHandler().importClientUsersDBCSV(this)"/> + <JButton text="vradi.admin.exportCSV" actionIcon="export" + onActionPerformed="getHandler().exportClientUsersDBCSV(this)"/> + </JToolBar> + </JPanel> + <JPanel id="content" layout="{contentLayout}"> + <JPanel layout='{new BorderLayout()}' constraints='NONE'> + <JLabel id='none' horizontalAlignment="0" text="vradi.email.noSelection" + constraints='BorderLayout.CENTER'/> + </JPanel> + </JPanel> +</JSplitPane> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminNavUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminPopupUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminPopupUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminPopupUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,196 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JFrame id='adminPopupUI' + title='vradi.admin.title' + layout='{new BorderLayout()}' + defaultCloseOperation='{JFrame.DO_NOTHING_ON_CLOSE}' + onWindowClosing='close()'> + + <style source='../VradiMainUI.css'/> + + <import> + java.awt.Component + + javax.swing.DefaultSingleSelectionModel + javax.swing.JLabel + javax.swing.SingleSelectionModel + + org.chorem.vradi.ui.admin.content.AdminThesaurusHandler + org.chorem.vradi.ui.admin.content.* + org.chorem.vradi.ui.tree.VradiDataProvider + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper + org.chorem.vradi.ui.admin.helpers.ClientNavigationTreeHelper + org.chorem.vradi.ui.admin.helpers.GroupNavigationTreeHelper + org.chorem.vradi.ui.admin.helpers.FormTypeNavigationTreeHelper + org.chorem.vradi.ui.admin.helpers.XmlStreamNavigationTreeHelper + jaxx.runtime.JAXXContext + javax.swing.tree.TreePath + org.chorem.vradi.services.VradiService + org.chorem.vradi.services.VradiException + </import> + + <script><![CDATA[ + +private boolean contextInitialized; +private SingleSelectionModel selectionModel; + +private VradiDataProvider dataProvider = new VradiDataProvider(); + +public AdminPopupUI(JAXXContext parentContext, Window parent) { + super(); + SwingUtil.initContext(this, parentContext); + selectionModel = new DefaultSingleSelectionModel() { + private static final long serialVersionUID = 1L; + + @Override + public void setSelectedIndex(int index) { + int oldIndex = getSelectedIndex(); + if (oldIndex != -1) { + // on verifie que l'onglet en cours n'est pas modifie + AdminContentUI<?> content = getCurrentContent(); + + // null if is thesaurus selected + if (content != null){ + boolean canContinue = getHandler().answerToSave(content); + if (!canContinue) { + // l'utilisateur ne veut pas partir au final + return; + } + } + } + super.setSelectedIndex(index); + } + }; + contextInitialized = true; + this.pack(); +} + +protected AdminThesaurusHandler getThesaurusHandler() { + return UIHelper.getHandler(this, AdminThesaurusHandler.class); +} + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +public void close(){ + Component selected = adminTabs.getSelectedComponent(); + AdminHandler handler = getHandler(); + + // Nothing for thesaurus + if (selected instanceof AdminThesaurusUI) { + handler.close(this); + } + AdminContentUI currentContent; + + // Status ui is not nav ui + if (selected instanceof AdminStatusUI) { + currentContent = (AdminStatusUI) selected; + } else { + currentContent = getCurrentContent(); + + // if is thesaurus selected + if (currentContent == null){ + handler.close(this); + return; + } + } + boolean canContinue = handler.answerToSave(currentContent); + if (canContinue) { + handler.close(this); + } +} + +public void showTab(int i){ + adminTabs.setSelectedIndex(i); +} + +public AdminContentUI getCurrentContent() { + Component selected = adminTabs.getSelectedComponent(); + if (selected instanceof AdminNavUI) { + return ((AdminNavUI)selected).getCurrentContent(); + } else if (selected instanceof AdminStatusUI) { + return (AdminContentUI) selected; + } + return null; +} + +public AdminNavUI getCurrentTab() { + Component selected = adminTabs.getSelectedComponent(); + if (selected instanceof AdminThesaurusUI || + selected instanceof AdminStatusUI) { + return null; + } + return (AdminNavUI) selected; +} + +public AdminStatusUI getStatusTab(){ + return (AdminStatusUI)adminTabs.getComponentAt(4); +} + +public AdminThesaurusUI getTesaurusTab(){ + return (AdminThesaurusUI)adminTabs.getComponentAt(5); +} + +void $afterCompleteSetup() { + SwingUtil.center(getOwner(), this); +} +]]> + </script> + + <JTabbedPane id='adminTabs' constraints='BorderLayout.CENTER' + model='{selectionModel}'> + + <tab title='vradi.admin.client'> + <AdminNavUI id="clientAdminNavUI" + showImportExport='true' + constructorParams='this, new ClientNavigationTreeHelper(dataProvider)'/> + </tab> + <tab title='vradi.admin.group'> + <AdminNavUI id="groupAdminNavUI" + showImportExport='true' + constructorParams='this, new GroupNavigationTreeHelper(dataProvider)'/> + </tab> + <tab title='vradi.admin.form'> + <AdminNavUI id="formAdminNavUI" + constructorParams='this, new FormTypeNavigationTreeHelper(dataProvider)'/> + </tab> + <tab title='vradi.admin.xmlStream'> + <AdminNavUI id="xmlStreamAdminNavUI" + constructorParams='this, new XmlStreamNavigationTreeHelper(dataProvider)'/> + </tab> + <tab title='vradi.admin.status'> + <AdminStatusUI id='adminStatus' constructorParams='this'/> + </tab> + <tab title='vradi.admin.thesaurus'> + <AdminThesaurusUI id='adminThesaurus' + constructorParams='this, new ThesaurusTreeTableHelper()'/> + </tab> + </JTabbedPane> + + <JButton actionIcon='close' text='vradi.action.close' + constraints='BorderLayout.SOUTH' + onActionPerformed='close()'/> +</JFrame> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/AdminPopupUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminClientUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminClientUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminClientUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,215 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI superGenericType='Client' + enabled='{getBean() != null}'> + + <style source='../../VradiMainUI.css'/> + + <!-- bean property --> + <Client id='bean' javaBean='null'/> + + <!-- a state to known if attach to a group --> + <Boolean id='inGroup' javaBean='null'/> + + <!-- validators --> + <BeanValidator id='validator' + bean='{isEnabled() ? bean : null}' + beanClass='org.chorem.vradi.entities.Client'> + + <field name="name" component="clientName"/> + </BeanValidator> + + <import> + javax.swing.BoxLayout + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.text.DateFormat + java.util.Date + jaxx.runtime.swing.HidorButton + jaxx.runtime.swing.ListSelectorUI + static jaxx.runtime.SwingUtil.getStringValue + org.chorem.vradi.ui.tree.VradiTreeNode + org.chorem.vradi.ui.admin.helpers.AdminBeanConstant + </import> + + <script><![CDATA[ +void $afterCompleteSetup() { + errorTable.registerValidator(validator); +} + +@Override +protected void postLoadBean() { + + createButton.setEnabled(!isInCreation()); + + VradiTreeNode parentNode = getHelper().getParentCategoryNode(getHelper().getSelectedNode(), AdminBeanConstant.GROUP.getCategoryName()); + setInGroup(parentNode != null); +} + +@Override +public void save() { + + Client client = getHandler().saveClient(this, getHelper(), bean, null); + + //FIXME JC 25/08/2010 bean is the same (because of cache ?) so no property change fired. Set bean to null before to force fire. + setModified(false); + setBean(null); + setBean(client); + +} + +@Override +protected void clearUI() { + title.setText(updateTitle("")); + clientName.setText(""); + clientAddress.setText(""); + clientPhone.setText(""); + clientContact.setText(""); +} + +protected String updateTitle(String name) { + return _("vradi.adminClient.title", getStringValue(name)); +} + +protected void openAddressInBrowser() { + UIHelper.openAddressInBrowser(bean.getAddress()); +} + +]]> + </script> + + <Table id='toolbar' insets='0'> + <row> + <cell fill='horizontal' weightx='1' anchor='west'> + <JLabel id='title' styleClass='titleLeft' + text='{updateTitle(getBean().getName())}'/> + </cell> + <cell anchor='east'> + <JPanel> + <JButton id='createButton' + actionIcon='client.add' + text='vradi.adminClient.createClient' + enabled='{!isInCreation()}' + visible='{!isInGroup()}' + onActionPerformed='getHandler().createClient(this); + setModified(true);'/> + + <JButton text='vradi.adminClient.createUser' + enabled='{isEnabled() && !isInCreation()}' + visible='{!isInGroup()}' + onActionPerformed='getHandler().createUser(this, getHelper().getClientSelected())'/> + + <JButton actionIcon='client.delete' + toolTipText='vradi.adminClient.deleteClient' + enabled='{isEnabled() && !isInCreation()}' + visible='{!isInGroup()}' + onActionPerformed='getHandler().delete(this, getHelper(), getBean())'/> + + <!--JButton actionIcon='delete' + toolTipText='vradi.adminClient.deleteClientFromGroup' + enabled='{isEnabled()}' + visible='{isInGroup()}' + onActionPerformed='deleteFromGroup()'/--> + + <!--jaxx.runtime.swing.HidorButton target='{adminClientForm}' + hideTip='{_("vradi.adminClient.hideForm")}' + showTip='{_("vradi.adminClient.showForm")}' + targetVisible='{true}'/--> + </JPanel> + </cell> + </row> + </Table> + + <JPanel id='body'> + + <Table constraints='BorderLayout.NORTH' id="adminClientForm" + minimumSize='{SwingUtil.newMinDimension()}'> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminClient.name'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='clientName' text='{getBean().getName()}' + onKeyReleased='getBean().setName(clientName.getText()); + title.setText(updateTitle(getBean().getName()));'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminClient.adresse'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='clientAddress' text='{getBean().getAddress()}' + onKeyReleased='getBean().setAddress(clientAddress.getText())'/> + </cell> + <cell> + <JButton onActionPerformed='openAddressInBrowser()' + actionIcon="site"/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminClient.tel'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='clientPhone' text='{getBean().getPhone()}' + onKeyReleased='getBean().setPhone(clientPhone.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminClient.contact'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='clientContact' text='{getBean().getContact()}' + onKeyReleased='getBean().setContact(clientContact.getText())'/> + </cell> + </row> + </Table> + <!--Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' anchor="north"> + <JLabel text='vradi.adminClient.listGroup' visible='{!isInGroup()}'/> + </cell> + <cell fill='both' weightx='1' weighty='1'> + <ListSelectorUI id='clientGroups' genericType='Group' + visible='{!isInGroup()}' + showHidor='false' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + addToListTip='{_("vradi.adminClient.addGroup")}' + addToComboTip='{_("vradi.adminClient.removeGroups")}'/> + </cell> + </row> + </Table--> + + <!--RequestListUI id='requestListUI' + constructorParams='this' + constraints='BorderLayout.CENTER' + bean='{getBean()}'/--> + + </JPanel> + + +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminClientUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminFormTypeUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminFormTypeUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminFormTypeUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,335 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI superGenericType='WikittyExtension' + enabled='{getBean() != null}'> + + <style source='../../VradiMainUI.css'/> + + <import> + javax.swing.BoxLayout + + static jaxx.runtime.SwingUtil.getStringValue + + org.chorem.vradi.entities.Infogene + org.chorem.vradi.entities.Form + org.chorem.vradi.entities.FormImpl + org.chorem.vradi.ui.admin.popups.TemplateFieldBindingUI + + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + + org.nuiton.wikitty.entities.FieldType + org.chorem.vradi.VradiHelper + org.chorem.vradi.VradiContext + org.chorem.vradi.entities.InfogeneImpl + org.nuiton.wikitty.entities.WikittyExtension + jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer + org.chorem.vradi.ui.admin.models.FieldSelectModel + org.nuiton.wikitty.entities.WikittyI18n + org.nuiton.wikitty.addons.WikittyI18nUtil + org.chorem.vradi.ui.admin.widget.FieldSelectUI + org.chorem.vradi.services.VradiService + org.nuiton.wikitty.addons.WikittyI18nImpl + org.chorem.vradi.ui.admin.models.TemplateFieldTableModel + org.nuiton.wikitty.WikittyUtil + + java.text.DateFormat + java.util.Date + java.util.Collection + java.util.ArrayList + </import> + + <!-- bean property --> + <org.nuiton.wikitty.entities.WikittyExtension id='bean' javaBean='null'/> + + <jaxx.runtime.swing.CardLayout2 id='cardLayout' + useOnlyVisibleComponentDimension='{true}'/> + + <TemplateFieldTableModel id='fieldsModel' javaBean='null'/> + + <script><![CDATA[ + +protected WikittyI18n wikittyI18n; + +public WikittyI18n getWikittyI18n() { + return wikittyI18n; +} + +public void setWikittyI18n(WikittyI18n wikittyI18n) { + this.wikittyI18n = wikittyI18n; +} + +@Override +protected void postLoadBean() { + + title.setText(_("vradi.adminForm.title", getStringValue(bean == null ? "" : bean.getName()))); + if (bean == null) { + return; + } + + // Update template choice + templateChoice.setModel(getHandler().getTemplateComboBoxModel(bean)); + + // Select template + templateChoice.setSelectedItem(getHandler().getFormTypeTemplateName(bean)); + + // Fill other fields that infogene + int i = 0; + Collection<String> fieldNames = bean.getFieldNames(); + + // Get traduction for extension + wikittyI18n = WikittyI18nUtil.getI18n(VradiService.getWikittyProxy(), bean); + + for (String fieldName : fieldNames) { + FieldType fieldType = bean.getFieldType(fieldName); + FieldSelectModel fieldSelectModel = new FieldSelectModel(fieldName, fieldType, wikittyI18n, i); + create(fieldSelectModel, false); + i = i + 1; + } + fillInfogenePanel(); + setModified(false); + validate(); +} + +@Override +public void save() { + getHandler().saveFormType(this, getHelper()); + setModified(false); +} + +@Override +protected void clearUI() { + content.removeAll(); +} + +protected void create() { + create(new FieldSelectModel(content.getComponentCount()), false); +} + +protected FieldSelectUI create(FieldSelectModel fieldSelectModel, boolean isInfogene){ + FieldSelectUI result = new FieldSelectUI(this); + + result.updateBean(fieldSelectModel); + result.addPropertyChangeListener(FieldSelectUI.PROPERTY_MODIFIED, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + FieldSelectUI field = (FieldSelectUI) evt.getSource(); + if (log.isDebugEnabled()) { + log.debug("field " + field + " modified value = " + evt.getNewValue()); + } + setModified(true); + if(evt.getNewValue() == null) { + + if(field != null) { + field.setVisible(false); + content.remove(field); + } + if(field.getBean().isUpOrDown() != null) { + if(field.getBean().isUpOrDown() && field.getBean().getPosition() == 0) { + content.add(field, 0); + } else if(!field.getBean().isUpOrDown() && field.getBean().getPosition() == content.getComponentCount()) { + content.add(field); + } else { + int fieldToMovePosition = field.getBean().isUpOrDown() ? + field.getBean().getPosition() - 1 : field.getBean().getPosition(); + int fieldToAddPosition = field.getBean().isUpOrDown() ? + field.getBean().getPosition() - 1 : field.getBean().getPosition() + 1; + FieldSelectUI fieldToMove = (FieldSelectUI) content.getComponent(fieldToMovePosition); + if (log.isDebugEnabled()) { + log.debug(fieldToMove.getBean().getNameValue() + " : " + fieldToMove.getBean().getPosition()); + } + + content.add(field, fieldToAddPosition); + for(int i = 0 ; i < content.getComponentCount() ; i++) { + FieldSelectUI fieldSelectUI = (FieldSelectUI) content.getComponent(i); + fieldSelectUI.getBean().setPosition(i); + if (log.isDebugEnabled()) { + log.debug(fieldSelectUI.getBean().getNameValue() + " : " + fieldSelectUI.getBean().getPosition()); + } + } + } + field.getBean().setUpOrDown(null); + field.setVisible(true); + } + content.validate(); + } + } + }); + result.setModified(false); + result.setInfogene(isInfogene); + + content.add(result); + validate(); + + return result; +} + +private void fillInfogenePanel() { + infogene.removeAll(); + WikittyExtension extension = InfogeneImpl.extensionInfogene; + int i = 0; + java.util.List<String> fqFieldNames = new ArrayList<String>(); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_ID); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_OBJET); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_DESCRIPTION); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_CREATIONDATE); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_ENTITY); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCETEXT); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCEURL); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_COUNTRY); + fqFieldNames.add(Infogene.FQ_FIELD_INFOGENE_DEPARTMENT); + fillInfogenePanel(fqFieldNames, extension, i); + + extension = FormImpl.extensionForm; + fqFieldNames.clear(); + fqFieldNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fqFieldNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fillInfogenePanel(fqFieldNames, extension, i); +} + +private void fillInfogenePanel(java.util.List<String> fqFieldNames, + WikittyExtension extension, int i) { + + for (String fqFieldName : fqFieldNames) { + FieldType fieldType = extension.getFieldType(WikittyUtil.getFieldNameFromFQFieldName(fqFieldName)); + + FieldSelectModel fieldSelectModel = new FieldSelectModel(fqFieldName, fieldType, null, i); + + FieldSelectUI fieldDisplayUI = create(fieldSelectModel, true); + + infogene.add(fieldDisplayUI); + i = i + 1; + } + +} + +private void onHidorInfogene() { + if (hidorInfogene.isSelected()) { + cardLayout.show(cardPanel, "infogene"); + } else { + cardLayout.show(cardPanel, "content"); + } +} + +private void openTemplateFieldBindingUI() { + TemplateFieldBindingUI templateFieldBindingUI = + new TemplateFieldBindingUI(this); + getHandler().updateTemplateFieldTableModel(templateFieldBindingUI, + getBean(), (String) templateChoice.getSelectedItem()); + templateFieldBindingUI.setVisible(true); + setFieldsModel(templateFieldBindingUI.getFieldsModel()); + if (getFieldsModel() != null) { + setModified(true); + } +} + +protected void addNewTemplate() { + if (getHandler().uploadNewTemplate(this)) { + openTemplateFieldBindingUI(); + } +} +]]></script> + + <Table id='toolbar'> + <row> + <cell fill='horizontal' weightx='1' anchor='west'> + <JLabel styleClass='titleLeft' id='title'/> + </cell> + <cell fill='horizontal' anchor='east'> + <JButton id='createForm' + text='vradi.adminForm.createForm' + onActionPerformed='getHandler().createFormType(this, getHelper()); setModified(true);'/> + </cell> + <cell fill='horizontal' anchor='east'> + <JButton actionIcon='delete' + toolTipText='vradi.adminForm.deleteFormType' + enabled='{isEnabled() && !isInCreation()}' + onActionPerformed='getHandler().delete(this, getHelper(), getBean())'/> + </cell> + </row> + </Table> + + <JPanel id="body"> + <Table id='fieldListUI' constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' anchor='west'> + <JLabel text='vradi.adminField.title'/> + </cell> + <cell anchor='east'> + <JPanel> + <JButton id='createField' text='vradi.adminField.new' + actionIcon='add' + onActionPerformed='create()'/> + + <jaxx.runtime.swing.HidorButton id='hidorInfogene' + hideText='{_("vradi.adminFormType.hideInfogene")}' + showText='{_("vradi.adminFormType.showInfogene")}' + target='{new jaxx.runtime.swing.Spacer()}' + targetVisible='{false}' + onActionPerformed='onHidorInfogene()' + constraints='BorderLayout.WEST'/> + </JPanel> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='1'> + <JScrollPane> + <JPanel id='cardPanel' layout='{cardLayout}'> + <VBox id='content' constraints='"content"'/> + <JPanel id='infogene' + constraints='"infogene"' + layout='{new GridLayout(0,1)}'/> + </JPanel> + </JScrollPane> + </cell> + </row> + <row> + <cell anchor='west' columns='2' weightx='1'> + <JPanel> + <JLabel text='vradi.adminFormType.template.label'/> + <JComboBox id='templateChoice' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + onActionPerformed='setModified(true);'/> + <JButton id='newTemplate' + text='vradi.adminFormType.template.new' + onActionPerformed='addNewTemplate()'/> + <JButton id='downloadTemplate' + text='vradi.adminFormType.template.download' + onActionPerformed='getHandler().downloadTemplate(this)'/> + <JButton id='templateBindingButton' + text='vradi.adminFormType.template.fieldBinding' + onActionPerformed='openTemplateFieldBindingUI()'/> + <JButton id='templateExampleButton' + text='vradi.adminFormType.template.showExample' + onActionPerformed='getHandler().showTemplateExample(this)'/> + </JPanel> + </cell> + </row> + </Table> + + <HBox id='lastModified' horizontalAlignment='right' + constraints='BorderLayout.SOUTH'/> + </JPanel> + +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminFormTypeUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminGroupUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminGroupUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminGroupUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,240 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI superGenericType='Group' + enabled='{getBean() != null}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.text.DateFormat + java.util.Collections + java.util.Set + java.util.Date + + javax.swing.BoxLayout + + org.chorem.vradi.entities.User + org.chorem.vradi.services.VradiService + + jaxx.runtime.swing.HidorButton + jaxx.runtime.swing.ListSelectorUI + static jaxx.runtime.SwingUtil.getStringValue + org.chorem.vradi.VradiConstants + org.jdesktop.swingx.autocomplete.AutoCompleteDecorator + org.chorem.vradi.ui.renderers.EntityRenderer + org.chorem.vradi.ui.helpers.VradiComparators + org.chorem.vradi.ui.admin.widget.UserListSelectorHandler + </import> + + <!-- validators --> + <BeanValidator id='validator' + bean='{isEnabled() ? bean : null}' + beanClass='org.chorem.vradi.entities.Group'> + <field name="name" component="groupName"/> + </BeanValidator> + + <!-- bean property --> + <Group id='bean' javaBean='null'/> + + <UserListSelectorHandler id='groupUserHandler' javaBean='null'/> + + <script><![CDATA[ + +void $afterCompleteSetup() { + + AutoCompleteDecorator.decorate(groupUsers.getCombo(), EntityRenderer.getInstance()); + + groupUsers.addPropertyChangeListener("modified", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Boolean b = (Boolean) evt.getNewValue(); + if (b != null && b) { + log.info("modified changed from users"); + setModified(true); + } + } + }); + errorTable.registerValidator(validator); + + groupUserHandler = new UserListSelectorHandler(groupUsers); + groupUsers.setHandler(groupUserHandler); +} + +/** + * Fill groups and users ListSelectorUI. + */ +@Override +protected void postLoadBean() { + + createButton.setEnabled(!isInCreation()); + + requestListUI.setBean(bean); + groupUserHandler.setBean(bean); + if (bean == null) { + + // Clear all user + groupUsers.init(Collections.EMPTY_LIST, Collections.EMPTY_LIST); + + // Clear all requests + requestListUI.init(); + + return; + } + + Set<String> users = bean.getUser(); + + java.util.List<User> toUserList = new java.util.ArrayList<User>(); + if (users != null){ + toUserList = VradiService.getWikittyProxy().restore(User.class, new ArrayList<String>(users)); + } + + java.util.List<User> toUserCombo = new java.util.ArrayList<User>(getHandler().getAllUsers()); + + toUserCombo.removeAll(toUserList); + + // Sort + Collections.sort(toUserList, VradiComparators.USER_COMPARATOR); + + groupUsers.init(toUserCombo, toUserList); + + requestListUI.setBean(bean); + requestListUI.init(); + groupUserHandler.setBean(bean); +} + +@Override +public void save() { + setModified(false); + + //Use new list to avoid empty queries after clearing + Group bean = requestListUI.getBean(); + java.util.List<String> queries = null; + if (bean.getQueries()!=null){ + queries = new java.util.ArrayList<String>(requestListUI.getBean().getQueries()); + } + + //Store queries + bean.clearQueries(); + if (queries!=null){ + for (String query : queries) { + bean.addQueries(query); + } + } + + //Store users + bean.clearUser(); + for (User user : groupUsers.getListDatas()) { + log.debug("Store user : " + user.getName()); + bean.addUser(user.getWikittyId()); + } + + //Set modified to false just before saving to avoid multiple confirmation + setModified(false); + Group group = getHandler().saveGroup(this, getHelper(), bean); + + + //FIXME JC 25/08/2010 bean is the same (because of cache ?) so no property change fired. Set bean to null before to force fire. + setModified(false); + setBean(null); + setBean(group); + + groupUsers.setModified(false); +} + +@Override +protected void clearUI() { + title.setText(updateTitle("")); + groupName.setText(""); + groupUsers.init(null, null); +} + +protected String updateTitle(String name) { + return _("vradi.adminGroup.title", getStringValue(name)); +} + +]]> + </script> + + <Table id='toolbar' insets='0'> + <row> + <cell fill='horizontal' weightx='1' anchor='west'> + <JLabel id='title' styleClass='titleLeft' + text='{updateTitle(getBean().getName())}'/> + </cell> + <cell anchor='east'> + <JPanel> + <JButton id='createButton' + actionIcon='group.add' + text='vradi.adminGroup.createGroup' + enabled='{!isInCreation()}' + onActionPerformed='getHandler().createGroup(this);setModified(true);'/> + + <JButton actionIcon='group.delete' + toolTipText='vradi.adminClient.deleteGroup' + enabled='{isEnabled() && !isInCreation()}' + onActionPerformed='getHandler().delete(this, getHelper(), getBean())'/> + </JPanel> + </cell> + </row> + </Table> + + <JPanel id='body'> + <Table id='adminGroupForm' constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminGroup.name'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='groupName' text='{getBean().getName()}' + onKeyReleased='getBean().setName(groupName.getText()); + title.setText(updateTitle(getBean().getName()));'/> + </cell> + </row> + <row> + <cell fill='horizontal' anchor="north"> + <JLabel text='vradi.adminGroup.listUsers'/> + </cell> + <cell fill='both' weightx='1' weighty='2'> + <ListSelectorUI id='groupUsers' + genericType='User' + handler='{groupUserHandler}' + showHidor='false' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + addToListTip='{_("vradi.adminGroup.addUser")}' + addToComboTip='{_("vradi.adminGroup.removeUser")}'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1' weighty='3'> + <RequestListUI id='requestListUI' constructorParams='this' + bean='{getBean()}'/> + </cell> + </row> + </Table> + </JPanel> + +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminGroupUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminStatusUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminStatusUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminStatusUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,236 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI id='adminStatusUI'> + + <import> + java.awt.Component + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + javax.swing.BoxLayout + javax.swing.JOptionPane + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + jaxx.runtime.swing.BlockingLayerUI + + org.nuiton.validator.bean.BeanValidatorEvent + org.nuiton.validator.bean.BeanValidatorListener + + org.chorem.vradi.entities.Status + org.chorem.vradi.entities.StatusImpl + org.chorem.vradi.ui.admin.AdminHandler + + static jaxx.runtime.SwingUtil.getStringValue + java.util.List + java.util.ArrayList + </import> + + <script><![CDATA[ + +protected List<Status> statuses; +protected List<Status> deleted = new ArrayList<Status>(); + +void $afterCompleteSetup() { + createStatuses(false); + setValide(hasNoMoreError()); + revalidate(); +} + +public List<Status> getStatuses(){ + return statuses; +} + +public List<Status> getDeleted(){ + return deleted; +} + +public void createStatuses(boolean triggeredByCancelButton) { + int confirm = JOptionPane.DEFAULT_OPTION; + if(triggeredByCancelButton) { + confirm = JOptionPane.showConfirmDialog(this, + _("vradi.admin.cancel.message"), + _("vradi.admin.cancel.title"), + JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + } + if(!triggeredByCancelButton || confirm == JOptionPane.YES_OPTION) { + content.removeAll(); + statuses = getHandler().getAllStatuses(); + for (Status status : statuses){ + createStatus(status); + } + deleted = new ArrayList<Status>(); + setModified(false); + } +} + +protected void createNewStatus() { + Status status = new StatusImpl(); + status.setValue(content.getComponentCount()); + status.setModifiable(true); + statuses.add(status); + createStatus(status); +} + +protected void createStatus(Status status) { + + StatusEditionUI editionUI = new StatusEditionUI(this); + + status.addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + setModified(true); + } + }); + + editionUI.getValidator().addBeanValidatorListener(new BeanValidatorListener() { + + @Override + public void onFieldChanged(BeanValidatorEvent event) { + setValide(hasNoMoreError()); + } + }); + + editionUI.setBean(status); + + content.add(editionUI); + validate(); + setValide(hasNoMoreError()); +} + +protected boolean hasNoMoreError() { + Component[] components = content.getComponents(); + for (Component c : components) { + StatusEditionUI editionUI = (StatusEditionUI)c; + if (editionUI.getValidator().hasErrors()) { + return false; + } + } + return true; +} + +public void up(StatusEditionUI editionUI) { + move(editionUI, -1); +} + +public void down(StatusEditionUI editionUI) { + move(editionUI, 1); +} + +public void delete(StatusEditionUI editionUI) { + remove(editionUI); + deleted.add(editionUI.getBean()); + setModified(true); +} + +public void remove(StatusEditionUI editionUI) { + + Status status = editionUI.getBean(); + + // Remove in list + statuses.remove(status); + + // Remove in UI + content.remove(editionUI); +} + +protected void move(StatusEditionUI editionUI, int inc) { + Status status = editionUI.getBean(); + + // Get index + int index = statuses.indexOf(status) + inc; + + if (index >= 0 && statuses.size() > index) { + + if (log.isDebugEnabled()) { + log.debug("Move " + status.getName() + " to " + index); + } + + remove(editionUI); + + // Add in list + statuses.add(index, status); + + // Add in UI + content.add(editionUI, index); + + revalidate(); + + setModified(true); + } +} + +@Override +public void save() { + getHandler().saveStatuses(this); + setModified(false); +} + +@Override +public Object getBean() { + return null; +} + +@Override +public void setBean(Object bean) { +} + +@Override +protected void postLoadBean() { +} + +@Override +public void cancel() { + createStatuses(true); +} + +@Override +protected void clearUI() { +} + ]]> + </script> + + <JPanel id='body'> + <Table constraints='BorderLayout.CENTER'> + <row> + <cell anchor="west"> + <JLabel styleClass='titleLeft' + text='vradi.adminStatus.title'/> + </cell> + <cell anchor='east' insets='0'> + <JButton id='createStatus' + text='vradi.adminStatus.createStatus' + actionIcon='add' + onActionPerformed='createNewStatus(); setModified(true);'/> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='1' insets='0'> + <JScrollPane> + <JPanel id='content' + layout='{new BoxLayout(content, BoxLayout.Y_AXIS)}'/> + </JScrollPane> + </cell> + </row> + </Table> + </JPanel> +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminStatusUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,926 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.content; + +import com.sun.star.uno.RuntimeException; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.ThesaurusImpl; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.admin.popups.ThesaurusConfirmDialogUI; +import org.chorem.vradi.ui.admin.popups.ThesaurusEditUI; +import org.chorem.vradi.ui.admin.popups.ThesaurusPathChooserUI; +import org.chorem.vradi.ui.admin.popups.ThesaurusQueryChangesHandler; +import org.chorem.vradi.ui.admin.popups.ThesaurusQueryChangesUI; +import org.chorem.vradi.ui.admin.query.ThesaurusChangesTreeTableModel; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.ThesaurusCartographyUI; +import org.chorem.vradi.ui.renderers.ColorsMap; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; +import org.jdesktop.swingx.JXTreeTable; +import org.nuiton.wikitty.WikittyProxy; + +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.JColorChooser; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.KeyStroke; +import java.awt.Color; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier <letellier@codelutin.com> */ +public class AdminThesaurusHandler { + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(AdminThesaurusHandler.class); + + public WikittyProxy getProxy() { + return VradiService.getWikittyProxy(); + } + + protected AdminThesaurusUI getUI(JAXXContext context) { + return (AdminThesaurusUI) context; + } + + public Thesaurus getThesaurus(VradiTreeTableNode parentNode) { + Class<?> type = parentNode.getInternalClass(); + if (!type.equals(Thesaurus.class)) { + return null; + } + String id = parentNode.getId(); + return getThesaurus(id); + } + + public Thesaurus getThesaurus(String id) { + return ThesaurusDataHelper.restoreThesaurus(id); + } + + public RootThesaurus getRootThesaurus(VradiTreeTableNode parentNode) { + Class<?> type = parentNode.getInternalClass(); + if (!type.equals(RootThesaurus.class)) { + return null; + } + String id = parentNode.getId(); + return getRootThesaurus(id); + } + + public RootThesaurus getRootThesaurus(String id) { + return ThesaurusDataHelper.restoreRootThesaurus(id); + } + + /** + * Return helpers selected node + * + * @param helper thesaurus tree table helper + * @return selected node + */ + protected VradiTreeTableNode getSelectedNode(ThesaurusTreeTableHelper helper) { + + // Get selected thesaurus + VradiTreeTableNode selectedNode = helper.getSelectedNode(); + if (selectedNode == null) { + selectedNode = helper.getRootNode(); + } + return selectedNode; + } + + /** + * Creation d'un thesaurus root. + * <p/> + * Le root thesaurus sert de requetage solr, il ne doit contenir que + * des caraceres alphanumerique. + * + * @param context parent ui + */ + public void createRootThesaurus(JAXXContext context) { + String rootThesaurusName = JOptionPane.showInputDialog(getUI(context), + _("vradi.adminThesaurus.askRootThesaurusName"), + _("vradi.adminThesaurus.askRootThesaurusTitle"), + JOptionPane.QUESTION_MESSAGE); + + try { + if (rootThesaurusName != null) { + + // test des caracteres alphanumerique + if (!rootThesaurusName.matches("\\w+")) { + JOptionPane.showMessageDialog(getUI(context), + _("vradi.adminThesaurus.rootThesaurusInvalidName"), + _("Error"), JOptionPane.ERROR_MESSAGE); + } else { + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.askCreateRootThesaurus", rootThesaurusName), + _("vradi.admin.saveTitle"), + JOptionPane.YES_OPTION); + + if (n == JOptionPane.YES_OPTION) { + + // Check existing + if (VradiService.getVradiDataService().isRootThesaurusNameExists(rootThesaurusName)) { + + // Ask retry + int n2 = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.warnNameIsExisting", rootThesaurusName), + _("vradi.admin.warnTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n2 == JOptionPane.OK_OPTION) { + createRootThesaurus(context); + } + return; + } + + // Store + RootThesaurus newRootThesaurus = VradiService.getVradiDataService().createRootThesaurus(rootThesaurusName); + + // Select node created + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + helper.createRootThesaurusAndSelect(newRootThesaurus.getWikittyId()); + } + } + } + } catch (VradiException ex) { + if (log.isErrorEnabled()) { + log.error("Can't create root thesaurus", ex); + } + throw new RuntimeException("Can't create root thesaurus", ex); + } + } + + public void createThesaurus(JAXXContext context, RootThesaurus parentRootThesaurus) { + + // Create child + Thesaurus thesaurusToCreate = new ThesaurusImpl(); + + // Register parent and root thesaurus + String rootId = parentRootThesaurus.getWikittyId(); + thesaurusToCreate.setParent(rootId); + thesaurusToCreate.setRootThesaurus(rootId); + + // Open edit ui + ThesaurusEditUI edit = new ThesaurusEditUI(context); + + // Init edit ui + edit.init(thesaurusToCreate, _("vradi.adminThesaurus.creationTitle"), true); + + // If is to save + if (edit.isSave()) { + + // If name is not empty + String name = thesaurusToCreate.getName(); + if (name != null && !name.isEmpty()) { + + // Check existing + RootThesaurus rootThesaurus = ThesaurusDataHelper.restoreRootThesaurus(rootId); + if (VradiService.getVradiDataService().isThesaurusNameExistsInRootThesaurus(rootThesaurus, name)) { + + // Ask retry + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.warnNameIsExisting", name), + _("vradi.adminThesaurus.warnTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + // reouvre la fenetre de creation + createThesaurus(context, parentRootThesaurus); + } + return; + } + + // Store + thesaurusToCreate = getProxy().store(thesaurusToCreate); + + if (log.isDebugEnabled()) { + log.debug("Adding thesaurus " + thesaurusToCreate.getName() + + " to parent " + parentRootThesaurus.getName()); + } + + // Select node created + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + + helper.createThesaurusChildOfRootAndSelect(parentRootThesaurus.getWikittyId(), thesaurusToCreate.getWikittyId()); + } + } + } + + public void createThesaurus(JAXXContext context, Thesaurus parentThesaurus) { + + // Create child + Thesaurus thesaurusToCreate = new ThesaurusImpl(); + + if (parentThesaurus == null) { + return; + } + + // Register parent and root thesaurus + thesaurusToCreate.setParent(parentThesaurus.getWikittyId()); + thesaurusToCreate.setRootThesaurus(parentThesaurus.getRootThesaurus()); + + // Open edit ui + ThesaurusEditUI edit = new ThesaurusEditUI(context); + + // Init edit ui + edit.init(thesaurusToCreate, _("vradi.adminThesaurus.creationTitle"), true); + + // If is to save + if (edit.isSave()) { + + // If name is not empty + String name = thesaurusToCreate.getName(); + if (name != null && !name.isEmpty()) { + // Get root + RootThesaurus rootThesaurus = ThesaurusDataHelper + .restoreRootThesaurus(thesaurusToCreate.getRootThesaurus()); + + // Check existing + if (VradiService.getVradiDataService().isThesaurusNameExistsInRootThesaurus(rootThesaurus, name)) { + + // Ask retry + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.warnNameIsExisting", name), + _("vradi.admin.warnTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + createThesaurus(context, parentThesaurus); + } + return; + } + + // Store + getProxy().store(thesaurusToCreate); + + if (log.isDebugEnabled()) { + log.debug("Adding thesaurus " + thesaurusToCreate.getName() + + " to parent " + parentThesaurus.getName()); + } + + // Select node created + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + helper.createThesaurusAndSelect(parentThesaurus.getWikittyId(), thesaurusToCreate.getWikittyId()); + } + } + } + + public void editRootThesaurus(JAXXContext context, RootThesaurus rootThesaurus) { + + // Keep oldName + String oldName = rootThesaurus.getName(); + + // Ask name + String name = JOptionPane + .showInputDialog(getUI(context), + _("vradi.adminThesaurus.askRootThesaurusEditName", + oldName), oldName); + + if (name != null && !name.isEmpty()) { + + // Check existing + if (VradiService.getVradiDataService().isRootThesaurusNameExists(rootThesaurus.getName(), + rootThesaurus.getWikittyId())) { + + // Ask retry + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.warnNameIsExisting", name), + _("vradi.admin.warnTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + editRootThesaurus(context, rootThesaurus); + } + return; + } + + // Confirm and view apply + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.askEditRootThesaurus", + oldName, name), + _("vradi.admin.saveTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + + // Impact group request + modifyQueries(context, oldName, name, null, null); + + // Set name + rootThesaurus.setName(name); + + // Store + log.info(rootThesaurus); + getProxy().store(rootThesaurus); + } + } + } + + public void editThesaurus(JAXXContext context, Thesaurus thesaurus) { + + // To prevent wikity obselete + thesaurus = ThesaurusDataHelper.restoreThesaurus(thesaurus.getWikittyId()); + + // Open edit ui + ThesaurusEditUI edit = new ThesaurusEditUI(context); + + // Get old name + String oldName = thesaurus.getName(); + + // Open edit UI + edit.init(thesaurus, _("vradi.adminThesaurus.editTitle", oldName), false); + + if (edit.isSave()) { + + // If name is not empty + if (oldName != null && !oldName.isEmpty()) { + + // Check existing + String rootId = thesaurus.getRootThesaurus(); + RootThesaurus rootThesaurus = getRootThesaurus(rootId); + if (VradiService.getVradiDataService().isThesaurusNameExistsInRootThesaurus(rootThesaurus, + thesaurus.getName(), thesaurus.getWikittyId())) { + + // Ask retry + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.warnNameIsExisting", oldName), + _("vradi.admin.warnTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + editThesaurus(context, thesaurus); + } + return; + } + + String newName = thesaurus.getName(); + + boolean responce = true; + + if (!oldName.equals(newName)) { + + thesaurus.setName(oldName); + + // Confirm + responce = showThesaurusConfirmDialog(context, thesaurus, + _("vradi.adminThesaurus.askEditThesaurus", oldName, + ThesaurusDataHelper.getNbFormsForThesaurus(thesaurus)), + _("vradi.admin.saveTitle")); + } + + if (responce) { + + // Set name + thesaurus.setName(newName); + + // Impact user request + modifyQueries(context, rootThesaurus.getName(), rootThesaurus.getName(), oldName, thesaurus.getName()); + + // Store + getProxy().store(thesaurus); + } + } + } + } + + public void moveThesaurus(JAXXContext context, Thesaurus thesaurus) { + + // To prevent wikity obselete + thesaurus = ThesaurusDataHelper.restoreThesaurus(thesaurus.getWikittyId()); + + // Get root thesaurus of selected + String rootThesaurusId = thesaurus.getRootThesaurus(); + RootThesaurus rootThesaurus = getRootThesaurus(rootThesaurusId); + + // Create new helpers + ThesaurusTreeTableHelper selectHelper = new ThesaurusTreeTableHelper(rootThesaurus); + + // Create select ui + ThesaurusPathChooserUI selectUI = new ThesaurusPathChooserUI(context, + selectHelper); + + // Remove concerned + VradiTreeTableNode concernedNode = selectHelper.findThesaurusNode(thesaurus); + selectHelper.removeNode(concernedNode); + + selectUI.setVisible(true); + + // If select + if (selectUI.isSaved()) { + + // Confirm + String thesaurusName = thesaurus.getName(); + boolean responce = showThesaurusConfirmDialog(context, thesaurus, + _("vradi.adminThesaurus.askMoveThesaurus", thesaurusName), + _("vradi.adminThesaurus.moveTitle")); + + if (responce) { + + // Get new parent selected + VradiTreeTableNode selectedNode = getSelectedNode(selectHelper); + + // Apply move + String newParentId = selectedNode.getId(); + if (!newParentId.equals(thesaurus.getParent())) { + + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + + // Modify queries + String rootThesaurusName = rootThesaurus.getName(); + modifyQueries(context, rootThesaurusName, rootThesaurusName, thesaurusName, thesaurusName); + + // Apply move + VradiTreeTableNode oldThesaurusNode = helper.findThesaurusNode(thesaurus); + + // Remove old + helper.removeNode(oldThesaurusNode); + + // Create new + helper.createThesaurusAndSelect(newParentId, thesaurus.getWikittyId()); + + // Store + thesaurus.setParent(newParentId); + getProxy().store(thesaurus); + } + } + } + } + + public void deleteRootThesaurus(JAXXContext context, RootThesaurus rootThesaurus) { + + // Confirm + int n = JOptionPane.showConfirmDialog(getUI(context), + _("vradi.adminThesaurus.askDeleteRootThesaurus", rootThesaurus.getName()), + _("vradi.admin.deleteTitle"), + JOptionPane.OK_CANCEL_OPTION); + + if (n == JOptionPane.OK_OPTION) { + + // TODO sletellier 19/09/10 : impact query for root deletion ? + // Impact user request + // modifyQueries(context, rootThesaurus); + + // Select parent node deleted + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + VradiTreeTableNode nodeToDelete = helper.findRootThesaurusNode(rootThesaurus); + helper.removeNode(nodeToDelete); + + // delete all thesaurus and subnodes recursively + try { + VradiService.getVradiDataService().deleteThesaurus(rootThesaurus.getWikittyId()); + } catch (VradiException ex) { + throw new RuntimeException("Can't delete thesaurus", ex); + } + } + } + + public boolean deleteThesaurus(JAXXContext context, Thesaurus thesaurus) { + + // Confirm + boolean response = showThesaurusConfirmDialog(context, thesaurus, + _("vradi.adminThesaurus.askDeleteThesaurus", thesaurus.getName(), + ThesaurusDataHelper.getNbFormsForThesaurus(thesaurus)), + _("vradi.admin.deleteTitle")); + + if (response) { + + // Keep parent id + String parentId = thesaurus.getParent(); + + // delete all thesaurus and subnodes recursively + try { + // Select parent node deleted + ThesaurusTreeTableHelper helper = context.getContextValue(ThesaurusTreeTableHelper.class); + VradiTreeTableNode nodeToDelete = helper.findThesaurusNode(thesaurus); + helper.removeNode(nodeToDelete); + + String thesaurusId = thesaurus.getWikittyId(); + + // Get root thesaurus + RootThesaurus rootThesaurus = ThesaurusDataHelper.restoreRootThesaurus(thesaurus.getRootThesaurus()); + + // Keep all thesaurus and children + List<Thesaurus> childrenList = ThesaurusDataHelper.getChildrenRecursivly(thesaurus); + childrenList.add(thesaurus); + + // Modify queries + modifyDeleteRequest(context, rootThesaurus, thesaurus, childrenList); + + // Delete + VradiService.getVradiDataService().deleteThesaurus(thesaurusId); + + VradiTreeTableNode parentNode = helper.findThesaurusNode(parentId); + helper.selectNode(parentNode); + + } catch (VradiException ex) { + throw new RuntimeException("Can't delete thesaurus", ex); + } + + return true; + } + return false; + } + + protected void modifyDeleteRequest(JAXXContext context, RootThesaurus rootThesaurus, + Thesaurus thesaurus, Collection<Thesaurus> childrenList) { + + if (ThesaurusDataHelper.isFirstChild(thesaurus)) { + + // In this case, we cant propose any other thesaurus + for (Thesaurus child : childrenList) { + + modifyQueries(context, rootThesaurus.getName(), rootThesaurus.getName(), child.getName(), ""); + } + return; + } + + // Keep parent id + String parentId = thesaurus.getParent(); + Thesaurus parentToPropose = ThesaurusDataHelper.restoreThesaurus(parentId); + + // Impact group request for all deleted thesaurus + for (Thesaurus child : childrenList) { + + // Propose parent + modifyQueries(context, rootThesaurus.getName(), rootThesaurus.getName(), + child.getName(), parentToPropose == null ? child.getName() : parentToPropose.getName()); + } + } + + public void addChildThesaurusToSelected(JAXXContext context, ThesaurusTreeTableHelper helper) { + VradiTreeTableNode selectedNode = getSelectedNode(helper); + RootThesaurus rootThesaurus = getRootThesaurus(selectedNode); + if (rootThesaurus != null) { + createThesaurus(context, rootThesaurus); + return; + } + createThesaurus(context, getThesaurus(selectedNode)); + } + + public void editThesaurusSelected(JAXXContext context, ThesaurusTreeTableHelper helper) { + VradiTreeTableNode selectedNode = getSelectedNode(helper); + RootThesaurus rootThesaurus = getRootThesaurus(selectedNode); + if (rootThesaurus != null) { + editRootThesaurus(context, rootThesaurus); + return; + } + editThesaurus(context, getThesaurus(selectedNode)); + } + + public void deleteThesaurusSelected(JAXXContext context, ThesaurusTreeTableHelper helper) { + VradiTreeTableNode selectedNode = getSelectedNode(helper); + RootThesaurus rootThesaurus = getRootThesaurus(selectedNode); + if (rootThesaurus != null) { + deleteRootThesaurus(context, rootThesaurus); + return; + } + deleteThesaurus(context, getThesaurus(selectedNode)); + } + + public void moveThesaurusSelected(JAXXContext context, ThesaurusTreeTableHelper helper) { + VradiTreeTableNode selectedNode = getSelectedNode(helper); + + Thesaurus thesaurus = getThesaurus(selectedNode); + + moveThesaurus(context, thesaurus); + } + + public boolean showThesaurusConfirmDialog(JAXXContext context, Thesaurus concerned, String title, String msg) { + ThesaurusConfirmDialogUI condirmDialogUI = new ThesaurusConfirmDialogUI(context); + condirmDialogUI.init(concerned, title, msg); + return condirmDialogUI.isSave(); + } + + public void showApply(JAXXContext context, Thesaurus concerned) { + UIHelper.getHandler(context, AdminHandler.class).openRequest(context, concerned); + } +// +// public void modifyAllQuery(JAXXContext context, RootThesaurus rootThesaurusModified) { +// +// RootThesaurus beforeModified = ThesaurusDataHelper.restoreRootThesaurus(rootThesaurusModified.getWikittyId()); +// +// // modify clients queries +// modifyQueries(context, beforeModified.getName(), rootThesaurusModified.getName()); +// } +// +// public void modifyAllQuery(JAXXContext context, Thesaurus thesaurusModified, boolean isToDelete) { +// +// if (isToDelete) { +// // before has been deleted, so the replacement would be the parent node +// while (!ThesaurusDataHelper.isFirstChild(thesaurusModified) && isToDelete) { +// String parentId = thesaurusModified.getParent(); +// thesaurusModified = ThesaurusDataHelper.restoreThesaurus(parentId); +// } +// } +// +// Thesaurus beforeModified = ThesaurusDataHelper.restoreThesaurus(thesaurusModified.getWikittyId()); +// +// modifyQueries(context, beforeModified.getName(), +// ThesaurusDataHelper.getRequestName(thesaurusModified)); +// } + + protected void modifyQueries(JAXXContext context, + String rootThesaurusBefore, + String rootThesaurusAfter, + String thesaurusBefore, + String thesaurusAfter) { + + Map<Group, List<QueryBean>> queryMakers = VradiService + .getVradiDataService() + .getQueriesToModifyAfterThesaurusModification(rootThesaurusBefore, thesaurusBefore); + + if (queryMakers.isEmpty()) { + // the modified thesaurus is not part of a client query + if (log.isDebugEnabled()) { + log.debug("[ModifyQueries] Query makers are empty for thesaurus : " + rootThesaurusBefore + + ":" + thesaurusBefore); + } + return; + } + + if (log.isDebugEnabled()) { + log.debug("[ModifyQueries] Query makers are not empty for thesaurus : " + rootThesaurusBefore + + ":" + thesaurusBefore + " will show modification UI"); + } + // show window with modified queries according thesaurus nodes changes + ThesaurusQueryChangesHandler handler = new ThesaurusQueryChangesHandler(); + ThesaurusQueryChangesUI thesaurusChangesUI = handler.initUI( + context, queryMakers, + rootThesaurusBefore, rootThesaurusAfter, + thesaurusBefore, thesaurusAfter); + thesaurusChangesUI.setModifiedQueries(Boolean.FALSE); + thesaurusChangesUI.setVisible(true); + + if (!thesaurusChangesUI.isModifiedQueries()) { + return; + } + + try { + // retrieve updated groups + ThesaurusChangesTreeTableModel model = thesaurusChangesUI + .getContextValue(ThesaurusChangesTreeTableModel.class); + List<Group> updatedQueryMakers = model.getUpdatedQueryMakers(); + + // save updated groups + VradiService.getWikittyProxy().store(updatedQueryMakers); + + if (log.isDebugEnabled()) { + log.debug("[ModifyQueries] Store modifications"); + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + /** + * Change color + * + * @param context jaxx context + * @param helper helpers of adminThesaurus + */ + public void changeThesaurusColor(JAXXContext context, + ThesaurusTreeTableHelper helper) { + + VradiTreeTableNode selectedNode = getSelectedNode(helper); + Thesaurus selected = getThesaurus(selectedNode); + + int depth = ThesaurusDataHelper.getDepth(selected); + + Color initialColor = ColorsMap.getInstance().get(depth); + Color colorChoosed = JColorChooser.showDialog((AdminThesaurusUI) context, _("vradi.thesaurus.colorTitle"), initialColor); + + // Save in properties + if (log.isDebugEnabled()) { + log.debug("Store color " + colorChoosed + " for depth " + depth); + } + VradiHelper.storeThesaurusColor(depth, colorChoosed); + + reinitColors(); + } + + public void reinitColors() { + ColorsMap.getInstance().updateColors(); + } + + /** + * Export all clients as CSV. + * + * @param adminThesaurusUI parent ui + */ + public void exportThesaurusCSV(AdminThesaurusUI adminThesaurusUI) { + + try { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle(_("vradi.adminThesaurus.exportThesaurusTitle")); + chooser.setApproveButtonText(_("vradi.adminThesaurus.exportButtonText")); + int returnVal = chooser.showOpenDialog(adminThesaurusUI); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File selectedFile = chooser.getSelectedFile(); + + if (log.isDebugEnabled()) { + log.debug("Exporting thesaurus to : " + selectedFile.getAbsolutePath()); + } + + // export + VradiStorageService vradiStorageService = getVradiStorageService(); + String vscContent = vradiStorageService.exportThesaurusAsCSV(); + + // write content into file + FileUtils.writeStringToFile(selectedFile, vscContent); + } + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't export thesaurus", eee); + } + ErrorDialogUI.showError(eee); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't export thesaurus", eee); + } + } + } + + private VradiStorageService vradiStorageService = null; + + protected VradiStorageService getVradiStorageService() { + if (vradiStorageService == null) { + vradiStorageService = VradiService.getVradiStorageService(); + } + return vradiStorageService; + } + + /** + * Import CSV file. + * <p/> + * Can be used to import clients, groups or thesaurus. + * + * @param adminThesaurusUI parent ui + */ + public void importCSV(AdminThesaurusUI adminThesaurusUI) { + + // warn user about thesaurus deletion + int response = JOptionPane.showConfirmDialog(adminThesaurusUI, + _("Warning all your thesaurus will be deleted before new import. Do you want to continue ?"), + _("Confirm thesaurus deletion"), JOptionPane.OK_CANCEL_OPTION); + if (response != JOptionPane.OK_OPTION) { + return; + } + + try { + JFileChooser chooser = new JFileChooser(); + chooser.setDialogTitle(_("vradi.adminThesaurus.importTitle")); + chooser.setApproveButtonText(_("vradi.adminThesaurus.importButtonText")); + int returnVal = chooser.showOpenDialog(adminThesaurusUI); + if (returnVal == JFileChooser.APPROVE_OPTION) { + + // delete all thesaurus + VradiService.getVradiDataService().deleteAllThesaurus(); + + File selectedFile = chooser.getSelectedFile(); + + if (log.isDebugEnabled()) { + log.debug("Importing file : " + selectedFile.getAbsolutePath()); + } + + // export + VradiStorageService vradiStorageService = getVradiStorageService(); + String uri = VradiService.getFileService().uploadTempFile(selectedFile); + vradiStorageService.importAsCSV(uri); + } + } catch (VradiException eee) { + if (log.isErrorEnabled()) { + log.error("Can't import file", eee); + } + ErrorDialogUI.showError(eee); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't import file", eee); + } + } + } + + /** + * Copy to clipboard thesaurus action. + * <p/> + * Get selection thesaurus, and set following string in clipboard : + * rootThesaurusName:"selectedThesaurusName" + */ + public static class CopyToClipboard extends AbstractAction { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + protected AdminThesaurusUI thesaurusUI; + + protected ThesaurusCartographyUI thesaurusCartography; + + /** + * Register the keystroke Control+C (copy) on the treetable of the + * specified AdminThesaurusUI. + * + * @param thesaurusUI ui of thesaurus selection for AO + */ + public CopyToClipboard(AdminThesaurusUI thesaurusUI) { + super(_("vradi.common.copy")); + this.thesaurusUI = thesaurusUI; + + JXTreeTable treeTable = thesaurusUI.getThesaurus(); + init(treeTable); + } + + /** + * Register the keystroke Control+C (copy) on the treetable of the + * specified thesaurus cartography. + * + * @param thesaurusCartography ui of thesaurus selection for AO + */ + public CopyToClipboard(ThesaurusCartographyUI thesaurusCartography) { + super(_("vradi.common.copy")); + this.thesaurusCartography = thesaurusCartography; + JXTreeTable treeTable = thesaurusCartography.getThesaurus(); + init(treeTable); + } + + protected void init(JXTreeTable treeTable) { + InputMap inputMap = treeTable.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), + "ThesaurusHandler.CopyToClipboard"); + + ActionMap actionMap = treeTable.getActionMap(); + actionMap.put("ThesaurusHandler.CopyToClipboard", this); + } + + @Override + public void actionPerformed(ActionEvent e) { + ThesaurusTreeTableHelper helper; + if (thesaurusUI != null) { + helper = thesaurusUI.getHelper(); + + } else { + helper = thesaurusCartography.getHelper(); + } + VradiTreeTableNode selectedNode = helper.getSelectedNode(); + if (selectedNode == null || selectedNode.isRoot()) { + return; + } + String id = selectedNode.getId(); + Thesaurus selectedThesaurus = ThesaurusDataHelper.restoreThesaurus(id); + + if (selectedThesaurus == null) { + return; + } + RootThesaurus rootThesaurus = ThesaurusDataHelper.restoreRootThesaurus(selectedThesaurus.getRootThesaurus()); + + String name = "\"" + selectedThesaurus.getName() + "\""; + StringSelection selection = new StringSelection(rootThesaurus.getName() + ":" + name); + + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, null); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,289 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='adminThesaurusUI'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + + javax.swing.ListSelectionModel + javax.swing.event.TreeSelectionListener + javax.swing.event.TreeSelectionEvent + javax.swing.JPopupMenu + javax.swing.JMenuItem + javax.swing.Action + javax.swing.BoxLayout + javax.swing.tree.TreePath + jaxx.runtime.JAXXContext + jaxx.runtime.SwingUtil + jaxx.runtime.swing.JAXXTree + jaxx.runtime.swing.JAXXTree.JAXXTreeModel + org.chorem.vradi.entities.Thesaurus + org.chorem.vradi.VradiHelper + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper + org.chorem.vradi.VradiContext + org.jdesktop.swingx.JXTreeTable + javax.swing.tree.DefaultTreeCellRenderer + org.jdesktop.swingx.decorator.* + org.chorem.vradi.ui.renderers.ThesaurusHighlighter + org.chorem.vradi.ui.tree.VradiTreeTableNode + javax.swing.tree.TreeSelectionModel + </import> + + <Boolean id='modified' javaBean='false'/> + + <Boolean id='selected' javaBean='false'/> + + <Boolean id='thesaurusSelected' javaBean='false'/> + + <script><![CDATA[ + +protected ThesaurusTreeTableHelper helper; +protected ThesaurusHighlighter highlighter; + +public AdminThesaurusUI(JAXXContext parentContext, ThesaurusTreeTableHelper helper) { + SwingUtil.initContext(this, parentContext); +// setContextValue(new ModifThesaurusModel(this, helper)); + this.helper = helper; + setContextValue(helper); + highlighter = new ThesaurusHighlighter(ThesaurusHighlighter.HighlighterType.EDIT); +} + +protected AdminThesaurusHandler getThesaurusHandler() { + return UIHelper.getHandler(this, AdminThesaurusHandler.class); +} + +public ThesaurusTreeTableHelper getHelper() { + return helper; +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + thesaurus.putClientProperty("JTree.lineStyle", "Angled"); + final Action copyToClipboard = new AdminThesaurusHandler.CopyToClipboard(this); + + // Adding ridht clic menu + thesaurus.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(final MouseEvent mouseEvent) { + + + JPopupMenu popup = new JPopupMenu(); + + // Add mouse listener to enable menus + if (mouseEvent.getButton() == MouseEvent.BUTTON3){ + + // Add mouse listener to enable menus + JMenuItem menuAddRootChild = new JMenuItem(); + menuAddRootChild.setText(_("vradi.menu.addRootChildThesaurus")); + menuAddRootChild.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + + createNewRoot(); + } + }); + popup.add(menuAddRootChild); + + JMenuItem menuAddChild = new JMenuItem(); + menuAddChild.setText(_("vradi.menu.addChildThesaurus")); + menuAddChild.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + + addChildToSelected(); + } + }); + popup.add(menuAddChild); + + JMenuItem menuRenameSelected = new JMenuItem(); + menuRenameSelected.setText(_("vradi.menu.editThesaurusSelected")); + menuRenameSelected.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + editSelected(); + } + }); + popup.add(menuRenameSelected); + + JMenuItem menuDeleteSeleted = new JMenuItem(); + menuDeleteSeleted.setText(_("vradi.menu.deleteThesaurusSelected")); + menuDeleteSeleted.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + deleteSelected(); + } + }); + popup.add(menuDeleteSeleted); + + if (isThesaurusSelected()) { + JMenuItem menuMoveSeleted = new JMenuItem(); + menuMoveSeleted.setText(_("vradi.menu.moveThesaurusSelected")); + menuMoveSeleted.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + moveSelected(); + } + }); + popup.add(menuMoveSeleted); + } + + JMenuItem menuChangeColorSeleted = new JMenuItem(); + menuChangeColorSeleted.setText(_("vradi.menu.menuChangeColorSeleted")); + menuChangeColorSeleted.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + changeColorSelected(); + } + }); + popup.add(menuChangeColorSeleted); + + popup.add(copyToClipboard); + + popup.show(thesaurus, mouseEvent.getX(), mouseEvent.getY()); + } + } + }); + + TreeSelectionListener listener = new TreeSelectionListener(){ + + @Override + public void valueChanged(TreeSelectionEvent e) { + + // Get selcted node + VradiTreeTableNode selectedNode = (VradiTreeTableNode)e.getPath().getLastPathComponent(); + + boolean selectionEmpty = thesaurus.getTreeSelectionModel().isSelectionEmpty(); + + // Set as selected + setSelected(!selectionEmpty); + + // Is thesaurus + if (selectedNode != null) { + setThesaurusSelected(isSelected() && + Thesaurus.class.equals(selectedNode.getInternalClass())); + } + } + }; + + // Register tree table + helper.setUI(thesaurus, true, false, listener); + + // Single selection mode + thesaurus.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + // Expend on click + UIHelper.addThesaurusExpandOnClickListener(thesaurus); + + // Render + thesaurus.setTreeCellRenderer(highlighter); +} + +protected void createNewRoot(){ + // Ajout dun nouveau root thesaurus + getThesaurusHandler().createRootThesaurus(this); +} + +protected void addChildToSelected(){ + // Ajout dun nouveau thesaurus + getThesaurusHandler().addChildThesaurusToSelected(this, helper); +} + +protected void editSelected(){ + // Edition dun thesaurus + getThesaurusHandler().editThesaurusSelected(this, helper); +} + +protected void deleteSelected(){ + // Suppression dun thesaurus + getThesaurusHandler().deleteThesaurusSelected(this, helper); +} + +protected void moveSelected(){ + // Move thesaurus + getThesaurusHandler().moveThesaurusSelected(this, helper); +} + +protected void changeColorSelected(){ + // Change color af selected detph + getThesaurusHandler().changeThesaurusColor(this, helper); +} + +protected void setExpandByDefault(){ + VradiHelper.storeOnClickThesaurusExpanded(expandByDefault.isSelected()); +} + +protected void sort() { + thesaurus.setTreeTableModel(helper.createTreeModel()); +} +]]></script> + + <row> + <cell fill='horizontal' columns='2' weightx='1' insets='0,0,0,0'> + <JToolBar floatable='false' id='headerPanel' + layout='{new BoxLayout(headerPanel, BoxLayout.X_AXIS)}'> + <JButton id='createNewRoot' actionIcon='add' + text='vradi.thesaurus.createNewRoot' + onActionPerformed='createNewRoot()'/> + <JButton id='create' actionIcon='add' text='vradi.common.create' + enabled='{isSelected()}' + onActionPerformed='addChildToSelected()'/> + <JButton id='edit' actionIcon='edit' text='vradi.common.edit' + enabled='{isSelected()}' + onActionPerformed='editSelected()'/> + <JButton id='delete' actionIcon='delete' text='vradi.common.delete' + enabled='{isSelected()}' + onActionPerformed='deleteSelected()'/> + <JCheckBox id='expandByDefault' text='vradi.thesaurus.expendByDefault' + selected='{VradiHelper.isOnClickThesaurusExpanded()}' + onActionPerformed='setExpandByDefault()'/> + <JButton text="vradi.adminThesaurus.importThesaurusCSV" + actionIcon='import' + onActionPerformed="getThesaurusHandler().importCSV(this)"/> + <JButton text="vradi.adminThesaurus.exportThesaurusCSV" + actionIcon='export' + onActionPerformed="getThesaurusHandler().exportThesaurusCSV(this)"/> + <JButton id='sortButton' actionIcon='sort' onActionPerformed='sort()'/> + </JToolBar> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='1'> + <JScrollPane> + <JXTreeTable id="thesaurus" + font-size='11' + rootVisible='false' + showsRootHandles='true' + treeTableModel='{helper.createTreeModel()}' + highlighters='{highlighter}'/> + </JScrollPane> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminThesaurusUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminUserUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminUserUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminUserUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,350 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI superGenericType='User' + enabled='{getBean() != null}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.text.DateFormat + java.util.Date + org.jdesktop.swingx.JXDatePicker + + jaxx.runtime.swing.HidorButton + jaxx.runtime.swing.ListSelectorUI + static jaxx.runtime.SwingUtil.getStringValue + org.chorem.vradi.ui.tree.VradiTreeNode + + org.chorem.vradi.ui.admin.helpers.AdminBeanConstant + org.jdesktop.swingx.autocomplete.AutoCompleteDecorator + + org.chorem.vradi.entities.Group + + org.chorem.vradi.ui.renderers.EntityRenderer + org.chorem.vradi.services.VradiException + org.chorem.vradi.services.VradiService + org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper + org.chorem.vradi.ui.admin.widget.GroupListSelectorHandler + + java.util.Collections + java.util.Map + java.util.HashMap + + javax.swing.BoxLayout + </import> + + <!-- bean property --> + <User id='bean' javaBean='null'/> + + <!-- a state to known if attach to a group --> + <Boolean id='inGroup' javaBean='false'/> + + <!-- validators --> + <BeanValidator id='validator' + bean='{isEnabled() ? bean : null}' + beanClass='org.chorem.vradi.entities.User'> + + <field name="name" component="userName"/> + <field name="email" component="userEmail"/> + </BeanValidator> + + <GroupListSelectorHandler id='userGroupsHandler' javaBean='null'/> + + <script><![CDATA[ +void $afterCompleteSetup() { + + AutoCompleteDecorator.decorate(userGroups.getCombo(), EntityRenderer.getInstance()); + + userGroups.addPropertyChangeListener("modified", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + Boolean b = (Boolean) evt.getNewValue(); + if (b != null && b) { + log.info("modified changed from groups"); + setModified(true); + } + } + }); + errorTable.registerValidator(validator); + + userGroupsHandler = new GroupListSelectorHandler(userGroups); + userGroups.setHandler(userGroupsHandler); +} + +@Override +protected void postLoadBean() { + VradiTreeNode parentNode = getHelper().getParentCategoryNode(getHelper().getSelectedNode(), AdminBeanConstant.GROUP.getCategoryName()); + setInGroup(parentNode != null); + + createButton.setEnabled(!isInCreation()); + + userGroupsHandler.setBean(bean); + if (bean == null) { + // Clear all user + userGroups.init(Collections.EMPTY_LIST, Collections.EMPTY_LIST); + + return; + } + + java.util.List<Group> toCombo = getHandler().getAllGroups(); + + java.util.List<Group> toList = new ArrayList<Group>(); + try { + toList = VradiService.getVradiDataService().getGroupsForUser(bean.getWikittyId()); + } catch (VradiException eee){ + log.error("Could not retrieve groups for user : " + bean.getName(), + eee); + } + + toCombo.removeAll(toList); + + userGroups.init(toCombo, toList); + userGroupsHandler.setBean(bean); +} + +@Override +public void save() { + + // groups to save + Map<String, Group> groups = new HashMap<String, Group>(); + + if (log.isDebugEnabled()){ + log.debug("Will save user " + bean.getName()); + } + + String wikittyId = bean.getWikittyId(); + + // FIXME EC20100628 move this code to handler + //Remove the groups that were remove from the list. + for (Group g : userGroups.getComboDatas()) { + + if (g != null && g.getUser() != null && g.getUser().contains(wikittyId)) { + + if (log.isDebugEnabled()){ + log.debug("Removing user " + bean.getName() + " from group " + g.getName()); + } + + // group was containing user, but no more + g.removeUser(wikittyId); + + // mark it for save + groups.put(g.getWikittyId(), g); + } + } + + //Add groups that have been added to the list + for (Group g : userGroups.getListDatas()) { + + if (g != null) { + + if (log.isDebugEnabled()){ + log.debug("Adding user " + bean.getName() + " to group " +g.getName()); + } + + g.addUser(wikittyId); + //mark group for save + groups.put(g.getWikittyId(), g); + } + + } + + //Effectively save bean + User user = getHandler().saveUser(this, getHelper(), bean, groups.values()); + + AdminNavigationTreeHelper helper = getHelper(); + VradiTreeNode userNode = helper.findNode(helper.getRootNode(), user.getWikittyId()); + helper.refresh(userNode); + + //FIXME JC 25/08/2010 bean is the same (because of cache ?) so no property change fired. Set bean to null before to force fire. + setModified(false); + setBean(null); + setBean(user); + + userGroups.setModified(false); +} + +@Override +protected void clearUI() { + title.setText(updateTitle("")); + userName.setText(""); + userService.setText(""); + userAddress.setText(""); + userPhone.setText(""); + userEmail.setText(""); + userBeginSearchDate.setDate(null); + userEnable.setSelected(false); +} + +protected String updateTitle(String name) { + return _("vradi.adminUser.title", getStringValue(name)); +} + +protected void openAddressInBrowser() { + UIHelper.openAddressInBrowser(getBean().getAddress()); +} + +]]> + </script> + + <Table id='toolbar' insets='0'> + <row> + <cell fill='horizontal' weightx='1' anchor="west"> + <JLabel id='title' styleClass='titleLeft' + text='{updateTitle(getBean().getName())}'/> + </cell> + <cell anchor='east'> + <JPanel> + <JButton id='createButton' + text='vradi.adminUser.createUser' + visible='{!isInGroup() && !isInCreation()}' + onActionPerformed='getHandler().createUser(this, getHelper().getClientSelected());setModified(true);'/> + + <JButton actionIcon='client.delete' + toolTipText='vradi.adminUser.deleteUser' + enabled='{isEnabled() && !isInCreation()}' + visible='{!isInGroup()}' + onActionPerformed='getHandler().delete(this, getHelper(), getBean())'/> + + <!--JButton actionIcon='delete' + toolTipText='vradi.adminUser.deleteUserFromGroup' + enabled='{isEnabled()}' + visible='{isInGroup()}' + onActionPerformed='deleteFromGroup()'/--> + + <!--HidorButton target='{adminUserForm}' + hideTip='{_("vradi.adminUser.hideForm")}' + showTip='{_("vradi.adminUser.showForm")}' + targetVisible='{true}'/--> + </JPanel> + </cell> + </row> + </Table> + + <JPanel id='body'> + + <Table constraints='BorderLayout.NORTH' id="adminUserForm" + minimumSize='{SwingUtil.newMinDimension()}'> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.name'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='userName' text='{getBean().getName()}' + onKeyReleased='getBean().setName(userName.getText()); + title.setText(updateTitle(getBean().getName()));'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.service'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='userService' text='{getBean().getService()}' + onKeyReleased='getBean().setService(userService.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.adresse'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='userAddress' text='{getBean().getAddress()}' + onKeyReleased='getBean().setAddress(userAddress.getText())'/> + </cell> + <cell> + <JButton onActionPerformed='openAddressInBrowser()' + actionIcon="site"/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.phone'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='userPhone' text='{getBean().getPhone()}' + onKeyReleased='getBean().setPhone(userPhone.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.mail'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='userEmail' text='{getBean().getEmail()}' + onKeyReleased='getBean().setEmail(userEmail.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminUser.beginSearchDate'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JXDatePicker id='userBeginSearchDate' + date='{getBean().getBeginSearchDate()}' + onActionPerformed='getBean().setBeginSearchDate(userBeginSearchDate.getDate())'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.admin.userEnable'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JPanel layout='{new BorderLayout()}'> + <JCheckBox id='userEnable' + constraints='BorderLayout.WEST' + selected='{getBean().getEnable()}' + onActionPerformed='getBean().setEnable(userEnable.isSelected())'/> + <JPanel constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + </Table> + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' anchor="north"> + <JLabel text='vradi.adminClient.listGroup' visible='{!isInGroup()}'/> + </cell> + <cell fill='both' weightx='1' weighty='1'> + <ListSelectorUI id='userGroups' + genericType='Group' + handler='{userGroupsHandler}' + visible='{!isInGroup()}' + showHidor='false' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + addToListTip='{_("vradi.adminUser.addGroup")}' + addToComboTip='{_("vradi.adminUser.removeGroup")}'/> + </cell> + </row> + </Table> + <!--RequestListUI id='requestListUI' constructorParams='this' constraints='BorderLayout.CENTER' + bean='{getBean()}'/--> + + </JPanel> + + +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminUserUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminXmlStreamUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminXmlStreamUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminXmlStreamUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,397 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<org.chorem.vradi.ui.admin.AdminContentUI id='adminXmlStreamUI' + superGenericType='XmlStream' + enabled='{getBean() != null}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.Component + + java.io.IOException + + javax.swing.BoxLayout + javax.swing.JOptionPane + javax.swing.DefaultComboBoxModel + javax.swing.JTable + javax.swing.event.TableModelEvent + + org.chorem.vradi.entities.VradiUser + org.chorem.vradi.entities.WebHarvestStream + org.chorem.vradi.entities.Infogene + org.chorem.vradi.entities.Form + org.chorem.vradi.entities.ModificationTag + + org.nuiton.wikitty.entities.WikittyExtension + org.chorem.vradi.ui.offer.editors.JListCellEditor + org.chorem.vradi.ui.admin.renderers.JListCellRenderer + org.chorem.vradi.ui.task.ProgressBarUI + org.chorem.vradi.ui.admin.AdminPopupUI + org.chorem.vradi.ui.admin.models.XmlStreamFieldTableModel + jaxx.runtime.SwingUtil + java.text.DateFormat + java.util.Date + org.jdesktop.swingx.decorator.Highlighter + org.jdesktop.swingx.decorator.HighlighterFactory + org.jdesktop.swingx.JXTable + javax.swing.table.DefaultTableCellRenderer + javax.swing.table.TableCellRenderer + javax.swing.table.TableCellRenderer + java.awt.CardLayout + javax.swing.event.TableModelListener + org.chorem.vradi.services.VradiService + </import> + + <!-- bean property --> + <XmlStream id='bean' javaBean='null'/> + + <XmlStreamFieldTableModel id='fieldsModel'/> + + <ComboBoxModel id='formTypeSelectionModel' + javaBean='UIHelper.getFormTypesModel()'/> + + <!-- validators --> + <BeanValidator id='validator' + bean='{isEnabled() ? bean : null}' + beanClass='org.chorem.vradi.entities.XmlStream'> + + <field name="name" component="xmlStreamName"/> + <field name="url" component="xmlStreamUrl"/> + <field name="formTypeName" component="formTypeCombo"/> + </BeanValidator> + + <script><![CDATA[ +final static String XML_STREAM_PANEL = "vradi.adminXmlStream.xmlPanel"; +final static String WEB_HARVEST_PANEL = "vradi.adminXmlStream.webHarvestPanel"; + +protected TableModelListener tableListener; + +void $afterCompleteSetup() { + + tableListener = new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + setModified(true); + } + }; + + SwingUtil.setI18nTableHeaderRenderer(fieldsTable, + n_("vradi.adminXmlStream.table.field.name"), + n_("vradi.adminXmlStream.table.field.name.tip"), + n_("vradi.adminXmlStream.table.field.values"), + n_("vradi.adminXmlStream.table.field.values.tip"), + n_("vradi.adminXmlStream.table.field.defaultValue"), + n_("vradi.adminXmlStream.table.field.defaultValue.tip")); + + TableCellRenderer tbc = new DefaultTableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + String sTranslatedValue = null; + if (column == 0 && value != null) { + String sValue = (String) value; + int dot = sValue.lastIndexOf("."); + String extName = sValue.substring(0, dot); + if (Infogene.EXT_INFOGENE.equals(extName) || Form.EXT_FORM.equals(extName)) { + sTranslatedValue = _(sValue); + } else { + sTranslatedValue = sValue.substring(dot + 1); + } + } + return super.getTableCellRendererComponent(table, sTranslatedValue, isSelected, hasFocus, row, column); + } + }; + + JListCellRenderer render = new JListCellRenderer(fieldsTable.getDefaultRenderer(String.class)); + setContextValue(render); + + SwingUtil.setTableColumnRenderer(fieldsTable, 0, tbc); + SwingUtil.setTableColumnRenderer(fieldsTable, 1, render); + + JListCellEditor editor = new JListCellEditor(); + setContextValue(editor); + SwingUtil.setTableColumnEditor(fieldsTable, 1, editor); + + final Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + fieldsTable.addHighlighter(highlighter); + errorTable.registerValidator(validator); +} + +@Override +protected void postLoadBean() { + + getHandler().openAdminXmlStreamUI(this); + xmlStreamPreview.setToolTipText(getFirstElementPreview()); + formTypeCombo.setModel(formTypeSelectionModel); + + fieldsModel.addTableModelListener(tableListener); +} + +protected void updateFormType() { + WikittyExtension extension = (WikittyExtension) formTypeCombo.getSelectedItem(); + if (extension != null && bean != null && !extension.getName().equals(bean.getFormTypeName())) { + bean.setFormTypeName(extension.getName()); + validateFormTypeChoice(); + } +} + +protected void validateFormTypeChoice() { + stopEditing(); + getHandler().updateXmlStreamFieldModel(this); + validate(); +} + +@Override +public void save() { + stopEditing(); + + fieldsModel.removeTableModelListener(tableListener); + + // add modification info + String login = getContextValue(VradiUser.class).getLogin(); + ModificationTag xmlStreamTag = VradiService.getWikittyProxy().cast(bean, ModificationTag.class); + xmlStreamTag.setLastModified(new Date()); + xmlStreamTag.setLastModifier(login); + + XmlStream stream = getHandler().saveStream(this, getHelper(), getBean(), fieldsModel.getBindings()); + // echatellier juste pour que la date de mise à jour se rafraichisse + setBean(null); + setBean(stream); +} + +@Override +protected void clearUI() { + title.setText(updateTitle("")); + xmlStreamName.setText(""); + xmlStreamUrl.setText(""); + webHarvestStreamUrl.setText(""); + webHarvestScript.setModel(new DefaultComboBoxModel()); + formTypeCombo.setSelectedItem(null); + fieldsModel.clear(); +} + +protected void initScriptComboBox() { + getHandler().initScriptComboBox(webHarvestScript, (WebHarvestStream)getBean()); +} + +protected void stopEditing() { + //FIXME-TC20091116 il faut pouvoir annuler l'édition si on sort du tableau + if (fieldsTable.getCellEditor() != null) { + fieldsTable.getCellEditor().stopCellEditing(); + } +} + +protected void createForms() { + getHandler().createForms(this); +} + +protected String updateTitle(String name) { + return _("vradi.adminXmlStream.title", SwingUtil.getStringValue(name)); +} + +protected void browseURI(String url) { + try { + UIHelper.browseURI(url); + } catch (IOException eee){ + log.error("Cannot display XMLStream : " + url); + JOptionPane.showMessageDialog(null, + _("vradi.message.cannot.display.stream")); + + } +} + +protected String getCardToDisplay() { + if (getBean() instanceof WebHarvestStream) { + return WEB_HARVEST_PANEL; + } + return XML_STREAM_PANEL; +} + +protected String getFirstElementPreview() { + return getHandler().getFirstElementPreview(this, getBean()); +} + +protected void updateUrl() { + getBean().setUrl(xmlStreamUrl.getText().matches("\\w+://.*") ? xmlStreamUrl.getText() : "http://" + xmlStreamUrl.getText()); + xmlStreamPreview.setToolTipText(getFirstElementPreview()); +} + +protected void updateWebHarvestUrl() { + getBean().setUrl(webHarvestStreamUrl.getText().matches("\\w+://.*") ? webHarvestStreamUrl.getText() : "http://" + webHarvestStreamUrl.getText()); +} +]]></script> + + <Table id="toolbar" insets='0'> + <row> + <cell fill='horizontal' weightx='1' anchor="west"> + <JLabel styleClass='titleLeft' id='title' + text='{updateTitle(getBean().getName())}'/> + </cell> + <cell anchor='east'> + <JPanel> + <JButton id='createXmlStream' + actionIcon="feed.add" + enabled='{!isInCreation()}' + text='vradi.adminXmlStream.createXmlStream' + onActionPerformed='getHandler().createXmlStream(this)'/> + + <JButton id='createWebHarvestStream' + actionIcon="feed.add" + visible='{false}' + text='vradi.adminXmlStream.createWebHarvestStream' + onActionPerformed='getHandler().createWebHarvestStream(this)'/> + + <JButton id='createForms' + text='vradi.adminXmlStream.createForms' + enabled='{isEnabled() && isValide()}' + onActionPerformed='createForms()'/> + + <JButton actionIcon='feed.delete' + toolTipText='vradi.adminXmlStream.deleteXmlStream' + enabled='{isEnabled()}' + onActionPerformed='getHandler().delete(this, getHelper(), getBean())'/> + + <HidorButton target='{adminXmlStreamForm}' + hideTip='{_("vradi.adminXmlStream.hideForm")}' + showTip='{_("vradi.adminXmlStream.showForm")}' + targetVisible='{true}'/> + + </JPanel> + </cell> + </row> + </Table> + + <JPanel id='body'> + <Table constraints='BorderLayout.NORTH' id="adminXmlStreamForm" + minimumSize='{SwingUtil.newMinDimension()}'> + <row> + <cell fill='horizontal'> + <JLabel id='lblName' text='vradi.adminXmlStream.name'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='xmlStreamName' + text='{getBean().getName()}' + onKeyReleased='getBean().setName(xmlStreamName.getText()); + title.setText(updateTitle(getBean().getName()));'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1' columns='2'> + <JPanel id='cards' layout='{new CardLayout()}'> + <Table constraints="XML_STREAM_PANEL"> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminXmlStream.url' + size='{lblName.getSize()}'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JTextField id='xmlStreamUrl' text='{getBean().getUrl()}' + onKeyReleased='updateUrl()'/> + </cell> + <cell> + <JLabel id='xmlStreamPreview' + actionIcon='feed.magnify' + toolTipText='{getFirstElementPreview()}'/> + </cell> + <cell> + <JButton id='xmlStreamSite' + actionIcon='site' + onActionPerformed='browseURI(getBean().getUrl())'/> + </cell> + </row> + </Table> + <Table constraints="WEB_HARVEST_PANEL"> + <!-- Web Harvest script --> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminXmlStream.startUrl' + size='{lblName.getSize()}'/> + </cell> + <cell fill='horizontal' weightx='1' columns='4'> + <JTextField id='webHarvestStreamUrl' + text='{getBean().getUrl()}' + onKeyReleased='updateWebHarvestUrl()'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminXmlStream.webHarvestScript' + size='{lblName.getSize()}'/> + </cell> + <cell fill='horizontal' weightx='1' columns='2'> + <JComboBox id='webHarvestScript'/> + </cell> + <cell> + <JButton id='openWebHarvestScript' + actionIcon='open' + onActionPerformed='getHandler().addWebHarvestScript(this, (WebHarvestStream)getBean());initScriptComboBox();'/> + </cell> + <cell> + <JButton id='openWebHarvestEditor' + actionIcon='edit' + onActionPerformed='getHandler().openWebHarvestEditor(this)' + toolTipText='vradi.adminXmlStream.createNewWebHarvest.toolTip'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminXmlStream.formType'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JComboBox id='formTypeCombo' + model='{formTypeSelectionModel}' + selectedItem='{getHandler().getExtension(getBean().getFormTypeName())}' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + onActionPerformed='updateFormType()'/> + </cell> + </row> + <row> + <cell fill='horizontal' columns='2'> + <JButton id='validateUrl' text='vradi.adminXmlStream.validateUrl' + enabled='{isEnabled() && isValide()}' + onActionPerformed='validateFormTypeChoice()'/> + </cell> + </row> + <row> + <cell fill='horizontal' columns='2' anchor='west'> + <XmlStreamConfigUI id="xmlStreamConfig" bean="{getBean()}"/> + </cell> + </row> + </Table> + + <JScrollPane constraints='BorderLayout.CENTER'> + <JXTable id='fieldsTable' model='{fieldsModel}' + rowSelectionAllowed='false' font-size='11'/> + </JScrollPane> + + </JPanel> +</org.chorem.vradi.ui.admin.AdminContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/AdminXmlStreamUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestListUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestListUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestListUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,134 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel layout='{new GridLayout(0,1)}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.Component + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.io.IOException + javax.swing.BoxLayout + org.chorem.vradi.beans.QueryBean + org.chorem.vradi.ui.admin.AdminHandler + </import> + + <!-- bean property --> + <Group id='bean' javaBean='null'/> + + <script><![CDATA[ + +public void init() { + content.setVisible(false); + content.removeAll(); + content.setAlignmentY(TOP_ALIGNMENT); + + if (bean != null && bean.getQueries() != null) { + for (String query : bean.getQueries()) { + createRequest(query); + } + } + content.setVisible(true); +} + +protected void createRequest(final String query) { + RequestSelectUI requestUI = new RequestSelectUI(RequestListUI.this); + requestUI.setAlignmentY(TOP_ALIGNMENT); + + if (log.isDebugEnabled()){ + log.debug("Open query " + query); + } + + try { + requestUI.setBean(new QueryBean(query)); + } catch (IOException e) { + log.error(e.getMessage(), e); + return; + } + + requestUI.addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + RequestSelectUI query = (RequestSelectUI) evt.getSource(); + + QueryBean oldValue = (QueryBean) evt.getOldValue(); + QueryBean newValue = (QueryBean) evt.getNewValue(); + + if (log.isDebugEnabled() + && oldValue != null + && newValue != null) { + log.debug("Update query from '" + oldValue.getQueryLine() + "' to '" + newValue.getQueryLine() + "'"); + } + + bean.removeQueries(oldValue.getQueryLine()); + + if (newValue == null) { + // this means remove + content.setVisible(false); + content.remove(query); + content.setVisible(true); + } else { + // this means update + bean.addQueries(newValue.getQueryLine()); + } + } + }); + requestUI.setAlignmentY(Component.TOP_ALIGNMENT); + content.add(requestUI); + validate(); +} + +protected void showHistory() { + AdminHandler handler = getContextValue(AdminHandler.class); + handler.showHistory(bean.getWikittyId()); +} + +]]></script> + <Table id="header" insets='0'> + <row> + <cell fill='horizontal' weightx='1' anchor="west"> + <JLabel text='vradi.adminRequest.title'/> + </cell> + <cell anchor='east'> + <JButton text='vradi.adminRequest.history.show' + actionIcon="history" + enabled='{isEnabled()}' + onActionPerformed='showHistory()'/> + </cell> + <cell anchor='east'> + <JButton text='vradi.adminRequest.new' + enabled='{isEnabled()}' + onActionPerformed='createRequest("")'/> + </cell> + </row> + </Table> + + <JScrollPane id='contentScroll' constraints='BorderLayout.CENTER' + columnHeaderView='{header}'> + <JPanel id='content' layout='{new BoxLayout(content, BoxLayout.Y_AXIS)}'/> + </JScrollPane> + +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestListUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestSelectUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestSelectUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestSelectUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,97 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='requestSelectUI' fill='horizontal' anchor='north'> + <style source='../../VradiMainUI.css'/> + + <import> + javax.swing.JOptionPane + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.VradiHelper + org.apache.commons.lang.StringUtils + </import> + + <!-- bean property --> + <org.chorem.vradi.beans.QueryBean id='bean' + javaBean='new org.chorem.vradi.beans.QueryBean()'/> + + <script><![CDATA[ + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} +public void confirmDeletion() { + org.chorem.vradi.beans.QueryBean queryBean = getBean(); + if (StringUtils.isBlank(queryBean.getName()) + && StringUtils.isBlank(queryBean.getDescription()) + && StringUtils.isBlank(queryBean.getQuery())) { + setBean(null); + + } else { + int confirm = JOptionPane.showConfirmDialog(this, + _("vradi.admin.confirmDelete", VradiHelper.getEntityName(getBean())), + _("vradi.admin.deleteTitle"), JOptionPane.YES_NO_OPTION); + + if (confirm == JOptionPane.YES_OPTION) { + setBean(null); + } + } +} + ]]></script> + + <row fill='horizontal' anchor='north'> + <cell fill='horizontal' weightx='0.3' weighty='0' insets='0,6,0,0'> + <JLabel text='vradi.requestSelectUI.name'/> + </cell> + <cell fill='horizontal' weightx='0.7' weighty='0' columns='3' + insets='0,6,0,0'> + <JLabel text='vradi.requestSelectUI.description'/> + </cell> + </row> + <row fill='both' anchor='north'> + <cell fill='horizontal' weightx='0.3' weighty='0' anchor='north'> + <JTextField id='queryName' text='{getBean().getName()}' + onKeyReleased='setBean(getBean().setName(queryName.getText()))' + toolTipText='{getBean().getQuery()}'/> + </cell> + <cell fill='horizontal' weightx='0.5' weighty='0' anchor='north'> + <JScrollPane> + <JTextArea id='queryDescription' text='{getBean().getDescription()}' + rows='2' + onKeyReleased='setBean(getBean().setDescription(queryDescription.getText()))' + toolTipText='{getBean().getQuery()}'/> + </JScrollPane> + </cell> + <cell fill='horizontal' weightx='0.1' weighty='0' anchor='north'> + <JButton text='vradi.adminRequest.edit' + onActionPerformed='getHandler().openRequest(this, getBean())' + toolTipText='{getBean().getQuery()}'/> + </cell> + <cell fill='horizontal' weightx='0.1' weighty='0' anchor='north'> + <JButton actionIcon='delete' + toolTipText='vradi.adminRequest.remove' + onActionPerformed='confirmDeletion();'/> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/RequestSelectUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/StatusEditionUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/StatusEditionUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/StatusEditionUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,133 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='statusEditionUI'> + + <import> + java.awt.Color + + javax.swing.JPanel + javax.swing.JOptionPane + + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.VradiHelper + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + </import> + + <style source='../../VradiMainUI.css'/> + + <!-- bean property --> + <Status id='bean' javaBean='null'/> + + <!-- wikitty property --> + <Status id='wikitty' javaBean='null'/> + + <!-- validators --> + <BeanValidator id='validator' + bean='{getBean()}' + beanClass='org.chorem.vradi.entities.Status'> + + <field name="name" component="nameField"/> + </BeanValidator> + + <script><![CDATA[ + +protected JPanel contentPane; + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public void setContentPane(JPanel contentPane){ + this.contentPane = contentPane; +} + +void $afterCompleteSetup() { +} + +protected AdminStatusUI getAdminStatusUI() { + return getParentContainer(AdminStatusUI.class); +} + +public void confirmDeletion() { + int confirm = JOptionPane.showConfirmDialog(this, + _("vradi.admin.confirmDelete", VradiHelper.getEntityName(bean)), + _("vradi.admin.deleteTitle"), JOptionPane.YES_NO_OPTION); + + if (confirm == JOptionPane.YES_OPTION) { + getAdminStatusUI().delete(this); + } +} + +public void up() { + getAdminStatusUI().up(this); +} + +public void down() { + getAdminStatusUI().down(this); +} + ]]></script> + + <row> + <cell> + <JLabel text='vradi.adminStatus.name'/> + </cell> + <cell fill='horizontal' weightx='0.3'> + <JTextField id='nameField' text='{_(getBean().getName())}' + editable='{getBean().getModifiable()}' + columns='20' + background='{getBean().getModifiable() ? null : new Color(230, 230, 240)}' + onKeyReleased='bean.setName(nameField.getText())'/> + </cell> + <cell> + <JLabel text='vradi.adminStatus.desc'/> + </cell> + <cell fill='horizontal' weightx='0.7'> + <JTextArea id='descField' text='{_(getBean().getDescription())}' + editable='{getBean().getModifiable()}' + background='{getBean().getModifiable() ? null : new Color(230, 230, 240)}' + onKeyReleased='bean.setDescription(descField.getText())'/> + </cell> + <cell> + <JButton id='up' actionIcon='arrowUp' + onActionPerformed='up()'/> + </cell> + <cell> + <JButton id='down' actionIcon='arrowDown' + onActionPerformed='down()'/> + </cell> + <cell> + <JButton id='remove' actionIcon='delete' + visible='{getBean().getModifiable()}' + onActionPerformed='confirmDeletion()'/> + </cell> + </row> + +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/StatusEditionUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/XmlStreamConfigUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/XmlStreamConfigUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/XmlStreamConfigUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,111 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='xmlStreamConfigUI'> + + <XmlStream id='bean' javaBean='null'/> + + <style source='../../VradiMainUI.css'/> + + <import> + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + java.util.regex.Matcher + javax.swing.ComboBoxModel + javax.swing.DefaultComboBoxModel + org.chorem.vradi.services.VradiService + org.chorem.vradi.services.VradiStorageService + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.VradiConstants + </import> + + <script><![CDATA[ + +protected ComboBoxModel minutesModel = new DefaultComboBoxModel(new Object[]{15, 30, 45}); +protected ComboBoxModel hoursModel = UIHelper.getNumberComboBoxModel(1, 24); +protected ComboBoxModel daysModel = UIHelper.getNumberComboBoxModel(1, 31); + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +void $afterCompleteSetup() { + addPropertyChangeListener("bean", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (getBean() != null) { + + + // Parse la valeur ImportTime du bean XmlStream courant et + // initialise correctement les differents panel. + // + // Dans le cas ou le pattern ne match pas, la valeur par defaut + // est celle des services (à savoir, tous les 1 jour, à minuit). + // + String xmlStringImportTime = bean.getImportTime(); + + if (xmlStringImportTime != null && !xmlStringImportTime.isEmpty()) { + Matcher matcher = VradiConstants.XML_STREAM_IMPORT_TIME.matcher(xmlStringImportTime); + + if (matcher.find()) { + // selection des heures + hourDays.setSelectedItem(Integer.valueOf(matcher.group(1))); + // selection de la minutes + minuteDays.setSelectedItem(Integer.valueOf(matcher.group(2))); + } + } + } else { + // clear UI + hourDays.setSelectedItem(0); + minuteDays.setSelectedItem(0);; + } + } + }); +} + +/** + * Set import time value into bean. + */ +protected void setImportTimeValue() { + if (bean != null) { + String importTime = null; + importTime = hourDays.getSelectedItem().toString() + ":" + minuteDays.getSelectedItem().toString(); + bean.setImportTime(importTime); + } +} + +]]> + </script> + + <JLabel text='vradi.adminXmlStream.config.load'/> + <JComboBox id='hourDays' selectedItem='{0}' + model='{UIHelper.getHourModel()}' + renderer='{UIHelper.get2DigitsRenderer()}' + onActionPerformed='setImportTimeValue()'/> + <JLabel text='vradi.common.timeseparator'/> + <JComboBox id='minuteDays' selectedItem='{0}' + model='{UIHelper.getMinuteModel()}' + renderer='{UIHelper.get2DigitsRenderer()}' + onActionPerformed='setImportTimeValue()'/> +</JPanel> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/content/XmlStreamConfigUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminBeanConstant.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminBeanConstant.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminBeanConstant.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,234 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +/* *##% + * Copyright (C) 2010 Code Lutin, Chatellier Eric + * + * 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.chorem.vradi.ui.admin.helpers; + +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.ClientImpl; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.UserImpl; +import org.chorem.vradi.entities.WebHarvestStream; +import org.chorem.vradi.entities.WebHarvestStreamImpl; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.entities.XmlStreamImpl; +import org.chorem.vradi.ui.admin.content.AdminClientUI; +import org.chorem.vradi.ui.admin.content.AdminFormTypeUI; +import org.chorem.vradi.ui.admin.content.AdminGroupUI; +import org.chorem.vradi.ui.admin.content.AdminStatusUI; +import org.chorem.vradi.ui.admin.content.AdminUserUI; +import org.chorem.vradi.ui.admin.content.AdminXmlStreamUI; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.Date; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * @author sletellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public enum AdminBeanConstant { + // Client category + CLIENT(n_("vradi.client.category"), n_("vradi.adminClient.newClientName"), Client.class, AdminClientUI.class), + // Group category + GROUP(n_("vradi.group.category"), n_("vradi.adminGroup.newGroupName"), Group.class, AdminGroupUI.class), + // User category + USER(n_("vradi.user.category"), n_("vradi.adminUser.newUserName"), User.class, AdminUserUI.class), + // Status category + STATUS(n_("vradi.status.category"), n_("vradi.adminStatus.newStatusName"), Status.class, AdminStatusUI.class), + // Stream category + XML_STREAM(n_("vradi.stream.category"), n_("vradi.adminXmlStream.newStreamName"), XmlStream.class, AdminXmlStreamUI.class), + // Stream category + WEB_HARVEST_STREAM(n_("vradi.stream.category"), n_("vradi.adminXmlStream.newWebHarvestStreamName"), WebHarvestStream.class, AdminXmlStreamUI.class), + // Form type category + FORM_TYPE(n_("vradi.formType.category"), n_("vradi.adminXmlStream.newFormTypeName"), WikittyExtension.class, AdminFormTypeUI.class); + + private String categoryName; + + private String newEntityName; + + private Class<?> beanClass; + + private Class<?> uiClass; + + private AdminBeanConstant(String categoryName, String newEntityName, Class<?> beanClass, Class<?> uiClass) { + this.categoryName = categoryName; + this.newEntityName = newEntityName; + this.beanClass = beanClass; + this.uiClass = uiClass; + } + + public String getCategoryName() { + return categoryName; + } + + public String getNewEntityName() { + return _(newEntityName); + } + + public Class<?> getBeanClass() { + return beanClass; + } + + public Class<?> getUIClass() { + return uiClass; + } + + public static AdminBeanConstant getConstantByUIClass(Class uiClass) { + for (AdminBeanConstant constant : values()) { + if (uiClass.equals(constant.getUIClass())) { + return constant; + } + } + return null; + } + + public static AdminBeanConstant getConstantByBeanClass(Class beanClass) { + for (AdminBeanConstant constant : values()) { + if (beanClass.equals(constant.getBeanClass())) { + return constant; + } + } + return null; + } + + public Object getBean(WikittyProxy proxy, String id) { + Object result = null; + switch (this) { + case CLIENT: + if (id == null) { + Client newClient = new ClientImpl(); + newClient.setName(getNewEntityName()); + result = newClient; + } else { + result = proxy.restore(Client.class, id); + } + break; + case GROUP: + if (id == null) { + Group newGroup = new GroupImpl(); + newGroup.setName(getNewEntityName()); + result = newGroup; + } else { + result = proxy.restore(Group.class, id); + } + break; + case USER: + if (id == null) { + User newUser = new UserImpl(); + newUser.setCreationDate(new Date()); + newUser.setBeginSearchDate(new Date()); + newUser.setName(getNewEntityName()); + newUser.setEnable(true); + newUser.setValidEmail(false); + result = newUser; + } else { + result = proxy.restore(User.class, id); + } + break; + case FORM_TYPE: + result = proxy.restoreExtensionLastVersion(id); + break; + case XML_STREAM: + if (id == null) { + XmlStream newXmlStream = new XmlStreamImpl(); + newXmlStream.setName(getNewEntityName()); + result = newXmlStream; + } else { + result = proxy.restore(XmlStream.class, id); + } + break; + case WEB_HARVEST_STREAM: + if (id == null) { + WebHarvestStream newWebHarvest = new WebHarvestStreamImpl(); + newWebHarvest.setName(_(getNewEntityName())); + result = newWebHarvest; + } else { + result = proxy.restore(WebHarvestStream.class, id); + } + break; + } + return result; + } + + public static Class<?> getUIClass(String categoryName) { + for (AdminBeanConstant constant : values()) { + + // For user category : clientId + CategoryUserName + if (categoryName.matches(".*" + constant.getCategoryName())) { + return constant.getUIClass(); + } + } + return null; + } + + public static Class<?> getUIClass(Class<?> beanClass) { + for (AdminBeanConstant constant : values()) { + if (beanClass.equals(constant.getBeanClass())) { + return constant.getUIClass(); + } + } + return null; + } + + public static boolean isCategoryNode(VradiTreeNode node) { + return isCategoryId(node.getId()); + } + + public static boolean isCategoryId(String id) { + for (AdminBeanConstant constant : AdminBeanConstant.values()) { + if (id.contains(constant.categoryName)) { + return true; + } + } + return false; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminBeanConstant.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,218 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.helpers; + +import jaxx.runtime.swing.nav.tree.NavTreeHelper; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.admin.loadors.ClientUsersNodeLoadors; +import org.chorem.vradi.ui.admin.loadors.ClientsAndUsersNodeLoadors; +import org.chorem.vradi.ui.admin.loadors.FormTypeNodeLoadors; +import org.chorem.vradi.ui.admin.loadors.GroupsNodeLoadors; +import org.chorem.vradi.ui.admin.loadors.StreamNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.helpers.VradiTreeHelper; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.tree.TreeModel; + +/** + * Navigation tree helpers. + * + * @author sletellier + * @see NavTreeHelper + */ +public abstract class AdminNavigationTreeHelper<C extends BusinessEntity> extends VradiTreeHelper<C> { + + /** Logger */ + static private final Log log = LogFactory.getLog(AdminNavigationTreeHelper.class); + + public AdminNavigationTreeHelper(VradiDataProvider dataProvider) { + super(); + setDataProvider(dataProvider); + } + + public TreeModel createTreeModel() { + + // Create root static node + VradiTreeNode root = new VradiTreeNode( + String.class, + "Root node", + null, + null + ); + + VradiTreeNode child = createNode(); + + // Add to root + root.add(child); + + // Create model + TreeModel model = createModel(root); + + // Populate childs nodes + root.populateChilds(getBridge(), getDataProvider()); + + registerLoadedIds(child); + + return model; + } + + public abstract VradiTreeNode createNode(); + + public VradiTreeNode getParentSelectedCategoryNode(String categoryName) { + return getParentCategoryNode(getSelectedNode(), categoryName); + } + + public static VradiTreeNode getParentCategoryNode(VradiTreeNode node, String categoryName) { + if (node == null) { + return null; + } + + if (node.getId().contains(categoryName)) { + return node; + } + return getParentCategoryNode(node.getParent(), categoryName); + } + + public VradiTreeNode getParentSelectedNode(Class type) { + return getParentNode(getSelectedNode(), type); + } + + public static VradiTreeNode getParentNode(VradiTreeNode node, Class type) { + if (node == null) { + return null; + } + + if (type.equals(node.getInternalClass())) { + return node; + } + return getParentNode(node.getParent(), type); + } + + public void createNode(Class<? extends NavTreeNodeChildLoador<String, ?, VradiTreeNode>> nodeLoadorsClass, String categoryName) { + createNode(nodeLoadorsClass, categoryName, null, false); + } + + public void createNode(Class<? extends NavTreeNodeChildLoador<String, ?, VradiTreeNode>> nodeLoadorsClass, + String categoryName, String id, boolean select) { + + VradiTreeNode node = findNode(getRootNode(), id); + + // If not found create it + if (node == null) { + VradiTreeNode parentNode = findNode(getRootNode(), categoryName); + if (parentNode == null) { + return; + } + node = getChildLoador(nodeLoadorsClass).createNode(id, getDataProvider()); + + insertNode(parentNode, node); + } + + // Select + if (select && (getSelectedNode() == null || !getSelectedNode().getId().equals(node.getId()))) { + selectNode(node); + } + } + + public void createAndSelectClientNode(String clientId) { + createClientNode(clientId, true); + } + + public void createClientNode(String clientId, boolean select) { + createNode(ClientsAndUsersNodeLoadors.class, AdminBeanConstant.CLIENT.getCategoryName(), clientId, select); + } + + public void createAndSelectGroupNode(String groupId) { + createGroupNode(groupId, true); + } + + public void createGroupNode(String groupId, boolean select) { + createNode(GroupsNodeLoadors.class, AdminBeanConstant.GROUP.getCategoryName(), groupId, select); + } + + public void createAndSelectUserNode(String userId, String clientId) { + createUserNode(userId, clientId, true); + } + + public void createUserNode(String userId, boolean select) { + createUserNode(userId, null, select); + } + + public void createUserNode(String userId, String clientId, boolean select) { + if (clientId == null) { + User user = VradiService.getWikittyProxy().restore(User.class, userId); + if (user == null) { + return; + } + clientId = user.getClient(); + } + createNode(ClientUsersNodeLoadors.class, clientId + AdminBeanConstant.USER.getCategoryName(), userId, select); + } + + public void createAndSelectFormTypeNode(String extensionId) { + createFormTypeNode(extensionId, true); + } + + public void createFormTypeNode(String extensionId, boolean select) { + createNode(FormTypeNodeLoadors.class, AdminBeanConstant.FORM_TYPE.getCategoryName(), extensionId, select); + } + + public void createAndSelectStreamNode(String streamId) { + createStreamNode(streamId, true); + } + + public void createStreamNode(String streamId, boolean select) { + createNode(StreamNodeLoadors.class, AdminBeanConstant.XML_STREAM.getCategoryName(), streamId, select); + } + + /** + * Method to reselect a category node (during some tree updates, while + * saving, node id change so, it not possible to reselect using oldPath. + * + * @param node The node to reselect + */ + public void reSelectCategory(VradiTreeNode node) { + String id = node.getParent().getId(); + log.debug("Try to load subcategory for node : " + id); + selectNode(id, node.getId()); + } + + public Client getClientSelected() { + VradiTreeNode clientNode = getParentSelectedNode(Client.class); + if (clientNode == null) { + return null; + } + return VradiService.getWikittyProxy().restore(Client.class, clientNode.getId()); + } + + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/AdminNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ClientNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ClientNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ClientNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,103 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.helpers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.ui.admin.loadors.ClientsAndUsersNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.Set; + +/** @author letellier */ +public class ClientNavigationTreeHelper extends AdminNavigationTreeHelper<Client> { + + /** Logger. */ + static private final Log log = LogFactory.getLog(ClientNavigationTreeHelper.class); + + protected VradiEntitiesListener<User> userVradiEntitiesListener; + + public ClientNavigationTreeHelper(VradiDataProvider dataProvider) { + super(dataProvider); + + VradiContext.get().getVradiNotifier().addVradiListener(Client.class, this); + userVradiEntitiesListener = new VradiEntitiesListener<User>() { + + @Override + public void entitiesAdded(Set<User> added) { + + for (User user : added) { + + String wikittyId = user.getWikittyId(); + + // cas creation + VradiTreeNode existingNode = findNode(getRootNode(), wikittyId); + + // cas modification + if (existingNode != null) { + if (log.isDebugEnabled()) { + log.debug("User modification occured"); + } + // Reconstruction des fils + refresh(existingNode); + } else { + if (log.isDebugEnabled()) { + log.debug("User creation occured"); + } + createUserNode(wikittyId, false); + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + removeEntities(removed); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(User.class, userVradiEntitiesListener); + } + + @Override + public VradiTreeNode createNode() { + + // Create client category node + return new VradiTreeNode( + String.class, + AdminBeanConstant.CLIENT.getCategoryName(), + null, + new ClientsAndUsersNodeLoadors() + ); + } + + @Override + public void createEntityNode(String wikittyId) { + createClientNode(wikittyId, false); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/ClientNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/FormTypeNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/FormTypeNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/FormTypeNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,96 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.helpers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiExtensionsListener; +import org.chorem.vradi.ui.admin.loadors.FormTypeNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.Set; + + +/** @author letellier */ +public class FormTypeNavigationTreeHelper extends AdminNavigationTreeHelper implements VradiExtensionsListener { + + /** Logger. */ + static private final Log log = LogFactory.getLog(FormTypeNavigationTreeHelper.class); + + public FormTypeNavigationTreeHelper(VradiDataProvider dataProvider) { + super(dataProvider); + VradiContext.get().getVradiNotifier().addVradiListener(this); + } + + @Override + public VradiTreeNode createNode() { + + // Create client category node + return new VradiTreeNode( + String.class, + AdminBeanConstant.FORM_TYPE.getCategoryName(), + null, + new FormTypeNodeLoadors() + ); + } + + @Override + public void createEntityNode(String name) { + createFormTypeNode(name, false); + } + + @Override + public void extensionsAdded(Set<WikittyExtension> added) { + for (WikittyExtension ext : added) { + + // for putExtension, wikittyExtensions has only one element + String name = ext.getName(); + + if (log.isDebugEnabled()) { + log.debug("search node with name " + name); + } + VradiTreeNode existingNode = findNode(getRootNode(), name); + + // cas modification + if (existingNode != null) { + refresh(existingNode); + } + + // cas creation + else { + createEntityNode(name); + } + } + } + + @Override + public void extensionsRemoved(Set<String> removedName) { + removeEntities(removedName); + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/FormTypeNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/GroupNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/GroupNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/GroupNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,172 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.helpers; + +import jaxx.runtime.swing.nav.NavHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.ui.admin.loadors.GroupUsersNodeLoadors; +import org.chorem.vradi.ui.admin.loadors.GroupsNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.Enumeration; +import java.util.Set; + +/** @author letellier */ +public class GroupNavigationTreeHelper extends AdminNavigationTreeHelper<Group> { + + /** Logger. */ + static private final Log log = LogFactory.getLog(GroupNavigationTreeHelper.class); + + protected VradiEntitiesListener<User> userVradiEntitiesListener; + + public GroupNavigationTreeHelper(VradiDataProvider dataProvider) { + super(dataProvider); + VradiContext.get().getVradiNotifier().addVradiListener(Group.class, this); + userVradiEntitiesListener = new VradiEntitiesListener<User>() { + + @Override + public void entitiesAdded(Set<User> added) { + for (User user : added) { + + String wikittyId = user.getWikittyId(); + + // cas creation + VradiTreeNode existingNode = findNode(getRootNode(), wikittyId); + + // cas modification + if (existingNode != null) { + if (log.isDebugEnabled()) { + log.debug("User modification occured"); + } + // Reconstruction des fils + refresh(existingNode); + } + } + } + + @Override + public void entitiesRemoved(Set<String> removedIds) { + removeEntities(removedIds); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(User.class, userVradiEntitiesListener); + } + + @Override + public VradiTreeNode createNode() { + return new VradiTreeNode( + String.class, + AdminBeanConstant.GROUP.getCategoryName(), + null, + new GroupsNodeLoadors() + ); + } + + @Override + public void createEntityNode(String wikittyId) { + createGroupNode(wikittyId, false); + } + + /* + * @see org.nuiton.wikitty.WikittyServiceListener#putWikitty(org.nuiton.wikitty.WikittyServiceEvent) + */ + @Override + public void entitiesAdded(Set<Group> added) { + if (log.isDebugEnabled()) { + log.debug("Groups added"); + } + + for (Group group : added) { + String wikittyId = group.getWikittyId(); + VradiTreeNode existingNode = findNode(getRootNode(), wikittyId); + + // cas modification + if (existingNode != null) { + + // Refresh + refresh(existingNode); + + // Add missing users + Set<String> userIds = group.getUser(); + + // Remove old users + VradiTreeNode userCategory = findNode(existingNode, AdminBeanConstant.USER.getCategoryName()); + if (userCategory != null) { + Enumeration<VradiTreeNode> childrenEnum = userCategory.children(); + while (childrenEnum.hasMoreElements()) { + VradiTreeNode child = childrenEnum.nextElement(); + + if (userIds == null || !userIds.contains(child.getId())) { + removeNode(child); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("User category not found"); + } + + // Create users category node + userCategory = new VradiTreeNode( + String.class, + AdminBeanConstant.USER.getCategoryName(), + null, + NavHelper.getChildLoador(GroupUsersNodeLoadors.class) + ); + insertNode(existingNode, userCategory); + return; + } + if (userIds != null) { + for (String userId : userIds) { + VradiTreeNode userNode = findNode(existingNode, userId); + if (userNode == null) { + + // Create user node + userNode = new VradiTreeNode(User.class, userId, null, null); + insertNode(userCategory, userNode); + + if (log.isDebugEnabled()) { + log.debug("Create user node"); + } + } + } + } + } + + // cas creation + else { + if (log.isDebugEnabled()) { + log.debug("Create group node"); + } + createEntityNode(wikittyId); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/GroupNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/XmlStreamNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/XmlStreamNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/XmlStreamNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,62 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.helpers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.ui.admin.loadors.StreamNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +/** @author letellier */ +public class XmlStreamNavigationTreeHelper extends AdminNavigationTreeHelper<XmlStream> { + + /** Logger. */ + static private final Log log = LogFactory.getLog(XmlStreamNavigationTreeHelper.class); + + public XmlStreamNavigationTreeHelper(VradiDataProvider dataProvider) { + super(dataProvider); + VradiContext.get().getVradiNotifier().addVradiListener(XmlStream.class, this); + } + + @Override + public VradiTreeNode createNode() { + + // Create client category node + return new VradiTreeNode( + String.class, + AdminBeanConstant.XML_STREAM.getCategoryName(), + null, + new StreamNodeLoadors() + ); + } + + @Override + public void createEntityNode(String wikittyId) { + createStreamNode(wikittyId, false); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/helpers/XmlStreamNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientUsersNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientUsersNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientUsersNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,68 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class ClientUsersNodeLoadors extends AbstractVradiNodeLoadors<User> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6834221183179682758L; + + public ClientUsersNodeLoadors() { + super(User.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + if (parentId == null) { + return null; + } + + VradiDataService dataService = getDataService(dataProvider); + List<User> serviceUsers = dataService.findClientUsers(parentId); + List<User> users = new ArrayList<User>(serviceUsers); + + // Return users of clients + Collections.sort(users, VradiComparators.USER_COMPARATOR); + return extractIds(users); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientUsersNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsAndUsersNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsAndUsersNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsAndUsersNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,81 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.admin.helpers.AdminBeanConstant; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; + +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class ClientsAndUsersNodeLoadors extends AbstractVradiNodeLoadors<Client> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6540304326033236054L; + + public ClientsAndUsersNodeLoadors() { + super(Client.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // Return all clients + // ne recupere pas seulement les id pour les mettre en cache + VradiDataService dataService = getDataService(dataProvider); + List<Client> clients = dataService.findAllClients(); + + Collections.sort(clients, VradiComparators.CLIENT_COMPARATOR); + return extractIds(clients); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + + // Create clients static nodes + VradiTreeNode clientNode = createVradiNode(id); + + VradiTreeNode usersCategoryNode = new VradiTreeNode( + String.class, + id + AdminBeanConstant.USER.getCategoryName(), + null, + NavHelper.getChildLoador(ClientUsersNodeLoadors.class) + ); + + // Add users nodes to clients node + clientNode.add(usersCategoryNode); + + return clientNode; + } + +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsAndUsersNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,63 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; + +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class ClientsNodeLoadors extends AbstractVradiNodeLoadors<Client> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6540304326033236054L; + + public ClientsNodeLoadors() { + super(Client.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // Return all clients + // ne recupere pas seulement les id pour les mettre en cache + VradiDataService dataService = getDataService(dataProvider); + List<Client> clients = dataService.findAllClients(); + Collections.sort(clients, VradiComparators.CLIENT_COMPARATOR); + return extractIds(clients); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/ClientsNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/FormTypeNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/FormTypeNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/FormTypeNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,87 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class FormTypeNodeLoadors extends NavTreeNodeChildLoador<String, WikittyExtension, VradiTreeNode> { + + /** Logger. */ + static private final Log log = LogFactory.getLog(FormTypeNodeLoadors.class); + + /** serialVersionUID. */ + private static final long serialVersionUID = 6346950208157931299L; + + public FormTypeNodeLoadors() { + super(WikittyExtension.class); + } + + public VradiDataService getDataService(NavDataProvider dataProvider) { + return ((VradiDataProvider) dataProvider).getVradiDataService(); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + VradiDataService dataService = getDataService(dataProvider); + List<WikittyExtension> formTypes = dataService.getAllFormTypes(); + Collections.sort(formTypes, VradiComparators.EXTENSION_COMPARATOR); + return extractNames(formTypes); + } + + @Override + public VradiTreeNode createNode(String name, NavDataProvider dataProvider) { + + if (log.isDebugEnabled()) { + log.debug("Create node with name " + name); + } + + return new VradiTreeNode( + getBeanType(), + name, + null, + null); + } + + public List<String> extractNames(List<WikittyExtension> entities) { + List<String> names = new ArrayList<String>(); + for (WikittyExtension e : entities) { + names.add(e.getName()); + } + return names; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/FormTypeNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupUsersNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupUsersNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupUsersNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,78 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.apache.commons.collections.CollectionUtils; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** @author letellier */ +public class GroupUsersNodeLoadors extends AbstractVradiNodeLoadors<User> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6834221183179682758L; + + public GroupUsersNodeLoadors() { + super(User.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + if (parentId == null) { + return null; + } + + WikittyProxy proxy = getProxy(dataProvider); + Group group = proxy.restore(Group.class, parentId); + + List<User> users = null; + if (CollectionUtils.isNotEmpty(group.getUser())) { + Set<String> userIds = group.getUser(); + if (userIds != null) { + users = proxy.restore(User.class, new ArrayList<String>(userIds)); + Collections.sort(users, VradiComparators.USER_COMPARATOR); + } + } + + // Return users of group + return extractIds(users); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupUsersNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupsNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupsNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupsNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,81 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.admin.helpers.AdminBeanConstant; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; + +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class GroupsNodeLoadors extends AbstractVradiNodeLoadors<Group> { + + /** serialVersionUID. */ + private static final long serialVersionUID = -1199890344440487950L; + + public GroupsNodeLoadors() { + super(Group.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // Return all groups + VradiDataService dataService = getDataService(dataProvider); + + List<Group> groups = dataService.findAllGroups(); + Collections.sort(groups, VradiComparators.GROUP_COMPARATOR); + + return extractIds(groups); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + + // Create groups static nodes + VradiTreeNode groupNode = createVradiNode(id); + + // Create users category node + VradiTreeNode usersCategoryNode = new VradiTreeNode( + String.class, + AdminBeanConstant.USER.getCategoryName(), + null, + NavHelper.getChildLoador(GroupUsersNodeLoadors.class) + ); + + // Add users nodes to groups node + groupNode.add(usersCategoryNode); + + return groupNode; + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/GroupsNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/StreamNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/StreamNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/StreamNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,63 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; + +import java.util.Collections; +import java.util.List; + +/** @author letellier */ +public class StreamNodeLoadors extends AbstractVradiNodeLoadors<XmlStream> { + + /** serialVersionUID. */ + private static final long serialVersionUID = -7828183287422107044L; + + public StreamNodeLoadors() { + super(XmlStream.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // ne recupere pas seulement les id pour les mettre en cache + VradiDataService dataService = getDataService(dataProvider); + + List<XmlStream> streamList = dataService.findAllXmlStreams(); + Collections.sort(streamList, VradiComparators.XML_STREAM_COMPARATOR); + + return extractIds(streamList); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/loadors/StreamNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/AdminTreeSelectionModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/AdminTreeSelectionModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/AdminTreeSelectionModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,138 @@ +/* + * #%L + * Vradi :: Swing + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.models; + +import org.chorem.vradi.ui.admin.AdminContentUI; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.admin.AdminNavUI; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import javax.swing.tree.DefaultTreeSelectionModel; +import javax.swing.tree.TreePath; + +/** @author sletellier */ +public class AdminTreeSelectionModel extends DefaultTreeSelectionModel { + + protected AdminHandler handler; + + protected AdminNavUI ui; + + public AdminTreeSelectionModel(AdminNavUI ui, AdminHandler handler) { + super(); + this.handler = handler; + this.ui = ui; + } + + @Override + public void setSelectionPath(TreePath path) { + if (willContinueSelection()) { + super.setSelectionPath(path); + afterSelection(path); + } + } + + @Override + public void setSelectionPaths(TreePath[] pPaths) { + if (willContinueSelection()) { + super.setSelectionPaths(pPaths); + } + } + + @Override + public void addSelectionPath(TreePath path) { + if (willContinueSelection()) { + super.addSelectionPath(path); + afterSelection(path); + } + } + + @Override + public void addSelectionPaths(TreePath[] paths) { + if (willContinueSelection()) { + super.addSelectionPaths(paths); + } + } + + @Override + public void removeSelectionPath(TreePath path) { + if (willContinueSelection()) { + super.removeSelectionPath(path); + } + checkEmptySelection(); + } + + @Override + public void removeSelectionPaths(TreePath[] paths) { + if (willContinueSelection()) { + super.removeSelectionPaths(paths); + } + checkEmptySelection(); + } + + @Override + public void clearSelection() { + if (willContinueSelection()) { + super.clearSelection(); + } + checkEmptySelection(); + } + + protected boolean willContinueSelection() { + if (isSelectionEmpty()) { + return true; + } + AdminContentUI contentUI = ui.getCurrentContent(); + + if (contentUI != null && contentUI.isModified()) { + + VradiTreeNode node = (VradiTreeNode) getSelectionPath().getLastPathComponent(); + + // Ask to save if modified + boolean canContinue = handler.answerToSave(contentUI, node); + + // l'utilisateur ne veut pas partir au final + if (!canContinue) { + return false; + } + } + + return true; + } + + protected void afterSelection(TreePath path) { + + VradiTreeNode node = (VradiTreeNode) path.getLastPathComponent(); + + // Open ui + handler.openUI(ui, node); + } + + protected void checkEmptySelection() { + // If nothing is selected + if (isSelectionEmpty()) { + ui.getContentLayout().show(ui.getContent(), AdminNavUI.NONE); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/AdminTreeSelectionModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldSelectModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldSelectModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldSelectModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,222 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.models; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.FieldTypeEnum; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyI18n; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; + +/** + * @author morin + * Date: 25 nov. 2009 + * Time: 17:19:44 + */ +public class FieldSelectModel implements Serializable { + + private static final Log log = LogFactory.getLog(FieldSelectModel.class); + + public static final String PROPERTY_NAME_VALUE = "nameValue"; + + public static final String PROPERTY_DESC_VALUE = "descValue"; + + public static final String PROPERTY_TRADUCTION = "traduction"; + + public static final String PROPERTY_TYPE = "type"; + + public static final String PROPERTY_POSITION = "position"; + + public static final String PROPERTY_UP_OR_DOWN = "upOrDown"; + + private static final long serialVersionUID = 1L; + + protected PropertyChangeSupport propertyChange = new PropertyChangeSupport(this); + + protected String nameValue; + + protected String fqFieldName; + + protected String descValue; + + protected FieldTypeEnum type; + + protected Integer position; + + //true if up, false if down, else null + protected Boolean upOrDown = null; + + // Language - value + protected String traduction; + + protected WikittyI18n wikittyI18n; + + public FieldSelectModel() { + this(null); + } + + public FieldSelectModel(Integer position) { + this(null, null, null, position); + } + + public FieldSelectModel(String fqFieldName, FieldType fieldType, WikittyI18n wikittyI18n, Integer position) { + super(); + this.wikittyI18n = wikittyI18n; + this.fqFieldName = fqFieldName; + if (fqFieldName != null) { + if (fqFieldName.indexOf('.') != -1) { + nameValue = WikittyUtil.getFieldNameFromFQFieldName(fqFieldName); + } else { + nameValue = fqFieldName; + } + } + descValue = VradiHelper.getFieldTypeDescription(fieldType); + type = FieldTypeEnum.valueOf(fieldType); + this.position = position; + + // Init languages + traduction = VradiHelper.getTraduction(wikittyI18n, fqFieldName); + } + + public void update(FieldSelectModel model) { + setNameValue(model.getNameValue()); + setFqFieldName(model.getFqFieldName()); + setType(model.getType()); + setDescValue(model.getDescValue()); + setPosition(model.getPosition()); + wikittyI18n = model.getWikittyI18n(); + setTraduction(VradiHelper.getTraduction(wikittyI18n, fqFieldName)); + } + + public String getNameValue() { + return nameValue; + } + + public void setNameValue(String value) { + String oldValue = nameValue; + nameValue = value; + propertyChange.firePropertyChange(PROPERTY_NAME_VALUE, oldValue, value); + } + + public String getFqFieldName() { + return fqFieldName; + } + + public void setFqFieldName(String fqFieldNames) { + fqFieldName = fqFieldNames; + } + + public String getDescValue() { + return descValue; + } + + public void setDescValue(String value) { + String oldValue = descValue; + descValue = value; + propertyChange.firePropertyChange(PROPERTY_DESC_VALUE, oldValue, value); + } + + public FieldTypeEnum getType() { + return type; + } + + public void setType(FieldTypeEnum value) { + FieldTypeEnum oldValue = type; + type = value; + propertyChange.firePropertyChange(PROPERTY_TYPE, oldValue, value); + } + + public Integer getPosition() { + return position; + } + + public void setPosition(Integer value) { + Integer oldValue = position; + position = value; + propertyChange.firePropertyChange(PROPERTY_POSITION, oldValue, value); + } + + public Boolean isUpOrDown() { + return upOrDown; + } + + public void setUpOrDown(Boolean value) { + Boolean oldValue = upOrDown; + upOrDown = value; + propertyChange.firePropertyChange(PROPERTY_UP_OR_DOWN, oldValue, value); + } + + public String getTraduction() { + String result = null; + if (traduction != null) { + if (!traduction.equals(nameValue)) { + result = traduction; + } + } + + return result == null ? "" : result; + } + + public void setTraduction(String traduction) { + + String old = this.traduction; + + // Put in wikitty i18n + this.traduction = traduction; + + if (wikittyI18n != null) { + wikittyI18n.setTranslation(VradiHelper.getCurrentLocale().getLanguage(), nameValue, traduction); + } + + propertyChange.firePropertyChange(PROPERTY_TRADUCTION, old, traduction); + } + + public WikittyI18n getWikittyI18n() { + return wikittyI18n; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + propertyChange.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + propertyChange.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + propertyChange.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + propertyChange.removePropertyChangeListener(propertyName, listener); + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldSelectModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldTypeModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldTypeModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldTypeModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,77 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.models; + +import org.chorem.vradi.entities.FieldTypeEnum; + +import javax.swing.AbstractListModel; +import javax.swing.MutableComboBoxModel; + +/** @author letellier */ +public class FieldTypeModel extends AbstractListModel implements MutableComboBoxModel { + + private static final long serialVersionUID = 1L; + + protected FieldTypeEnum selected = null; + + protected FieldTypeEnum[] values = FieldTypeEnum.values(); + + @Override + public int getSize() { + return values.length; + } + + @Override + public Object getElementAt(int index) { + return values[index]; + } + + @Override + public void addElement(Object obj) { + } + + @Override + public void removeElement(Object obj) { + } + + @Override + public void insertElementAt(Object obj, int index) { + } + + @Override + public void removeElementAt(int index) { + } + + @Override + public void setSelectedItem(Object anItem) { + selected = (FieldTypeEnum) anItem; + } + + @Override + public Object getSelectedItem() { + return selected; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/FieldTypeModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/TemplateFieldTableModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/TemplateFieldTableModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/TemplateFieldTableModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,148 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.models; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Le modèle du tableau pour afficher et éditer les bindings d'un template OpenOffice. + * <p/> + * User: kmorin + */ +public class TemplateFieldTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = LogFactory.getLog(TemplateFieldTableModel.class); + + /** Liste des bindings à afficher */ + protected List<Map.Entry<String, String>> data; + + /** Un drapeau pour bloquer le déclanchement des fireXXX) */ + protected boolean valueIsAdjusting; + + public TemplateFieldTableModel() { + data = new ArrayList<Map.Entry<String, String>>(); + } + + @Override + public int getRowCount() { + return data.size(); + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex == 1; + } + + /** Pour vider le modèle. */ + public void clear() { + data.clear(); + if (!valueIsAdjusting) { + fireTableDataChanged(); + } + } + + public boolean isValueIsAdjusting() { + return valueIsAdjusting; + } + + public void setValueIsAdjusting(boolean valueIsAdjusting) { + this.valueIsAdjusting = valueIsAdjusting; + } + + /** @return une copie de la liste des bindings */ + public Map<String, String> getData() { + // always send a copy + Map<String, String> result = new HashMap<String, String>(); + for (Map.Entry<String, String> entry : data) { + result.put(entry.getKey(), entry.getValue()); + } + return result; + } + + public void setData(Map<String, String> data) { + // always send a copy + this.data.addAll(data.entrySet()); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + ensureColumnIndex(columnIndex); + ensureRowIndex(rowIndex); + Map.Entry<String, String> entry = data.get(rowIndex); + Object result = null; + switch (columnIndex) { + case 0: + result = entry.getKey(); + break; + case 1: + String value = entry.getValue(); + if (value != null) { + result = Collections.singletonList(value); + } + break; + } + return result; + } + + @Override + public void setValueAt(Object sValue, int rowIndex, int columnIndex) { + ensureColumnIndex(columnIndex); + ensureRowIndex(rowIndex); + Map.Entry<String, String> entry = data.get(rowIndex); + Object[] value = (Object[]) sValue; + entry.setValue(value.length > 0 ? (String) value[0] : null); + + fireTableCellUpdated(rowIndex, columnIndex); + } + + protected void ensureRowIndex(int rowIndex) { + if (rowIndex >= getRowCount()) { + throw new ArrayIndexOutOfBoundsException("rowIndex (" + rowIndex + ") can not be greater than " + getRowCount()); + } + } + + protected void ensureColumnIndex(int columnIndex) { + if (columnIndex >= getColumnCount()) { + throw new ArrayIndexOutOfBoundsException("columnIndex (" + columnIndex + ") can not be greater than " + getColumnCount()); + } + } + +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/TemplateFieldTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/XmlStreamFieldTableModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/XmlStreamFieldTableModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/XmlStreamFieldTableModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,155 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.models; + +import org.chorem.vradi.entities.XmlFieldBinding; + +import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Le modèle du tableau pour afficher et éditer les bindings d'un flux XML. + * <p/> + * User: chemit + * Date: 15 nov. 2009 + * Time: 16:56:08 + */ +public class XmlStreamFieldTableModel extends AbstractTableModel { + private static final long serialVersionUID = 1L; + + /** Liste des bindings à afficher */ + protected final List<XmlFieldBinding> data; + + /** Un drapeau pour bloquer le déclanchement des fireXXX) */ + protected boolean valueIsAdjusting; + + public XmlStreamFieldTableModel() { + data = new ArrayList<XmlFieldBinding>(); + } + + @Override + public int getRowCount() { + return data.size(); + } + + @Override + public int getColumnCount() { + return 3; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex == 1 || columnIndex == 2; + } + + /** Pour vider le modèle. */ + public void clear() { + data.clear(); + if (!isValueIsAdjusting()) { + fireTableDataChanged(); + } + } + + public boolean isValueIsAdjusting() { + return valueIsAdjusting; + } + + public void setValueIsAdjusting(boolean valueIsAdjusting) { + this.valueIsAdjusting = valueIsAdjusting; + } + + /** @return une copie de la liste des bindings */ + public List<XmlFieldBinding> getBindings() { + return new ArrayList<XmlFieldBinding>(data); + } + + public void setBindings(Collection<XmlFieldBinding> bindings) { + data.clear(); + data.addAll(bindings); + if (isValueIsAdjusting()) { + int firstRow = data.size() - bindings.size(); + int lastRow = data.size() - 1; + fireTableRowsInserted(firstRow, lastRow); + } + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + Object result = null; + + if (ensureColumnIndex(columnIndex) && ensureRowIndex(rowIndex)) { + XmlFieldBinding value = data.get(rowIndex); + switch (columnIndex) { + case 0: + result = value.getFormField(); + break; + case 1: + result = value.getXmlField(); + break; + case 2: + result = value.getDefaultValue(); + break; + } + } + return result; + } + + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + if (ensureColumnIndex(columnIndex) && ensureRowIndex(rowIndex)) { + XmlFieldBinding binding = data.get(rowIndex); + + if (columnIndex == 1) { + Object[] values = (Object[]) value; + binding.clearXmlField(); + for (Object v : values) { + binding.addXmlField(String.valueOf(v)); + } + + } else if (columnIndex == 2) { + binding.setDefaultValue(String.valueOf(value)); + } + + fireTableCellUpdated(rowIndex, columnIndex); + } + } + + protected boolean ensureRowIndex(int rowIndex) { + if (rowIndex >= getRowCount()) { + return false; + } + return true; + } + + protected boolean ensureColumnIndex(int columnIndex) { + if (columnIndex >= getColumnCount()) { + return false; + } + return true; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/models/XmlStreamFieldTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/AdminRequestUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/AdminRequestUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/AdminRequestUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,146 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='adminRequestUI' + title='vradi.adminRequest.title' + layout='{new BorderLayout()}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.Color + + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.ui.offer.models.OfferListTableModel + org.chorem.vradi.ui.offer.OfferListColumnFactory + org.chorem.vradi.ui.search.SearchUI + org.chorem.vradi.ui.search.SearchHandler + org.chorem.vradi.ui.search.PaginationUI + </import> + + <String id='request' javaBean='null'/> + + <Boolean id='canSave' javaBean='true'/> + + <!-- le modèle du tableau --> + <OfferListColumnFactory id='offerListColumnFactory' + javaBean='getContextValue(OfferListColumnFactory.class)'/> + + <OfferListTableModel id='resultTableModel' + javaBean='getContextValue(OfferListTableModel.class)' + nbFormsPerPage='{10}' pageToShow='{1}'/> + + <script><![CDATA[ + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +public SearchHandler getSearchHandler() { + return UIHelper.getHandler(this, SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public SearchUI getSearchUI() { + return (SearchUI) searchPanel.getComponent(0); +} + +void $afterCompleteSetup() { + OfferListTableModel.OfferListTableModelBinding djb = new OfferListTableModel.OfferListTableModelBinding(this, + "resultTableModel", resultTableModel) { + @Override + public void processDataBinding() { + if (resultTableModel != null) { + SearchUI searchUI = getSearchUI(); + getSearchHandler().executeQuery(searchUI); + } + } + }; + + registerDataBinding(djb); + djb.applyDataBinding(); + + validate(); + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected void saveAndClose() { + setRequest(getSearchUI().getRequest()); + close(); +} + +protected void close() { + UIHelper.saveComponentDispositionConfig(); + setVisible(false); + dispose(); +} +]]> + </script> + + <JPanel id='searchPanel' + layout='{new BorderLayout()}' constraints='BorderLayout.NORTH'/> + + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> + <JScrollPane constraints='BorderLayout.CENTER'> + <org.chorem.vradi.ui.offer.OfferTable id='resultTable' + columnFactory='{offerListColumnFactory}' + model='{resultTableModel}' + autoResizeMode='{2}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + showGrid='{true}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + + <PaginationUI id='paginationUI' + constructorParams='this' + constraints='BorderLayout.SOUTH'/> + </JPanel> + + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.common.close' + id='closeButton' + actionIcon='close' + onActionPerformed='close()'/> + </cell> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.adminRequest.valid' + id='validButton' + actionIcon='accept' + visible='{isCanSave()}' + onActionPerformed='saveAndClose()'/> + </cell> + </row> + </Table> + +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/AdminRequestUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/TemplateFieldBindingUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/TemplateFieldBindingUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/TemplateFieldBindingUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,151 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='templateFieldBindingUI' + title='vradi.adminFormType.template.fieldBinding.title' + modal='true' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='dispose()'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.Component + + javax.swing.DefaultListCellRenderer + javax.swing.ListCellRenderer + javax.swing.JList + javax.swing.table.DefaultTableCellRenderer + javax.swing.table.TableCellRenderer + org.nuiton.wikitty.entities.WikittyExtension + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.VradiContext + org.chorem.vradi.ui.offer.editors.JListCellEditor + org.chorem.vradi.ui.admin.renderers.JListCellRenderer + org.chorem.vradi.ui.admin.models.TemplateFieldTableModel + jaxx.runtime.SwingUtil + org.jdesktop.swingx.decorator.Highlighter + org.jdesktop.swingx.decorator.HighlighterFactory + org.jdesktop.swingx.JXTable + org.chorem.vradi.VradiHelper + </import> + + <WikittyExtension id='extension' javaBean='null'/> + + <String id='template' javaBean='null'/> + + <TemplateFieldTableModel id='fieldsModel' + javaBean='new TemplateFieldTableModel()'/> + + <script><![CDATA[ + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +void $afterCompleteSetup() { + SwingUtil.setI18nTableHeaderRenderer(fieldsTable, + n_("vradi.table.field.name"), + n_("vradi.table.field.name.tip"), + n_("vradi.table.field.values"), + n_("vradi.table.field.values.tip")); + + ListCellRenderer listRenderer = new DefaultListCellRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + if (value != null) { + value = VradiHelper.getTraduction(extension, (String) value); + } + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + }; + + JListCellRenderer renderer = new JListCellRenderer(listRenderer); + + setContextValue(renderer); + SwingUtil.setTableColumnRenderer(fieldsTable, 0, fieldsTable.getDefaultRenderer(String.class)); + SwingUtil.setTableColumnRenderer(fieldsTable, 1, renderer); + + JListCellEditor editor = new JListCellEditor(listRenderer, true); + setContextValue(editor); + SwingUtil.setTableColumnEditor(fieldsTable, 1, editor); + final Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + fieldsTable.addHighlighter(highlighter); + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +public void cancel() { + setFieldsModel(null); + close(); +} + +public void valid() { + if (getHandler().checkAssociation(this, getExtension(), fieldsModel)) { + close(); + } else { + cancel(); + } +} + +public void close() { + UIHelper.saveComponentDispositionConfig(); + this.dispose(); +} +]]></script> + + <Table> + <row> + <cell columns='2' anchor='west' fill='both'> + <JLabel text='vradi.adminFormType.template.fieldBinding.label'/> + </cell> + </row> + <row> + <cell columns='2' weightx='1' weighty='1' fill='both'> + <JScrollPane> + <JXTable id='fieldsTable' model='{fieldsModel}' + rowSelectionAllowed='false' font-size='11'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='both' weightx='0.5'> + <JButton text='vradi.common.cancel' + onActionPerformed='cancel()'/> + </cell> + <cell fill='both' weightx='0.5'> + <JButton text='vradi.common.validate' + onActionPerformed='valid()'/> + </cell> + </row> + </Table> + +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/TemplateFieldBindingUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusConfirmDialogUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusConfirmDialogUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusConfirmDialogUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,113 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='thesaurusConfirmDialogUI' + modal='true' + layout='{new BorderLayout()}'> + + <import> + javax.swing.UIManager + org.chorem.vradi.ui.admin.content.AdminThesaurusHandler + </import> + + <String id='msg' javaBean='""'/> + + <Thesaurus id='bean' javaBean='null'/> + + <Boolean id='save' javaBean='false'/> + + <script><![CDATA[ + +protected AdminThesaurusHandler getHandler() { + return getContextValue(AdminThesaurusHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { +} + +public void init(Thesaurus thesaurus, String msg, String title) { + setBean(thesaurus); + setTitle(title); + setMsg(msg); + + this.pack(); + setVisible(true); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected void showApply() { + getHandler().showApply(this, getBean()); +} + +protected void saveAndClose() { + setSave(true); + close(); +} + +protected void close() { + setVisible(false); + UIHelper.saveComponentDispositionConfig(); + dispose(); +} +]]> + </script> + + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JLabel id='msgLabel' + icon='{UIManager.getLookAndFeelDefaults().getIcon("OptionPane.warningIcon")}' + text='{getMsg()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton id='showApply' text='vradi.thesaurus.showApply' + onActionPerformed='showApply()'/> + </cell> + </row> + </Table> + + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.adminRequest.cancel' + actionIcon='cancel' + onActionPerformed='close()'/> + </cell> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.thesaurus.confirm.save' + actionIcon='save' + onActionPerformed='saveAndClose()'/> + </cell> + </row> + </Table> + +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusConfirmDialogUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusEditUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusEditUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusEditUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,174 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='thesaurusEditUI' + title='{titleThesaurus}' + modal='true' + layout='{new BorderLayout()}'> + + <import> + static jaxx.runtime.SwingUtil.getStringValue + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper + jaxx.runtime.swing.editor.NumberEditor + org.chorem.vradi.ui.admin.content.AdminThesaurusHandler + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper + </import> + + <script><![CDATA[ + +public void init(Thesaurus thesaurus, String title, final boolean isCreating) { + setBean(thesaurus); + setTitleThesaurus(title); + orderEditor.setBean(getBean()); + orderEditor.init(); + orderEditor.setModel(getBean().getOrder()); + thesaurus.addPropertyChangeListener(new PropertyChangeListener(){ + + @Override + public void propertyChange(PropertyChangeEvent evt) { + setModified(true); + } + }); + orderEditor.getTextField().setColumns(4); + this.pack(); + setVisible(true); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected AdminThesaurusHandler getHandler() { + return UIHelper.getHandler(this, AdminThesaurusHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { +} + +protected void valid(){ + setSave(true); + close(); +} + +protected void close(){ + setVisible(false); + UIHelper.saveComponentDispositionConfig(); + dispose(); +} + +protected void move(){ + getHandler().moveThesaurus(this, getBean()); +} +]]></script> + + <Thesaurus id='bean' javaBean='null'/> + + <Boolean id='save' javaBean='false'/> + + <String id='titleThesaurus' javaBean='""'/> + + <Boolean id='modified' javaBean='false'/> + + <Boolean id='moved' javaBean='false'/> + + <Table constraints='BorderLayout.NORTH'> + <row> + <cell fill='horizontal' columns='3' anchor="west"> + <JLabel styleClass='titleLeft' text='{getTitleThesaurus()}'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminThesaurus.orderName'/> + </cell> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.1'> + <NumberEditor id='orderEditor' + constructorParams='this' + property='order' + useFloat='{false}' + useSign='{false}' + autoPopup='{false}' + showPopupButton='{false}' + showReset='{true}'/> + </cell> + <cell fill='horizontal' columns='2' insets='0,0,0,0' weightx='0.9'> + <JTextField id='nameField' text='{getBean().getName()}' + onKeyReleased='bean.setName(nameField.getText())'/> + </cell> + </row> + </Table> + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminThesaurus.path'/> + </cell> + <cell fill='horizontal' anchor="west" weightx='1'> + <JLabel id='pathField' + text='{ThesaurusDataHelper.getParentPath(getBean(), "/")}'/> + </cell> + <cell fill='horizontal'> + <JButton id='pathSelect' text='vradi.adminThesaurus.move' + actionIcon="move" onActionPerformed='move()'/> + </cell> + </row> + <row> + <cell fill='horizontal'> + <JLabel text='vradi.adminThesaurus.tags'/> + </cell> + <cell fill='horizontal' columns='3' insets='0,0,0,0' weightx='1'> + <JTextField id='tagsField' + text='{ThesaurusDataHelper.getTagsAsString(getBean())}' + onKeyReleased='ThesaurusDataHelper.setTagsAsString(getBean(), tagsField.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal' columns='3'> + <JLabel text='vradi.adminThesaurus.comment'/> + </cell> + </row> + <row> + <cell fill='both' insets='0,0,0,0' columns="4" weightx='1' weighty='1'> + <JTextArea id='commentField' text='{getBean().getComment()}' + onKeyReleased='bean.setComment(commentField.getText())'/> + </cell> + </row> + </Table> + <Table constraints="BorderLayout.SOUTH"> + <row> + <cell fill='horizontal' weightx='0.5'> + <JButton text='vradi.common.close' actionIcon='close' + onActionPerformed='close()'/> + </cell> + <cell fill='horizontal' weightx='0.5'> + <JButton text='vradi.common.save' actionIcon='save' + enabled='{isModified()}' onActionPerformed='valid()'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusEditUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusPathChooserUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusPathChooserUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusPathChooserUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,147 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='thesaurusPathChooserUI' + title='vradi.adminThesaurus.select' + modal='true' + layout='{new BorderLayout()}'> + + <style source='../../VradiMainUI.css'/> + + <import> + javax.swing.event.TreeSelectionListener + javax.swing.event.TreeSelectionEvent + + jaxx.runtime.JAXXContext + jaxx.runtime.SwingUtil + org.chorem.vradi.ui.renderers.ThesaurusHighlighter + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.ui.tree.VradiTreeTableNode + javax.swing.tree.TreePath + jaxx.runtime.swing.JAXXTree + jaxx.runtime.swing.JAXXTree.JAXXTreeModel + org.chorem.vradi.VradiHelper + org.jdesktop.swingx.JXTreeTable + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper + javax.swing.tree.DefaultTreeCellRenderer + org.jdesktop.swingx.decorator.* + </import> + + <Boolean id='selected' javaBean='false'/> + + <Boolean id='saved' javaBean='false'/> + + <script><![CDATA[ + +protected ThesaurusTreeTableHelper helper; + +public ThesaurusPathChooserUI(JAXXContext parentContext, ThesaurusTreeTableHelper helper) { + SwingUtil.initContext(this, parentContext); + this.helper = helper; +} + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +protected ThesaurusTreeTableHelper getHelper() { + return helper; +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + thesaurus.putClientProperty("JTree.lineStyle", "Angled"); + + TreeSelectionListener listener = new TreeSelectionListener(){ + + @Override + public void valueChanged(TreeSelectionEvent e) { + + // Get selcted node + VradiTreeTableNode selectedNode = helper.getSelectedNode(); + + // Set as selected + setSelected(selectedNode != null); + } + }; + + // Register tree table + helper.setUI(thesaurus, true, false, listener); + + UIHelper.addThesaurusExpandOnClickListener(thesaurus); + + // Render + thesaurus.setTreeCellRenderer(new ThesaurusHighlighter(ThesaurusHighlighter.HighlighterType.MOVE)); + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected void close(){ + UIHelper.saveComponentDispositionConfig(); + setVisible(false); + dispose(); +} + +]]> + </script> + + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' weightx='1.0'> + <JLabel text='vradi.adminThesaurus.selectAsk'/> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='0.7'> + <JScrollPane> + + <JXTreeTable id="thesaurus" + font-size='11' + rootVisible='false' + showsRootHandles='true' + treeTableModel='{helper.createTreeModel()}' + highlighters='{new ThesaurusHighlighter(ThesaurusHighlighter.HighlighterType.MOVE)}'/> + + </JScrollPane> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id='cancel' actionIcon='cancel' text='vradi.common.cancel' + onActionPerformed='close()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='select' actionIcon='select' text='vradi.common.select' + enabled='{isSelected()}' + onActionPerformed='setSaved(true);close()'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusPathChooserUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,117 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.popups; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.ui.admin.query.QueryCellEditor; +import org.chorem.vradi.ui.admin.query.QueryCheckCellRenderer; +import org.chorem.vradi.ui.admin.query.ThesaurusChangesTreeTableModel; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.TreeTableModel; + +import javax.swing.DefaultCellEditor; +import javax.swing.table.TableColumn; +import java.util.List; +import java.util.Map; + +/** + * ThesaurusQueryChangesHandler. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 25 mars 2010 15:05:55 + */ +public class ThesaurusQueryChangesHandler { + + public static final String QUERY = "query"; + + public static final String ROOT_BEFORE_MODIF = "rootBeforeModif"; + + public static final String THESAURUS_BEFORE_MODIF = "thesaurusBeforeModif"; + + public static final String ROOT_AFTER_MODIF = "rootAfterModif"; + + public static final String THESAURUS_AFTER_MODIF = "thesaurusAfterModif"; + + public ThesaurusQueryChangesUI initUI(JAXXContext rootContext, Map<Group, List<QueryBean>> queries, + String rootThesaurusBefore, String rootThesaurusAfter, + String thesaurusBefore, String thesaurusAfter) { + JAXXInitialContext context = new JAXXInitialContext().add(rootContext).add(this); + context.add(QUERY, queries); + context.add(ROOT_BEFORE_MODIF, rootThesaurusBefore); + context.add(ROOT_AFTER_MODIF, rootThesaurusAfter); + + if (thesaurusAfter != null) { + context.add(THESAURUS_AFTER_MODIF, thesaurusAfter); + context.add(THESAURUS_BEFORE_MODIF, thesaurusBefore); + } + + ThesaurusQueryChangesUI thesaurusChangesUI = new ThesaurusQueryChangesUI(context); + JXTreeTable resultTreeTable = thesaurusChangesUI.getResultTreeTable(); + resultTreeTable.expandAll(); + + // editor column + TableColumn column = resultTreeTable.getColumnModel().getColumn(3); + column.setCellEditor(new QueryCellEditor(rootContext)); + + // checkbox column + column = resultTreeTable.getColumnModel().getColumn(4); + QueryCheckCellRenderer checkBox = new QueryCheckCellRenderer(); + column.setCellRenderer(checkBox); + column.setCellEditor(new DefaultCellEditor(checkBox)); + column.setMaxWidth((int) checkBox.getPreferredSize().getWidth()); + + Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + resultTreeTable.addHighlighter(highlighter); + + return thesaurusChangesUI; + } + + void close(ThesaurusQueryChangesUI context) { + context.setVisible(false); + context.dispose(); + } + + public TreeTableModel getResultTreeTableModel(ThesaurusQueryChangesUI context) { + ThesaurusChangesTreeTableModel treeTableModel = context.getContextValue(ThesaurusChangesTreeTableModel.class); + if (treeTableModel == null) { + Map<Group, List<QueryBean>> queries = context.getContextValue(Map.class, QUERY); + String rootThesaurusBefore = context.getContextValue(String.class, ROOT_BEFORE_MODIF); + String rootThesaurusAfter = context.getContextValue(String.class, ROOT_AFTER_MODIF); + String thesaurusBefore = context.getContextValue(String.class, THESAURUS_BEFORE_MODIF); + String thesaurusAfter = context.getContextValue(String.class, THESAURUS_AFTER_MODIF); + + treeTableModel = new ThesaurusChangesTreeTableModel(queries, rootThesaurusBefore, rootThesaurusAfter, thesaurusBefore, thesaurusAfter); + context.setContextValue(treeTableModel); + } + return treeTableModel; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,98 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='thesaurusQueryChangesUI' + modal='true' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='this.dispose()'> + + <import> + java.awt.Color + javax.swing.JOptionPane + javax.swing.JTable + javax.swing.ListSelectionModel + org.jdesktop.swingx.JXTreeTable + org.chorem.vradi.ui.admin.content.AdminThesaurusHandler + </import> + + <Boolean id='modifiedQueries' javaBean='Boolean.FALSE'/> + + <script><![CDATA[ + +void $afterCompleteSetup() { + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected AdminThesaurusHandler getThesaurusHandler() { + return UIHelper.getHandler(this, AdminThesaurusHandler.class); +} + +protected ThesaurusQueryChangesHandler getHandler() { + return UIHelper.getHandler(this, ThesaurusQueryChangesHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void onCancel() { + int confirm = JOptionPane.showConfirmDialog(this, + _("vradi.thesaurusQueryChangesUI.confirm.cancel"), _("vradi.common.cancel"), + JOptionPane.YES_NO_OPTION); + + if (confirm == JOptionPane.YES_OPTION) { + dispose(); + } +} + ]]></script> + + <JScrollPane constraints='BorderLayout.CENTER'> + <JXTreeTable id='resultTreeTable' + treeTableModel='{getHandler().getResultTreeTableModel(this)}' + autoResizeMode='{JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + selectionMode='{ListSelectionModel.SINGLE_SELECTION}' + showGrid='{false}' + gridColor='{Color.GRAY}' + expandsSelectedPaths='{true}'/> + </JScrollPane> + + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton text='vradi.common.cancel' actionIcon='cancel' + onActionPerformed='onCancel()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton text='vradi.common.validate' actionIcon='accept' + onActionPerformed='setModifiedQueries(Boolean.TRUE); this.dispose()'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/popups/ThesaurusQueryChangesUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCellEditor.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCellEditor.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCellEditor.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,125 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.query; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.DefaultJAXXContext; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.admin.popups.AdminRequestUI; +import org.chorem.vradi.ui.helpers.UIHelper; + +import javax.swing.AbstractCellEditor; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.table.TableCellEditor; +import javax.swing.tree.TreeCellEditor; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * QueryCellEditor. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 6 avr. 2010 16:24:19 + */ +public class QueryCellEditor extends AbstractCellEditor implements + TreeCellEditor, TableCellEditor { + + private static final long serialVersionUID = 1L; + + final JLabel label; + + final JAXXContext parentContext; + + String currentQuery = null; + + public QueryCellEditor(JAXXContext context) { + parentContext = context; + + label = new JLabel(); + label.setOpaque(true); + + label.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + openRequest(); + } + }); + } + + @Override + public Object getCellEditorValue() { + return currentQuery; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + + currentQuery = (String) value; + label.setText(currentQuery); + return label; + } + + @Override + public Component getTreeCellEditorComponent(JTree tree, Object value, + boolean isSelected, boolean expanded, boolean leaf, int row) { + + currentQuery = (String) value; + label.setText(currentQuery); + return label; + } + + public void openRequest() { + JAXXContext context = new DefaultJAXXContext(); + context.setContextValue(parentContext); + + QueryBean query = new QueryBean(); + query = query.setQuery(currentQuery); + + AdminHandler adminHandler = UIHelper.getHandler(context, + AdminHandler.class); + AdminRequestUI adminRequestUI = adminHandler.createAdminRequestUI( + context, query, null); + + adminRequestUI.addPropertyChangeListener( + AdminRequestUI.PROPERTY_REQUEST, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + currentQuery = (String) evt.getNewValue(); + } + }); + + adminRequestUI.setModal(true); + adminRequestUI.setVisible(true); + fireEditingStopped(); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCellEditor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCheckCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCheckCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCheckCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,68 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.query; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.io.Serializable; + +/** + * QueryCheckCellRenderer is a special renderer used by {@code ThesaurusQueryChangesHandler}. + * It render a checkbox if value is not null or a simple empty label instead. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 6 avr. 2010 16:24:19 + */ +public class QueryCheckCellRenderer extends JCheckBox implements TableCellRenderer, + Serializable { + + private static final long serialVersionUID = 1L; + + final JLabel label = new JLabel(); + + public QueryCheckCellRenderer() { + super.setOpaque(true); + label.setOpaque(true); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + if (value != null) { + Boolean b = (Boolean) value; + setSelected(b); + return this; + + } else { + return label; + } + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/QueryCheckCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ThesaurusChangesTreeTableModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ThesaurusChangesTreeTableModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ThesaurusChangesTreeTableModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,315 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.query; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import org.nuiton.i18n.I18n; + +import javax.swing.tree.TreePath; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * ThesaurusChangesTreeTableModel. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 8 avr. 2010 15:19:16 + */ +public class ThesaurusChangesTreeTableModel extends AbstractTreeTableModel { + private static final Log log = LogFactory.getLog(ThesaurusChangesTreeTableModel.class); + + /** clients and groups */ + final ArrayList<Group> topLevels = new ArrayList<Group>(); + + /** queryMakers indexed by wikittyId */ + final HashMap<String, Group> groupsMap = new HashMap<String, Group>(); + + /** queries indexed by wikittyId */ + final HashMap<String, List<QueryBean>> queryBeanMap = new HashMap<String, List<QueryBean>>(); + + /** key:before, value:after */ + final HashMap<QueryBean, QueryBean> modifiedBeanMap = new HashMap<QueryBean, QueryBean>(); + + /** queries validation state */ + final HashMap<QueryBean, Boolean> queryBeanValidate = new HashMap<QueryBean, Boolean>(); + + public ThesaurusChangesTreeTableModel(Map<Group, List<QueryBean>> queryMap, String rootThesaurusBefore, + String rootThesaurusAfter, String thesaurusBefore, String thesaurusAfter) { + super(1L); + + HashMap<String, Group> groupMap = new HashMap<String, Group>(); + + for (Map.Entry<Group, List<QueryBean>> entry : queryMap.entrySet()) { + // queryMaker + Group group = entry.getKey(); + // original queries for queryMaker + List<QueryBean> queries = entry.getValue(); + + String wikittyId = group.getWikittyId(); + + // index queries by wikittyId + queryBeanMap.put(wikittyId, queries); + + // group + groupMap.put(wikittyId, group); + + // index queries by original:modified + for (QueryBean original : queries) { + String query = original.getQuery(); + + // If root thesaurus modif + if (!rootThesaurusBefore.equals(rootThesaurusAfter)) { + query = StringUtils.replace(query, rootThesaurusBefore + ':', rootThesaurusAfter + ':'); + } + + // If thesaurus modif + if (thesaurusAfter != null) { + if (!thesaurusBefore.equals(thesaurusAfter)) { + query = StringUtils.replace(query, ':' + thesaurusBefore, ':' + thesaurusAfter); + query = StringUtils.replace(query, ":\"" + thesaurusBefore + "\"", ":\"" + thesaurusAfter + "\""); + } + } + + QueryBean modified = original.setQuery(query); + + modifiedBeanMap.put(original, modified); + queryBeanValidate.put(original, Boolean.TRUE); + } + } + + List<Group> groupList = new ArrayList<Group>(groupMap.values()); + + Collections.sort(groupList, VradiComparators.GROUP_COMPARATOR); + + topLevels.addAll(groupList); + + groupsMap.putAll(groupMap); + } + + public List<Group> getUpdatedQueryMakers() throws IOException { + List<Group> list = new ArrayList<Group>(); + + for (Group queryMaker : groupsMap.values()) { + list.add(queryMaker); + Set<String> queries = new HashSet<String>(); + Set<String> initialQueries = queryMaker.getQueries(); + if (initialQueries != null) { + queries.addAll(initialQueries); + } + queryMaker.clearQueries(); + + for (String query : queries) { + QueryBean original = new QueryBean(query, queryMaker.getWikittyId()); + + if (queryBeanValidate.containsKey(original) && queryBeanValidate.get(original)) { + QueryBean modified = modifiedBeanMap.get(original); + queryMaker.addQueries(modified.getQueryLine()); + + } else { + queryMaker.addQueries(query); + } + } + + } + return list; + } + + @Override + public int getColumnCount() { + return 5; + } + + @Override + public Object getValueAt(Object node, int column) { + if (node instanceof Group) { + if (column == 0) { + Group group = (Group) node; + return group.getName(); + } + + } else if (node instanceof QueryBean) { + QueryBean bean = (QueryBean) node; + if (column == 0) { + return bean.getName(); + + } else if (column == 1) { + return bean.getDescription(); + + } else if (column == 2) { + return bean.getQuery(); + + } else if (column == 3) { + QueryBean modifiedBean = modifiedBeanMap.get(bean); + return modifiedBean.getQuery(); + + } else if (column == 4) { + boolean validate = queryBeanValidate.get(bean); + return validate; + } + } + + return null; + } + + @Override + public boolean isCellEditable(Object node, int column) { + if (column == 3 || column == 4) { + boolean b = node instanceof QueryBean; + return b; + } + return false; + } + + @Override + public void setValueAt(Object value, Object node, int column) { + if (column == 3) { + QueryBean bean = (QueryBean) node; + String beanId = bean.getId(); + if (beanId == null) { + return; + } + + QueryBean initialBean = modifiedBeanMap.get(bean); + QueryBean modifiedBean = initialBean.setQuery(String.valueOf(value)); + + if (!initialBean.equals(modifiedBean)) { + modifiedBeanMap.put(bean, modifiedBean); + queryBeanValidate.put(bean, Boolean.TRUE); + fireQueryChanged(bean); + } + + } else if (column == 4) { + QueryBean bean = (QueryBean) node; + String beanId = bean.getId(); + if (beanId == null) { + return; + } + + queryBeanValidate.put(bean, (Boolean) value); + fireQueryChanged(bean); + } + } + + private void fireQueryChanged(QueryBean bean) { + String beanId = bean.getId(); + + TreePath parentPath = null; + int index; + + Group group = groupsMap.get(beanId); + + Object[] paths = new Object[2]; + paths[0] = 1L; + paths[1] = group; + + parentPath = new TreePath(paths); + index = getIndexOfChild(paths[1], bean); + + modelSupport.fireChildChanged(parentPath, index, bean); + } + + @Override + public Object getChild(Object parent, int index) { + if (parent instanceof Long) { + return topLevels.get(index); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + QueryBean bean = list.get(index); + return bean; + } + + return null; + } + + @Override + public int getChildCount(Object parent) { + if (parent instanceof Long) { + return topLevels.size(); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + return list.size(); + } + + return 0; + } + + @Override + public int getIndexOfChild(Object parent, Object child) { + if (parent instanceof Long) { + return topLevels.indexOf(child); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + return list.indexOf(child); + } + + return -1; + } + + @Override + public String getColumnName(int column) { + String columnName = null; + if (column == 0) { + columnName = I18n._("vradi.requestFormView.resultTable.name"); + } else if (column == 1) { + columnName = I18n._("vradi.requestFormView.resultTable.description"); + } else if (column == 2) { + columnName = I18n._("vradi.requestFormView.resultTable.oldQuery"); + } else if (column == 3) { + columnName = I18n._("vradi.requestFormView.resultTable.newQuery"); + } + return columnName; + } + + private VradiStorageService vradiStorageService = null; + + protected VradiStorageService getVradiStorageService() { + if (vradiStorageService == null) { + vradiStorageService = VradiService.getVradiStorageService(); + } + return vradiStorageService; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/query/ThesaurusChangesTreeTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/AdminCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/AdminCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/AdminCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,169 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.renderers; + +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorProvider; +import jaxx.runtime.swing.nav.tree.AbstractNavTreeCellRenderer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.ui.admin.helpers.AdminBeanConstant; +import org.chorem.vradi.ui.admin.helpers.AdminNavigationTreeHelper; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeModel; +import java.awt.Component; + +import static org.nuiton.i18n.I18n._; + +/** + * @author letellier + * @see AbstractNavTreeCellRenderer + */ +public class AdminCellRenderer extends AbstractNavTreeCellRenderer<DefaultTreeModel, VradiTreeNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7917305304778635796L; + + /** Logger */ + protected static final Log log = LogFactory.getLog(AdminCellRenderer.class); + + protected DecoratorProvider decoratorProvider; + + /** + * Init renderer. + * + * @param decoratorProvider ??? + * @param dataProvider data provider + */ + public AdminCellRenderer(DecoratorProvider decoratorProvider, + VradiDataProvider dataProvider) { + + setDataProvider(dataProvider); + this.decoratorProvider = decoratorProvider; + } + + // Override to decorate User category node + @Override + public String getNodeText(VradiTreeNode node) { + if (node == null) { + return null; + } + String text; + + if (node.isDirty() || !renderCache.containsKey(node)) { + + // calculer le rendu du noeud + if (node.isStringNode()) { + String id = node.getId(); + if (id.matches(".+" + AdminBeanConstant.USER.getCategoryName())) { + text = _(AdminBeanConstant.USER.getCategoryName()); + } else { + text = _(id); + } + + } else { + + text = computeNodeText(node); + } + + if (log.isDebugEnabled()) { + log.debug("text for node [" + node + "] = <" + text + ">"); + } + + // sauvegarde dans le cache + renderCache.put(node, text); + + // le noeud est de nouveau propre + node.setDirty(false); + + } else { + + // recupération directement du rendu dans le cache + text = renderCache.get(node); + } + + return text; + } + + @Override + protected String computeNodeText(VradiTreeNode node) { + + // Get node type + Class<?> editType = node.getInternalClass(); + String id = node.getId(); + + // get decorator + Decorator<?> decorator = decoratorProvider.getDecorator(editType); + + // for user + if (editType.equals(User.class)) { + + // And if its client ui + VradiTreeNode clientCategoryNode = AdminNavigationTreeHelper.getParentCategoryNode(node, AdminBeanConstant.CLIENT.getCategoryName()); + if (clientCategoryNode != null) { + + // Decorate with user name only + decorator = decoratorProvider.getDecorator(User.class, VradiConstants.USER_ONLY_DECORATOR); + } + } + + Object toDecorate = AdminBeanConstant.getConstantByBeanClass(editType). + getBean(((VradiDataProvider) getDataProvider()).getWikittyProxy(), id); + + // Get decorated value + String decorated = decorator.toString(toDecorate); + + if (log.isDebugEnabled()) { + log.debug("Compute text for node " + node + " return " + decorated); + } + + return decorated; + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, int row, + boolean hasFocus) { + + // get node + VradiTreeNode node = (VradiTreeNode) value; + + // get text for node + String text = getNodeText(node); + + // Render node + return super.getTreeCellRendererComponent(tree, text, sel, + expanded, leaf, + row, hasFocus); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/AdminCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/JListCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/JListCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/JListCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,117 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.renderers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.ui.helpers.UIHelper; + +import javax.swing.DefaultListModel; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JTable; +import javax.swing.ListCellRenderer; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.util.List; + +/** + * Un renderer d'une cellule d'un tableau qui contient une liste de valeurs sélectionnables. + * <p/> + * User: chemit + * Date: 15 nov. 2009 + * Time: 21:36:08 + */ +public class JListCellRenderer implements TableCellRenderer { + + /** Logger */ + static private final Log log = LogFactory.getLog(JListCellRenderer.class); + + /** le composant pour le rendu */ + protected JList list; + + /** le composant de délégation pour obtenir le rendu visuel (commun à tout le tableau) */ + protected TableCellRenderer delegateRenderer; + + public JListCellRenderer() { + this(null, new DefaultTableCellRenderer()); + } + + public JListCellRenderer(ListCellRenderer listRenderer) { + this(listRenderer, new DefaultTableCellRenderer()); + } + + public JListCellRenderer(TableCellRenderer delegateRenderer) { + this(null, delegateRenderer); + } + + public JListCellRenderer(ListCellRenderer listRenderer, TableCellRenderer delegateRenderer) { + this.delegateRenderer = delegateRenderer; + list = new JList(new DefaultListModel()); + if (listRenderer != null) { + list.setCellRenderer(listRenderer); + } + } + + /** + * Pour mettre à jour la liste des valeurs sélectionnables. + * + * @param values les valeurs sélectionnables (à placer dans le modèle de la liste) + */ + public void updateUniverse(List<String> values) { + UIHelper.fillList(list, values, null); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (log.isDebugEnabled()) { + log.debug("renderer value " + value); + } + UIHelper.updateListSelection(list, value); + + renderFromDelegate(table, value, isSelected, hasFocus, row, column); + + return list; + } + + /** + * Effectuer le rendu visual à partir du renderer delegate. + * + * @param table la table a afficher + * @param value la valeur à afficher + * @param isSelected {@code true} si la cellule est sélectionnée + * @param hasFocus {@code true} si la cellule a le focus + * @param row la ligne sélectionnée + * @param column la colonne sélectionnée + */ + protected void renderFromDelegate(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + // obtain visual render from delegate + JComponent rendererComponent = (JComponent) delegateRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + list.setBackground(rendererComponent.getBackground()); + list.setFont(rendererComponent.getFont()); + list.setBorder(rendererComponent.getBorder()); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/renderers/JListCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/AdminListSelectorHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/AdminListSelectorHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/AdminListSelectorHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,79 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.widget; + +import jaxx.runtime.swing.ListSelectorHandler; +import jaxx.runtime.swing.ListSelectorUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiEntitiesListener; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.ArrayList; +import java.util.List; + +public abstract class AdminListSelectorHandler<B extends BusinessEntity> extends ListSelectorHandler<B> implements VradiEntitiesListener<B> { + + /** Logger. */ + static private final Log log = LogFactory.getLog(AdminListSelectorHandler.class); + + protected List<String> idsInCombo = new ArrayList<String>(); + + protected List<String> idsInList = new ArrayList<String>(); + + protected AdminListSelectorHandler(ListSelectorUI<B> listSelector) { + super(listSelector); + } + + /** + * Initialize the component. + * + * @param toCombo datas to set in combo + * @param toList datas to set in list + */ + @Override + public void init(List<B> toCombo, List<B> toList) { + + idsInCombo = extractId(toCombo); + idsInList = extractId(toList); + + super.init(toCombo, toList); + } + + protected List<String> extractId(List<B> beans) { + + List<String> ids = new ArrayList<String>(); + if (beans != null) { + for (BusinessEntity bean : beans) { + ids.add(bean.getWikittyId()); + } + } + return ids; + } + + protected boolean isLoadedId(String wikittyId) { + return idsInCombo.contains(wikittyId) || idsInList.contains(wikittyId); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/AdminListSelectorHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/FieldSelectUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/FieldSelectUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/FieldSelectUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,148 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='requestSelectUI'> + + <style source='../../VradiMainUI.css'/> + + <import> + javax.swing.JPanel + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + org.chorem.vradi.entities.FieldTypeEnum + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.ui.admin.models.FieldSelectModel + jaxx.runtime.context.JAXXInitialContext + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + </import> + + <!-- bean property --> + <FieldSelectModel id='bean'/> + + <Boolean id='modified' javaBean='false'/> + + <Boolean id='infogene' javaBean='false'/> + + <!-- validators --> + <BeanValidator id='validator' + bean='bean' + beanClass='org.chorem.vradi.ui.admin.models.FieldSelectModel'> + <field name="nameValue" component="nameField"/> + <field name="descValue" component="descField"/> + <field name="type" component="clazzCombo"/> + </BeanValidator> + + <script><![CDATA[ + +protected JPanel contentPane; + +public void updateBean(FieldSelectModel model) { + bean.update(model); +} + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public void setContentPane(JPanel contentPane){ + this.contentPane = contentPane; +} + +void $afterCompleteSetup() { + getContextValue(SwingValidatorMessageTableModel.class,"errorTable").registerValidator(validator); +} + ]]></script> + + <row fill='horizontal' weighty='0' weightx='0'> + <cell fill='horizontal'> + <JLabel text='vradi.adminField.name'/> + </cell> + <cell fill='horizontal'> + <JTextField id='nameField' + text='{bean.getNameValue()}' + enabled='{!isInfogene()}' + onKeyReleased='bean.setNameValue(nameField.getText().trim()); + setModified(true);'/> + </cell> + <cell fill='horizontal'> + <JLabel text='vradi.adminField.lbl'/> + </cell> + <cell fill='horizontal'> + <JTextField id='traductionField' + text='{bean.getTraduction()}' + enabled='{!isInfogene()}' + onKeyReleased='bean.setTraduction(traductionField.getText().trim()); + setModified(true);'/> + </cell> + <cell fill='horizontal'> + <JLabel text='vradi.adminField.desc'/> + </cell> + <cell fill='horizontal'> + <JTextField id='descField' + text='{bean.getDescValue()}' + enabled='{!isInfogene()}' + onKeyReleased='bean.setDescValue(descField.getText()); + setModified(true);'/> + </cell> + <cell fill='horizontal'> + <JLabel text='vradi.adminField.type'/> + </cell> + <cell fill='horizontal'> + <JComboBox id='clazzCombo' + model='{getHandler().getTypesModel()}' + selectedItem='{bean.getType()}' + enabled='{!isInfogene()}' + renderer='{UIHelper.getTranslationListCellRenderer()}' + onActionPerformed='bean.setType((FieldTypeEnum) clazzCombo.getSelectedItem()); + setModified(true);'/> + </cell> + <cell fill='horizontal'> + <JButton id='up' actionIcon='arrowUp' + visible='{!isInfogene()}' + onActionPerformed='bean.setUpOrDown(true); + log.debug(bean.getNameValue() + " : " + bean.isUpOrDown()); + setModified(null);'/> + </cell> + <cell fill='horizontal'> + <JButton id='down' actionIcon='arrowDown' + visible='{!isInfogene()}' + onActionPerformed='bean.setUpOrDown(false); + log.debug(bean.getNameValue() + " : " + bean.isUpOrDown()); + setModified(null);'/> + <!--/VBox--> + </cell> + <cell fill='horizontal'> + <JButton id='remove' + visible='{!isInfogene()}' + actionIcon='delete' + onActionPerformed='bean.setUpOrDown(null); + setModified(null);'/> + </cell> + </row> + +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/FieldSelectUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/GroupListSelectorHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/GroupListSelectorHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/GroupListSelectorHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,148 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.widget; + +import jaxx.runtime.swing.ListSelectorUI; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiService; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.List; +import java.util.Set; + +public class GroupListSelectorHandler extends AdminListSelectorHandler<Group> { + + protected User bean; + + protected VradiEntitiesListener<User> userVradiEntitiesListener; + + public GroupListSelectorHandler(ListSelectorUI<Group> listSelector) { + super(listSelector); + + VradiContext.get().getVradiNotifier().addVradiListener(Group.class, this); + userVradiEntitiesListener = new VradiEntitiesListener<User>() { + + @Override + public void entitiesAdded(Set<User> added) { + if (added.contains(bean)) { + updateAll(); + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(User.class, userVradiEntitiesListener); + } + + public User getBean() { + return bean; + } + + public void setBean(User bean) { + this.bean = bean; + } + + protected void updateAll() { + String wikittyId = bean.getWikittyId(); + bean = VradiService.getWikittyProxy().restore(User.class, bean.getWikittyId()); + updateCombo(wikittyId); + updateList(wikittyId); + } + + protected void updateList(String wikittyId) { + + // Fill list with groups + List<Group> groups = VradiService.getVradiDataService().findUserGroups(wikittyId); + setListDatas(groups); + + idsInList.clear(); + idsInList.addAll(VradiHelper.extractIds(groups)); + } + + protected void updateCombo(String wikittyId) { + + // Fill list with groups + VradiDataService vradiDataService = VradiService.getVradiDataService(); + List<Group> allGroups = vradiDataService.findAllGroups(); + List<Group> groups = vradiDataService.findUserGroups(wikittyId); + allGroups.removeAll(groups); + setComboDatas(allGroups); + + idsInCombo.clear(); + idsInCombo.addAll(VradiHelper.extractIds(allGroups)); + } + + @Override + public void entitiesAdded(Set<Group> groupAdded) { + + if (bean == null) { + return; + } + + for (Group added : groupAdded) { + String wikittyId = added.getWikittyId(); + if (added.getUser() != null && added.getUser().contains(bean.getWikittyId())) { + if (!idsInList.contains(wikittyId)) { + updateAll(); + } + } else { + // Remove if is in list + if (idsInList.contains(wikittyId)) { + updateAll(); + } else if (!idsInCombo.contains(wikittyId)) { + idsInCombo.add(wikittyId); + WikittyProxy proxy = VradiService.getWikittyProxy(); + setComboDatas(proxy.restore(Group.class, idsInCombo)); + } + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + + for (String wikittyId : removed) { + WikittyProxy proxy = VradiService.getWikittyProxy(); + if (idsInCombo.contains(wikittyId)) { + idsInCombo.remove(wikittyId); + List<Group> groups = proxy.restore(Group.class, idsInCombo); + setComboDatas(groups); + } + if (idsInList.contains(wikittyId)) { + idsInList.remove(wikittyId); + List<Group> groups = proxy.restore(Group.class, idsInList); + setListDatas(groups); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/GroupListSelectorHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/UserListSelectorHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/UserListSelectorHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/UserListSelectorHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,174 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.admin.widget; + +import jaxx.runtime.swing.ListSelectorUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiService; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +public class UserListSelectorHandler extends AdminListSelectorHandler<User> { + + + static private final Log log = LogFactory.getLog(UserListSelectorHandler.class); + + protected Group bean; + + protected VradiEntitiesListener<Group> groupVradiEntitiesListener; + + public UserListSelectorHandler(ListSelectorUI<User> listSelector) { + super(listSelector); + + VradiContext.get().getVradiNotifier().addVradiListener(User.class, this); + groupVradiEntitiesListener = new VradiEntitiesListener<Group>() { + + @Override + public void entitiesAdded(Set<Group> added) { + if (log.isDebugEnabled()) { + log.debug("[UserListSelectorHandler] group added"); + } + if (added.contains(bean)) { + updateAll(); + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + if (log.isDebugEnabled()) { + log.debug("[UserListSelectorHandler] group removed"); + } + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(Group.class, groupVradiEntitiesListener); + } + + public Group getBean() { + return bean; + } + + public void setBean(Group bean) { + this.bean = bean; + } + + protected void updateAll() { + String wikittyId = bean.getWikittyId(); + + // Update bean + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + bean = wikittyProxy.restore(Group.class, wikittyId); + + List<User> users = updateList(wikittyProxy); + updateCombo(users); + } + + protected List<User> updateList(WikittyProxy wikittyProxy) { + + // Fill list with users + Set<String> usersIds = bean.getUser(); + if (usersIds != null) { + List<User> users = wikittyProxy.restore(User.class, new ArrayList<String>(usersIds)); + setListDatas(users); + + idsInList.clear(); + idsInList.addAll(VradiHelper.extractIds(users)); + return users; + } + return Collections.EMPTY_LIST; + } + + protected void updateCombo(List<User> userInList) { + + // Fill list with groups + VradiDataService vradiDataService = VradiService.getVradiDataService(); + List<User> allUsers = vradiDataService.findAllUsers(); + allUsers.removeAll(userInList); + setComboDatas(allUsers); + + idsInCombo.clear(); + idsInCombo.addAll(VradiHelper.extractIds(allUsers)); + } + + @Override + public void entitiesAdded(Set<User> usersAdded) { + if (log.isDebugEnabled()) { + log.debug("[UserListSelectorHandler] user added"); + } + + if (bean == null) { + return; + } + + for (User added : usersAdded) { + String wikittyId = added.getWikittyId(); + if (bean.getUser() != null && bean.getUser().contains(wikittyId)) { + if (!idsInList.contains(wikittyId)) { + updateAll(); + } + } else { + // Remove if is in list + if (idsInList.contains(wikittyId)) { + updateAll(); + } else if (!idsInCombo.contains(wikittyId)) { + idsInCombo.add(wikittyId); + WikittyProxy proxy = VradiService.getWikittyProxy(); + setComboDatas(proxy.restore(User.class, idsInCombo)); + } + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + if (log.isDebugEnabled()) { + log.info("[UserListSelectorHandler] user removed"); + } + + for (String wikittyId : removed) { + WikittyProxy proxy = VradiService.getWikittyProxy(); + if (idsInCombo.contains(wikittyId)) { + idsInCombo.remove(wikittyId); + List<User> users = proxy.restore(User.class, idsInCombo); + setComboDatas(users); + } + if (idsInList.contains(wikittyId)) { + idsInList.remove(wikittyId); + List<User> users = proxy.restore(User.class, idsInList); + setListDatas(users); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/admin/widget/UserListSelectorHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailContentUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailContentUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailContentUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,64 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='content' abstract='true' layout='{new BorderLayout()}'> + + <import> + org.chorem.vradi.VradiContext + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper + org.chorem.vradi.ui.helpers.UIHelper + org.chorem.vradi.ui.tree.VradiTreeNode + </import> + + <script><![CDATA[ + +protected EmailNavigationTreeHelper helper; + +public EmailNavigationTreeHelper getHelper() { + if (helper != null) { + return helper; + } + EmailNavigationTreeHelper helper = getContextValue(EmailNavigationTreeHelper.class); + if (helper != null) { + return helper; + } + return getParentContainer(EmailPopupUI.class).helper; +} + +protected EmailHandler getHandler() { + return UIHelper.getHandler(this, EmailHandler.class); +} +protected AdminHandler getAdminHandler() { + return UIHelper.getHandler(this, AdminHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public abstract void openUI(VradiTreeNode node); + ]]> + </script> +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailContentUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,1225 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.CardLayout2; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.email.helpers.EmailBeanConstant; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper; +import org.chorem.vradi.ui.email.helpers.SendingViewManager; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.OfferListHandler; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.task.AbstractProgressBarUI; +import org.chorem.vradi.ui.task.VradiTask; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; +import org.nuiton.util.FileUtil; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.WikittyProxy; + +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.filechooser.FileFilter; +import javax.swing.tree.TreePath; +import java.awt.Component; +import java.awt.Cursor; +import java.io.File; +import java.lang.reflect.Constructor; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import static org.chorem.vradi.VradiConstants.SessionStatus; +import static org.chorem.vradi.VradiContext.EMAIL_UI_ENTRY_DEF; +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * Handler de l'UI de gestion des email. + * + * @author morin + */ +public class EmailHandler { + + static private final Log log = LogFactory.getLog(EmailHandler.class); + + public EmailPopupUI init(JAXXContext rootContext) { + EmailPopupUI ui = EMAIL_UI_ENTRY_DEF + .getContextValue(rootContext); + + if (ui == null) { + JAXXInitialContext context = new JAXXInitialContext() + .add(rootContext).add(this); + + ui = new EmailPopupUI(context); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(ui); + + EMAIL_UI_ENTRY_DEF.setContextValue(rootContext, ui); + } + return ui; + } + + public EmailPopupUI getUI(JAXXContext context) { + if (context instanceof EmailPopupUI) { + return (EmailPopupUI) context; + } + EmailPopupUI ui = EMAIL_UI_ENTRY_DEF + .getContextValue(context); + return ui; + } + + public SessionViewUI getSessionsListUI(JAXXContext context) { + if (context instanceof SessionViewUI) { + return (SessionViewUI) context; + } + return context.getContextValue(SessionViewUI.class); + } + + public SendingViewUI getSessionViewUI(JAXXContext context) { + if (context instanceof SendingViewUI) { + return (SendingViewUI) context; + } + return context.getContextValue(SendingViewUI.class); + } + + public VradiStorageService getStorageService() { + return VradiService.getVradiStorageService(); + } + + public VradiDataService getDataService() { + return VradiService.getVradiDataService(); + } + + public WikittyProxy getProxy() { + return VradiService.getWikittyProxy(); + } + + protected void close(JAXXContext context) { + EmailPopupUI ui = getUI(context); + UIHelper.saveComponentDispositionConfig(); + ui.setVisible(false); + ui.dispose(); + } + + public List<Session> getSessions(Date date) { + if (log.isDebugEnabled()) { + log.debug("getSessions for date : " + date); + } + List<Session> sessions = null; + try { + sessions = getDataService().getSessions(date); + } catch (VradiException eee) { + log.error(eee); + ErrorDialogUI.showError(eee); + } + + return sessions; + } + + /** + * Creer une nouvelle session. + * + * @param ui email ui + */ + public void createNewSession(EmailPopupUI ui) { + + try { + Session session = getStorageService().createNewSession(); + EmailNavigationTreeHelper helper = ui.getHelper(); + VradiTreeNode node = helper.createSessionNode(session); + helper.selectNode(node); + } catch (VradiException ex) { + if (log.isErrorEnabled()) { + log.error("Can't create new session", ex); + } + JOptionPane.showMessageDialog(ui, _("Can't create new session for reason : %s", ex.getMessage()), _("Can't create new session"), JOptionPane.ERROR_MESSAGE); + } + } + + /** + * Lien les formulaires non lié sur la session selectionnée. + * Seulement pour une session active + * + * @param ui ui + */ + public void bindEmailsWithForms(final EmailPopupUI ui) { + + VradiTask<Void> task = new VradiTask<Void>(ui) { + @Override + public Void doAction() throws Exception { + + try { + Session selectedSession = ui.getHelper().getSelectedActiveSession(); + if (!SessionStatus.isActive(selectedSession)) { + + JOptionPane.showMessageDialog(ui, + _("vradi.error.session.bindNonActiveSession"), + _("vradi.error.session.bindNonActiveSession.title"), + JOptionPane.ERROR_MESSAGE); + + return null; + } + + getStorageService().bindForms(selectedSession); + + } catch (WikittyException eee) { + if (log.isErrorEnabled()) { + log.error("An exception occured while binding form", eee); + } + JOptionPane.showMessageDialog(ui, + _("vradi.binding.forms.concurrence.message")); + } + return null; + } + }; + + task.execute(); + } + + /** + * Open UI depending on node type. + * + * @param context JaxxContext + * @param contentLayout Layout of content + * @param content in layout + * @param node to display + */ + protected void openUI(JAXXContext context, CardLayout2 contentLayout, JPanel content, VradiTreeNode node) { + + // Get node type + Class<?> editType = node.getInternalClass(); + Class<? extends EmailContentUI> uiClass = EmailBeanConstant.getUIClass(editType); + + if (uiClass == null) { + // show none ui + contentLayout.show(content, EmailPopupUI.NONE); + return; + } + + // Verify if instance is existing + EmailContentUI ui = UIHelper.getContentIfExist(contentLayout, content, uiClass); + + // Get layout identifier + String contentName = editType.getName(); + + if (ui == null) { + try { + // Get constructor + Constructor<? extends EmailContentUI> constructor = + uiClass.getConstructor(JAXXContext.class); + + // Invoke instance creation + ui = constructor.newInstance(context); + + // Open UI + ui.openUI(node); + } catch (Exception eee) { + log.error(eee); + ErrorDialogUI.showError(eee); + } + + // Add to content panel + content.add(ui, contentName); + } + + // show ui + contentLayout.show(content, contentName); + } + + public void displaySession(JAXXContext context, EmailNavigationTreeHelper helper, VradiTreeNode node) { + SendingViewUI ui = getSessionViewUI(context); + + // Get datas + Sending sending = helper.getSendingToDisplay(node); + + // Get session + Session session = helper.getSelectedActiveSession(); + + // Open ui + SendingViewManager manager = SendingViewManager.getInstance(); + context.setContextValue(manager); + + manager.openUI(ui, session, sending); + if (log.isDebugEnabled()) { + log.debug("Sending displayed : " + sending); + } + } + + public boolean askToRemoveUserForm(JPanel ui, String userName, String formAsString) { + + int yes = JOptionPane.showConfirmDialog( + ui, + _("vradi.email.confirmRemoveUserForms", formAsString, userName), + _("vradi.email.confirmRemoveUserFormsTitle"), + JOptionPane.YES_NO_OPTION); + + return yes == JOptionPane.YES_OPTION; + } + + public boolean askToRemoveAllForm(JPanel ui, String formAsString) { + + int yes = JOptionPane.showConfirmDialog( + ui, + _("vradi.email.confirmRemoveForms", formAsString), + _("vradi.email.confirmRemoveFormsTitle"), + JOptionPane.YES_NO_OPTION); + + return yes == JOptionPane.YES_OPTION; + } + + public void revertDeletion(SendingViewUI ui, final Sending sending, final List<String> formsIdsToUpdate) { + + int yes = JOptionPane.showConfirmDialog( + ui, + _("vradi.email.confirmRevertFormDeletion", EmailDataHelper.convertFormsIdsToString(formsIdsToUpdate)), + _("vradi.email.confirmRevertFormDeletionTitle"), + JOptionPane.YES_NO_OPTION); + + if (yes == JOptionPane.YES_OPTION) { + VradiTask<Void> revertSendingTask = new VradiTask<Void>(ui) { + + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().revertDeletion(sending.getWikittyId(), formsIdsToUpdate); + return null; + } + }; + revertSendingTask.execute(); + } + } + + public void revertUserDeletion(QueryMakerViewUI<?> ui, Session session, String formId, Object[] selectedValues) { + if (askUserRevert(ui, EmailDataHelper.convertFormToString(formId), EmailDataHelper.convertObjectBeanToString(Arrays.asList(selectedValues), User.class))) { + for (Object o : selectedValues) { + revertUserDeletion(ui, session, (User) o, formId, false); + } + } + } + + public void revertUserDeletion(QueryMakerViewUI<?> ui, Session session, User user, String formToRevert) { + revertUserDeletion(ui, session, user, formToRevert, true); + } + + protected void revertUserDeletion(QueryMakerViewUI<?> ui, final Session session, final User user, final String formToRevert, boolean ask) { + if (!ask || askUserRevert(ui, EmailDataHelper.convertFormToString(formToRevert), VradiHelper.getEntityName(user))) { + VradiTask<Void> revertSendingTask = new VradiTask<Void>(ui) { + + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().revertUserDeletion(session.getWikittyId(), user.getWikittyId(), formToRevert); + return null; + } + }; + revertSendingTask.execute(); + } + } + + public void revertGroupDeletion(QueryMakerViewUI<?> ui, Session session, String formId, Object[] selectedValues) { + if (askGroupRevert(ui, EmailDataHelper.convertFormToString(formId), EmailDataHelper.convertObjectBeanToString(Arrays.asList(selectedValues), Group.class))) { + for (Object o : selectedValues) { + revertGroupDeletion(ui, session, (Group) o, formId, false); + } + } + } + + public void revertGroupDeletion(QueryMakerViewUI<?> ui, Session session, Group group, String formToRevert) { + revertGroupDeletion(ui, session, group, formToRevert, true); + } + + protected void revertGroupDeletion(QueryMakerViewUI<?> ui, final Session session, final Group group, final String formToRevert, boolean ask) { + if (!ask || askGroupRevert(ui, EmailDataHelper.convertFormToString(formToRevert), VradiHelper.getEntityName(group))) { + VradiTask<Void> revertSendingTask = new VradiTask<Void>(ui) { + + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().revertGroupDeletion(session.getWikittyId(), group.getWikittyId(), formToRevert); + return null; + } + }; + revertSendingTask.execute(); + } + } + + protected boolean askUserRevert(JPanel ui, String formAsString, String userAsString) { + + int yes = JOptionPane.showConfirmDialog( + ui, + _("vradi.email.confirmRevertUserFormDeletion", formAsString, + userAsString), + _("vradi.email.confirmRevertUserFormDeletionTitle"), + JOptionPane.YES_NO_OPTION); + + return yes == JOptionPane.YES_OPTION; + } + + protected boolean askGroupRevert(JPanel ui, String formAsString, String userAsString) { + + int yes = JOptionPane.showConfirmDialog( + ui, + _("vradi.email.confirmRevertGroupFormDeletion", formAsString, + userAsString), + _("vradi.email.confirmRevertGroupFormDeletionTitle"), + JOptionPane.YES_NO_OPTION); + + return yes == JOptionPane.YES_OPTION; + } + + public void selectOffer(JAXXContext context, JTable listTable) { + OfferListTableModel tableModel = (OfferListTableModel) listTable.getModel(); + int selectedRow = listTable.getSelectedRow(); + + if (selectedRow >= 0 && selectedRow < tableModel.getRowCount()) { + selectedRow = listTable.convertRowIndexToModel(selectedRow); + + FormPagedResult formPageDTO = tableModel.getFormPagedResult(); + List<String> formsToShow = formPageDTO.getFormsIdsToShow(); + + String id = formsToShow.get(selectedRow); + if (id != null) { + UIHelper.getHandler(context, OfferListHandler.class).addEditPane(context, id); + } + } + } + + public void displayForm(JAXXContext context, VradiTreeNode node) { + + Session session = EmailNavigationTreeHelper.getParentSession(node); + + if (session != null) { + context.setContextValue(session); + } + + String id = node.getId(); + + Form form = getProxy().restore(Form.class, id); + + context.setContextValue(form); + } + + public void addAllUserSending(QueryMakerViewUI ui, Session session, String formId, List values) { + if (askToAddUsers(ui, EmailDataHelper.convertFormToString(formId), EmailDataHelper.convertObjectBeanToString(values, User.class))) { + for (Object selected : values) { + addUserSending(ui, session, formId, selected, false); + } + } + } + + public void addAllUserSending(QueryMakerViewUI ui, Session session, List<String> formsIds, List values) { + + if (askToAddUsers(ui, EmailDataHelper.convertFormsIdsToString(formsIds), EmailDataHelper.convertObjectBeanToString(values, User.class))) { + for (Object selected : values) { + addUserSending(ui, session, formsIds, selected, false); + } + } + } + + public void addUserSending( + JAXXContext context, + Session session, + List<String> formsId, + Object selected) { + + addUserSending( + context, + session, + formsId, + selected, + true); + } + + protected void addUserSending( + JAXXContext context, + final Session session, + final List<String> formsIds, + final Object selected, + boolean ask) { + + User user = (User) selected; + if (!ask || askToAddUsers(context, EmailDataHelper.convertFormsIdsToString(formsIds), VradiHelper.getEntityName(user))) { + + VradiTask<Void> createSendingTask = new VradiTask<Void>(context) { + + @Override + public Void doAction() throws Exception { + // Create sendings + getStorageService().createSending(session.getWikittyId(), (User) selected, formsIds); + return null; + } + }; + + createSendingTask.execute(); + } + } + + public void addUserSending( + JAXXContext context, + Session session, + String formId, + Object selected) { + + addUserSending( + context, + session, + formId, + selected, true); + } + + protected void addUserSending( + JAXXContext context, + Session session, + String formId, + Object selected, boolean ask) { + + User user = (User) selected; + if (!ask || askToAddUsers(context, EmailDataHelper.convertFormToString(formId), VradiHelper.getEntityName(user))) { + List<String> formsIds = new ArrayList<String>(); + formsIds.add(formId); + addUserSending(context, session, formsIds, user, false); + } + } + + protected boolean askToAddUsers(JAXXContext context, String formAsString, String userAsString) { + + if (StringUtils.isEmpty(userAsString)) { + return true; + } + int yes = JOptionPane.showConfirmDialog( + (Component) context, + _("vradi.email.confirmAddUser", formAsString, + userAsString), + _("vradi.email.confirmAddTitle"), + JOptionPane.YES_NO_OPTION); + + return yes == JOptionPane.YES_OPTION; + } + + public void removeUserSending( + JAXXContext context, + Session session, + List<String> formsIds, + Object[] selecteds) { + removeUserSending(context, session, formsIds, selecteds, true); + } + + public void removeUserSending( + JAXXContext context, + final Session session, + final List<String> formsIds, + final Object[] selecteds, boolean ask) { + + int yes = JOptionPane.YES_OPTION; + + if (ask) { + yes = JOptionPane.showConfirmDialog( + (Component) context, + _("vradi.email.confirmDelete", EmailDataHelper.convertFormsIdsToString(formsIds)), + _("vradi.email.confirmDeleteTitle"), + JOptionPane.YES_NO_OPTION); + } + + if (yes == JOptionPane.YES_OPTION) { + + VradiTask<Void> removeSendingTask = new VradiTask<Void>(context) { + + @Override + public Void doAction() throws Exception { + for (Object selected : selecteds) { + getStorageService().removeSending(session.getWikittyId(), formsIds, (User) selected); + } + return null; + } + }; + + removeSendingTask.execute(); + } + } + + @SuppressWarnings({"unchecked"}) + public void removeUserSending( + JAXXContext context, + Session session, + String formId, + Object[] selecteds) { + + removeUserSending(context, session, formId, selecteds, true); + } + + @SuppressWarnings({"unchecked"}) + protected void removeUserSending( + JAXXContext context, + Session session, + String formId, + Object[] selecteds, boolean ask) { + + List<String> formsIds = new ArrayList<String>(); + formsIds.add(formId); + + removeUserSending(context, session, formsIds, selecteds, ask); + } + + public void addAllGroupSending(JAXXContext context, Session session, String formId, List values) { + if (askToAddGroups(context, EmailDataHelper.convertFormToString(formId), EmailDataHelper.convertObjectBeanToString(values, Group.class))) { + for (Object selected : values) { + addGroupSending(context, session, formId, selected, false); + } + } + } + + public void addAllGroupSending(JAXXContext context, Session session, List<String> beanList, List values) { + + if (askToAddGroups(context, EmailDataHelper.convertFormsIdsToString(beanList), EmailDataHelper.convertObjectBeanToString(values, Group.class))) { + for (Object selected : values) { + addGroupSending(context, session, beanList, selected, false); + } + } + } + + protected void addGroupSending( + JAXXContext context, + Session session, + List<String> formsIds, + Object selected) { + + addGroupSending( + context, + session, + formsIds, + selected, + true); + } + + protected void addGroupSending( + JAXXContext context, + final Session session, + final List<String> formsIds, + Object selected, + boolean ask) { + + final Group group = (Group) selected; + if (!ask || askToAddGroups(context, EmailDataHelper.convertFormsIdsToString(formsIds), VradiHelper.getEntityName(group))) { + + VradiTask<Void> createSendingTask = new VradiTask<Void>(context) { + @Override + public Void doAction() throws Exception { + // Create sendings + getStorageService().createAllSending(session.getWikittyId(), group, formsIds); + + return null; + } + }; + + createSendingTask.execute(); + } + } + + public void addGroupSending( + JAXXContext context, + Session session, + String formId, + Object selected) { + + addGroupSending(context, session, formId, selected, true); + } + + public void addGroupSending( + JAXXContext context, + Session session, + String formId, + Object selected, + boolean ask) { + + List<String> formsIds = new ArrayList<String>(); + formsIds.add(formId); + + addGroupSending(context, session, formsIds, selected, ask); + } + + protected boolean askToAddGroups(JAXXContext context, String formAsString, String groupAsString) { + + if (StringUtils.isEmpty(groupAsString)) { + return true; + } + int yes = JOptionPane.showConfirmDialog( + (Component) context, + _("vradi.email.confirmAddGroup", formAsString, + groupAsString), + _("vradi.email.confirmAddTitle"), + JOptionPane.YES_NO_OPTION); + return yes == JOptionPane.YES_OPTION; + } + + public void removeGroupSending( + JAXXContext context, + final Session session, + final List<String> formsIds, + final Object[] selecteds) { + + int yes = JOptionPane.showConfirmDialog( + (Component) context, + _("vradi.email.confirmDelete", EmailDataHelper.convertFormsIdsToString(formsIds)), + _("vradi.email.confirmDeleteTitle"), + JOptionPane.YES_NO_OPTION); + + if (yes == JOptionPane.YES_OPTION) { + + VradiTask<Void> removeAllSendingTask = new VradiTask<Void>(context) { + @Override + public Void doAction() throws Exception { + for (Object selected : selecteds) { + getStorageService().removeAllSending(session.getWikittyId(), formsIds, (Group) selected); + } + return null; + } + }; + + removeAllSendingTask.execute(); + } + } + + @SuppressWarnings({"unchecked"}) + public void removeGroupSending( + JAXXContext context, + Session session, + String formId, + Object[] selecteds) { + + List<String> formsIds = new ArrayList<String>(); + formsIds.add(formId); + removeGroupSending(context, session, formsIds, selecteds); + } + + protected void reloadTree(EmailPopupUI ui) { + + // Refresh + EmailNavigationTreeHelper helper = ui.getHelper(); + + // Get selected path + TreePath[] selectionPaths = helper.getSelectionModel().getSelectionPaths(); + + // Update datas + ui.updateTree(); + + // Select + if (selectionPaths != null) { + helper.getSelectionModel().setSelectionPaths(selectionPaths); + } + } + +// public Map<VradiClientDTO, Set<String>> getAllClientsAndUsers() { +// SortedMap<VradiClientDTO, Set<String>> clientsAndUsers = new TreeMap<VradiClientDTO, Set<String>>(VradiComparators.CLIENT_COMPARATOR); +// +// // map client id = user ids +// Map<String, Set<String>> clientsIdAndUsers = new TreeMap<String, Set<String>>(); +// +// List<VradiClientDTO> clients = getAllClients(); +// List<User> users = VradiContext.getUsersInEntryDef(); +// +// for (VradiClientDTO client : clients) { +// Set<String> ids = new HashSet<String>(); +// clientsAndUsers.put(client, ids); +// clientsIdAndUsers.put(client.getWikittyId(), ids); +// } +// +// for (User user : users) { +// clientsIdAndUsers.get(user.getClient()).add(user.getWikittyId()); +// } +// +// return clientsAndUsers; +// } + + /** + * Called to send only one simple sending. + * + * @param ui parent ui + * @param sending sending to send + */ + public void sendSending(SendingViewUI ui, final Sending sending) { + Object[] options = {_("vradi.email.confirmSendSending.optionYes"), + _("vradi.email.confirmSendSending.optionNo"), + _("vradi.email.confirmSendSending.optionOtherMail")}; + + int i = JOptionPane.showOptionDialog(ui, + _("vradi.email.confirmSendSending", getUserName(sending)), + _("vradi.email.confirmSendSendingTitle"), + JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, + null, + options, + options[2]); + + String email = null; + + if (i == JOptionPane.CANCEL_OPTION) { + + // Ask email to send + email = JOptionPane.showInputDialog( + ui, + _("vradi.email.confirmSendSending.askMail"), + _("vradi.email.confirmSendSending.askMailTitle"), + JOptionPane.PLAIN_MESSAGE); + + i = JOptionPane.OK_OPTION; + } + + if (i == JOptionPane.OK_OPTION) { + + // Get session paragraph + Session session = getSessionBySending(sending.getWikittyId()); + + Set<String> filesNames = session.getFiles(); + final List<File> filesToAttach = new ArrayList<File>(); + if (filesNames != null) { + for (String fileName : filesNames) { + File file = null; + try { + file = VradiService.getFileService().downloadSessionAttachment(fileName, session.getWikittyId()); + } catch (VradiException eee) { + log.error("Failed to download attachement : " + fileName, eee); + ErrorDialogUI.showError(eee); + + } + filesToAttach.add(file); + } + } + + final String sessionParagraph = session.getParagraph(); + + final String finalEmail = email; + final EmailPopupUI finalUI = ui.getParentContainer(EmailPopupUI.class); + VradiTask<Void> sendSendingTask = new VradiTask<Void>(ui, "vradi.email.sendSending") { + + @Override + public Void doAction() throws VradiException { + try { + String sendingLogs = getStorageService().sendMessage(sending.getWikittyId(), sessionParagraph, finalEmail, filesToAttach); + + if (sendingLogs != null && !sendingLogs.isEmpty()) { + JOptionPane.showMessageDialog(finalUI, _("vradi.error.sending.sendDialogError", sendingLogs), + _("vradi.error.sending.sendDialogError.title"), + JOptionPane.ERROR_MESSAGE); + } + } catch (VradiException eee) { + JOptionPane.showMessageDialog(finalUI, _("vradi.email.sendSending.sendError", + eee.getMessage()), _("vradi.email.sendSession.error"), + JOptionPane.ERROR_MESSAGE); + + // Set session status to error +// updateSendingStatus(sendingResult, VradiConstants.SendingStatus.ERROR); + } + return null; + } + + @Override + public void doWhenError(Exception eee) { +// updateSendingStatus(sending, VradiConstants.SendingStatus.ERROR); + } + }; + sendSendingTask.execute(); + } + } + + /** + * Called to send a full session. + * <p/> + * Don't call without VradiSessionDTO selection ! + * + * @param ui parent ui + * @return {@code true} if task has been + */ + public boolean send(final EmailPopupUI ui) { + final Session session = ui.getHelper().getSelectedActiveSession(); + + // ask user for confirmation + int confirm = JOptionPane.showConfirmDialog(ui, + _("vradi.email.confirmSendSession"), + _("vradi.email.confirmSendSessionTitle"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (confirm != JOptionPane.YES_OPTION) { + return false; + } + + // Check if emails and templates exists + if (!checkAllSending(ui, session)) { + return false; + } + + // Display progess bar with cancel button + final AbstractProgressBarUI pb = new AbstractProgressBarUI((JAXXContext) ui) { + /** serialVersionUID. */ + private static final long serialVersionUID = 5926558779822425487L; + + @Override + public void cancel() { + try { + VradiService.getVradiStorageService().stopSentMail(session); + dispose(); + } catch (VradiException eee) { + log.info("Cant stop sending emails : ", eee); + ErrorDialogUI.showError(eee); + } + ui.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + }; + + if (log.isInfoEnabled()) { + SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); + log.info("Sending session : " + session.getNum() + " - " + + format.format(session.getSessionDate()) + " status : " + + SessionStatus.getStatus(session.getStatus()).getDescription()); + } + + + // premiere tache de génération des PDF + VradiTask<Boolean> pdfGenerationAndSendingTask = new VradiTask<Boolean>( + ui, pb, n_("vradi.email.generation")) { + + @Override + public Boolean doAction() throws Exception { + try { + + VradiService.getVradiStorageService().generatePDFForSession( + session.getWikittyId()); + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Error generating pdf : ", eee); + } + doWhenError(eee); + ErrorDialogUI.showError(eee); + return false; + } + return true; + } + + @Override + public void doWhenDone() throws Exception { + + // If pdf generation is successfully done + Boolean result = get(); + if (result != null && result) { + + if (log.isInfoEnabled()) { + log.info("Start sending mails"); + } + + VradiTask<Void> sentTask = new VradiTask<Void>(ui, pb, n_("vradi.email.sendSession")) { + + @Override + public Void doAction() throws Exception { + try { + String sessionLogs = VradiService.getVradiStorageService().sendMessages(session.getWikittyId()); + + if (!sessionLogs.isEmpty()) { + JOptionPane.showMessageDialog(ui, + _("vradi.error.session.sendDialogError", sessionLogs), + _("vradi.error.session.sendDialogError.title"), + JOptionPane.ERROR_MESSAGE); + } + } catch (VradiException eee) { + + log.error("Failed to send message : ", eee); + + JOptionPane.showMessageDialog(ui, _("vradi.email.sendSending.sendError", + eee.getMessage()), _("vradi.email.sendSession.error"), + JOptionPane.ERROR_MESSAGE); + + // Set session status to error +// updateSessionStatus(session, VradiConstants.SessionStatus.ERROR); + } + return null; + } + + + @Override + public void doWhenError(Exception eee) { +// updateSessionStatus(session, VradiConstants.SessionStatus.ERROR); + } + }; + + sentTask.execute(); + } + } + + @Override + public void doWhenError(Exception eee) { +// updateSessionStatus(session, VradiConstants.SessionStatus.ERROR); + } + }; + + // Executes task + pdfGenerationAndSendingTask.execute(); + + return true; + } + + protected boolean checkAllSending(EmailPopupUI ui, Session session) { + + for (Sending sending : EmailDataHelper.getAllSending(session)) { + + boolean emailEmpty = VradiService.getVradiDataService().checkUserEmail(sending); + + if (emailEmpty) { + User user = VradiService.getWikittyProxy().restore(User.class, sending.getUser()); + Client client = VradiService.getWikittyProxy().restore(Client.class, user.getClient()); + boolean abord = askAbordSending(ui, _("vradi.email.askUserEmailEmpty", user.getName(), client.getName())); + if (abord) { + + // Set to error status + updateSendingStatus(sending, VradiConstants.SendingStatus.ERROR); + + return false; + } + } + + // Check PDF generation + Set<String> formIds = SendingHelper.extractForms(VradiService.getWikittyProxy(), sending.getGroupForms()); + + // If forms are deleted, nothing to send + if (formIds == null) { + return true; + } + List<Form> forms = getProxy().restore(Form.class, new ArrayList<String>(formIds)); + + List<String> alreadyAskFormType = new ArrayList<String>(); + for (Form form : forms) { + + String extensionName = null; + for (String ext : form.getExtensionNames()) { + if (!ext.equals(Infogene.EXT_INFOGENE) + && !ext.equals(Form.EXT_FORM)) { + extensionName = ext; + break; + } + } + boolean isTemplateExist = false; + try { + isTemplateExist = VradiService.getVradiStorageService().checkTemplateExist(extensionName); + } catch (VradiException eee) { + log.error("Cant check if template exist : ", eee); + ErrorDialogUI.showError(eee); + } + + if (!isTemplateExist && !alreadyAskFormType.contains(extensionName)) { + boolean abord = askAbordSending(ui, _("vradi.email.askModelEmpty", extensionName)); + if (abord) { + + // Set to error status + updateSendingStatus(sending, VradiConstants.SendingStatus.ERROR); + + return false; + } + alreadyAskFormType.add(extensionName); + } + } + } + return true; + } + + protected boolean askAbordSending(EmailPopupUI ui, String msg) { + int i = JOptionPane.showConfirmDialog(ui, + msg, + _("vradi.email.askAbordSendingTitle"), + JOptionPane.YES_NO_OPTION); + + return i != JOptionPane.YES_OPTION; + } + + public Sending updateSendingStatus(Sending sending, VradiConstants.SendingStatus status) { + if (sending == null) { + return null; + } + + Sending sendingRestored = getProxy().restore(Sending.class, sending.getWikittyId()); + + sendingRestored.setStatus(status.getValue()); + + log.info("Saving sending " + sendingRestored.getWikittyId() + " with status " + status.getDescription()); + return getProxy().store(sendingRestored); + + } + +// public Session updateSessionStatus(Session session, VradiConstants.SessionStatus status) { +// if (session == null) { +// return null; +// } +// +// Session sessionRestored = getProxy().restore(Session.class, session.getWikittyId()); +// +// sessionRestored.setStatus(status.getValue()); +// sessionRestored.setSessionDate(new Date()); +// +// log.info("Saving session " + sessionRestored.getWikittyId() + " with status " + status.getDescription()); +// return getProxy().store(sessionRestored); +// +// } + + protected String getUserName(Sending sending) { + try { + String userId = sending.getUser(); + return getProxy().restore(User.class, userId).getName(); + } catch (Exception eee) { + log.error("Cant get sending user name : ", eee); + ErrorDialogUI.showError(eee); + } + return null; + } + + /** + * Close selected session in tree. + * <p/> + * Don't call it if no session is selected + * + * @param ui parent ui + */ + public void deleteSession(EmailPopupUI ui) { + Session session = ui.getHelper().getSessionSelected(); + if (session != null) { + + int i = JOptionPane.showConfirmDialog( + ui, _("vradi.email.confimCloseSession"), + _("vradi.email.confimCloseSession.titles"), + JOptionPane.YES_NO_OPTION); + + if (i == JOptionPane.YES_OPTION) { + try { + VradiService.getVradiStorageService().deleteSession(session.getWikittyId()); + } catch (VradiException eee) { + log.error("Cant delete session : ", eee); + ErrorDialogUI.showError(eee); + } + } + } + } + + public void updateReceptionProof(Sending sending, boolean isSelected) { + sending.setReceptionProof(isSelected); + getProxy().store(sending); + } + + public void updateParagraph(Sending sending, String text) { + sending.setParagraph(text); + getProxy().store(sending); + } + + protected Sending getSendingForUser(Session session, String userId) { + List<Sending> sendings = EmailDataHelper.getAllSending(session); + for (Sending sending : sendings) { + if (sending != null) { + if (sending.getUser().equals(userId)) { + return sending; + } + } + } + return null; + } + +// protected Sending getSendingForClient(Session session, String clientId) { +// List<Sending> sendings = getSendingList(session); +// for (Sending sending : sendings) { +// if (sending.getClient().equals(clientId)) { +// return sending; +// } +// } +// return null; +// } + + protected Session getSessionBySending(String sendingId) { + // Get all sending with form + return VradiService.getVradiDataService().getSessionBySending(sendingId); + } + + protected List<String> getStringAsList(String s) { + List<String> result = new ArrayList<String>(); + result.add(s); + return result; + } + + /** + * Add new attachement file. + * + * @param context + */ + public File addAttachmentFile(MultipleSelectionPane ui, Session session) { + if (log.isDebugEnabled()) { + log.debug("addAttachment(context)"); + } + File attachment = FileUtil.getFile(ui, new FileFilter[0]); + if (attachment != null) { + session.addFiles(attachment.getName()); + try { + VradiService.getFileService().uploadSessionAttachment(attachment, session.getWikittyId()); + } catch (VradiException eee) { + log.error("Failled to upload attachment : " + attachment.getName()); + ErrorDialogUI.showError(eee); + return null; + } + session = getProxy().store(session); + } + return attachment; + } + + /** + * Remove attachement. + * <p/> + * TODO EC20100609 really remove physical file too on server + * + * @param context parent ui + */ + public List<String> removeAttachmentFile(Session session, List<String> filesNamesToRemove) { + for (String fileNameToRemove : filesNamesToRemove) { + session.removeFiles(fileNameToRemove); + } + session = getProxy().store(session); + return filesNamesToRemove; + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailPopupUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailPopupUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailPopupUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,256 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JFrame id='emailPopupUI' + title='vradi.email.title' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='getHandler().close(this)'> + + <import> + java.util.Date + + javax.swing.DefaultComboBoxModel + javax.swing.JDialog + javax.swing.event.TreeSelectionListener + javax.swing.event.TreeSelectionEvent + + org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper + org.jdesktop.swingx.JXDatePicker + javax.swing.tree.TreeModel + javax.swing.tree.TreePath + + org.chorem.vradi.entities.Session + org.chorem.vradi.ui.tree.VradiDataProvider + org.chorem.vradi.ui.tree.VradiTreeNode + org.chorem.vradi.ui.email.renderers.EmailCellRenderer + jaxx.runtime.decorator.DecoratorProvider + org.chorem.vradi.VradiConstants + javax.swing.tree.TreeSelectionModel + static org.chorem.vradi.VradiConstants.SessionStatus + </import> + + <CardLayout2 id='contentLayout' useOnlyVisibleComponentDimension='true'/> + + <script><![CDATA[ +public static final String NONE = "none"; + +protected EmailNavigationTreeHelper helper; + +protected EmailNavigationTreeHelper getHelper() { + return helper; +} + +protected EmailHandler getHandler() { + return UIHelper.getHandler(this, EmailHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + SwingUtil.center(getOwner(), this); + + final VradiDataProvider dataProvider = new VradiDataProvider(); + + helper = new EmailNavigationTreeHelper(dataProvider); + setContextValue(helper); + + // Creation of selection listener to open ui when tree selection change + TreeSelectionListener selectionListener = new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent event) { + + // If nothing is selected + if (nav.getSelectionModel().isSelectionEmpty()) { + getContentLayout().show(getContent(), NONE); + return; + } + + TreePath path = event.getPath(); + VradiTreeNode node = (VradiTreeNode) path.getLastPathComponent(); + + if (log.isDebugEnabled()) { + log.debug("Select node " + node); + } + + getHandler().openUI(EmailPopupUI.this, contentLayout, content, node); + updateButtons(); + } + }; + + // Register tree + helper.setUI(nav, true, selectionListener); + + sessionDatePicker.setDate(new Date()); + + updateTree(); + SwingUtil.addExpandOnClickListener(nav); + + // Attach renderer + nav.setCellRenderer(new EmailCellRenderer(dataProvider)); + + // Single selection mode + nav.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + + // Tooltip is not active without this code... + javax.swing.ToolTipManager.sharedInstance().registerComponent(nav); + + this.pack(); +} + +public void updateTree() { + if (log.isDebugEnabled()) { + log.debug("updateTree"); + } + Date searchDate = sessionDatePicker.getDate(); + java.util.List<Session> sessions = getHandler().getSessions(searchDate); + helper.updateTree(sessions, (EmailNavigationTreeHelper.EmailFilterEnum)filterChooser.getSelectedItem(), searchDate); + updateButtons(); +} + +protected void sendSession() { + // disable buttons to avoid duplicate send + boolean started = getHandler().send(this); + updateButtons(); +} + +protected void updateButtons() { + sendSession.setEnabled(canBeSend()); + deleteSession.setEnabled(isActiveSession()); + searchButton.setEnabled(isActiveSession()); +} + +protected boolean isActiveSession() { + if (helper == null) { + return false; + } + Session session = helper.getSelectedActiveSession(); + + if (session == null) { + return false; + } + + return true; +} + +protected boolean canBeSend() { + if (helper == null) { + return false; + } + Session session = helper.getSessionSelected(); + + if (session == null) { + return false; + } + + if (SessionStatus.isToSend(session)) { + return true; + } + return false; +} +]]> + </script> + + <JSplitPane constraints='BorderLayout.CENTER' + resizeWeight='{0.1}' + oneTouchExpandable='true'> + + <JPanel layout='{new BorderLayout()}'> + <JPanel constraints='BorderLayout.NORTH' layout='{new BorderLayout()}'> + <Table constraints='BorderLayout.CENTER'> + <row> + <cell anchor='west'> + <JLabel text='vradi.email.session'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JXDatePicker id='sessionDatePicker'/> + </cell> + </row> + <row> + <cell anchor='west'> + <JLabel text='vradi.email.filter'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JComboBox id='filterChooser' + model='{new DefaultComboBoxModel(EmailNavigationTreeHelper.EmailFilterEnum.values())}'/> + </cell> + </row> + </Table> + <JButton actionIcon='search' onActionPerformed="updateTree()" + constraints='BorderLayout.EAST'/> + </JPanel> + <JScrollPane constraints='BorderLayout.CENTER'> + <JTree id="nav" + font-size='11' + rootVisible='false' + showsRootHandles='true'/> + </JScrollPane> + </JPanel> + <JPanel id="content" layout="{contentLayout}"> + <JPanel layout='{new BorderLayout()}' constraints='NONE'> + <JLabel id='none' horizontalAlignment="0" text="vradi.email.noSelection" + constraints='BorderLayout.CENTER'/> + </JPanel> + </JPanel> + </JSplitPane> + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' weightx='0.25'> + <JButton text='vradi.email.newSession' + actionIcon='new' + onActionPerformed='getHandler().createNewSession(this)'/> + </cell> + <cell fill='horizontal' weightx='0.25'> + <JButton text='vradi.email.bindSession' + id='searchButton' + actionIcon='search' + enabled='{isActiveSession()}' + onActionPerformed='getHandler().bindEmailsWithForms(this)'/> + </cell> + <cell fill='horizontal' weightx='0.25'> + <JButton text='vradi.email.sendSession' + id='sendSession' + actionIcon='send' + enabled='{canBeSend()}' + onActionPerformed='sendSession()'/> + </cell> + <cell fill='horizontal' weightx='0.25'> + <JButton text='vradi.email.deleteSession' + id='deleteSession' + actionIcon='delete' + visible='true' + enabled='{isActiveSession()}' + onActionPerformed='getHandler().deleteSession(this)'/> + </cell> + </row> + <row> + <cell fill='horizontal' columns='4' weightx='1'> + <JButton actionIcon='cancel' text='vradi.action.close' + onActionPerformed='getHandler().close(this)'/> + </cell> + </row> + </Table> +</JFrame> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/EmailPopupUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/FormViewUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/FormViewUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/FormViewUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,126 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<EmailContentUI> + + <import> + org.chorem.vradi.entities.Group + org.chorem.vradi.entities.User + org.chorem.vradi.ui.offer.OfferListColumnFactory + org.chorem.vradi.ui.offer.OfferTable + org.chorem.vradi.ui.tree.VradiTreeNode + org.jdesktop.swingx.JXDatePicker + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + org.chorem.vradi.ui.email.helpers.EmailDataHelper + static org.chorem.vradi.VradiConstants.SessionStatus + org.chorem.vradi.ui.email.models.GroupEmailEntityModel + org.chorem.vradi.ui.email.models.UserEmailEntityModel + org.chorem.vradi.ui.email.renderers.EmailFormsListCellRenderer + </import> + + <Session id='session' javaBean='null'/> + + <Form id='bean' javaBean='null'/> + + <script><![CDATA[ +@Override +public void openUI(VradiTreeNode node) { + // Get datas + getHandler().displayForm(this, node); + Form formSelected = getContextValue(Form.class); + setBean(formSelected); + + session = getHelper().getSessionToDisplay(node); + updateSession(session); +} + +public void updateSession(Session currentSession){ + setSession(currentSession); + + groupsForm.setSession(currentSession); + usersForm.setSession(currentSession); + + java.util.List<User> userSending = EmailDataHelper.getUsersSendingConcernedBy(session, bean.getWikittyId()); + java.util.List<User> allUsers = getAdminHandler().getAllUsers(); + allUsers.removeAll(userSending); + EmailFormsListCellRenderer emailFormsCellRenderer = new EmailFormsListCellRenderer(); + emailFormsCellRenderer.updateDatas(getSession(), getBean().getWikittyId()); + usersForm.init(true, getBean(), emailFormsCellRenderer, allUsers, userSending); + usersForm.getQueryMakerForm().getList().setModel(new UserEmailEntityModel(emailFormsCellRenderer, session, getBean())); + + java.util.List<Group> groupSending = EmailDataHelper.getGroupsSendingConcernedBy(session, bean.getWikittyId()); + java.util.List<Group> allGroups = getAdminHandler().getAllGroups(); + allGroups.removeAll(groupSending); + groupsForm.init(true, getBean(), emailFormsCellRenderer, allGroups, groupSending); + groupsForm.getQueryMakerForm().getList().setModel(new GroupEmailEntityModel(emailFormsCellRenderer, session, getBean())); + + usersForm.setEnabled(sessionCanBeSent()); + groupsForm.setEnabled(sessionCanBeSent()); +} + +protected boolean sessionCanBeSent() { + if (session == null) { + return false; + } + return SessionStatus.isActive(session); +} + +]]></script> + + <Table constraints='BorderLayout.CENTER'> + <row> + <cell> + <JLabel text='vradi.email.formGroupTitle'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='0.5'> + <QueryMakerViewUI id='groupsForm' + enabled='{sessionCanBeSent()}' + constructorParams='this' + genericType='Group' + session='{getSession()}' + form='{getBean()}' + clazz='{Group.class}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='vradi.email.formUserTitle'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='0.5'> + <QueryMakerViewUI id='usersForm' + enabled='{sessionCanBeSent()}' + constructorParams='this' + genericType='User' + session='{getSession()}' + form='{getBean()}' + clazz='{User.class}'/> + </cell> + </row> + </Table> +</EmailContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/FormViewUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/QueryMakerViewUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/QueryMakerViewUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/QueryMakerViewUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,212 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='queryMakerViewUI' + genericType='E extends BusinessEntity' + layout='{new BorderLayout()}'> + + <import> + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + java.awt.event.ActionListener + java.awt.event.ActionEvent + + javax.swing.JList + javax.swing.JButton + javax.swing.JPopupMenu + javax.swing.JMenuItem + + org.chorem.vradi.entities.* + org.chorem.vradi.ui.renderers.EntityRenderer + org.jdesktop.swingx.autocomplete.AutoCompleteDecorator + org.chorem.vradi.services.VradiService + org.chorem.vradi.ui.email.renderers.EmailFormsListCellRenderer + org.nuiton.wikitty.entities.BusinessEntity + org.chorem.vradi.ui.email.models.EmailEntityModel + org.chorem.vradi.entities.User + org.chorem.vradi.VradiConstants + + static org.nuiton.i18n.I18n._ + </import> + + <Session id='session' javaBean='null'/> + + <Class genericType='E' id='clazz' javaBean='null'/> + + <Form id='form' javaBean='null'/> + + <java.util.List genericType='String' id='formsIds' javaBean='null'/> + + <script><![CDATA[ +protected EmailFormsListCellRenderer emailFormsCellRenderer; + +public void init(java.util.List<E> toCombo, java.util.List<E> toList) { + init(false, null, null, toCombo, toList); +} + +public void init(boolean isEmailUI, Form form, EmailFormsListCellRenderer emailFormsCellRenderer, java.util.List<E> toCombo, java.util.List<E> toList) { + + this.form = form; + this.emailFormsCellRenderer = emailFormsCellRenderer; + + // Add completion + AutoCompleteDecorator.decorate(queryMakerForm.getCombo(), EntityRenderer.getInstance()); + + JButton addButton = queryMakerForm.getAdd(); + + JButton removeButton = queryMakerForm.getRemove(); + + if (!isEmailUI) { + + queryMakerForm.init(toCombo, toList); + + log.info("is not email ui"); + return; + } + + // Add own + addButton.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + addSending(); + } + }); + + // Add own + removeButton.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + removeSending(); + } + }); + + // Remove default listener + addButton.removeActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", queryMakerForm, "doActionPerformed__on__add")); + + // Remove default listener + removeButton.removeActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", queryMakerForm, "doActionPerformed__on__remove")); + + queryMakerForm.init(toCombo, toList); + + queryMakerForm.getList().setCellRenderer(emailFormsCellRenderer); + + queryMakerForm.getList().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + + JList list = (JList)e.getSource(); + + if (e.getButton() == MouseEvent.BUTTON3) { + Object[] objects = list.getSelectedValues(); + showPopupMenu(e, objects); + } + } + }); +} + +protected void showPopupMenu(MouseEvent e, Object[] objects) { + if (emailFormsCellRenderer.areDeleted(objects) && VradiConstants.SessionStatus.isToSend(session)) { + + // Display popup menu + final JPopupMenu menu = new JPopupMenu(); + final JMenuItem revertDeletion = new JMenuItem(_("vradi.email.forms.revertDeletion")); + revertDeletion.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + revertDeletion(); + } + }); + + menu.add(revertDeletion); + menu.show(e.getComponent(), e.getX(), e.getY()); + } + +} + +protected void revertDeletion() { + Form form = getForm(); + if (form != null) { + if (clazz == User.class) { + getHandler().revertUserDeletion(this, session, form.getWikittyId(), queryMakerForm.getList().getSelectedValues()); + } else { + getHandler().revertGroupDeletion(this, session, form.getWikittyId(), queryMakerForm.getList().getSelectedValues()); + } + } +} + +protected void addSending() { + Form form = getForm(); + if (form != null) { + if (clazz == User.class) { + getHandler().addUserSending(QueryMakerViewUI.this, session, form.getWikittyId(), queryMakerForm.getCombo().getSelectedItem()); + } else { + getHandler().addGroupSending(QueryMakerViewUI.this, session, form.getWikittyId(), queryMakerForm.getCombo().getSelectedItem()); + } + } else { + if (clazz == User.class) { + getHandler().addUserSending(QueryMakerViewUI.this, session, getFormsIds(), queryMakerForm.getCombo().getSelectedItem()); + } else { + getHandler().addGroupSending(QueryMakerViewUI.this, session, getFormsIds(), queryMakerForm.getCombo().getSelectedItem()); + } + } +} + +protected void removeSending() { + Form form = getForm(); + if (form != null) { + if (clazz == User.class) { + getHandler().removeUserSending(QueryMakerViewUI.this, session, form.getWikittyId(), queryMakerForm.getList().getSelectedValues()); + } else { + getHandler().removeGroupSending(QueryMakerViewUI.this, session, form.getWikittyId(), queryMakerForm.getList().getSelectedValues()); + } + } else { + if (clazz == User.class) { + getHandler().removeUserSending(QueryMakerViewUI.this, session, getFormsIds(), queryMakerForm.getList().getSelectedValues()); + } else { + getHandler().removeGroupSending(QueryMakerViewUI.this, session, getFormsIds(), queryMakerForm.getList().getSelectedValues()); + } + } +} + +protected void updateSession(Session sessionRestored) { + getParentContainer(FormViewUI.class).updateSession(sessionRestored); +} + +public EmailHandler getHandler() { + return UIHelper.getHandler(this, EmailHandler.class); +} + +]]></script> + + <ListSelectorUI id='queryMakerForm' + constraints='BorderLayout.CENTER' + enabled='{isEnabled()}' + genericType='E' + showHidor='false' + renderer='{new EntityRenderer()}'/> + +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/QueryMakerViewUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SendingViewUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SendingViewUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SendingViewUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,216 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<EmailContentUI> + + <import> + org.chorem.vradi.VradiContext + org.chorem.vradi.entities.User + org.chorem.vradi.beans.FormPagedResult + org.chorem.vradi.ui.offer.OfferListColumnFactory + org.chorem.vradi.ui.offer.OfferTable + org.chorem.vradi.ui.offer.models.OfferListTableModel + org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper + org.chorem.vradi.ui.helpers.UIHelper + org.chorem.vradi.VradiConstants + org.jdesktop.swingx.JXDatePicker + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + org.chorem.vradi.services.VradiService + org.nuiton.wikitty.WikittyProxy + org.chorem.vradi.ui.tree.VradiTreeNode + java.awt.Color + static org.chorem.vradi.VradiConstants.SendingStatus + </import> + + <OfferListColumnFactory id='offerListColumnFactory'/> + + <OfferListTableModel id='offerListTableModel' constructorParams='true'/> + + <Sending id='bean' javaBean='null'/> + + <Session id='session' javaBean='null'/> + + <script><![CDATA[ + +protected EmailNavigationTreeHelper helper; + +@Override +public void openUI(VradiTreeNode node) { + getHandler().displaySession(this, getHelper(), node); +} + +public void setHelper(EmailNavigationTreeHelper helper){ + this.helper = helper; +} + +public EmailNavigationTreeHelper getHelper(){ + if (helper != null){ + return helper; + } + helper = getContextValue(EmailNavigationTreeHelper.class); + if (helper != null){ + return helper; + } + return getParentContainer(EmailPopupUI.class).helper; +} + +protected EmailHandler getHandler() { + return UIHelper.getHandler(this, EmailHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public void init() { + title.setText(updateTitle()); + sendSending.setEnabled(canBeReSend()); +} + +protected String updateTitle() { + if (getBean() == null){ + return ""; + } + String title = ""; + WikittyProxy proxy = VradiService.getWikittyProxy(); + String userId = getBean().getUser(); + if (userId != null){ + User user = proxy.restore(User.class, userId); + if (user != null) { + title = _("vradi.email.titleUser", user.getName()); + } + } + return title; +} + +protected boolean canBeReSend(){ + if (getBean() == null){ + return false; + } + return SendingStatus.isSent(getBean()); +} + +public boolean isNotClosed() { + if (getBean() == null) { + return false; + } + return !SendingStatus.isClosed(getBean()); +} +]]></script> + + <JScrollPane constraints='BorderLayout.CENTER'> + + <JPanel layout='{new BorderLayout()}'> + + <Table constraints='BorderLayout.NORTH'> + <row> + <cell anchor='west'> + <JLabel id='title' text='{updateTitle()}'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JPanel/> + </cell> + <cell> + <JButton id='sendSending' + text='vradi.email.sendSending' + actionIcon='send' + enabled='{canBeReSend()}' + onActionPerformed='getHandler().sendSending(this, getBean())'/> + </cell> + <cell> + <jaxx.runtime.swing.HidorButton target='{sendingContent}' + hideTip='{_("vradi.email.hideForm")}' + showTip='{_("vradi.email.showForm")}' + targetVisible='{true}'/> + </cell> + </row> + </Table> + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> + <Table id='sendingContent' constraints="BorderLayout.NORTH"> + <row> + <cell fill='horizontal' weightx='0.2'> + <Table> + <row> + <cell anchor='west'> + <JLabel text='vradi.email.status'/> + </cell> + <cell anchor='west'> + <JLabel id='statusField' + text='{VradiConstants.SendingStatus.getStatus(getBean().getStatus()).getDescription()}'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1'> + <JCheckBox id='receptionProofField' + text='vradi.email.receptionProof' + selected='{getBean().getReceptionProof()}' + onActionPerformed='getHandler().updateReceptionProof(getBean(), + receptionProofField.isSelected())'/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both' weightx='0.8' weighty='1'> + <Table> + <row> + <cell anchor='west'> + <JLabel text='vradi.email.paragraph'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='1'> + <JScrollPane> + <JTextArea id='descriptionField' + text='{getBean().getParagraph()}' + onKeyReleased='getBean().setParagraph(descriptionField.getText())' + onFocusLost='getHandler().updateParagraph(getBean(), + getBean().getParagraph())'/> + </JScrollPane> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + <JScrollPane constructorParams='JScrollPane.VERTICAL_SCROLLBAR_NEVER, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER' + constraints='BorderLayout.CENTER'> + + <OfferTable id='listTable' + fillsViewportHeight='{true}' + columnFactory='{offerListColumnFactory}' + model='{offerListTableModel}' + autoResizeMode='{2}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + showGrid='{true}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + </JPanel> + </JPanel> + </JScrollPane> +</EmailContentUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SendingViewUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SessionViewUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SessionViewUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SessionViewUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,71 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<EmailContentUI> + + <import> + java.io.File + + org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper + org.chorem.vradi.ui.widgets.MultipleSelectionPane + javax.swing.table.DefaultTableCellRenderer + org.chorem.vradi.ui.tree.VradiTreeNode + org.chorem.vradi.services.VradiService + org.chorem.vradi.ui.email.widgets.AttachmentSessionFileHandler + </import> + + <Session id='selectedSession' javaBean='null'/> + + <script><![CDATA[ + +@Override +public void openUI(VradiTreeNode node) { + + String id = node.getId(); + Session session = VradiService.getWikittyProxy().restore(Session.class, id); + setSelectedSession(session); + attachmentSessionPane.setBean(session); + attachmentSessionPane.init(); +} + +]]></script> + + <JLabel text='vradi.email.sessionParagraph' + constraints='BorderLayout.NORTH'/> + + <JScrollPane constraints='BorderLayout.CENTER'> + <JTextArea id='sessionParagraph' + text='{getSelectedSession().getParagraph()}' + onKeyReleased='getSelectedSession().setParagraph(sessionParagraph.getText())' + onFocusLost='VradiService.getWikittyProxy().store(getSelectedSession())'/> + </JScrollPane> + + <MultipleSelectionPane id='attachmentSessionPane' + constraints='BorderLayout.SOUTH' + genericType='File, Session' + beanType='{Session.class}' + handler='{new AttachmentSessionFileHandler(attachmentSessionPane)}' + bean='{getSelectedSession()}'/> + +</EmailContentUI> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/SessionViewUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailBeanConstant.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailBeanConstant.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailBeanConstant.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,188 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.helpers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.EmailContentUI; +import org.chorem.vradi.ui.email.FormViewUI; +import org.chorem.vradi.ui.email.SendingViewUI; +import org.chorem.vradi.ui.email.SessionViewUI; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.text.SimpleDateFormat; + +import static org.chorem.vradi.VradiConstants.SendingStatus; +import static org.chorem.vradi.VradiConstants.SessionStatus; + +/** + * @author sletellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public enum EmailBeanConstant { + + // Group + GROUP(Group.class, null), + // User + USER(User.class, SendingViewUI.class), + // Form + FORM(Form.class, FormViewUI.class), + //Session$ + SESSION(Session.class, SessionViewUI.class); + + /** Logger */ + private static Log log = LogFactory.getLog(EmailBeanConstant.class); + + protected Class<? extends BusinessEntity> beanClass; + + protected Class<? extends EmailContentUI> uiClass; + + private EmailBeanConstant(Class<? extends BusinessEntity> beanClass, Class<? extends EmailContentUI> uiClass) { + this.beanClass = beanClass; + this.uiClass = uiClass; + } + + public Class<? extends BusinessEntity> getBeanClass() { + return beanClass; + } + + public Class<? extends EmailContentUI> getUIClass() { + return uiClass; + } + + public static EmailBeanConstant getConstantByBeanClass(Class<?> beanClass) { + for (EmailBeanConstant constant : values()) { + if (beanClass.equals(constant.getBeanClass())) { + return constant; + } + } + return null; + } + + public BusinessEntity getBean(VradiDataProvider provider, String id) { + WikittyProxy proxy = provider.getWikittyProxy(); + return proxy.restore(beanClass, id); + } + + public static Class<? extends EmailContentUI> getUIClass(Class<?> beanClass) { + for (EmailBeanConstant constant : values()) { + if (beanClass.equals(constant.getBeanClass())) { + return constant.getUIClass(); + } + } + return null; + } + + public String decorate(Session currentSession, BusinessEntity bean) { + String result = ""; + switch (this) { + case GROUP: + Group group = cast(Group.class, bean); + result = group.getName() + " (" + EmailDataHelper.getNbFormToSend(currentSession, group) + ")"; + break; + case USER: + StringBuffer sendingBuffer = new StringBuffer(); + User user = cast(User.class, bean); + Client client = VradiService.getWikittyProxy().restore(Client.class, user.getClient()); + + sendingBuffer.append(client.getName()); + sendingBuffer.append(" - "); + sendingBuffer.append(user.getName()); + + // Get sending concerned by user + Sending sending = EmailDataHelper.getUserSending(currentSession, user.getWikittyId()); + + if (sending != null) { + sendingBuffer.append(" ["); + SendingStatus status = SendingStatus.getStatus(sending.getStatus()); + sendingBuffer.append(status.getDescription()); + sendingBuffer.append("] "); + } + sendingBuffer.append(" ("); + sendingBuffer.append(EmailDataHelper.getNbFormToSend(currentSession, user)); + sendingBuffer.append(")"); + + result = sendingBuffer.toString(); + break; + case FORM: + Form form = cast(Form.class, bean); + result = form.getObjet(); + break; + case SESSION: + // 1 - dd/MM/yyyy - status + Session session = cast(Session.class, bean); + StringBuffer sessionBuffer = new StringBuffer(); + sessionBuffer.append(session.getNum()); + sessionBuffer.append(" - "); + SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); + sessionBuffer.append(format.format(session.getSessionDate())); + + SessionStatus sessionStatus = SessionStatus.getStatus(session.getStatus()); + + if (sessionStatus != null) { + sessionBuffer.append(" ["); + sessionBuffer.append(sessionStatus.getDescription()); + sessionBuffer.append("]"); + } else { + log.warn("Cant find status for num : " + session.getStatus()); + } + result = sessionBuffer.toString(); + + break; + } + return result; + } + + public String getToolTipText(BusinessEntity bean) { + String result = null; + switch (this) { + case SESSION: + Session session = cast(Session.class, bean); + String sessionLogs = session.getSessionLogs(); + if (sessionLogs != null && !sessionLogs.isEmpty()) { + result = sessionLogs; + } + + break; + } + return result; + } + + protected <B extends BusinessEntity> B cast(Class<B> toCast, BusinessEntity bean) { + return (B) bean; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailBeanConstant.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailDataHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailDataHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailDataHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,354 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.helpers; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** @author sletellier <letellier@codelutin.com> */ +public class EmailDataHelper { + + + private static final Log log = LogFactory.getLog(EmailDataHelper.class); + + protected static WikittyProxy getProxy() { + return VradiService.getWikittyProxy(); + } + + public static Sending getUserSending(Session session, User user) { + String id = user.getWikittyId(); + return getUserSending(session, id); + } + + public static List<Sending> getUsersSendings(Session session, Collection<String> usersId) { + if (session == null || usersId == null) { + return null; + } + Set<String> sendingIdsSet = session.getSending(); + if (sendingIdsSet == null) { + return null; + } + List<String> sendingIds = new ArrayList<String>(sendingIdsSet); + List<Sending> sendings = getProxy().restore(Sending.class, sendingIds); + List<Sending> result = new ArrayList<Sending>(); + for (Sending sending : sendings) { + if (sending != null && usersId.contains(sending.getUser())) { + + result.add(sending); + } + } + return result; + } + + public static Sending getUserSending(Session session, String userId) { + if (session == null) { + return null; + } + Set<String> sendingIdsSet = session.getSending(); + if (sendingIdsSet == null) { + return null; + } + List<String> sendingIds = new ArrayList<String>(sendingIdsSet); + List<Sending> sendings = getProxy().restore(Sending.class, sendingIds); + for (Sending sending : sendings) { + if (sending != null && userId.equals(sending.getUser())) { + + return sending; + } + } + return null; + } + + public static int getNbFormToSend(Session session, User bean) { + Sending sending = getUserSending(session, bean); + Set<String> formIds = null; + if (sending != null) { + formIds = SendingHelper.extractForms(getProxy(), sending.getGroupForms()); + } + return formIds == null ? 0 : formIds.size(); + } + + + public static int getNbFormToSend(Session session, Group group) { + Set<String> formIds = new HashSet<String>(); + Set<String> userIds = group.getUser(); + if (userIds != null) { + for (String userId : userIds) { + Sending sending = getUserSending(session, userId); + if (sending != null) { + Set<String> formsIds = SendingHelper.extractForms(getProxy(), sending.getGroupForms()); + if (formsIds != null) { + formIds.addAll(formsIds); + } + } + } + } + return formIds.size(); + } + + public static String convertFormsToString(List<Form> forms) { + + List<String> objects = extractObject(forms); + + return StringUtils.join(objects, ",\n"); + } + + public static String convertFormsIdsToString(List<String> formsId) { + + List<Form> forms = VradiService.getWikittyProxy().restore(Form.class, formsId); + + return convertFormsToString(forms); + } + + public static <E extends BusinessEntity> String convertObjectBeanToString(List beans, Class<E> clazz) { + + List<E> casted = new ArrayList<E>(); + for (Object o : beans) { + casted.add((E) o); + } + + return convertBeanToString(casted); + } + + public static String convertBeanToString(List<? extends BusinessEntity> beans) { + + List<String> names = extractNames(beans); + + return StringUtils.join(names, ",\n"); + } + + protected static List<String> extractObject(List<Form> forms) { + List<String> objects = new ArrayList<String>(); + for (Form f : forms) { + objects.add(f.getObjet()); + } + return objects; + } + + protected static List<String> extractNames(List<? extends BusinessEntity> beans) { + List<String> beansAsNames = new ArrayList<String>(); + for (BusinessEntity b : beans) { + beansAsNames.add(VradiHelper.getEntityName(b)); + } + return beansAsNames; + } + + public static String convertFormToString(String formId) { + Form form = VradiService.getWikittyProxy().restore(Form.class, formId); + if (form != null) { + return form.getObjet(); + } + return ""; + } + + public static List<Sending> getAllSending(Session session) { + Set<String> sendingSetIds = session.getSending(); + if (sendingSetIds == null) { + return Collections.EMPTY_LIST; + } + List<String> sendingIds = new ArrayList<String>(sendingSetIds); + WikittyProxy proxy = VradiService.getWikittyProxy(); + return proxy.restore(Sending.class, sendingIds); + } + + public static List<User> getUsersSendingConcernedBy(Session session, String formId) { + Set<String> userSet = new HashSet<String>(); + List<Sending> sendings = getAllSending(session); + for (Sending sending : sendings) { + if (sending != null) { + List<String> allFormsIds = new ArrayList<String>(); + Set<String> formsIds = SendingHelper.extractForms(getProxy(), sending.getGroupForms()); + if (formsIds != null) { + allFormsIds.addAll(formsIds); + } + Set<String> deletedFormsIds = SendingHelper.extractForms(getProxy(), sending.getDeletedGroupForms()); + if (deletedFormsIds != null) { + allFormsIds.addAll(deletedFormsIds); + } + + if (allFormsIds.contains(formId)) { + String userId = sending.getUser(); + userSet.add(userId); + } + } + } + List<User> result = VradiService.getWikittyProxy().restore(User.class, new ArrayList<String>(userSet)); + Collections.sort(result, VradiComparators.USER_COMPARATOR); + return result; + } + + public static List<Group> getGroupsSendingConcernedBy(Session session, String formId) { + Set<String> groupsSet = new HashSet<String>(); + Set<String> groupFormsIdsOfSession = new HashSet<String>(); + for (Sending sending : getAllSending(session)) { + + Set<String> groupFormsIds = sending.getGroupForms(); + if (groupFormsIds != null) { + groupFormsIdsOfSession.addAll(groupFormsIds); + } + Set<String> deletedGroupFormsIds = sending.getDeletedGroupForms(); + if (deletedGroupFormsIds != null) { + groupFormsIdsOfSession.addAll(deletedGroupFormsIds); + } + } + List<GroupForms> groupFormsOfSession = getProxy().restore(GroupForms.class, new ArrayList<String>(groupFormsIdsOfSession)); + for (GroupForms gf : groupFormsOfSession) { + if (gf != null) { + Set<String> formsIds = gf.getForm(); + if (formsIds != null && formsIds.contains(formId)) { + String groupId = gf.getGroup(); + if (groupId != null) { + groupsSet.add(groupId); + } + } + } + } + List<Group> result = VradiService.getWikittyProxy().restore(Group.class, new ArrayList<String>(groupsSet)); + Collections.sort(result, VradiComparators.GROUP_COMPARATOR); + return result; + } + + public static Set<String> findAllGroupsConcernedBySending(Sending sending) { + Set<String> result = new HashSet<String>(); + if (sending != null) { + Set<GroupForms> groupsForms = findAllGroupsFormsConcernedBySending(sending); + for (GroupForms gf : groupsForms) { + if (gf != null) { + result.add(gf.getGroup()); + } + } + } + return result; + } + + protected static Set<GroupForms> findAllGroupsFormsConcernedBySending(Sending sending) { + + Set<GroupForms> result = new HashSet<GroupForms>(); + + if (sending != null) { + + Set<String> groupFormsConcerned = sending.getGroupForms(); + if (groupFormsConcerned != null) { + + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormsConcerned)); + result.addAll(groupForms); + } + Set<String> groupFormsConcernedDeleted = sending.getDeletedGroupForms(); + if (groupFormsConcernedDeleted != null) { + + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + List<GroupForms> groupFormsDeleted = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormsConcernedDeleted)); + result.addAll(groupFormsDeleted); + } + +// // Get forms concerned (active or deleted) +// List<String> formsConcerned = new ArrayList<String>(); +// Set<String> formsIds = sending.getForm(); +// if (formsIds != null) { +// formsConcerned.addAll(formsIds); +// } +// Set<String> deletedFormsIds = sending.getDeletedForms(); +// if (deletedFormsIds != null) { +// formsConcerned.addAll(deletedFormsIds); +// } +// if (!formsConcerned.isEmpty()) { +// +// // For all forms, find groups concerned +// for (String formId : formsConcerned) { +// result.addAll(findAllGroupsConcernedBySending(sending, formId)); +// } +// } + } + return result; + } + +// public static List<String> findAllGroupsConcernedBySending(Sending sending, String formId) { +// +// List<String> result = new ArrayList<String>(); +// +// List<Group> userGroups = VradiService.getVradiDataService().findUserGroups(sending.getUser()); +// List<String> userGroupsIds = extractIds(userGroups); +// Map<Group,List<QueryBean>> groupRequestMap; +// try { +// // Get group concerned +// groupRequestMap = VradiService.getVradiStorageService().findQueriesReturningForm(formId); +// } catch (VradiException eee) { +// log.error("Cant get all groups concenred by sending ", eee); +// ErrorDialogUI.showError(eee); +// return null; +// } +// Set<Group> groupRequestSet = groupRequestMap.keySet(); +// List<String> groupRequestIds = extractIds(groupRequestSet); +// +// if (log.isDebugEnabled()) { +// log.debug(groupRequestIds.size() + " groups found for forms : " + formId); +// } +// +// // Extract groups match +// for (String groupId : userGroupsIds) { +// if (groupRequestIds.contains(groupId)) { +// if (log.isDebugEnabled()) { +// log.debug("Add group : " + groupId); +// } +// result.add(groupId); +// } +// } +// return result; +// } + + public static List<String> extractIds(Collection<? extends BusinessEntity> entities) { + List<String> ids = new ArrayList<String>(); + if (entities == null) { + return ids; + } + for (BusinessEntity e : entities) { + if (e != null) { + ids.add(e.getWikittyId()); + } + } + return ids; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailDataHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailNavigationTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailNavigationTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailNavigationTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,486 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.helpers; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.swing.ErrorDialogUI; +import jaxx.runtime.swing.nav.NavHelper; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.EmailHandler; +import org.chorem.vradi.ui.email.loadors.AbstractEmailNodeLoador; +import org.chorem.vradi.ui.email.loadors.EmailFormNodeLoadors; +import org.chorem.vradi.ui.email.loadors.EmailGroupNodeLoadors; +import org.chorem.vradi.ui.email.loadors.EmailGroupUsersNodeLoadors; +import org.chorem.vradi.ui.email.loadors.EmailUsersNodeLoadors; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.helpers.VradiTreeHelper; +import org.nuiton.util.DateUtil; +import org.nuiton.wikitty.WikittyProxy; + +import javax.swing.tree.TreeModel; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.chorem.vradi.VradiConstants.SessionStatus; +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class EmailNavigationTreeHelper extends VradiTreeHelper<Session> { + + /** Logger */ + static private final Log log = LogFactory.getLog(EmailNavigationTreeHelper.class); + + protected List<Session> sessions; + + protected Date searchDate; + + // All filter + public enum EmailFilterEnum { + // FILTER_BY_CLIENT(_("vradi.email.clientFilter")), + FILTER_BY_USER(_("vradi.email.userFilter")), + FILTER_BY_GROUP(_("vradi.email.groupFilter")), + FILTER_BY_FORM(_("vradi.email.formFilter")); + + protected int value; + + protected String text; + + EmailFilterEnum(String text) { + this.text = text; + } + + @Override + public String toString() { + return text; + } + } + + public static String PATH_SEPARATOR = "/"; + + // Filter by client by defaut + protected EmailFilterEnum filter = EmailFilterEnum.FILTER_BY_USER; + + protected VradiEntitiesListener<Sending> sendingVradiEntitiesListener; + + public EmailNavigationTreeHelper(VradiDataProvider dataProvider) { + super(); + setDataProvider(dataProvider); + + VradiContext.get().getVradiNotifier().addVradiListener(Session.class, this); + sendingVradiEntitiesListener = new VradiEntitiesListener<Sending>() { + + @Override + public void entitiesAdded(Set<Sending> added) { + for (Sending sending : added) { + updateSendingInTree(sending); + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + removeEntities(removed); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(Sending.class, sendingVradiEntitiesListener); + } + + @Override + public VradiDataProvider getDataProvider() { + return (VradiDataProvider) dataProvider; + } + + public WikittyProxy getProxy() { + return getDataProvider().getWikittyProxy(); + } + + // Get email handler + protected EmailHandler getHandler(JAXXContext context) { + return UIHelper.getHandler(context, EmailHandler.class); + } + + public String getPathSeparator() { + return PATH_SEPARATOR; + } + + public boolean isByForm() { + return filter.equals(EmailFilterEnum.FILTER_BY_FORM); + } + + public boolean isByUser() { + return filter.equals(EmailFilterEnum.FILTER_BY_USER); + } + + /* public boolean isByClient() { + return filter.equals(EmailFilterEnum.FILTER_BY_CLIENT); + }*/ + + public boolean isByGroup() { + return filter.equals(EmailFilterEnum.FILTER_BY_GROUP); + } + + /** + * Return selected session active session. + * + * @return session entity + */ + public Session getSelectedActiveSession() { + + Session activeSession = null; + VradiTreeNode selectedNode = getSelectedNode(); + + if (selectedNode != null) { + Session session = getParentSession(selectedNode); + + if (SessionStatus.isToSend(session)) { + activeSession = session; + } + } + + return activeSession; + } + + public void updateTree(List<Session> sessions, EmailFilterEnum filter, Date searchDate) { + if (log.isDebugEnabled()) { + log.debug("update data, nb sessions : " + sessions.size()); + } + this.filter = filter; + this.sessions = sessions; + this.searchDate = searchDate; + + VradiTreeNode rootNode = new VradiTreeNode( + String.class, + "Root node", + null, + null + ); + + for (Session session : sessions) { + rootNode.add(createSessionNode(session)); + } + TreeModel model = createModel(rootNode); + getBridge().setRoot(rootNode); + + // Populate childs nodes + rootNode.populateChilds(getBridge(), getDataProvider()); + + getUI().setModel(model); + } + + public VradiTreeNode createSessionNode(Session session) { + if (log.isDebugEnabled()) { + log.debug("createSession node " + session.getSessionDate() + " num " + session.getNum()); + } + String sessionId = session.getWikittyId(); + + NavTreeNodeChildLoador<?, ?, VradiTreeNode> nodeLoador = null; + + if (isByForm()) { + nodeLoador = new EmailFormNodeLoadors(); + } else { + if (isByUser()) { + nodeLoador = new EmailUsersNodeLoadors(); + } else if (isByGroup()) { + nodeLoador = new EmailGroupNodeLoadors(); + } + } + + return new VradiTreeNode( + Session.class, + sessionId, + null, + nodeLoador); + + } + + public Session getSessionSelected() { + return getSessionToDisplay(getSelectedNode()); + } + + public Session getSessionToDisplay(VradiTreeNode node) { + Session session = getParentSession(node); + + return session; + } + + public Sending getSendingToDisplay(VradiTreeNode node) { + String id = node.getId(); + + Session session = getParentSession(node); + + return EmailDataHelper.getUserSending(session, id); + } + + public List<Sending> getSendingListToDisplay(VradiTreeNode node) { + Map<String, Sending> result = new HashMap<String, Sending>(); + Class type = node.getInternalClass(); + String id = node.getId(); + + Session session = getParentSession(node); + + if (type.equals(Form.class)) { + + // Get sending by form + List<Sending> sendings = getSendingByForm(session, id); + addSendingToMap(result, sendings); + + } + + return new ArrayList<Sending>(result.values()); + } + + protected void addSendingToMap(Map<String, Sending> result, List<Sending> sendings) { + for (Sending sending : sendings) { + result.put(sending.getWikittyId(), sending); + } + } + + protected List<Sending> getSendingByForm(Session session, String formId) { + Set<String> sendingIdsSet = session.getSending(); + List<Sending> result = new ArrayList<Sending>(); + if (sendingIdsSet == null) { + return result; + } + List<Sending> sendings = getProxy().restore(Sending.class, new ArrayList<String>(sendingIdsSet)); + for (Sending sending : sendings) { + if (sending != null) { + Set<String> formIdsSet = SendingHelper.extractForms(VradiService.getWikittyProxy(), sending.getGroupForms()); + if (formIdsSet == null) { + return result; + } + if (formIdsSet.contains(formId)) { + result.add(sending); + } + } + } + return result; + } + + protected List<String> getStringAsList(String s) { + List<String> result = new ArrayList<String>(); + result.add(s); + return result; + } + + public static Session getParentSession(VradiTreeNode node) { + VradiTreeNode sessionNode = getParentSessionNode(node); + if (sessionNode == null) { + return null; + } + return VradiService.getWikittyProxy().restore(Session.class, sessionNode.getId()); + } + + public static VradiTreeNode getParentSessionNode(VradiTreeNode node) { + if (node == null) { + return null; + } + if (node.getInternalClass().equals(Session.class)) { + return node; + } + VradiTreeNode parent = node.getParent(); + return getParentSessionNode(parent); + } + + @Override + public void createEntityNode(String wikittyId) { + + } + + @Override + public void entitiesAdded(Set<Session> added) { + + for (Session session : added) { + + String wikittyId = session.getWikittyId(); + + // Check if session exist + VradiTreeNode existingNode = findNode(getRootNode(), wikittyId); + + // cas modification + if (existingNode != null) { + + if (log.isDebugEnabled()) { + log.debug("[Session] Modification case : " + existingNode.getId()); + } + + refresh(existingNode); + } + + // Creation case + else { + + // Si la date correspond + if (0 == DateUtil.getDifferenceInDays(searchDate, session.getSessionDate())) { + + if (log.isDebugEnabled()) { + log.debug("[Session] Creation case : " + session.getSessionDate()); + } + + // Tri + VradiTreeNode newSessionNode = createSessionNode(session); + + // On l'insert + insertNode(getRootNode(), newSessionNode); + + refresh(newSessionNode); + } + + } + } + } + + protected void updateSendingInTree(Sending sending) { + + if (sending == null) { + return; + } + + // Find session node + Session session = null; + String wikittyId = sending.getWikittyId(); + try { + session = VradiService.getVradiDataService().getSessionOfSending(wikittyId); + } catch (VradiException eee) { + log.error("Can't find session for sending '" + wikittyId + "'", eee); + ErrorDialogUI.showError(eee); + } + + if (session == null) { + return; + } + + // Verify session is already in tree + VradiTreeNode sessionNode = findNode(getRootNode(), session.getWikittyId()); + + // If not found do nothing + if (sessionNode == null) { + return; + } + + // If its sort by form + if (isByForm()) { + Set<String> formsIds = SendingHelper.extractForms(VradiService.getWikittyProxy(), sending.getGroupForms()); + if (formsIds != null) { + for (String formId : formsIds) { + VradiTreeNode formNode = findNode(sessionNode, formId); + + // If form is not in tree, add it + if (formNode == null) { + if (log.isDebugEnabled()) { + log.debug("[Sending] add form " + formId); + } + createNode(sessionNode, Form.class, formId, null); + } + } + } + // Sort by user + } else if (isByUser()) { + String userId = sending.getUser(); + VradiTreeNode userNode = findNode(sessionNode, userId); + + // Refresh if already in tree + if (userNode != null) { + if (log.isDebugEnabled()) { + log.debug("[Sending] refresh user " + userId); + } + refresh(userNode); + } else { + if (log.isDebugEnabled()) { + log.debug("[Sending] create user " + userId); + } + + // Create if user is not in tree + createNode(sessionNode, User.class, userId, null); + } + + // If its sort by group + } else if (isByGroup()) { + String userId = sending.getUser(); + VradiTreeNode userNode = findNode(sessionNode, userId); + + // If user node is in tree, refresh it + if (userNode != null) { + if (log.isDebugEnabled()) { + log.debug("[Sending] refresh user " + userId); + } + refresh(userNode); + } else { + + // Else, try to add it, we search all user group and for all + // we will create missing node + List<Group> groupList = VradiService.getVradiDataService().findUserGroups(userId); + for (Group group : groupList) { + String groupId = group.getWikittyId(); + + // if group is already in tree + VradiTreeNode groupNode = findNode(sessionNode, groupId); + if (groupNode != null) { + + if (log.isDebugEnabled()) { + log.debug("[Sending] create user " + userId); + } + + // Create userNode + createNode(sessionNode, User.class, userId, null); + } else { + + if (log.isDebugEnabled()) { + log.debug("[Sending] create group " + userId); + } + // Else create groupNode + createNode(sessionNode, Group.class, groupId, EmailGroupUsersNodeLoadors.class); + } + } + } + } + } + + protected void createNode(VradiTreeNode sessionNode, Class typeNode, String id, Class<? extends AbstractEmailNodeLoador<?>> loadorClass) { + AbstractEmailNodeLoador<?> nodeLoador = null; + if (loadorClass != null) { + nodeLoador = NavHelper.getChildLoador(loadorClass); + } + VradiTreeNode newNode = new VradiTreeNode(typeNode, id, null, nodeLoador); + sessionNode.add(newNode); + getBridge().notifyNodeInserted(newNode); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/EmailNavigationTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,420 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.helpers; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.EmailHandler; +import org.chorem.vradi.ui.email.SendingViewUI; +import org.chorem.vradi.ui.email.renderers.EmailFormsHighlighter; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.OfferTable; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.task.VradiTask; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.nuiton.wikitty.WikittyProxy; + +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +public class SendingViewManager implements VradiEntitiesListener<Sending> { + + /** Logger */ + static private final Log log = LogFactory.getLog(SendingViewManager.class); + + protected Session session; + + protected Sending sending; + + protected SendingViewUI ui; + + protected EmailFormsHighlighter emailFormsHighlighter; + + protected OfferListTableModel listTableModel; + + private static SendingViewManager instance; + + protected SendingViewManager() { + + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(Sending.class, this); + } + + // Singleton + public static SendingViewManager getInstance() { + if (instance == null) { + instance = new SendingViewManager(); + } + return instance; + } + + public void openUI(SendingViewUI ui, Session session, Sending sending) { + + if (sending == null) { + return; + } + + this.ui = ui; + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + this.sending = wikittyProxy.restore(Sending.class, sending.getWikittyId()); + this.session = session; + + // Init session ui + ui.setBean(sending); + + ui.setSession(session); + + // listTable cellRenderer + // TODO SLE 30/09/2010 : Refactor it ! + OfferListTableModel.OfferListTableCellRenderer renderer = + new OfferListTableModel.OfferListTableCellRenderer(); + + OfferTable listTable = ui.getListTable(); + + listTableModel = (OfferListTableModel) listTable.getModel(); + + emailFormsHighlighter = new EmailFormsHighlighter(listTableModel); + updateDatas(); + + listTable.setModel(listTableModel); + + listTable.setDefaultRenderer(Boolean.class, renderer); + listTable.setDefaultRenderer(Date.class, renderer); + listTable.setDefaultRenderer(Double.class, renderer); + listTable.setDefaultRenderer(String.class, renderer); + listTable.setDefaultRenderer(XmlStream.class, renderer); + listTable.setDefaultRenderer(Status.class, renderer); + + // listTable highlighter + Highlighter highlighter = + HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + + listTable.addHighlighter(highlighter); + listTable.addHighlighter(emailFormsHighlighter); + + // Add mouse listener + MouseListener offerListTableMouseListener = getOfferListTableMouseListener(); + listTable.addMouseListener(offerListTableMouseListener); + + // init ui + ui.init(); + } + + protected void updateDatas() { + if (sending == null) { + return; + } + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + + FormPagedResult formPage = new FormPagedResult(); + + Set<String> formsIdsToDisplay = new HashSet<String>(); + + // Get forms + Set<String> forms = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + if (forms != null) { + formsIdsToDisplay.addAll(forms); + } + + // Get deleted + Set<String> deletedForms = SendingHelper.extractForms(wikittyProxy, sending.getDeletedGroupForms()); + Set<String> addedForms = SendingHelper.extractForms(wikittyProxy, sending.getAddedGroupForms()); + if (deletedForms != null) { + formsIdsToDisplay.addAll(deletedForms); + } + if (!formsIdsToDisplay.isEmpty()) { + formPage.setFormsToShow(new ArrayList<String>(formsIdsToDisplay)); + } + + emailFormsHighlighter.setFormsAdded(addedForms); + emailFormsHighlighter.setFormsDeleted(deletedForms); + listTableModel.setFormPagedResult(formPage); + + emailFormsHighlighter.notifyChange(); + } + + protected void refresh() { + + SwingUtilities.invokeLater(new Thread() { + + @Override + public void run() { + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + sending = wikittyProxy.restore(Sending.class, sending.getWikittyId()); + + ui.setBean(sending); + + updateDatas(); + } + }); + } + + @Override + public void entitiesAdded(Set<Sending> added) { + refresh(); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + } + + /** + * Implementation du click (droit/gauche) sur la table des offres résultats/ + * <p/> + * Comportement : + * <ul> + * <li>double clic : ouvre l'offre + * <li>clic droit : changer le status, ajouter a une session de mail + * </ul> + * + * @return le mouse listener + */ + public MouseListener getOfferListTableMouseListener() { + // double click on listTable shows selected offer + return new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + JXTable listTable = (JXTable) e.getSource(); + + // double clic + if (e.getButton() == MouseEvent.BUTTON1 && + e.getClickCount() == 2) { + try { + ui.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + EmailHandler handler = UIHelper.getHandler(ui, EmailHandler.class); + handler.selectOffer(ui, listTable); + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't open offer", ex); + } + ErrorDialogUI.showError(ex); + } finally { + ui.setCursor(null); + } + + // clic droit + } else if (e.getButton() == MouseEvent.BUTTON3) { + int[] selectedRows = listTable.getSelectedRows(); + int rowClicked = listTable.rowAtPoint(e.getPoint()); + boolean rowClickedSelected = false; + if (selectedRows == null || selectedRows.length == 0) { + listTable.getSelectionModel().setSelectionInterval(rowClicked, rowClicked); + rowClickedSelected = true; + } else { + int i = 0; + while (i < selectedRows.length && !rowClickedSelected) { + rowClickedSelected = rowClicked == selectedRows[i++]; + } + } + + if (rowClickedSelected) { + showOfferListContextMenu(ui, listTable, ui.getOfferListTableModel(), e); + } + } + } + }; + } + + /** + * Le menu contextuel lors d'un clic droit sur la table. + * + * @param ui sending view ui + * @param table of offers + * @param model of table + * @param e event du clic + */ + protected void showOfferListContextMenu(final SendingViewUI ui, JXTable table, OfferListTableModel model, MouseEvent e) { + + // Enable menu only if session is active + boolean enabled = ui.getSession() != null && ui.isNotClosed(); + + JPopupMenu menu = new JPopupMenu(); + + // Menu to add user or group sending + JMenuItem removeFormFromSession = new JMenuItem(_("vradi.email.removeFormFromSession")); + + removeFormFromSession.setEnabled(enabled); + + if (enabled) { + removeFormFromSession.addActionListener(new RemoveAllFormFromSession(ui, table, model)); + } + + menu.add(removeFormFromSession); + + // Menu to add user or group sending + JMenuItem removeFormFromSessionForUser = new JMenuItem(_("vradi.email.removeFormFromSessionForUser")); + + removeFormFromSessionForUser.setEnabled(enabled); + + if (enabled) { + removeFormFromSessionForUser.addActionListener(new RemoveFormFromSessionForUser(ui, table, model)); + } + + menu.add(removeFormFromSessionForUser); + + int[] selectedRows = table.getSelectedRows(); + final List<String> formsIdsToUpdate = new ArrayList<String>(); + for (int row : selectedRows) { + row = table.convertRowIndexToModel(row); + + FormPagedResult formPage = listTableModel.getFormPagedResult(); + List<String> formsToShow = formPage.getFormsIdsToShow(); + + String formId = formsToShow.get(row); + if (formId != null) { + + Set<String> deletedFormsIds = SendingHelper.extractForms(VradiService.getWikittyProxy(), sending.getDeletedGroupForms()); + if (deletedFormsIds != null) { + if (deletedFormsIds.contains(formId)) { + formsIdsToUpdate.add(formId); + } + + } + } + } + + if (!formsIdsToUpdate.isEmpty()) { + + // Display popup menu + JMenuItem revertDeletion = new JMenuItem(_("vradi.email.forms.revertDeletion")); + revertDeletion.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + EmailHandler handler = UIHelper.getHandler(ui, EmailHandler.class); + handler.revertDeletion(ui, sending, formsIdsToUpdate); + } + }); + + revertDeletion.setEnabled(session != null); + + menu.add(revertDeletion); + } + + menu.show(e.getComponent(), e.getX(), e.getY()); + } + + protected abstract class RemoveFormFromSession implements ActionListener { + + protected List<String> formsIdsToUpdate = new ArrayList<String>(); + + protected SendingViewUI ui; + + protected User user; + + protected Session session; + + protected EmailHandler handler; + + protected RemoveFormFromSession(SendingViewUI ui, JXTable listTable, OfferListTableModel tableModel) { + this.ui = ui; + handler = UIHelper.getHandler(ui, EmailHandler.class); + + Sending sending = ui.getBean(); + user = VradiService.getWikittyProxy().restore(User.class, sending.getUser()); + + session = VradiService.getVradiDataService().getSessionBySending(sending.getWikittyId()); + + int[] selectedRows = listTable.getSelectedRows(); + + for (int row : selectedRows) { + row = listTable.convertRowIndexToModel(row); + + FormPagedResult formPage = tableModel.getFormPagedResult(); + List<String> formsIdsToShow = formPage.getFormsIdsToShow(); + + String formId = formsIdsToShow.get(row); + if (formId != null) { + formsIdsToUpdate.add(formId); + } + } + } + } + + protected class RemoveAllFormFromSession extends RemoveFormFromSession { + + public RemoveAllFormFromSession(SendingViewUI ui, JXTable listTable, OfferListTableModel tableModel) { + super(ui, listTable, tableModel); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (handler.askToRemoveAllForm(ui, EmailDataHelper.convertFormsIdsToString(formsIdsToUpdate))) { + VradiTask<Void> removeFormsFromSessionTask = new VradiTask<Void>(ui) { + @Override + public Void doAction() throws Exception { + VradiService.getVradiStorageService().removeFormsFromSession(session.getWikittyId(), formsIdsToUpdate); + return null; + } + }; + removeFormsFromSessionTask.execute(); + } + } + } + + protected class RemoveFormFromSessionForUser extends RemoveFormFromSession { + + public RemoveFormFromSessionForUser(SendingViewUI ui, JXTable listTable, OfferListTableModel tableModel) { + super(ui, listTable, tableModel); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (handler.askToRemoveUserForm(ui, EmailDataHelper.convertFormsIdsToString(formsIdsToUpdate), user.getName())) { + handler.removeUserSending(ui, session, formsIdsToUpdate, new Object[]{user}, false); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/helpers/SendingViewManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/AbstractEmailNodeLoador.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/AbstractEmailNodeLoador.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/AbstractEmailNodeLoador.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,59 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.tree.loadors.AbstractVradiNodeLoadors; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.List; + +/** @author sletellier <letellier@codelutin.com> */ +public abstract class AbstractEmailNodeLoador<B extends BusinessEntity> extends AbstractVradiNodeLoadors<B> { + + static private final Log log = LogFactory.getLog(AbstractEmailNodeLoador.class); + + protected AbstractEmailNodeLoador(Class<B> beanType) { + super(beanType); + } + + public List<Sending> getSendingList(NavDataProvider dataProvider, String sessionId) { + + // Get proxy + WikittyProxy proxy = getProxy(dataProvider); + + // Restore session + Session session = proxy.restore(Session.class, sessionId); + + // Get all sending ids + return EmailDataHelper.getAllSending(session); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/AbstractEmailNodeLoador.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailFormNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailFormNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailFormNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** @author sletellier <letellier@codelutin.com> */ +public class EmailFormNodeLoadors extends AbstractEmailNodeLoador<Form> { + + public EmailFormNodeLoadors() { + super(Form.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + + // Get sending of session + List<Sending> sendings = getSendingList(dataProvider, parentId); + + // Extract clients ids + List<String> formsIdsToDisplay = new ArrayList<String>(); + for (Sending sending : sendings) { + if (sending != null) { + Set<String> formsIds = SendingHelper.extractForms(wikittyProxy, sending.getGroupForms()); + if (formsIds != null) { + formsIdsToDisplay.addAll(formsIds); + } + Set<String> deletedFormsIds = SendingHelper.extractForms(wikittyProxy, sending.getDeletedGroupForms()); + if (deletedFormsIds != null) { + formsIdsToDisplay.addAll(deletedFormsIds); + } + } + } + + // Sort + List<Form> formSorted = wikittyProxy.restore(Form.class, formsIdsToDisplay); + Collections.sort(formSorted, VradiComparators.FORM_COMPARATOR); + + // Return forms + return extractIds(formSorted); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailFormNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,81 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** @author sletellier <letellier@codelutin.com> */ +public class EmailGroupNodeLoadors extends AbstractEmailNodeLoador<Group> { + + private static final Log log = LogFactory.getLog(EmailGroupNodeLoadors.class); + + protected String sessionId; + + public EmailGroupNodeLoadors() { + super(Group.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + sessionId = parentId; + + // Get sending of session + List<Sending> sendings = getSendingList(dataProvider, parentId); + + // Extract group ids + List<String> groupIds = new ArrayList<String>(); + for (Sending sending : sendings) { + groupIds.addAll(EmailDataHelper.findAllGroupsConcernedBySending(sending)); + } + + // Sort + List<Group> groupSorted = VradiService.getWikittyProxy().restore(Group.class, groupIds); + Collections.sort(groupSorted, VradiComparators.GROUP_COMPARATOR); + + // Return groups + return extractIds(groupSorted); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + EmailGroupUsersNodeLoadors usersLoador = NavHelper.getChildLoador(EmailGroupUsersNodeLoadors.class); + usersLoador.setSessionId(sessionId); + return createVradiNode(id, usersLoador); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupUsersNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupUsersNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupUsersNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,103 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.apache.commons.collections.CollectionUtils; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** @author sletellier <letellier@codelutin.com> */ +public class EmailGroupUsersNodeLoadors extends AbstractEmailNodeLoador<User> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6834221183179682758L; + + protected String sessionId; + + public EmailGroupUsersNodeLoadors() { + super(User.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + if (parentId == null) { + return null; + } + + WikittyProxy proxy = getProxy(dataProvider); + + // Restore parent + Group group = proxy.restore(Group.class, parentId); + + List<User> users = null; + Set<String> groupUserIds = group.getUser(); + if (CollectionUtils.isNotEmpty(groupUserIds)) { + List<String> usersIds = new ArrayList<String>(); + + // Get sending for session + List<Sending> sendings = getSendingList(dataProvider, sessionId); + for (Sending sending : sendings) { + if (sending != null) { + if (groupUserIds != null) { + String sendingUserId = sending.getUser(); + + // If user is concerned + if (groupUserIds.contains(sendingUserId)) { + usersIds.add(sendingUserId); + } + } + } + } + + // Sort + users = VradiService.getWikittyProxy().restore(User.class, usersIds); + Collections.sort(users, VradiComparators.USER_COMPARATOR); + } + + // Return users of group + return extractIds(users); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailGroupUsersNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailUsersNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailUsersNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailUsersNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,72 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** @author sletellier <letellier@codelutin.com> */ +public class EmailUsersNodeLoadors extends AbstractEmailNodeLoador<User> { + + public EmailUsersNodeLoadors() { + super(User.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // Get sending of session + List<Sending> sendings = getSendingList(dataProvider, parentId); + + // Extract clients ids + List<String> userIds = new ArrayList<String>(); + for (Sending sending : sendings) { + if (sending != null) { + String userId = sending.getUser(); + userIds.add(userId); + } + } + + // Sort + List<User> userSorted = VradiService.getWikittyProxy().restore(User.class, userIds); + Collections.sort(userSorted, VradiComparators.USER_COMPARATOR); + + // Return clients + return extractIds(userSorted); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + return createVradiNode(id); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/loadors/EmailUsersNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/EmailEntityModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/EmailEntityModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/EmailEntityModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,132 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.models; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.renderers.EmailFormsListCellRenderer; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.DefaultListModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** @author letellier */ +public abstract class EmailEntityModel<E extends BusinessEntity> extends DefaultListModel implements VradiEntitiesListener<Sending> { + + /** Logger */ + private static final Log log = LogFactory.getLog(EmailEntityModel.class); + + protected EmailFormsListCellRenderer renderer; + + protected Map<String, E> datas; + + protected Session session; + + protected Form form; + + public EmailEntityModel(EmailFormsListCellRenderer renderer, Session session, Form form) { + this.renderer = renderer; + datas = new HashMap<String, E>(); + this.session = session; + this.form = form; + + updateModel(session, form); + + VradiContext.get().getVradiNotifier().addVradiListener(Sending.class, this); + } + + @Override + public int getSize() { + return datas.size(); + } + + public abstract void updateModel(Session session, Form form); + + @Override + public Object getElementAt(int index) { + List<String> keys = new ArrayList<String>(datas.keySet()); + return datas.get(keys.get(index)); + } + + protected void updateDatas(List<E> datas) { + if (datas == null) { + return; + } +// datas.clear(); + for (E data : datas) { + if (data != null) { + this.datas.put(data.getWikittyId(), data); + } + } + fireContentsChanged(this, 0, getSize()); + } + + protected void refresh() { + if (log.isDebugEnabled()) { + log.debug("Refresh datas"); + } + + session = VradiService.getWikittyProxy().restore(Session.class, session.getWikittyId()); + renderer.updateDatas(session, form.getWikittyId()); + updateModel(session, form); + } + + @Override + public void entitiesAdded(Set<Sending> added) { + refreshIfNeeded(VradiHelper.extractIds(added)); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + refreshIfNeeded(removed); + } + + protected void refreshIfNeeded(Collection<String> sendingsIds) { + + boolean mustBeRefresh = false; + for (String sendingId : sendingsIds) { + Session restoredSession = VradiService.getVradiDataService().getSessionBySending(sendingId); + if (session.equals(restoredSession)) { + mustBeRefresh = true; + break; + } + } + if (mustBeRefresh) { + refresh(); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/EmailEntityModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/GroupEmailEntityModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/GroupEmailEntityModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/GroupEmailEntityModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,47 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.models; + +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.email.renderers.EmailFormsListCellRenderer; + +import java.util.List; + +/** @author letellier */ +public class GroupEmailEntityModel extends EmailEntityModel<Group> { + + public GroupEmailEntityModel(EmailFormsListCellRenderer renderer, Session session, Form form) { + super(renderer, session, form); + } + + @Override + public void updateModel(Session session, Form form) { + List<Group> groupSending = EmailDataHelper.getGroupsSendingConcernedBy(session, form.getWikittyId()); + updateDatas(groupSending); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/GroupEmailEntityModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/UserEmailEntityModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/UserEmailEntityModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/UserEmailEntityModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,46 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.models; + +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.email.renderers.EmailFormsListCellRenderer; + +/** @author letellier */ +public class UserEmailEntityModel extends EmailEntityModel<User> { + + public UserEmailEntityModel(EmailFormsListCellRenderer renderer, Session session, Form form) { + super(renderer, session, form); + } + + @Override + public void updateModel(Session session, Form form) { + + java.util.List<User> userSending = EmailDataHelper.getUsersSendingConcernedBy(session, form.getWikittyId()); + updateDatas(userSending); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/models/UserEmailEntityModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,137 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.renderers; + +import jaxx.runtime.swing.nav.tree.AbstractNavTreeCellRenderer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.ui.email.helpers.EmailBeanConstant; +import org.chorem.vradi.ui.email.helpers.EmailNavigationTreeHelper; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.JLabel; +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeModel; +import java.awt.Component; + +/** + * @author letellier + * @see AbstractNavTreeCellRenderer + */ +public class EmailCellRenderer extends AbstractNavTreeCellRenderer<DefaultTreeModel, VradiTreeNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7917305304778635796L; + + /** Logger */ + protected static final Log log = LogFactory.getLog(EmailCellRenderer.class); + + /** + * Init renderer. + * + * @param decoratorProvider ??? + * @param dataProvider data provider + */ + public EmailCellRenderer(VradiDataProvider dataProvider) { + + setDataProvider(dataProvider); + } + + @Override + protected String computeNodeText(VradiTreeNode node) { + + // get decorator + EmailBeanConstant constant = getEmailConstant(node); + + // Get bean + BusinessEntity bean = getEmailBean(constant, node.getId()); + + // Get session + Session session = EmailNavigationTreeHelper.getParentSession(node); + + // Decorate + String decorated = constant.decorate(session, bean); + + if (log.isDebugEnabled()) { + log.debug("Compute text for node " + node + " return " + decorated); + } + + return decorated; + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, int row, + boolean hasFocus) { + + // get node + VradiTreeNode node = (VradiTreeNode) value; + + // get text for node + String text = getNodeText(node); + + // Render node + JLabel jLabel = (JLabel) super.getTreeCellRendererComponent(tree, text, sel, + expanded, leaf, + row, hasFocus); + + // get decorator + EmailBeanConstant constant = getEmailConstant(node); + + // Not for root node + if (constant != null) { + + // Get bean + BusinessEntity bean = getEmailBean(constant, node.getId()); + + // Get toolTipText + String toolTipText = constant.getToolTipText(bean); + + // Add toolTip + jLabel.setToolTipText(toolTipText); + } + + return jLabel; + } + + protected EmailBeanConstant getEmailConstant(VradiTreeNode node) { + // Get node type + Class<?> editType = node.getInternalClass(); + + // get decorator + return EmailBeanConstant.getConstantByBeanClass(editType); + } + + protected BusinessEntity getEmailBean(EmailBeanConstant constant, String id) { + // get decorator + return constant.getBean((VradiDataProvider) getDataProvider(), id); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsHighlighter.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsHighlighter.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsHighlighter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.renderers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.jdesktop.swingx.decorator.AbstractHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; + +import javax.swing.ListModel; +import java.awt.Color; +import java.awt.Component; +import java.util.Collection; + +/** + * Highlighter to cross of deleted forms + * + * @author letellier + */ +public class EmailFormsHighlighter extends AbstractHighlighter { + + static private final Log log = LogFactory.getLog(EmailFormsHighlighter.class); + + protected OfferListTableModel listTableModel; + + protected ListModel listModel; + + protected Collection<String> formsDeleted; + + protected Collection<String> formsAdded; + + public EmailFormsHighlighter(OfferListTableModel listTableModel) { + this.listTableModel = listTableModel; + } + + public void setFormsAdded(Collection<String> formsAdded) { + this.formsAdded = formsAdded; + } + + public void setFormsDeleted(Collection<String> formsDeleted) { + this.formsDeleted = formsDeleted; + } + + public void notifyChange() { + super.fireStateChanged(); + } + + @Override + protected Component doHighlight(Component component, ComponentAdapter adapter) { + String formId = listTableModel.getFormIdAt(adapter.row); + if (formsDeleted != null && formsDeleted.contains(formId)) { + component = UIHelper.crossOf(component); + } + if (formsAdded != null && formsAdded.contains(formId)) { + component.setForeground(Color.BLUE); + } + return component; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsHighlighter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsListCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsListCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsListCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,194 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.renderers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.SendingHelper; +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.GroupForms; +import org.chorem.vradi.entities.Sending; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import java.awt.Color; +import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class EmailFormsListCellRenderer extends DefaultListCellRenderer { + + private static final Log log = LogFactory.getLog(EmailFormsListCellRenderer.class); + + protected Session sessionConcerned; + + protected String formConcerned; + + protected List<Object> cachedDeletion; + + protected Map<String, String> cachedRendered; + + protected Map<String, Boolean> cachedAdded; + + public EmailFormsListCellRenderer() { + cachedDeletion = new ArrayList<Object>(); + cachedRendered = new HashMap<String, String>(); + cachedAdded = new HashMap<String, Boolean>(); + } + + public void updateDatas(Session sessionConcerned, String formConcerned) { + this.sessionConcerned = sessionConcerned; + this.formConcerned = formConcerned; + clearCaches(); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + if (value == null) { + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + + String wikittyId = ((BusinessEntity) value).getWikittyId(); + String renderedText = cachedRendered.get(wikittyId); + if (renderedText != null) { + Component rendered = super.getListCellRendererComponent(list, renderedText, index, isSelected, cellHasFocus); + Boolean added = cachedAdded.get(wikittyId); + if (added != null && added) { + rendered.setForeground(Color.BLUE); + } + return rendered; + } + + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + boolean isAdded = false; + + if (value instanceof User) { + User user = (User) value; + + // Get user text + String clientId = user.getClient(); + Client client = VradiService.getWikittyProxy().restore( + Client.class, clientId); + String clientString = ""; + if (client != null) { + clientString = client.getName() + " - "; + } + renderedText = clientString + user.getName(); + + Sending sending = EmailDataHelper.getUserSending(sessionConcerned, user); + if (sending != null) { + Set<String> deletedForms = SendingHelper.extractForms(wikittyProxy, sending.getDeletedGroupForms()); + if (deletedForms != null && deletedForms.contains(formConcerned)) { + cachedDeletion.add(value); + renderedText = UIHelper.crossOf(renderedText); + } + Set<String> addedForms = SendingHelper.extractForms(wikittyProxy, sending.getAddedGroupForms()); + if (addedForms != null && addedForms.contains(formConcerned)) { + isAdded = true; + } + } + } else if (value instanceof Group) { + Group group = (Group) value; + + renderedText = group.getName(); + + Set<String> userIds = group.getUser(); + if (userIds != null) { + int deletedCount = 0; + List<Sending> sendings = EmailDataHelper.getUsersSendings(sessionConcerned, userIds); + for (Sending sending : sendings) { + if (sending != null) { + Set<String> groupFormsDeletedIds = sending.getDeletedGroupForms(); + if (groupFormsDeletedIds != null) { + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormsDeletedIds)); + for (GroupForms groupForm : groupForms) { + if (groupForm.getForm() != null && groupForm.getForm().contains(formConcerned)) { + + deletedCount++; + break; + } + } + } + Set<String> groupFormsAddedIds = sending.getAddedGroupForms(); + if (groupFormsAddedIds != null) { + List<GroupForms> groupForms = wikittyProxy.restore(GroupForms.class, new ArrayList<String>(groupFormsAddedIds)); + for (GroupForms groupForm : groupForms) { + String groupId = groupForm.getGroup(); + if (groupId != null && groupId.equals(group.getWikittyId()) && + groupForm.getForm() != null && groupForm.getForm().contains(formConcerned)) { + + isAdded = true; + break; + } + } + } + } + } + + // If all are deleted + if (deletedCount == sendings.size()) { + cachedDeletion.add(value); + + renderedText = UIHelper.crossOf(renderedText); + } + } + } + + cachedRendered.put(wikittyId, renderedText); + cachedAdded.put(wikittyId, isAdded); + Component rendered = super.getListCellRendererComponent(list, renderedText, index, isSelected, cellHasFocus); + if (isAdded) { + rendered.setForeground(Color.BLUE); + } + return rendered; + } + + public boolean isDeleted(Object o) { + return cachedDeletion.contains(o); + } + + public boolean areDeleted(Object[] o) { + return cachedDeletion.containsAll(Arrays.asList(o)); + } + + public void clearCaches() { + cachedDeletion.clear(); + cachedRendered.clear(); + cachedAdded.clear(); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/renderers/EmailFormsListCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/AttachmentSessionFileHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/AttachmentSessionFileHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/AttachmentSessionFileHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,81 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.email.widgets; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.email.EmailHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionFileHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n_; + +/** @author sletellier */ +public class AttachmentSessionFileHandler extends MultipleSelectionFileHandler<Session, EmailHandler> { + + + /** log. */ + private static final Log log = LogFactory.getLog(AttachmentSessionFileHandler.class); + + public AttachmentSessionFileHandler(MultipleSelectionPane ui) { + super(ui, EmailHandler.class, n_("vradi.email.sessionAttachedfile")); + } + + @Override + public File downloadFile(String selected, String wikittyId) throws VradiException { + return VradiService.getFileService().downloadSessionAttachment(selected, getBean().getWikittyId()); + } + + @Override + public List<String> removeFiles(Session bean, List<String> selectedInList) { + List<String> result = getHandler().removeAttachmentFile(getBean(), getSelectedInList()); + updateSession(); + return result; + } + + @Override + public Set<String> getFiles() { + return getBean().getFiles(); + } + + @Override + public File addFiles(MultipleSelectionPane ui, Session bean) { + File result = getHandler().addAttachmentFile(ui, getBean()); + updateSession(); + return result; + } + + protected void updateSession() { + Session session = VradiService.getWikittyProxy().restore(Session.class, getBean().getWikittyId()); + setBean(session); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/email/widgets/AttachmentSessionFileHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ToolTipHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ToolTipHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ToolTipHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,240 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.helpers; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.text.DateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** + * ToolTipHelper. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 20 avr. 2010 12:05:07 + */ +public class ToolTipHelper { + + private static final Log log = LogFactory.getLog(ToolTipHelper.class); + + public static final int TOOLTIP_ELEMENT_MAX_CHAR_NB = 500; + + public static String getToolTip(List<Form> forms) { + if (forms == null || forms.isEmpty()) { + return null; + } + + StringBuffer result = new StringBuffer(); + result.append("<html>"); + + int size = forms.size(); + for (int i = 0; i < size && i < 15; i++) { + Form form = forms.get(i); + result.append("- ").append(form.getObjet()).append("<br/>"); + } + + result.append("</html>"); + return result.toString(); + } + + public static String getToolTip(Form form) { + if (form == null) { + return null; + } + + Map<String, Object> fieldValues = new LinkedHashMap<String, Object>(); + + // Form.EXT_FORM + String formFields[] = new String[]{ + Form.FQ_FIELD_FORM_DATEPUB, Form.FQ_FIELD_FORM_DATEPEREMPTION}; + + for (String fieldName : formFields) { + fieldValues.put(fieldName, form.getField(Form.EXT_FORM, + WikittyUtil.getFieldNameFromFQFieldName(fieldName))); + } + + // Infogene.EXT_INFOGENE + String infogeneFields[] = new String[]{ + Infogene.FQ_FIELD_INFOGENE_ID, Infogene.FQ_FIELD_INFOGENE_OBJET, + Infogene.FQ_FIELD_INFOGENE_ENTITY, Infogene.FQ_FIELD_INFOGENE_SOURCETEXT, + Infogene.FQ_FIELD_INFOGENE_DESCRIPTION}; + + for (String fieldName : infogeneFields) { + fieldValues.put(fieldName, form.getField(Infogene.EXT_INFOGENE, + WikittyUtil.getFieldNameFromFQFieldName(fieldName))); + } + + // others extensions + Collection<String> extensionNames = form.getExtensionNames(); + String formTypeName = null; + for (String extensionName : extensionNames) { + + if (!Form.EXT_FORM.equals(extensionName) + && !Infogene.EXT_INFOGENE.equals(extensionName)) { + + formTypeName = extensionName; + + Collection<String> fieldNames = form + .getExtensionFields(extensionName); + + for (String fieldName : fieldNames) { + fieldValues.put(fieldName, form.getField(extensionName, + fieldName)); + } + } + } + + StringBuffer result = new StringBuffer(); + result.append("<html>"); + + for (Map.Entry<String, Object> entry : fieldValues.entrySet()) { + Object value = entry.getValue(); + String key = entry.getKey(); + + if (value == null) { + continue; + } + + String stringValue; + if (value instanceof Date) { + stringValue = DateFormat.getDateTimeInstance(DateFormat.SHORT, + DateFormat.MEDIUM, Locale.FRANCE).format((Date) value); + } else { + + stringValue = String.valueOf(value); + stringValue = StringUtils.replace(stringValue, "\r", ""); + stringValue = StringUtils.replace(stringValue, "\n\n", "\n"); + stringValue = StringUtils.abbreviate(stringValue, TOOLTIP_ELEMENT_MAX_CHAR_NB); + stringValue = StringUtils.replace(stringValue, "\n", "<br/>"); + } + WikittyExtension formType = null; + try { + formType = VradiService.getVradiDataService().getFormType(formTypeName); + } catch (VradiException e) { + log.error("Failed to load formType : " + formTypeName); + } + + result.append("<strong>").append(VradiHelper.getTraduction(formType, key)).append("</strong>") + .append(" : ").append(stringValue).append("<br/>"); + } + + result.append("</html>"); + String resultToString = result.toString(); + return resultToString; + } + + public static String getEmailThesaurusToolTip(Form form) { + if (form == null) { + return null; + } + + StringBuffer result = new StringBuffer(); + + result.append("<html><h3>"); + + // Add title + result.append(_("vradi.email.thesaurusToolTipTitle")); + result.append("</h3><br/>"); + + try { + List<Thesaurus> thesauruses = VradiService.getVradiDataService().getThesaurusAttachedToForm(form); + + // Add thesaurus name path + for (Thesaurus thesaurus : thesauruses) { + String thesaurusPath = ThesaurusDataHelper.getNamePath(thesaurus, "/"); + result.append(thesaurusPath).append("<br/>"); + } + } catch (VradiException ex) { + throw new RuntimeException("Can't get form thesaurus", ex); + } + + result.append("</html>"); + + return result.toString(); + } + + public static String getThesaurusToolTip(Thesaurus thesaurus) { + + StringBuffer result = new StringBuffer(); + result.append("<html><h3>"); + + // Add title + String name = ThesaurusDataHelper.concateOrderName(thesaurus); + + result.append(_("vradi.thesaurus.toolTipTitle", name)); + result.append("</h3><br/>"); + + String namePath = ThesaurusDataHelper.getNamePath(thesaurus, "/"); + namePath = namePath.replaceAll(name, ""); + String comment = thesaurus.getComment(); + + // Render like + // Path + // Description : blablabla + // Tags : titi, toto, tata + result.append(_("vradi.thesaurus.nameToolTip")).append(namePath).append("<strong>").append(name).append("</strong>").append("<br/>"); + result.append(_("vradi.thesaurus.commentToolTip")).append(comment == null ? "" : comment).append("<br/>"); + result.append(_("vradi.thesaurus.tagsToolTip")).append(ThesaurusDataHelper.getTagsAsString(thesaurus)).append("<br/>"); + + result.append("</html>"); + + return result.toString(); + } + + public static String getThesaurusDescriptionToolTip(Thesaurus thesaurus) { + if (thesaurus == null) { + return null; + } + StringBuffer result = new StringBuffer(); + String comment = thesaurus.getComment(); + if (comment == null || comment.trim().isEmpty()) { + return null; + } + result.append("<html>"); + result.append(comment).append("<br/>"); + result.append("</html>"); + + return result.toString(); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/ToolTipHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/UIHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/UIHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/UIHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,687 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.helpers; + +import au.com.bytecode.opencsv.CSVWriter; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.CardLayout2; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.models.EntityModel; +import org.chorem.vradi.ui.models.FormTypeModel; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.renderers.VradiI18nTableCellRenderer; +import org.jdesktop.swingx.JXTreeTable; +import org.nuiton.widget.SwingSession; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JFileChooser; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.ListCellRenderer; +import javax.swing.ListModel; +import javax.swing.SwingUtilities; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.NumberFormatter; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.Component; +import java.awt.Desktop; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.text.NumberFormat; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * Classe de méthodes utiles pour les ui. + * <p/> + * User: chemit + * Date: 23 nov. 2009 + * Time: 11:51:14 + */ +public class UIHelper extends SwingUtil { + + /** Logger. */ + private static final Log log = LogFactory.getLog(UIHelper.class); + + public static final String INFOGENE_KEY_PREFIX = "vradi.infogene."; + + public static final String FORM_KEY_PREFIX = "vradi.form."; + + private UIHelper() { + // pas d'instance + } + + /** + * Return traduction of infogene field pass in param + * + * @param key to traduct + * @return traducted + */ + public static String getInfogeneTraduction(String key) { + return _(INFOGENE_KEY_PREFIX + key); + } + + /** + * Return traduction of form field pass in param + * + * @param key to traduct + * @return traducted + */ + public static String getFormTraduction(String key) { + return _(FORM_KEY_PREFIX + key); + } + + /** + * Met à jour le modèle de sélection {@code list} donnée avec l'objet {@code value} entrant. + * <p/> + * {@code value} represente normalement une collection de données. + * + * @param list la liste à updater + * @param value la liste des valeurs de la selection de la liste. + */ + public static void updateListSelection(JList list, Object value) { + + list.setValueIsAdjusting(true); + list.clearSelection(); + + try { + if (value != null) { + + // la valeur doit être une collection, on met a jour le model de selection + int size = list.getModel().getSize(); + Collection<?> valuesToSelect = (Collection<?>) value; + int[] indexToSelect = new int[valuesToSelect.size()]; + int index = 0; + for (Object v : valuesToSelect) { + for (int i = 0; i < size; i++) { + Object o = list.getModel().getElementAt(i); + if (o.equals(v)) { + indexToSelect[index++] = i; + break; + } + } + } + if (log.isTraceEnabled()) { + log.trace("index to select = " + Arrays.toString(indexToSelect)); + } + list.setSelectedIndices(indexToSelect); + } + + } finally { + + list.setValueIsAdjusting(false); + } + } + + // I18n + public static void setI18nTableHeaderRenderer(JTable table, String... libelles) { + table.getTableHeader().setDefaultRenderer(new VradiI18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles)); + } + + /** + * Ouvre un navigateur sur google maps. + * <p/> + * Utilisé dans les champs "address" des clients et des utilisateurs. + * + * @param address address to browse + */ + public static void openAddressInBrowser(String address) { + if (address != null) { + try { + browseURI("http://maps.google.fr/maps?f=q&source=s_q&hl=fr&geocode=&q=" + + getStringValue(address) + ",France"); + } catch (IOException eee) { + log.error("Cant display page for address : " + + getStringValue(address), eee); + JOptionPane.showMessageDialog(null, + _("vradi.message.cannot.display.address")); + + } + } + } + + public static void browseURI(URI uri) throws IOException { + if (uri != null) { + if (log.isDebugEnabled()) { + log.debug("Browse URI : " + uri.toString()); + } + Desktop desktop = Desktop.getDesktop(); + desktop.browse(uri); + } + } + + public static void browseURI(String uri) throws IOException { + if (uri != null) { + try { + browseURI(new URI(uri.replace(" ", "+"))); + } catch (URISyntaxException eee) { + log.error("Cant display uri : " + uri, eee); + ErrorDialogUI.showError(eee); + } + } + } + + public static void browseURI(URL url) throws IOException { + if (url != null) { + String externalForm = url.toExternalForm(); + browseURI(externalForm); + } + } + + public static void createEmail(String emailAdress) + throws IOException, URISyntaxException, UnsupportedOperationException { + URI mailtoURI = new URI("mailto:" + emailAdress); + Desktop.getDesktop().mail(mailtoURI); + } + + /** + * Export la table des résultats de recherche au format CSV. + * + * @param file file to export to + * @param model model to export + */ + public static void exportToCSV(File file, OfferListTableModel model) { + try { + FileWriter fileWriter = new FileWriter(file); + CSVWriter csvWriter = new CSVWriter(fileWriter); + + int columnCount = model.getColumnCount(); + String[] nextLine = new String[columnCount]; + + // writes headers + for (int i = 0; i < model.getColumnCount(); i++) { + nextLine[i] = _(model.getColumnName(i)); + } + csvWriter.writeNext(nextLine); + + // writes row values + for (int i = 0; i < model.getRowCount(); i++) { + nextLine = new String[columnCount]; + + for (int j = 0; j < model.getColumnCount(); j++) { + Object valueAt = model.getValueAt(i, j); + if (valueAt != null) { + String value = String.valueOf(valueAt); + if (valueAt instanceof Status) { + value = ((Status) valueAt).getName(); + } else if (valueAt instanceof XmlStream) { + value = ((XmlStream) valueAt).getName(); + } + + nextLine[j] = value; + } + } + csvWriter.writeNext(nextLine); + + } + csvWriter.close(); + + } catch (IOException e) { + log.error(e.getMessage(), e); + ErrorDialogUI.showError(e); + } + } + + /** + * Ouvre un file chooser configuré sur un certain type de fichier et + * retourne le fichier choisit par l'utilisateur. + * + * @param fileExtension extension with begin "." + * @param description filter description + * @param component parent component + * @param validationLabel ok button label + * @return selected file or {@code null} + */ + public static File openFileChooser(final String fileExtension, final String description, Component component, String validationLabel) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setAcceptAllFileFilterUsed(false); + fileChooser.setFileFilter(new FileFilter() { + + @Override + public boolean accept(File file) { + if (file.isDirectory()) { + return true; + } + + String ext = null; + String fileName = file.getName(); + int dot = fileName.lastIndexOf('.'); + + if (dot > 0 && dot < fileName.length() - 1) { + ext = fileName.substring(dot).toLowerCase(); + } + return ext != null && ext.equals(fileExtension); + } + + @Override + public String getDescription() { + return description; + } + }); + + int returnVal = fileChooser.showDialog(component, validationLabel); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + if (!file.getName().endsWith(fileExtension)) { + file = new File(file.getAbsolutePath() + fileExtension); + } + log.debug("saving : " + file.getName() + "."); + return file; + } else { + log.debug("No file chosen by user."); + return null; + } + } + + public static ListCellRenderer getTranslationListCellRenderer() { + return new DefaultListCellRenderer() { + + @Override + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + if (value != null) { + return super.getListCellRendererComponent(list, _(value.toString()), index, + isSelected, cellHasFocus); + } else { + return super.getListCellRendererComponent(list, value, index, + isSelected, cellHasFocus); + } + } + + }; + } + + public static <T> T getHandler(JAXXContext context, Class<T> handlerClass) { + T handler = context.getContextValue(handlerClass); + if (handler != null) { + return handler; + } + try { + handler = handlerClass.newInstance(); + } catch (InstantiationException e) { + log.error("Cant create handler instance of type " + handlerClass.getName() + " : ", e); + ErrorDialogUI.showError(e); + } catch (IllegalAccessException e) { + log.error("Cant create handler instance of type " + handlerClass.getName() + " : ", e); + ErrorDialogUI.showError(e); + } + + if (context instanceof JAXXInitialContext) { + ((JAXXInitialContext) context).add(handler); + } else { + context.setContextValue(handler); + } + return handler; + } + + /** + * Return an initialized ComboBoxModel with int from startIndex and filled + * with nbData. + * (used in xmlstream import time config) + * + * @param startIndex start index + * @param nbData nb data + * @return ComboBoxModel + */ + public static ComboBoxModel getNumberComboBoxModel(int startIndex, int nbData) { + Object[] data = new Integer[nbData]; + for (int i = startIndex; i < data.length; i++) { + data[i] = i; + } + return new DefaultComboBoxModel(data); + } + + /** + * Return an initialized ComboBoxModel with int from 0 to nbData. + * (used in xmlstream import time config) + * + * @param nbData nb data + * @return ComboBoxModel + */ + public static ComboBoxModel getNumberComboBoxModel(int nbData) { + return getNumberComboBoxModel(0, nbData); + } + + /** + * Return an initialized ComboBoxModel with int from 0 to 24. + * (used in xmlstream import time config) + * + * @return ComboBoxModel + */ + public static ComboBoxModel getHourModel() { + return getNumberComboBoxModel(24); + } + + /** + * Return an initialized ComboBoxModel with int from 0 to 60. + * (used in xmlstream import time config) + * + * @return ComboBoxModel + */ + public static ComboBoxModel getMinuteModel() { + return getNumberComboBoxModel(60); + } + + /** + * Get time list renderer (hour or minutes). + * + * @return ListCellRenderer + */ + public static ListCellRenderer get2DigitsRenderer() { + return new DefaultListCellRenderer() { + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + String stringValue = null; + if (value != null) { + stringValue = (Integer) value < 10 ? "0" + value.toString() : value.toString(); + } + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); + } + }; + } + + /** + * Return i18n translation for {@code value}. + * + * @return i18n transaltion + */ + public static ListCellRenderer getTranslationRenderer() { + return new DefaultListCellRenderer() { + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + String stringValue = null; + if (value != null) { + stringValue = value.toString(); + } + return super.getListCellRendererComponent(list, _(stringValue), index, isSelected, cellHasFocus); + } + }; + } + + public static VradiDataService getDataService() { + return VradiService.getVradiDataService(); + } + + public static EntityModel<Group> getGroupModel(boolean firstNull) { + List<Group> groupList = getDataService().findAllGroups(); + + // Sort + Collections.sort(groupList, VradiComparators.GROUP_COMPARATOR); + EntityModel<Group> entityModel = new EntityModel<Group>(Group.class, groupList, firstNull); + return entityModel; + } + + public static EntityModel<XmlStream> getXmlStreamsModel() { + List<XmlStream> streamList = getDataService().findAllXmlStreams(); + + // Sort + Collections.sort(streamList, VradiComparators.XML_STREAM_COMPARATOR); + EntityModel<XmlStream> entityModel = new EntityModel<XmlStream>(XmlStream.class, streamList); + return entityModel; + } + + public static ListModel getStatusesModel(boolean firstNull) { + List<Status> status = AdminHandler.getAllStatuses(); + EntityModel<Status> entityModel = new EntityModel<Status>(Status.class, status, firstNull); + return entityModel; + } + + /** + * Return status cell renderer (translate i18n status name key). + * + * @return ListCellRenderer + */ + public static ListCellRenderer getStatusCellRenderer() { + return new DefaultListCellRenderer() { + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Status status = (Status) value; + return super.getListCellRendererComponent(list, _(status.getName()), index, isSelected, cellHasFocus); + } + }; + } + + public static ComboBoxModel getFormTypesModel() { + return new FormTypeModel(false); + } + + public static ComboBoxModel getFormTypesModel(boolean firstNull) { + return new FormTypeModel(firstNull); + } + + /** + * Get content if exist in content, else return null + * + * @param contentLayout layout to search + * @param content concerned + * @param uiClass class of ui searched + * @return content if found + */ + public static <E extends Component> E getContentIfExist(CardLayout2 contentLayout, JPanel content, Class<E> uiClass) { + String contentName = uiClass.getName(); + if (log.isDebugEnabled()) { + log.debug("Get content if exist " + contentName); + } + if (!contentLayout.contains(contentName)) { + return null; + } + return (E) contentLayout.getComponent(content, contentName); + } + + /** NumberFormatterFactory creates a new NumberFormatter for Integer of variable length. */ + public static class NumberFormatterFactory extends JFormattedTextField.AbstractFormatterFactory { + @Override + public JFormattedTextField.AbstractFormatter getFormatter(JFormattedTextField jFormattedTextField) { + NumberFormat numberFormat = NumberFormat.getIntegerInstance(); + NumberFormatter numberFormatter = new NumberFormatter(numberFormat); + numberFormatter.setAllowsInvalid(false); + numberFormatter.setValueClass(Integer.class); + return numberFormatter; + } + } + + /** + * Used to cross of text + * + * @param text to cross of + * @return text crossed of + */ + public static String crossOf(String text) { + return "<html><strike>" + text + "</strike></html>"; + } + + /** + * Used to cross of component + * + * @param component to cross of + * @return component crossed of + */ + public static Component crossOf(Component component) { + if (component instanceof JLabel) { + JLabel label = (JLabel) component; + label.setText(crossOf(label.getText())); + + return label; + } + return component; + } + + /** + * To keep ui diposition + * + * @param c to register + */ + public static void registerComponentToSaveDispositionConfig(Component c) { + VradiContext.SWING_SESSION_ENTRY_DEF.getContextValue(VradiContext.get()).add(c); + } + + /** To save ui diposition */ + public static void saveComponentDispositionConfig() { + SwingSession swingSession = VradiContext.SWING_SESSION_ENTRY_DEF.getContextValue(VradiContext.get()); + swingSession.save(); + } + + /** + * Add a listener of tree selection model to expand a new selected node + * when it is selected. + * + * @param tree the tree to treate + */ + public static void addThesaurusExpandOnClickListener(final JTree tree) { + + tree.getSelectionModel().addTreeSelectionListener( + new TreeSelectionListener() { + + @Override + public void valueChanged(final TreeSelectionEvent e) { + + boolean isThesaurusExpanded = VradiHelper.isOnClickThesaurusExpanded(); + + if (!isThesaurusExpanded) { + return; + } + + TreeNode node = (TreeNode) + e.getPath().getLastPathComponent(); + if (node != null && !node.isLeaf()) { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + for (TreePath path : e.getPaths()) { + if (e.isAddedPath(path) && + !tree.isExpanded(path)) { + if (log.isDebugEnabled()) { + log.debug("expand node [" + path + + "]"); + } + + // will expand the node + tree.expandPath(path); + } + } + } + }); + } + } + }); + } + + /** + * Add a listener of tree selection model to expand a new selected node + * when it is selected. + * + * @param treeTable the treeTable to treate + */ + public static void addThesaurusExpandOnClickListener(final JXTreeTable treeTable) { + + treeTable.addTreeSelectionListener( + new TreeSelectionListener() { + + @Override + public void valueChanged(final TreeSelectionEvent e) { + + TreeNode node = (TreeNode) + e.getPath().getLastPathComponent(); + if (node != null && !node.isLeaf()) { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + boolean isThesaurusExpanded = VradiHelper.isOnClickThesaurusExpanded(); + for (TreePath path : e.getPaths()) { + if (e.isAddedPath(path) && + !treeTable.isExpanded(path)) { + + if (log.isDebugEnabled()) { + log.debug("expand node [" + path + + "]"); + } + + if (isThesaurusExpanded) { + + treeTable.expandPath(path); + } + + // Keep selection + treeTable.getTreeSelectionModel().setSelectionPath(path); + } + } + } + }); + } + } + }); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/UIHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/VradiComparators.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/VradiComparators.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/VradiComparators.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,253 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.helpers; + +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.WikittyExtension; + +import java.io.Serializable; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * VradiComparators. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 12 mars 2010 16:56:44 + */ +public class VradiComparators { + + public static class BusinessEntityComparator<T extends BusinessEntity> implements Comparator<T>, Serializable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + final String extension; + + final String field; + + public BusinessEntityComparator(String extension, String field) { + this.extension = extension; + this.field = field; + } + + @Override + public int compare(T o1, T o2) { + if (o1 != null && o2 != null) { + + Object name1 = o1.getField(extension, field); + Object name2 = o2.getField(extension, field); + + if (name1 != null && name2 != null) { + String string1 = WikittyUtil.toString(name1); + String string2 = WikittyUtil.toString(name2); + + return string1.compareToIgnoreCase(string2); + + } else if (name1 != null) { + return 1; + + } else if (name2 != null) { + return -1; + } + + } else if (o1 != null) { + return 1; + + } else if (o2 != null) { + return -1; + } + + return 0; + } + } + + ; + + public static final Comparator<Form> FORM_COMPARATOR = + new BusinessEntityComparator<Form>(Form.EXT_INFOGENE, Form.FIELD_INFOGENE_OBJET); + + public static final Comparator<Client> CLIENT_COMPARATOR = + new BusinessEntityComparator<Client>(Client.EXT_CLIENT, Client.FIELD_CLIENT_NAME); + + public static final Comparator<Group> GROUP_COMPARATOR = + new BusinessEntityComparator<Group>(Group.EXT_GROUP, Group.FIELD_GROUP_NAME); + + public static final Comparator<Status> STATUSES_COMPARATOR = + new BusinessEntityComparator<Status>(Status.EXT_STATUS, Status.FIELD_STATUS_VALUE); + + public static final Comparator<XmlStream> XML_STREAM_COMPARATOR = + new BusinessEntityComparator<XmlStream>(XmlStream.EXT_XMLSTREAM, XmlStream.FIELD_XMLSTREAM_NAME); + + public static final Comparator<WikittyExtension> EXTENSION_COMPARATOR = new Comparator<WikittyExtension>() { + @Override + public int compare(WikittyExtension o1, WikittyExtension o2) { + if (o1 != null && o2 != null) { + + String name1 = o1.getName(); + String name2 = o2.getName(); + + if (name1 != null && name2 != null) { + return name1.compareToIgnoreCase(name2); + + } else if (name1 != null) { + return 1; + + } else if (name2 != null) { + return -1; + } + + } else if (o1 != null) { + return 1; + + } else if (o2 != null) { + return -1; + } + + return 0; + } + }; + + /** Compares User by client.getName() + ":" + getName(). */ + public static final Comparator<User> USER_COMPARATOR = new Comparator<User>() { + @Override + public int compare(User o1, User o2) { + if (o1 != null && o2 != null) { + + + WikittyProxy proxy = VradiService.getWikittyProxy(); + Client client1 = proxy.restore(Client.class, o1.getClient()); + Client client2 = proxy.restore(Client.class, o2.getClient()); + + String name1 = client1.getName() + ":" + o1.getName(); + String name2 = client2.getName() + ":" + o2.getName(); + return name1.compareToIgnoreCase(name2); + + } else if (o1 != null) { + return 1; + + } else if (o2 != null) { + return -1; + } + + return 0; + } + }; + + /** Compares User by client.getName() + ":" + getName(). */ + public static final Comparator<User> USER_COMPARATOR_WITH_ALL_CLIENT_LOADED = new UserComparator(); + + public static class UserComparator implements Comparator<User> { + + protected Map<String, Client> clientsLoaded = new HashMap<String, Client>(); + + public UserComparator() { + loadClient(VradiService.getVradiDataService().findAllClients()); + } + + public UserComparator(List<Client> clientsLoad) { + loadClient(clientsLoad); + } + + protected void loadClient(List<Client> clients) { + for (Client client : clients) { + clientsLoaded.put(client.getWikittyId(), client); + } + } + + @Override + public int compare(User o1, User o2) { + if (o1 != null && o2 != null) { + + Client client1 = clientsLoaded.get(o1.getClient()); + Client client2 = clientsLoaded.get(o2.getClient()); + + String name1 = client1.getName() + ":" + o1.getName(); + String name2 = client2.getName() + ":" + o2.getName(); + return name1.compareToIgnoreCase(name2); + + } else if (o1 != null) { + return 1; + + } else if (o2 != null) { + return -1; + } + + return 0; + } + } + + /** Compares VradiThesaurusDTO by namePath : parentPath/getOrder() + ":" + getName(). */ + public static final Comparator<Thesaurus> THESAURUS_NAME_PATH_COMPARATOR = new Comparator<Thesaurus>() { + @Override + public int compare(Thesaurus o1, Thesaurus o2) { + return ThesaurusDataHelper.getNamePath(o1, "/").compareTo(ThesaurusDataHelper.getNamePath(o2, "/")); + } + }; + + /** Compares VradiThesaurusDTO by getOrder() + ":" + getName(). */ + public static final Comparator<Thesaurus> THESAURUS_COMPARATOR = new Comparator<Thesaurus>() { + @Override + public int compare(Thesaurus o1, Thesaurus o2) { + int result = 0; + + if (o1 != null && o2 != null) { + String orderName1 = ThesaurusDataHelper.concateOrderName(o1); + String orderName2 = ThesaurusDataHelper.concateOrderName(o2); + + return orderName1.compareToIgnoreCase(orderName2); + } + return result; + } + }; + + public static final Comparator<RootThesaurus> ROOT_THESAURUS_COMPARATOR = new Comparator<RootThesaurus>() { + @Override + public int compare(RootThesaurus o1, RootThesaurus o2) { + int result = 0; + + if (o1 != null && o2 != null) { + result = o1.getName().compareToIgnoreCase(o2.getName()); + } + return result; + } + }; +} + \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/VradiComparators.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/XmlStreamHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/XmlStreamHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/XmlStreamHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,186 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.helpers; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiConstants; +import org.chorem.vradi.services.VradiException; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * XmlStreamHelper. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 5 mars 2010 01:48:29 + */ +public class XmlStreamHelper { + private static final Log log = LogFactory.getLog(XmlStreamHelper.class); + + public static Element getFirstElement(String url) throws VradiException { + return getFirstElementXpp(url); + } + + protected static Element getFirstElementJDom(String url) throws VradiException { + try { + long currentTimeMillis = System.currentTimeMillis(); + + URL rssUrl = new URL(url); + + SAXBuilder builder = new SAXBuilder(); + Document document = builder.build(rssUrl); + + Element racine = document.getRootElement(); + log.debug("Root element name: " + racine.getName()); + + Element firstElement = null; + + if (racine.getChild(VradiConstants.ITEM) != null) { + firstElement = racine.getChild(VradiConstants.ITEM); + + } else if (racine.getChild(VradiConstants.ENTRY) != null) { + firstElement = racine.getChild(VradiConstants.ENTRY); + + } else if (racine.getChild(VradiConstants.CHANNEL) != null) { + Element element = racine.getChild(VradiConstants.CHANNEL); + firstElement = element.getChild(VradiConstants.ITEM); + } + + log.debug(System.currentTimeMillis() - currentTimeMillis); + return firstElement; + + } catch (Exception eee) { + log.error(eee.getMessage(), eee); + throw new VradiException("Cant get first element", eee); + } + } + + protected static Element getFirstElementXpp(String url) throws VradiException { + InputStream openStream = null; + try { + long currentTimeMillis = System.currentTimeMillis(); + + URL rssUrl = new URL(url); + + //Change timout + URLConnection connection = rssUrl.openConnection(); + connection.setConnectTimeout(2000); + + openStream = connection.getInputStream(); + InputStreamReader streamReader = new InputStreamReader(openStream); + BufferedReader bufferedReader = new BufferedReader(streamReader); + + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + // don't check for DTD validity + inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, "false"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(bufferedReader); + + Element firstElement = null; + + while (reader.hasNext()) { + int type = reader.next(); + + if (type == XMLStreamConstants.START_ELEMENT) { + String localName = reader.getLocalName(); + + if (firstElement == null && (localName.equals(VradiConstants.ITEM) || localName.equals(VradiConstants.ENTRY))) { + firstElement = new Element(localName); + + } else if (firstElement != null) { + Element element = new Element(localName); + firstElement.addContent(element); + } + + } else if (type == XMLStreamConstants.CHARACTERS || type == XMLStreamConstants.CDATA) { + if (firstElement != null && firstElement.getContentSize() > 0) { + int contentSize = firstElement.getContentSize(); + Element content = (Element) firstElement.getContent(contentSize - 1); + content.setText(content.getTextTrim() + reader.getText()); + } + + } else if (type == XMLStreamConstants.END_ELEMENT) { + String localName = reader.getLocalName(); + + if (firstElement != null && (localName.equals(VradiConstants.ITEM) || localName.equals(VradiConstants.ENTRY))) { + break; + } + } + } + + log.debug(System.currentTimeMillis() - currentTimeMillis); + return firstElement; + + } catch (Exception eee) { + log.error(eee.getMessage(), eee); + throw new VradiException("Cant get first element", eee); + } finally { + IOUtils.closeQuietly(openStream); + } + } + + public static Set<String> getRSSFields(Element firstElement) { + if (log.isDebugEnabled()) { + log.debug("getRSSFields"); + } + Set<String> result = new LinkedHashSet<String>(); + + if (firstElement != null) { + for (Element elt : (List<Element>) firstElement.getChildren()) { + result.add(elt.getName()); + } + } + return result; + } + + public static Map<String, String> getFirstElementValues(Element firstElement) { + Map<String, String> result = new LinkedHashMap<String, String>(); + + if (firstElement != null) { + for (Element elt : (List<Element>) firstElement.getChildren()) { + result.put(elt.getName(), elt.getText()); + } + } + return result; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/helpers/XmlStreamHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,146 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.login; + +import jaxx.runtime.JAXXContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.nuiton.util.StringUtil; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import java.awt.Color; + +import static org.nuiton.i18n.I18n._; + +/** + * Login and register user handler. + * + * @author morin + * Date: 4 déc. 2009 + * Time: 16:34:04 + */ +public class LoginHandler { + + /** Log. */ + static private final Log log = LogFactory.getLog(LoginHandler.class); + + /** Empty password value. */ + private final static String EMPTY_PASSWORD = "null"; + + /** + * Storage service. + * + * @return storage service + */ + public VradiStorageService getVradiStorageService() { + return VradiService.getVradiStorageService(); + } + + /** + * Loguser action. + * + * @param ui parent ui + */ + public void logUser(LoginUI ui) { + try { + String login = ui.getLogin().getText().trim(); + String password = String.valueOf(ui.getPassword().getPassword()).trim(); + + String md5Password = password.isEmpty() ? EMPTY_PASSWORD : StringUtil.encodeMD5(password); + VradiUser user = getVradiStorageService().loginUser(login, md5Password); + + if (user != null) { + if (log.isDebugEnabled()) { + log.debug("Login failed for user " + login); + } + ui.setBean(user); + } else { + JOptionPane.showMessageDialog(ui, _("vradi.login.error.message"), _("vradi.login.error"), + JOptionPane.ERROR_MESSAGE); + ui.getLogin().grabFocus(); + } + } catch (VradiException eee) { + JOptionPane.showMessageDialog(ui, _("vradi.login.error.message"), _("vradi.login.error"), + JOptionPane.ERROR_MESSAGE); + } + } + + /** + * Show register UI. + * + * @param ui parent ui. + */ + public void register(LoginUI ui) { + RegisterUI regUI = new RegisterUI((JAXXContext) ui); + regUI.setLocationRelativeTo(ui); + regUI.setVisible(true); + } + + /** + * Register action. + * + * @param ui parent ui + */ + public void register(RegisterUI ui) { + try { + String beanPassword = ui.getBean().getPassword(); + String repeatPassword = String.valueOf(ui.getRepeatPassword().getPassword()); + + if (beanPassword != null && beanPassword.equals(repeatPassword)) { + if (beanPassword.isEmpty()) { + ui.getBean().setPassword(EMPTY_PASSWORD); + } else { + ui.getBean().setPassword(StringUtil.encodeMD5(beanPassword.trim())); + } + VradiUser result = ui.getBean(); + result = getVradiStorageService().createUser(result); + if (result == null) { + JOptionPane.showMessageDialog(ui, _("vradi.register.user.error.message"), _("vradi.register.user.error"), + JOptionPane.ERROR_MESSAGE); + ui.getLogin().grabFocus(); + ui.getLogin().setBorder(BorderFactory.createLineBorder(Color.RED, 3)); + } else { + JOptionPane.showMessageDialog(ui, _("vradi.register.ok.message"), _("vradi.register.ok"), + JOptionPane.INFORMATION_MESSAGE); + ui.dispose(); + } + } else { + JOptionPane.showMessageDialog(ui, _("vradi.register.password.error.message"), _("vradi.register.password.error"), + JOptionPane.ERROR_MESSAGE); + ui.getPassword().grabFocus(); + ui.getPassword().setBorder(BorderFactory.createLineBorder(Color.RED)); + ui.getRepeatPassword().setBorder(BorderFactory.createLineBorder(Color.RED)); + } + } catch (VradiException eee) { + JOptionPane.showMessageDialog(ui, _("vradi.register.password.error.message"), _("vradi.register.password.error"), + JOptionPane.ERROR_MESSAGE); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,100 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='loginUI' + title='vradi.login.title' + modal='true' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='dispose(); System.exit(0);'> + + <import> + java.awt.Cursor + java.awt.event.KeyListener + java.awt.event.KeyAdapter + java.awt.event.KeyEvent + org.chorem.vradi.entities.VradiUser + org.chorem.vradi.entities.VradiUserImpl + </import> + + <VradiUser id='bean' javaBean='null'/> + + <Boolean id='mainUiInitialized' javaBean='false'/> + + <script><![CDATA[ + +protected LoginHandler getHandler() { + return getContextValue(LoginHandler.class); +} + +void $afterCompleteSetup() { + KeyAdapter keyAdapter = new KeyAdapter(){ + @Override + public void keyReleased(KeyEvent keyEvent) { + if(keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + validate.doClick(); + } + } + }; + login.addKeyListener(keyAdapter); + password.addKeyListener(keyAdapter); +} + +]]> + </script> + + <Table id='loginPanel'> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.login'/> + </cell> + <cell columns='2'> + <JTextField id='login' columns='20'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.password'/> + </cell> + <cell columns='2'> + <JPasswordField id='password' columns='20'/> + </cell> + </row> + <row fill='both'> + <cell> + <JButton id='cancel' text='vradi.login.cancel' mnemonic='A' + onActionPerformed='loginUI.dispose(); System.exit(0);'/> + </cell> + <cell> + <JButton id='register' text='vradi.login.register' mnemonic='E' + onActionPerformed='getHandler().register(this);'/> + </cell> + <cell> + <JButton id='validate' text='vradi.login.validate' mnemonic='V' + onActionPerformed='getHandler().logUser(this)'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/LoginUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/RegisterUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/RegisterUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/RegisterUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,123 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='registerUI' + title='vradi.register.title' + modal='true' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='dispose();'> + + <import> + org.chorem.vradi.entities.VradiUserImpl + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + </import> + + <!-- validators --> + <BeanValidator id='validator' + bean='{getBean()}' + beanClass='org.chorem.vradi.entities.VradiUser'> + + <field name="login" component="login"/> + <field name="email" component="email"/> + </BeanValidator> + + <!-- errors model --> + <SwingValidatorMessageTableModel id='errorTableModel' + onTableChanged='setValide(errorTableModel.getRowCount()==0);'/> + + <Boolean id='valide' javaBean='true'/> + + <VradiUser id='bean' javaBean='null'/> + + <script><![CDATA[ + +protected LoginHandler getHandler() { + return getContextValue(LoginHandler.class); +} + +void $afterCompleteSetup() { + errorTableModel.registerValidator(validator); + setBean(new VradiUserImpl()); + validator.setBean(getBean()); +} +]]> + </script> + + <Table id='loginPanel' fill='horizontal'> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.login'/> + </cell> + <cell weightx='1'> + <JTextField id='login' columns='20' text='{getBean().getLogin()}'/> + <javax.swing.text.Document javaBean="getLogin().getDocument()" + onInsertUpdate='getBean().setLogin(login.getText())' + onRemoveUpdate='getBean().setLogin(login.getText())'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.password'/> + </cell> + <cell weightx='1'> + <JPasswordField id='password' columns='20' + text='{getBean().getPassword()}'/> + <javax.swing.text.Document javaBean="getPassword().getDocument()" + onInsertUpdate='getBean().setPassword(String.valueOf(password.getPassword()))' + onRemoveUpdate='getBean().setPassword(String.valueOf(password.getPassword()))'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.repeatPassword'/> + </cell> + <cell weightx='1'> + <JPasswordField id='repeatPassword' columns='20'/> + </cell> + </row> + <row> + <cell anchor='east'> + <JLabel text='vradi.login.email'/> + </cell> + <cell weightx='1'> + <JTextField id='email' columns='20' text='{getBean().getEmail()}'/> + <javax.swing.text.Document javaBean="getEmail().getDocument()" + onInsertUpdate='getBean().setEmail(email.getText())' + onRemoveUpdate='getBean().setEmail(email.getText())'/> + </cell> + </row> + <row fill='both'> + <cell> + <JButton id='cancel' text='vradi.login.cancel' + onActionPerformed='registerUI.dispose();'/> + </cell> + <cell> + <JButton id='validate' text='vradi.login.validate' + enabled='{isValide()}' + onActionPerformed='getHandler().register(this)'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/login/RegisterUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/EntityModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/EntityModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/EntityModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,128 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.models; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** @author letellier */ +public class EntityModel<E extends BusinessEntity> extends AbstractListModel implements ComboBoxModel, VradiEntitiesListener<E> { + + /** Logger */ + private static final Log log = LogFactory.getLog(EntityModel.class); + + protected Map<String, E> datas; + + protected E selected; + + protected boolean firstNull = true; + + public EntityModel(Class<E> clazz, List<E> datas) { + this(clazz, datas, true); + } + + public EntityModel(Class<E> clazz, List<E> datas, boolean firstNull) { + this.firstNull = firstNull; + this.datas = new HashMap<String, E>(); + fillDatas(datas); + VradiContext.get().getVradiNotifier().addVradiListener(clazz, this); + } + + protected void fillDatas(List<E> datas) { + if (datas == null) { + return; + } + for (E data : datas) { + if (data != null) { + this.datas.put(data.getWikittyId(), data); + } + } + } + + @Override + public int getSize() { + if (firstNull) { + return datas.size() + 1; + } + return datas.size(); + } + + @Override + public Object getElementAt(int index) { + if (firstNull) { + if (index == 0) { + return null; + } + + List<String> keys = new ArrayList<String>(datas.keySet()); + return datas.get(keys.get(index - 1)); + } + List<String> keys = new ArrayList<String>(datas.keySet()); + return datas.get(keys.get(index)); + } + + @SuppressWarnings({"unchecked"}) + @Override + public void setSelectedItem(Object anItem) { + selected = (E) anItem; + } + + @Override + public Object getSelectedItem() { + return selected; + } + + protected void updateDatas(List<E> datas) { + fillDatas(datas); + fireContentsChanged(this, 0, datas.size() - 1); + } + + @Override + public void entitiesAdded(Set<E> added) { + for (E entity : added) { + datas.put(entity.getWikittyId(), entity); + } + fireContentsChanged(this, 0, datas.size() - 1); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + for (String wikittyId : removed) { + datas.remove(wikittyId); + } + fireContentsChanged(this, 0, datas.size() - 1); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/EntityModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormMenu.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormMenu.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormMenu.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,103 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.models; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiExtensionsListener; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.VradiMainUIHandler; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class FormMenu extends JMenu implements VradiExtensionsListener { + + /** Logger */ + private static final Log log = LogFactory.getLog(FormMenu.class); + + protected VradiMainUIHandler handler; + + protected List<JMenuItem> items = new ArrayList<JMenuItem>(); + + public FormMenu(VradiMainUIHandler handler) { + this.handler = handler; + updateMenus(); + + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(this); + } + + protected void updateMenus() { + for (JMenuItem item : items) { + remove(item); + } + List<WikittyExtension> forms = null; + try { + forms = VradiService.getVradiDataService().getAllFormTypes(); + } catch (VradiException eee) { + log.error("cant get all forms type", eee); + ErrorDialogUI.showError(eee); + } + Collections.sort(forms, VradiComparators.EXTENSION_COMPARATOR); + for (final WikittyExtension form : forms) { + JMenuItem item = new JMenuItem(_("vradi.menu.form.new", form.getName())); + item.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionEvent) { + handler.createForm(form); + } + }); + + items.add(item); + add(item); + } + } + + @Override + public void extensionsAdded(Set<WikittyExtension> added) { + updateMenus(); + } + + @Override + public void extensionsRemoved(Set<String> removedNames) { + updateMenus(); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormMenu.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormTypeModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormTypeModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormTypeModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,110 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.models; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiExtensionsListener; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.DefaultComboBoxModel; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** @author letellier */ +public class FormTypeModel extends DefaultComboBoxModel implements VradiExtensionsListener { + + /** Logger */ + private static final Log log = LogFactory.getLog(FormTypeModel.class); + + protected boolean firstNull = false; + + public FormTypeModel(boolean firstNull) { + this.firstNull = firstNull; + + init(); + + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(this); + } + + public void init() { + + List<WikittyExtension> formTypes = null; + try { + formTypes = VradiService.getVradiDataService().getAllFormTypes(); + } catch (VradiException eee) { + log.error("Cant get all forms types", eee); + ErrorDialogUI.showError(eee); + } + removeAllElements(); + + // Sort + Collections.sort(formTypes, VradiComparators.EXTENSION_COMPARATOR); + for (WikittyExtension formType : formTypes) { + addElement(formType); + } + + if (firstNull) { + setSelectedItem(null); + } + } + + @Override + public int getSize() { + if (firstNull) { + return super.getSize() + 1; + } + return super.getSize(); + } + + @Override + public Object getElementAt(int index) { + if (firstNull) { + if (index == 0) { + return null; + } + + return super.getElementAt(index - 1); + } + return super.getElementAt(index); + } + + @Override + public void extensionsAdded(Set<WikittyExtension> added) { + init(); + } + + @Override + public void extensionsRemoved(Set<String> removedNames) { + init(); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/FormTypeModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/RequestFieldMenu.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/RequestFieldMenu.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/RequestFieldMenu.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,287 @@ +/* + * #%L + * Vradi :: Swing + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.models; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiExtensionsListener; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.search.SearchUI; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JTextArea; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class RequestFieldMenu extends JMenu implements VradiExtensionsListener { + + /** Logger */ + private static final Log log = LogFactory.getLog(FormMenu.class); + + public static final String FIELD_NAME_SUFFIX = ":\"\""; + + protected SearchUI searchUI; + + protected Map<String, JMenu> formTypesMenu; + + protected Map<String, JMenuItem> formTypesFieldMenu; + + public RequestFieldMenu(SearchUI searchUI) { + super(_("vradi.request.keywords")); + + this.searchUI = searchUI; + + // Fill infogene fields + fillInfogeneMenu(); + + // Get all formsType + List<WikittyExtension> formTypes = null; + try { + formTypes = VradiService.getVradiDataService().getAllFormTypes(); + } catch (VradiException eee) { + log.error("cant get all forms type", eee); + ErrorDialogUI.showError(eee); + } + + // Sort + Collections.sort(formTypes, VradiComparators.EXTENSION_COMPARATOR); + + formTypesMenu = new HashMap<String, JMenu>(); + formTypesFieldMenu = new HashMap<String, JMenuItem>(); + + // Fill for all formTypes + if (formTypes != null) { + for (WikittyExtension formType : formTypes) { + fillFormTypeMenu(formType); + } + } + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(this); + } + + protected void fillInfogeneMenu() { + JMenu infogeneMenu = new JMenu(_("vradi.request.infogene")); + + // Fill infogene menu + for (String fieldName : getInfogeneFieldNames()) { + infogeneMenu.add(new FieldMenuItem(fieldName)); + } + + // Fill form menu + for (String fieldName : getFormFieldNames()) { + infogeneMenu.add(new FieldMenuItem(fieldName)); + } + + // TODO sletellier 15/12/10 : [#2557] Requête sur tout ce qui caractérise un formulaire +// // Fill formType menu +// FormMenuItem formTypeMenu = new FormMenuItem("formType"); +// infogeneMenu.add(formTypeMenu); +// +// // Get all formTypes +// List<WikittyExtension> formTypes; +// try { +// formTypes = VradiService.getVradiDataService().getAllFormTypes(); +// } catch (VradiException eee) { +// log.error("Failled to get all form types", eee); +// ErrorDialogUI.showError(eee); +// return; +// } +// for (WikittyExtension formType : formTypes) { +// formTypeMenu.add(new JMenuItem(formType.getName())); +// } +// +// // Fill status menu +// InfogeneMenuItem statusMenu = new InfogeneMenuItem(Infogene.FIELD_INFOGENE_STATUS); +// infogeneMenu.add(statusMenu); +// +// // Get all status +// List<Status> statuses = VradiService.getVradiDataService().findAllStatus(); +// for (Status status : statuses) { +// formTypeMenu.add(new JMenuItem(_(status.getName()))); +// } +// +// // Fill xmlStream menu +// FormMenuItem xmlStreamMenu = new FormMenuItem(Form.FIELD_FORM_XMLSTREAM); +// infogeneMenu.add(xmlStreamMenu); +// +// // Get all status +// List<XmlStream> streams = VradiService.getVradiDataService().findAllXmlStreams(); +// for (XmlStream stream : streams) { +// formTypeMenu.add(new JMenuItem(stream.getName())); +// } + + add(infogeneMenu); + } + + protected void fillFormTypeMenu(WikittyExtension formType) { + String formTypeName = formType.getName(); + JMenu formTypeMenu = new JMenu(formTypeName); + + for (String fieldName : formType.getFieldNames()) { + + FieldMenuItem fieldMenu = new FieldMenuItem(formType, fieldName); + formTypeMenu.add(fieldMenu); + + formTypesFieldMenu.put(fieldName, fieldMenu); + } + formTypesMenu.put(formTypeName, formTypeMenu); + add(formTypeMenu); + } + + protected List<String> getInfogeneFieldNames() { + List<String> fieldNames = new ArrayList<String>(); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_ID); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_OBJET); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_DESCRIPTION); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_CREATIONDATE); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_ENTITY); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCETEXT); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_SOURCEURL); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_COUNTRY); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_DEPARTMENT); + fieldNames.add(Infogene.FQ_FIELD_INFOGENE_STATUS); + + return fieldNames; + } + + protected List<String> getFormFieldNames() { + List<String> fieldNames = new ArrayList<String>(); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fieldNames.add(ModificationTag.FQ_FIELD_MODIFICATIONTAG_LASTMODIFIER); + + return fieldNames; + } + + protected class FieldMenuItem extends JMenuItem implements ActionListener { + + protected String fieldName; + + protected FieldType fieldType; + + protected String description; + + protected String traduction; + + public FieldMenuItem(String fqFieldName) { + this(null, fqFieldName); + } + + public FieldMenuItem(WikittyExtension extension, String fqFieldName) { + fieldName = fqFieldName; + int i = fqFieldName.indexOf('.'); + if (i != -1) { + fieldName = WikittyUtil.getFieldNameFromFQFieldName(fqFieldName); + } else { + fieldName = fqFieldName; + } + if (extension != null) { + fieldType = extension.getFieldType(fqFieldName); + description = VradiHelper.getFieldTypeDescription(fieldType); + } + traduction = VradiHelper.getTraduction(extension, fqFieldName); + + addActionListener(this); + } + + @Override + public String getText() { + if (traduction != null && !traduction.equals(fieldName)) { + return traduction + " (" + fieldName + ")"; + } + return fieldName; + } + + @Override + public void actionPerformed(ActionEvent e) { + + JTextArea requestArea = searchUI.getRequestArea(); + + int position = requestArea.getCaretPosition(); + requestArea.insert(fieldName + FIELD_NAME_SUFFIX, position); + + // Put carret under cotes + requestArea.setCaretPosition(position + fieldName.length() + 2); + + searchUI.setRequest(requestArea.getText()); + } + + @Override + public String getToolTipText(MouseEvent event) { + return getToolTipText(); + } + + @Override + public String getToolTipText() { + if (description != null) { + return description; + } else { + return super.getToolTipText(); + } + } + } + + @Override + public void extensionsAdded(Set<WikittyExtension> added) { + for (WikittyExtension ext : added) { + fillFormTypeMenu(ext); + } + } + + @Override + public void extensionsRemoved(Set<String> removedNames) { + for (String formTypeName : removedNames) { + + JMenu formTypeMenu = formTypesMenu.get(formTypeName); + if (formTypeMenu != null) { + formTypesMenu.remove(formTypeName); + remove(formTypeMenu); + } + } + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/models/RequestFieldMenu.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/CreateOfferDialogUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/CreateOfferDialogUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/CreateOfferDialogUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='createOfferDialogUI' + title='vradi.admin.title' + modal='true' + layout='{new BorderLayout()}'> + + <String id='nameValue' javaBean='null'/> + + <org.nuiton.wikitty.entities.WikittyExtension id='formType' javaBean='null'/> + + <ComboBoxModel id='formTypeSelectionModel' + javaBean='UIHelper.getFormTypesModel()'/> + + <Boolean id='ok' javaBean='false'/> + + <script><![CDATA[ +void $afterCompleteSetup() { + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +]]> + </script> + + <Table constraints='BorderLayout.CENTER'> + <row> + <cell fill='horizontal' weightx='1.0'> + <JLabel text='vradi.createForm.askName'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JTextArea id='nameField' text='{getNameValue()}' + onKeyReleased='setNameValue(nameField.getText())'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <JLabel text='vradi.createForm.askType'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id='formTypeCombo' model='{formTypeSelectionModel}' + selectedItem='{getFormType()}' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + onActionPerformed='setFormType((org.nuiton.wikitty.entities.WikittyExtension) formTypeCombo.getSelectedItem())'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1.0'> + <JButton id='cancel' text='vradi.common.cancel' + onActionPerformed='dispose()'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JButton id='okButton' text='vradi.common.ok' + onActionPerformed='setOk(true);dispose();'/> + </cell> + </row> + </Table> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/CreateOfferDialogUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,757 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.FieldTypeEnum; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.entities.FormLinkImpl; +import org.chorem.vradi.entities.FormLinkTypeEnum; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.VradiMainUIHandler; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.editors.CurrencyEditor; +import org.chorem.vradi.ui.offer.editors.DateEditor; +import org.chorem.vradi.ui.offer.editors.DateTimeEditor; +import org.chorem.vradi.ui.offer.editors.EmailEditor; +import org.chorem.vradi.ui.offer.editors.NumEditor; +import org.chorem.vradi.ui.offer.editors.StringEditor; +import org.chorem.vradi.ui.offer.editors.TextEditor; +import org.chorem.vradi.ui.offer.editors.UrlEditor; +import org.chorem.vradi.ui.offer.editors.VradiEditor; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.offer.widgets.SelectFormUI; +import org.chorem.vradi.ui.search.SearchHandler; +import org.chorem.vradi.ui.search.SearchUI; +import org.chorem.vradi.ui.task.VradiTask; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.nuiton.util.FileUtil; +import org.nuiton.wikitty.WikittyObsoleteException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.filechooser.FileFilter; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Desktop; +import java.io.File; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class OfferEditHandler { + + /** Logger */ + static private final Log log = LogFactory.getLog(OfferEditHandler.class); + + private static final String DEFAULT_EDITOR_NAME = "$default"; + + public static final String REQUIRED_FIELD_CONTEXT = "required"; + + public static final FileFilter[] EMPTY_FILTERS_ARRAY = new FileFilter[0]; + + protected VradiStorageService getVradiStorageService() { + return VradiService.getVradiStorageService(); + } + + protected VradiDataService getDataService() { + return VradiService.getVradiDataService(); + } + + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param rootContext le context applicatif + * @param formId id du formulaire + * @return l'ui instancie et initialisee mais non visible encore + */ + public OfferEditUI initUI(JAXXContext rootContext, String formId) { + Form data = VradiService.getWikittyProxy().restore(Form.class, formId); + return initUI(rootContext, data); + } + + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param rootContext le context applicatif + * @param data formulaire + * @return l'ui instancie et initialisee mais non visible encore + */ + public OfferEditUI initUI(JAXXContext rootContext, Form data) { + + JAXXInitialContext context = new JAXXInitialContext().add(rootContext).add(this).add(data); + + if (log.isDebugEnabled()) { + // show main ui + log.debug("Load form '" + data.getObjet() + "' with status : " + data.getStatus()); + } + + UIHelper.getHandler(context, ThesaurusHandler.class); + OfferEditUI ui = new OfferEditUI(context); + + fillfields(ui, data); + + // Init propositions + try { + List<Thesaurus> thesaurusToPropose = + getDataService().proposeThesaurus(data.getWikittyId()); + + if (log.isDebugEnabled()) { + log.debug("Find " + thesaurusToPropose.size() + + " thesaurus to propose for form " + data.getObjet()); + } + + addPropositions(ui, thesaurusToPropose.toArray( + new Thesaurus[thesaurusToPropose.size()])); + + } catch (VradiException eee) { + log.error("Cant get propositions of thesaurus ", eee); + ErrorDialogUI.showError(eee); + } + + // Init thesaurus + ThesaurusHandler thesaurusHandler = UIHelper.getHandler(context, ThesaurusHandler.class); + thesaurusHandler.initThesaurus(ui); + + return ui; + } + + public void fillfields(OfferEditUI ui, Form form) { + + // Check if form is an replace one + String previousReplaceForm = VradiService.getVradiDataService().getPreviousReplaceForm(form.getWikittyId()); + boolean isEditable = previousReplaceForm == null; + + // So, we cant edit this + if (!isEditable) { + + Form previousForm = VradiService.getWikittyProxy().restore(Form.class, previousReplaceForm); + + ui.setPreviousForm(previousForm); + } + + ui.setEditable(isEditable); + + Collection<String> extensions = form.getExtensionNames(); + for (String extensionName : extensions) { + if (!extensionName.equals(ModificationTag.EXT_MODIFICATIONTAG) + && !extensionName.equals(Form.EXT_INFOGENE) + && !extensionName.equals(Form.EXT_FORM)) { + + Wikitty wikitty = VradiService.getWikittyProxy().getWikitty(form); + WikittyExtension extension = wikitty.getExtension(extensionName); + + Collection<String> fieldNames = extension.getFieldNames(); + for (String fieldName : fieldNames) { + createField(ui, extension, fieldName, form, isEditable); + } + } + } + } + + protected static Map<String, Class<? extends VradiEditor<?, ?>>> editorMapping; + + protected void createField(OfferEditUI ui, WikittyExtension extension, String fieldName, BusinessEntity data, boolean isEditable) { + JPanel content = ui.getContent(); + FieldType fieldType = extension.getFieldType(fieldName); + + if (!fieldType.isCollection()) { + VradiEditor editor = getEditor(fieldType, ui); + + if (editor != null) { + String extensionName = extension.getName(); + Serializable value = (Serializable) data.getField(extensionName, fieldName); + + // Try to get traduction + String traduction = VradiHelper.getTraduction(extension, fieldName); + + editor.setFieldName(traduction); + + String fieldDesc = VradiHelper.getFieldTypeDescription(fieldType); + editor.setFieldDescription(fieldDesc); + + editor.setExtensionName(extensionName); + editor.setExtensionFieldName(fieldName); + + editor.setValue(value); + + if (fieldType.isNotNull()) { + editor.setValidatorContext(REQUIRED_FIELD_CONTEXT); + } + editor.setEnabled(isEditable); + content.add(editor); + content.setVisible(true); + } + } + } + + public OfferEditUI getUI(JAXXContext context) { + OfferEditUI ui = null; + if (context instanceof OfferEditUI) { + ui = (OfferEditUI) context; + } + if (ui == null) { + ui = context.getContextValue(OfferEditUI.class); + } + + return ui; + } + + protected void addPropositions(JAXXContext context, Thesaurus[] props) { + OfferEditUI ui = getUI(context); + DefaultListModel propositionListModel = ui.getPropositionListModel(); + propositionListModel.removeAllElements(); + for (Thesaurus p : props) { + if (log.isDebugEnabled()) { + log.debug("Add proposition element : " + p.getName()); + } + propositionListModel.addElement(p); + } + } + + /** + * @param context + * @param form + */ + protected void save(JAXXContext context, Form form) { + log.info("Saving Form: " + form.getWikittyId()); + + // Get proxy + WikittyProxy proxy = VradiService.getWikittyProxy(); + + OfferEditUI offerEditUI = getUI(context); + + try { + List<Thesaurus> thesaurusToSave = new ArrayList<Thesaurus>(); + + // Find all propositions selected + for (Object s : offerEditUI.getPropositionList().getSelectedValues()) { + Thesaurus selected = (Thesaurus) s; + + // Save thesaurus + //selected = ThesaurusDataHelper.restoreThesaurus(selected.getWikittyId()); + selected.addAttachment(form.getWikittyId()); + + if (!thesaurusToSave.contains(selected)) { + thesaurusToSave.add(selected); + } + } + + // Find all thesaurus selected + for (Component c : offerEditUI.getThesaurus().getComponents()) { + ThesaurusUI thesaurusUI = (ThesaurusUI) c; + DefaultListModel model = thesaurusUI.getThesaurusSelectedModel(); + Object[] selected = model.toArray(); + + for (Object s : selected) { + Thesaurus thesaurus = (Thesaurus) s; + + // Save thesaurus + //thesaurus = ThesaurusDataHelper.restoreThesaurus(thesaurus.getWikittyId()); + thesaurus.addAttachment(form.getWikittyId()); + + if (!thesaurusToSave.contains(thesaurus)) { + thesaurusToSave.add(thesaurus); + } + } + } + + // supprime tous les thesaurus qui ne sont plus selectionné + List<Thesaurus> actualThesauruses = getDataService().getThesaurusAttachedToForm(form); + for (Thesaurus actualThesaurus : actualThesauruses) { + if (!thesaurusToSave.contains(actualThesaurus)) { + actualThesaurus.removeAttachment(form.getWikittyId()); + thesaurusToSave.add(actualThesaurus); + } + } + + proxy.store(thesaurusToSave); + } catch (Exception eee) { + log.error("Can't save thesaurus : ", eee); + ErrorDialogUI.showError(eee); + } + + // Save dynamic content + JPanel content = offerEditUI.getContent(); + Component[] components = content.getComponents(); + for (Component c : components) { + VradiEditor editor = (VradiEditor) c; + updateFormField(editor, form); + } + + // Save infogene content + updateFormField(offerEditUI.getObjetEditor(), form); + updateFormField(offerEditUI.getIdEditor(), form); + updateFormField(offerEditUI.getSourceTextEditor(), form); + updateFormField(offerEditUI.getSourceURLEditor(), form); + updateFormField(offerEditUI.getEntityEditor(), form); + updateFormField(offerEditUI.getCountryEditor(), form); + updateFormField(offerEditUI.getDepartmentEditor(), form); + updateFormField(offerEditUI.getDatePubEditor(), form); + updateFormField(offerEditUI.getDatePeremeptionEditor(), form); + updateFormField(offerEditUI.getDescriptionEditor(), form); + + VradiUser vradiUser = context.getContextValue(VradiUser.class); + // add modification info + ModificationTag formTag = VradiService.getWikittyProxy().cast(form, ModificationTag.class); + formTag.setLastModified(new Date()); + formTag.setLastModifier(vradiUser.getLogin()); + + try { + for (File embeddedFile : offerEditUI.getEmbeddedFilePane().getAddedDatas()) { + VradiService.getFileService().uploadFormEmbeddedFile(embeddedFile, form.getWikittyId()); + } + for (File attachementFile : offerEditUI.getAttachmentFilePane().getAddedDatas()) { + VradiService.getFileService().uploadFormAttachment(attachementFile, form.getWikittyId()); + } + + } catch (Exception eee) { + log.error("Can't upload files for form : " + form.getObjet(), eee); + ErrorDialogUI.showError(eee); + } + + try { + // Store created form links + List<BusinessEntity> toSave = new ArrayList<BusinessEntity>(); + toSave.addAll(offerEditUI.getRelatedFormPane().getAddedDatas()); + toSave.addAll(offerEditUI.getReplaceFormPane().getAddedDatas()); + + toSave.add(form); + + proxy.store(toSave); + } catch (WikittyObsoleteException eee) { + if (log.isErrorEnabled()) { + log.error("Your form is obselete (" + form.getObjet() + ")", eee); + } + JOptionPane.showMessageDialog(getUI(context), + _("vradi.error.formWikittyObselete", form.getObjet()), + _("vradi.error.formWikittyObselete.title"), + JOptionPane.ERROR_MESSAGE); + } + } + + void updateFormField(VradiEditor editor, Form form) { + String extensionName = editor.getExtensionName(); + String extensionFieldName = editor.getExtensionFieldName(); + Object value = editor.getValue(); + if (log.isDebugEnabled()) { + log.debug("updating: " + extensionName + "." + extensionFieldName + "=" + value); + } + form.setField(extensionName, extensionFieldName, value); + } + + protected void update(JAXXContext context) { + VradiMainUIHandler rootHandler = VradiContext.get().getContextValue(VradiMainUIHandler.class); + rootHandler.goToHome(context); + } + + protected void findQueries(JAXXContext context) { + OfferEditUI ui = getUI(context); + Form form = ui.getData(); + + try { + Map<Group, List<QueryBean>> queries = getDataService() + .findQueriesReturningForm(form.getWikittyId()); + + RequestFormViewHandler handler = UIHelper.getHandler(context, + RequestFormViewHandler.class); + + RequestFormViewUI requestFormViewUI = handler.initUI(context, queries); + requestFormViewUI.setVisible(true); + + } catch (VradiException e) { + log.error(e.getMessage(), e); + ErrorDialogUI.showError(e); + } + } + + public void viewInPDF(JAXXContext context) { + final OfferEditUI ui = getUI(context); + + final Form form = ui.getData(); + + VradiTask<String> generatePDF = new VradiTask<String>(context, false) { + @Override + public String doAction() throws Exception { + return VradiService.getVradiStorageService().generatePDF(form.getWikittyId(), true); + } + + @Override + public void doWhenDone() throws Exception { + String fileUri = get(); + if (fileUri == null) { + JOptionPane.showMessageDialog(ui, + _("vradi.offerEdit.cantGeneratePDF"), + _("vradi.offerEdit.cantGeneratePDFTitle"), + JOptionPane.OK_OPTION); + + return; + } + + // file is temporary + File file = VradiService.getFileService().downloadPDF(fileUri); + Desktop.getDesktop().open(file); + } + }; + + generatePDF.execute(); + } + + /** + * Add new embedded file in current form. + * + * @param ui parent ui + * @param form + * @return + */ + public File addEmbeddedFile(MultipleSelectionPane ui, Form form) { + if (log.isDebugEnabled()) { + log.debug("addFile(context)"); + } + FileFilter imageFileFilter = new FileFilter() { + + private final String[] FILTER_EXTENSIONS = + new String[]{"jpg", "jpeg", "png", "gif"}; + + @Override + public boolean accept(File file) { + if (file.isDirectory()) { + return true; + } + for (String extension : FILTER_EXTENSIONS) { + if (file.getName().toLowerCase().endsWith(extension)) { + return true; + } + } + return false; + } + + @Override + public String getDescription() { + return "Images(.jpg, .jpeg, .png, .gif)"; + } + }; + File file = FileUtil.getFile(ui, imageFileFilter); + if (file != null) { + form.addFiles(file.getName()); + } + return file; + } + + /** + * Remove one form embedded file. + * + * @param form + * @param filesNamesToRemove + * @return + */ + public List<String> removeEmbeddedFile(Form form, List<String> filesNamesToRemove) { + for (String fileName : filesNamesToRemove) { + form.removeFiles(fileName); + } + return filesNamesToRemove; + } + + /** + * Add new attachement file. + * + * @param ui + * @param form + * @return + */ + public File addAttachmentFile(MultipleSelectionPane ui, Form form) { + if (log.isDebugEnabled()) { + log.debug("addAttachment(context)"); + } + File attachment = FileUtil.getFile(ui, EMPTY_FILTERS_ARRAY); + if (attachment != null) { + form.addAttachments(attachment.getName()); + } + return attachment; + } + + /** + * Remove attachement. + * <p/> + * TODO EC20100609 really remove physical file too on server + * + * @param form + * @param filesNamesToRemove + * @return + */ + public List<String> removeAttachmentFile(Form form, List<String> filesNamesToRemove) { + for (String fileNameToRemove : filesNamesToRemove) { + form.removeAttachments(fileNameToRemove); + } + return filesNamesToRemove; + } + + protected synchronized VradiEditor getEditor(FieldType type, JAXXContext context) { + if (editorMapping == null) { + editorMapping = new TreeMap<String, Class<? extends VradiEditor<?, ?>>>(); + editorMapping.put(FieldTypeEnum.STRING.name(), StringEditor.class); + editorMapping.put(FieldTypeEnum.DATE_TIME.name(), DateTimeEditor.class); + editorMapping.put(FieldTypeEnum.DATE.name(), DateEditor.class); + editorMapping.put(FieldTypeEnum.EMAIL.name(), EmailEditor.class); + editorMapping.put(FieldTypeEnum.NUMERIC.name(), NumEditor.class); + editorMapping.put(FieldTypeEnum.TEXT.name(), TextEditor.class); + editorMapping.put(FieldTypeEnum.URL.name(), UrlEditor.class); + editorMapping.put(FieldTypeEnum.CURRENCY.name(), CurrencyEditor.class); + editorMapping.put(DEFAULT_EDITOR_NAME, StringEditor.class); + } + + FieldTypeEnum typeEnum = FieldTypeEnum.valueOf(type); + if (log.isDebugEnabled()) { + log.debug("typeEnum of type " + type + " = " + typeEnum); + } + String editorName = typeEnum == null ? DEFAULT_EDITOR_NAME : typeEnum.name(); + if (log.isDebugEnabled()) { + log.debug("editor name for type [" + type.getType() + "] : " + editorName); + } + + Class<? extends VradiEditor<?, ?>> editorClass = editorMapping.get(editorName); + + if (log.isDebugEnabled()) { + log.debug("editor class to use : " + editorClass); + } + try { + Constructor[] constructors = editorClass.getConstructors(); + for (Constructor constructor : constructors) { + if (constructor.getParameterTypes() != null + && constructor.getParameterTypes().length == 1 + && constructor.getParameterTypes()[0].equals(JAXXContext.class)) { + VradiEditor editor = (VradiEditor) constructor.newInstance(context); + editor.init(); + return editor; + } + } + return null; + } catch (Exception eee) { + // should never happens + throw new IllegalStateException(eee); + } + } + + /** + * Changes the status of the form and save it. + * + * @param context the actual context of the ui + * @param form the form to modify and save + * @param status the new status of the form + */ + public void changeStatusAndSave(JAXXContext context, Form form, Status status) { + + try { + + String intialStatus = form.getStatus(); + String updateStatus = status.getWikittyId(); + + if (intialStatus == null || !updateStatus.equals(intialStatus)) { + + VradiUser vradiUser = context.getContextValue(VradiUser.class); + String statusModifier = vradiUser != null ? vradiUser.getLogin() : null; + + // add modification info + ModificationTag formTag = VradiService.getWikittyProxy().cast(form, ModificationTag.class); + formTag.setLastModified(new Date()); + formTag.setLastModifier(statusModifier); + formTag.setLastStatusModifier(statusModifier); + + if (log.isDebugEnabled()) { + log.debug(String.format("Updating: statusModifier=%s on form: %s", statusModifier, form.getWikittyId())); + log.debug(String.format("New Status: %s, Old Status: %s", intialStatus, updateStatus)); + } + } + + form.setStatus(updateStatus); + save(context, form); + + } catch (Exception eee) { + log.error("Cant change status for form '" + (form == null ? "null" : form.getObjet()) + "' with status '" + (status == null ? "null" : _(status.getName())) + "'", eee); + } + } + + // Replace and related forms + + public FormLink addRelatedForm(JAXXContext rootContext, Form form) { + String name = JOptionPane.showInputDialog(_("vradi.offerEdit.askRelatedFormName")); + + if (!StringUtils.isBlank(name)) { + + // Open searchUI + JAXXInitialContext context = new JAXXInitialContext().add(rootContext); + + SearchHandler searchHandler = new SearchHandler(); + OfferListTableModel offerListTableModel = new OfferListTableModel(); + OfferListColumnFactory offerListColumnFactory = new OfferListColumnFactory(); + + context.add(searchHandler); + context.add(offerListTableModel); + context.add(offerListColumnFactory); + + SelectFormUI selectFormUI = new SelectFormUI(context); + + // add listeners + JXTable listTable = selectFormUI.getResultTable(); + + TableModelListener offerListTableModelListener = + getOfferListTableModelListener(listTable); + offerListTableModel.addTableModelListener(offerListTableModelListener); + + // listTable cellRenderer + // TODO SLE 30/09/2010 : Refactor it ! + OfferListTableModel.OfferListTableCellRenderer renderer = + new OfferListTableModel.OfferListTableCellRenderer(); + listTable.setDefaultRenderer(Boolean.class, renderer); + listTable.setDefaultRenderer(Date.class, renderer); + listTable.setDefaultRenderer(Double.class, renderer); + listTable.setDefaultRenderer(String.class, renderer); + listTable.setDefaultRenderer(XmlStream.class, renderer); + listTable.setDefaultRenderer(Status.class, renderer); + + // listTable highlighter + Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + listTable.addHighlighter(highlighter); + + // search ui + SearchUI searchUI = searchHandler.initCloneUI(context, offerListTableModel); + selectFormUI.getSearchPanel().add(searchUI, BorderLayout.CENTER); + + selectFormUI.setVisible(true); + + String selectedFormId = selectFormUI.getFormId(); + if (selectedFormId != null) { + return createFormLink(name, FormLinkTypeEnum.RELATED, form.getWikittyId(), selectedFormId); + } + } + return null; + } + + private TableModelListener getOfferListTableModelListener(final JXTable listTable) { + return new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + listTable.packAll(); + } + }; + } + + public FormLink addReplaceForm(MultipleSelectionPane ui, Form form) { + String name = JOptionPane.showInputDialog(_("vradi.offerEdit.askReplaceFormName")); + + if (!StringUtils.isBlank(name)) { + Wikitty formWikittyCloned = null; + WikittyProxy wikittyProxy = VradiService.getWikittyProxy(); + try { + // Clone wikitty with other id + formWikittyCloned = WikittyUtil.clone(wikittyProxy.getWikitty(form), true); + + // Store cloned + formWikittyCloned = wikittyProxy.store(formWikittyCloned); + } catch (CloneNotSupportedException eee) { + log.error("Cant clone form : " + form); + ErrorDialogUI.showError(eee); + } + + // Create form cloned + if (formWikittyCloned != null) { + + Form formCloned = new FormImpl(formWikittyCloned); + + // Init id and creation date and save it + formCloned = VradiHelper.initForm(formCloned); + formCloned = wikittyProxy.store(formCloned); + + OfferListHandler listHandler = UIHelper.getHandler(ui, OfferListHandler.class); + OfferListUI offerListUI = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + OfferEditUI offerEditUI = listHandler.addEditPane(offerListUI, formCloned); + offerEditUI.setPreviousForm(form); + offerEditUI.setEditable(false); + return createFormLink(name, FormLinkTypeEnum.REPLACE, form.getWikittyId(), formCloned.getWikittyId()); + } + } + return null; + } + + protected FormLink createFormLink(String name, FormLinkTypeEnum type, String fromFormId, String toFormId) { + + FormLink formLink = new FormLinkImpl(); + formLink.setName(name); + formLink.setFromForm(fromFormId); + formLink.setToForm(toFormId); + formLink.setType(type.getValue()); + + formLink = VradiService.getWikittyProxy().store(formLink); + + return formLink; + } + + public List<String> removeLinkForm(List<String> formLinkIds) { + WikittyProxy proxy = VradiService.getWikittyProxy(); + proxy.delete(formLinkIds); + + return formLinkIds; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,407 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='offerEditUI' layout='{new BorderLayout()}'> + + <style source='../VradiMainUI.css'/> + + <import> + java.awt.Dimension + java.awt.Component + java.awt.FlowLayout + + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + + java.io.File + + javax.swing.BoxLayout + + jaxx.runtime.swing.OneClicListSelectionModel + org.chorem.vradi.entities.Form + org.chorem.vradi.VradiHelper + org.chorem.vradi.VradiContext + org.chorem.vradi.entities.FormLink + org.chorem.vradi.entities.ModificationTag + org.chorem.vradi.entities.FieldTypeEnum + + org.chorem.vradi.ui.renderers.ThesaurusHighlighter + org.chorem.vradi.ui.offer.editors.* + org.chorem.vradi.services.VradiService + org.chorem.vradi.ui.widgets.MultipleSelectionPane + org.chorem.vradi.ui.offer.widgets.AttachmentFileHandler + org.chorem.vradi.ui.offer.widgets.EmbeddedFileHandler + org.chorem.vradi.ui.offer.widgets.RelatedFormHandler + org.chorem.vradi.ui.offer.widgets.ReplaceFormHandler + org.chorem.vradi.VradiContext + </import> + + <Form id='data' javaBean='getContextValue(Form.class)'/> + + <DefaultListModel id='propositionListModel'/> + + <Boolean id='valide' javaBean='true'/> + + <Boolean id='editable' javaBean='true'/> + + <Form id='previousForm' javaBean='null'/> + + <!-- errors model --> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + id='errorEditorTable' + onTableChanged='setValide(errorEditorTable.getRowCount()==0);'/> + + <script><![CDATA[ + +public OfferEditHandler getHandler() { + return getContextValue(OfferEditHandler.class); +} + +public OfferListHandler getListHandler() { + return UIHelper.getHandler(this, OfferListHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + if(data != null && data.getCreationDate() != null) { + String creationDateText = String.format(_("vradi.entity.creation.date"), + data.getCreationDate()); + lastModified.add(new JLabel(creationDateText)); + + if (data.getExtensionNames().contains(ModificationTag.EXT_MODIFICATIONTAG)) { + // get modification info + ModificationTag formTag = VradiService.getWikittyProxy().cast(data, ModificationTag.class); + Object date = formTag.getLastModified(); + Object user = formTag.getLastModifier(); + if (date != null && user != null) { + String lastModifiedText = String.format(_("vradi.entity.lastModified.date.user"), date, user); + lastModified.add(new JLabel(lastModifiedText)); + } + } + } + setContextValue(errorEditorTable, "errorEditorTable"); + formScrollPane.getVerticalScrollBar().setBlockIncrement(100); + formScrollPane.getVerticalScrollBar().setUnitIncrement(50); + formSplitPane.addPropertyChangeListener("dividerLocation", new PropertyChangeListener(){ + @Override + public void propertyChange(PropertyChangeEvent evt) { + resize(); + } + }); + addPropertyChangeListener("previousForm", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + formTitleLbl.setText(getFormTitle()); + } + }); +} + +public void resize(){ + Dimension dimension = formContentPane.getSize(); + dimension.setSize(formSplitPane.getDividerLocation() - 20, formContentPane.getHeight()); + formContentPane.setPreferredSize(dimension); + formContentPane.revalidate(); +} + +public void updateThesaurusSize(){ + double total = getSize().getWidth(); + Component[] thesPanels = thesaurus.getComponents(); + double width = total / thesPanels.length; + for (Component c : thesPanels){ + ThesaurusUI thesaurus = (ThesaurusUI)c; + Dimension d = thesaurus.getSize(); + if (log.isDebugEnabled()){ + log.debug("Resizing total width : " + total + " thesaurus width : " + width); + } + d.setSize(width, d.getHeight()); + thesaurus.setPreferredSize(d); + } + validate(); +} + +protected String getFormTitle() { + return _("vradi.offerEdit.otherIndexationTitle", getPreviousForm() == null ? "null" : getPreviousForm().getId()); +} + +protected void openPreviousOffer() { + OfferListUI offerListUI = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(getVradiContext()); + getListHandler().addEditPane(offerListUI, getPreviousForm().getWikittyId()); +} + + ]]></script> + + <JSplitPane id='offerEdit' + constraints='BorderLayout.CENTER' + oneTouchExpandable='true' + orientation='{JSplitPane.VERTICAL_SPLIT}' + resizeWeight='0.3'> + + <JSplitPane id='formSplitPane' + oneTouchExpandable='true' + continuousLayout='true' + dividerLocation='750' + resizeWeight='0.8'> + + <JPanel id="formPane" + layout='{new BorderLayout()}' + minimumSize='{new Dimension(0,0)}' + preferredSize='{new Dimension(0,0)}'> + + <JButton id='formTitleLbl' + visible='{!isEditable()}' + text='{getFormTitle()}' + borderPainted='false' + opaque='false' + constraints='BorderLayout.NORTH' + onActionPerformed='openPreviousOffer()'/> + + <JScrollPane constraints='BorderLayout.CENTER' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + id='formScrollPane' + onComponentResized='resize()'> + + <Table id='formContentPane' + preferredSize='{new Dimension(0,0)}'> + <row> + <cell columns='2' fill="horizontal" weightx='1' insets='0'> + <StringEditor id='objetEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_OBJET}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_OBJET}' + value='{data.getObjet()}'/> + </cell> + </row> + <row> + <cell fill="horizontal" weightx='0.5' insets='0'> + <IdEditor id='idEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_ID}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_ID}' + value='{data.getId()}'/> + </cell> + <cell fill="horizontal" weightx='0.5' insets='0'> + <StringEditor id='entityEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_ENTITY}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_ENTITY}' + value='{data.getEntity()}'/> + </cell> + </row> + <row> + <cell fill="horizontal" weightx='0.5' insets='0'> + <StringEditor id='countryEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_COUNTRY}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_COUNTRY}' + value='{data.getCountry()}'/> + </cell> + <cell fill="horizontal" weightx='0.5' insets='0'> + <StringEditor id='departmentEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_DEPARTMENT}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_DEPARTMENT}' + value='{data.getDepartment()}'/> + </cell> + </row> + <row> + <cell fill="horizontal" weightx='0.5' insets='0'> + <DateTimeEditor id='datePubEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_FORM_DATEPUB}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.DATE_TIME.getFieldType())}' + extensionName='{Form.EXT_FORM}' + extensionFieldName='{Form.FIELD_FORM_DATEPUB}' + value='{data.getDatePub()}'/> + </cell> + <cell fill="horizontal" weightx='0.5' insets='0'> + <DateTimeEditor id='datePeremeptionEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_FORM_DATEPEREMPTION}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.DATE_TIME.getFieldType())}' + extensionName='{Form.EXT_FORM}' + extensionFieldName='{Form.FIELD_FORM_DATEPEREMPTION}' + value='{data.getDatePeremption()}'/> + </cell> + </row> + <row> + <cell fill="horizontal" weightx='0.5' insets='0'> + <StringEditor id='sourceTextEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_SOURCETEXT}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.STRING.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_SOURCETEXT}' + value='{data.getSourceText()}'/> + </cell> + <cell fill="horizontal" weightx='0.5' insets='0'> + <UrlEditor id='sourceURLEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_SOURCEURL}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.URL.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_SOURCEURL}' + value='{data.getSourceURL()}'/> + </cell> + </row> + <row> + <cell columns='2' fill="both" weightx='1' weighty='0.5' + insets='0'> + <JPanel id='content' visible='false' + layout='{new BoxLayout(content, BoxLayout.Y_AXIS)}'/> + </cell> + </row> + <row> + <cell columns='2' fill="both" weightx='1' weighty='0.5' + insets='0'> + <TextEditor id='descriptionEditor' + enabled='{isEditable()}' + fieldName='{Form.FQ_FIELD_INFOGENE_DESCRIPTION}' + fieldDescription='{VradiHelper.getFieldTypeDescription(FieldTypeEnum.TEXT.getFieldType())}' + extensionName='{Form.EXT_INFOGENE}' + extensionFieldName='{Form.FIELD_INFOGENE_DESCRIPTION}' + value='{data.getDescription()}'/> + </cell> + </row> + </Table> + </JScrollPane> + </JPanel> + <JSplitPane + oneTouchExpandable='true' + orientation='{JSplitPane.VERTICAL_SPLIT}' + resizeWeight='0.8'> + + <Table insets='0'> + <row> + <cell fill='both' weightx='1' weighty='0.5' insets='0'> + <MultipleSelectionPane id='relatedFormPane' + enabled='{isEditable()}' + genericType='FormLink, Form' + beanType='{Form.class}' + handler='{new RelatedFormHandler(relatedFormPane)}' + bean='{getData()}'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='0.5' insets='0'> + <MultipleSelectionPane id='replaceFormPane' + enabled='{isEditable()}' + genericType='FormLink, Form' + beanType='{Form.class}' + handler='{new ReplaceFormHandler(replaceFormPane)}' + bean='{getData()}'/> + </cell> + </row> + </Table> + <JSplitPane + oneTouchExpandable='true' + orientation='{JSplitPane.VERTICAL_SPLIT}' + resizeWeight='0.8'> + <Table insets='0'> + <row> + <cell fill='both' weightx='1' weighty='0.5' insets='0'> + <MultipleSelectionPane id='attachmentFilePane' + enabled='{isEditable()}' + genericType='File, Form' + beanType='{Form.class}' + handler='{new AttachmentFileHandler(attachmentFilePane)}' + bean='{getData()}'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='0.5' insets='0'> + <MultipleSelectionPane id='embeddedFilePane' + enabled='{isEditable()}' + genericType='File, Form' + beanType='{Form.class}' + handler='{new EmbeddedFileHandler(embeddedFilePane)}' + bean='{getData()}'/> + </cell> + </row> + </Table> + <Table> + <row> + <cell fill='horizontal' weightx='1' insets='0'> + <JLabel text='vradi.edit.proposition'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='0.5'> + <JScrollPane> + <JList id='propositionList' + selectionModel='{new OneClicListSelectionModel(propositionList.getSelectionModel(), propositionListModel)}' + model='{getPropositionListModel()}' + cellRenderer='{new ThesaurusHighlighter(ThesaurusHighlighter.HighlighterType.PROPOSITION)}'/> + </JScrollPane> + </cell> + </row> + </Table> + </JSplitPane> + </JSplitPane> + </JSplitPane> + <JPanel id='thesaurus' + layout='{new BoxLayout(thesaurus, BoxLayout.X_AXIS)}'/> + </JSplitPane> + <Table id='actionPanel' constraints='BorderLayout.SOUTH'> + <row> + <cell columns='2' fill='horizontal' weightx='1'> + <JPanel id='statusButtonPanel' + layout='{new FlowLayout(FlowLayout.LEADING)}'> + <JLabel text='vradi.status.validate'/> + </JPanel> + </cell> + <cell columns='1' anchor='east' weightx='0'> + <HBox id='lastModified' horizontalAlignment='right'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1' insets='0'> + <JButton id='annuler' text='vradi.action.cancel'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0'> + <JButton id='findQueriesButton' text='vradi.offerEdit.affectedQueries' + onActionPerformed='getHandler().findQueries(this)'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0'> + <JButton id='viewPDF' + text='vradi.offerEdit.view.pdf' + enabled='{isEditable()}' + onActionPerformed='getHandler().viewInPDF(this)'/> + </cell> + </row> + </Table> +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferEditUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListColumnFactory.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListColumnFactory.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListColumnFactory.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,153 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.InfogeneImpl; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.ColumnFactory; +import org.jdesktop.swingx.table.TableColumnExt; + +import java.util.ArrayList; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * <code>OfferListColumnFactory</code> restore the visibility state of + * <code>Infogene</code> colums. + * <p/> + * OfferListColumnFactory is used by OfferListColumnFactory and + * OfferListUI.jaxx. + * + * @author $Author$ + * @version $Revision$ $Date$ + * @since 0.0.4 + */ +public class OfferListColumnFactory extends ColumnFactory { + private static final Log log = LogFactory.getLog(OfferListColumnFactory.class); + + private static final String I18N_COLUMN_PREFIX = "vradi.offer."; + + private final List<TableColumnExt> columnExts = new ArrayList<TableColumnExt>(); + + public OfferListColumnFactory() { + initAvailableColumns(); + } + + @Override + public TableColumnExt createTableColumn(int modelIndex) { + TableColumnExt columnExt = new TableColumnExt(columnExts.get(modelIndex)); + return columnExt; + } + + @Override + public void packColumn(JXTable table, TableColumnExt columnExt, int margin, + int max) { + int preferredWidth = columnExt.getPreferredWidth(); + if (preferredWidth < 400) { + super.packColumn(table, columnExt, margin, 400); + } else { + // consider the column has been manually resized + } + } + + protected void initAvailableColumns() { + List<String> vradiListColumns = VradiHelper.getVradiListColumns(); + boolean empty = vradiListColumns.isEmpty(); + + // la liste des colonnes contient tout les champs de l'infogene + List<String> fieldNames = new ArrayList<String>(); + for (String fieldName : InfogeneImpl.extensionInfogene.getFieldNames()) { + fieldNames.add(Infogene.EXT_INFOGENE + "." + fieldName); + } + // plus datePeremption, datePub, xmlStreamURL + fieldNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fieldNames.add(Form.FQ_FIELD_FORM_XMLSTREAM); + + for (String fieldName : fieldNames) { + boolean visible = vradiListColumns.contains(fieldName); + visible = visible || empty; + + TableColumnExt columnExt = initAvailableColumn(fieldName, + columnExts.size(), visible); + columnExts.add(columnExt); + + if (empty) { + // default hidden columns: id and description + if (fieldName.equals(Infogene.FQ_FIELD_INFOGENE_ID) || + fieldName.equals(Infogene.FQ_FIELD_INFOGENE_DESCRIPTION)) { + columnExt.setVisible(false); + + } else { + // add fqField to vradi.columns property + VradiHelper.addVradiListColumns(fieldName); + } + } + } + } + + // Warning : Use a small i18n bug witch parse code in comment :) + // Do not remove it : usefull for i18n.strictMode + // _("vradi.offer.Form.datePeremption") + // _("vradi.offer.Form.datePub") + // _("vradi.offer.Form.xmlStream") + // _("vradi.offer.Infogene.country") + // _("vradi.offer.Infogene.creationDate") + // _("vradi.offer.Infogene.department") + // _("vradi.offer.Infogene.description") + // _("vradi.offer.Infogene.entity") + // _("vradi.offer.Infogene.id") + // _("vradi.offer.Infogene.objet") + // _("vradi.offer.Infogene.sourceText") + // _("vradi.offer.Infogene.sourceURL") + // _("vradi.offer.Infogene.status") + // _("vradi.offer.Infogene.tag") + protected TableColumnExt initAvailableColumn(String fqField, + int modelIndex, boolean visible) { + TableColumnExt tableColumnExt = new TableColumnExt(modelIndex); + + tableColumnExt.setIdentifier(fqField); + tableColumnExt.putClientProperty("fqFieldName", fqField); + + tableColumnExt.setEditable(false); + tableColumnExt.setSortable(true); + tableColumnExt.setVisible(visible); + + tableColumnExt.setToolTipText(_(I18N_COLUMN_PREFIX + fqField)); + + if (log.isTraceEnabled()) { + log.trace(String.format("adding column: %s; position: %s; visible: %s", + fqField, modelIndex, visible)); + } + + return tableColumnExt; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListColumnFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,884 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.ModificationTag; +import org.chorem.vradi.entities.Session; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.entities.VradiUser; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.VradiMainUI; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.email.EmailHandler; +import org.chorem.vradi.ui.email.QueryMakerViewUI; +import org.chorem.vradi.ui.email.helpers.EmailDataHelper; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.search.SearchHandler; +import org.chorem.vradi.ui.search.SearchUI; +import org.chorem.vradi.ui.task.VradiTask; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusSelectionManager; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.event.TableColumnModelExtListener; +import org.jdesktop.swingx.table.TableColumnExt; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JSeparator; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.MouseInputAdapter; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class OfferListHandler { + + static private final Log log = LogFactory.getLog(OfferListHandler.class); + + static final public int TABPANEL_LABEL_MAX_CHAR_NB = 30; + + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param rootContext le context applicatif + * @return l'ui instancie et initialisee mais non visible encore + */ + public OfferListUI initUI(JAXXContext rootContext) { + + JAXXInitialContext context = new JAXXInitialContext().add(rootContext).add(this); + + SearchHandler searchHandler = UIHelper.getHandler(context, SearchHandler.class); + + // show main ui + OfferListTableModel offerListTableModel = new OfferListTableModel(); + OfferListColumnFactory offerListColumnFactory = new OfferListColumnFactory(); + + context.add(offerListTableModel); + context.add(offerListColumnFactory); + + OfferListUI ui = new OfferListUI(context); + + // add listeners + JXTable listTable = ui.getListTable(); + listTable.getColumnModel().addColumnModelListener( + getOfferListTableColumnModelListener()); + + MouseListener offerListTableMouseListener = getOfferListTableMouseListener(); + listTable.addMouseListener(offerListTableMouseListener); + + TableModelListener offerListTableModelListener = getOfferListTableModelListener(listTable); + offerListTableModel.addTableModelListener(offerListTableModelListener); + + // listTable cellRenderer + // TODO SLE 30/09/2010 : Refactor it ! + OfferListTableModel.OfferListTableCellRenderer renderer = + new OfferListTableModel.OfferListTableCellRenderer(); + listTable.setDefaultRenderer(Boolean.class, renderer); + listTable.setDefaultRenderer(Date.class, renderer); + listTable.setDefaultRenderer(Double.class, renderer); + listTable.setDefaultRenderer(String.class, renderer); + listTable.setDefaultRenderer(XmlStream.class, renderer); + listTable.setDefaultRenderer(Status.class, renderer); + + // listTable highlighter + Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + listTable.addHighlighter(highlighter); + + // Show search ui + SearchUI searchUI = searchHandler.initUI(rootContext, offerListTableModel); + searchUI.setOfferListUI(true); + + ui.setSearchUI(searchUI); + + return ui; + } + + protected TableModelListener getOfferListTableModelListener(final JXTable listTable) { + return new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + listTable.packAll(); + } + }; + } + + protected TableColumnModelExtListener getOfferListTableColumnModelListener() { + return new TableColumnModelExtListener() { + @Override + public void columnPropertyChange( + PropertyChangeEvent paramPropertyChangeEvent) { + String propertyName = paramPropertyChangeEvent.getPropertyName(); + + if ("visible".equals(propertyName)) { + TableColumnExt column = (TableColumnExt) paramPropertyChangeEvent.getSource(); + String fqFieldName = (String) column.getClientProperty("fqFieldName"); + + if (log.isTraceEnabled()) { + log.trace("clientprop: " + fqFieldName); + log.trace("identifier: " + column.getIdentifier()); + } + + Boolean visible = (Boolean) paramPropertyChangeEvent.getNewValue(); + if (visible) { + VradiHelper.addVradiListColumns(fqFieldName); + } else { + VradiHelper.removeVradiListColumns(fqFieldName); + } + } + } + + @Override + public void columnAdded(TableColumnModelEvent e) { + } + + @Override + public void columnRemoved(TableColumnModelEvent e) { + } + + @Override + public void columnMoved(TableColumnModelEvent e) { + } + + @Override + public void columnMarginChanged(ChangeEvent e) { + } + + @Override + public void columnSelectionChanged(ListSelectionEvent e) { + } + }; + } + + /** + * Implementation du click (droit/gauche) sur la table des offres résultats/ + * <p/> + * Comportement : + * <ul> + * <li>double clic : ouvre l'offre + * <li>clic droit : changer le status, ajouter a une session de mail + * </ul> + * + * @return le mouse listener + */ + public MouseListener getOfferListTableMouseListener() { + // double click on listTable shows selected offer + return new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + JTable listTable = (JTable) e.getSource(); + OfferListUI offerListUI = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + + // double clic + if (e.getButton() == MouseEvent.BUTTON1 && + e.getClickCount() == 2) { + try { + offerListUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + selectOffer(offerListUI, listTable); + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Can't open offer", ex); + } + ErrorDialogUI.showError(ex); + } finally { + offerListUI.setCursor(null); + } + + // clic droit + } else if (e.getButton() == MouseEvent.BUTTON3) { + int[] selectedRows = offerListUI.getListTable().getSelectedRows(); + int rowClicked = offerListUI.getListTable().rowAtPoint(e.getPoint()); + boolean rowClickedSelected = false; + if (selectedRows == null || selectedRows.length == 0) { + offerListUI.getListTable().getSelectionModel().setSelectionInterval(rowClicked, rowClicked); + rowClickedSelected = true; + } else { + int i = 0; + while (i < selectedRows.length && !rowClickedSelected) { + rowClickedSelected = rowClicked == selectedRows[i++]; + } + } + + if (rowClickedSelected) { + showOfferListContextMenu(offerListUI, e); + } + } + } + }; + } + + /** + * Le menu contextuel lors d'un clic droit sur la table. + * + * @param offerListUI l'ui d'origine + * @param e event du clic + */ + protected void showOfferListContextMenu(OfferListUI offerListUI, MouseEvent e) { + JPopupMenu menu = new JPopupMenu(); + JMenu changeStatus = new JMenu(_("vradi.offer.status.change")); + + List<Status> statuses = AdminHandler.getAllStatuses(); + for (Status status : statuses) { + JMenuItem statusItem = new JMenuItem(_(status.getName())); + statusItem.addActionListener(new StatusActionListener(offerListUI, status)); + changeStatus.add(statusItem); + } + + menu.add(changeStatus); + menu.add(new JSeparator()); + + JMenu addSending = new JMenu(_("vradi.offer.email.add")); + + // Menu to add user or group sending + JMenuItem addUserSendingItem = new JMenuItem(_("vradi.email.addUser")); + addUserSendingItem.addActionListener(new UserAddSendingListener(offerListUI)); + + JMenuItem addgroupSendingItem = new JMenuItem(_("vradi.email.addGroup")); + addgroupSendingItem.addActionListener(new GroupAddSendingListener(offerListUI)); + + addSending.add(addUserSendingItem); + addSending.add(addgroupSendingItem); + + menu.add(addSending); + + // Menu to remove form from session + // Menu not asked +// JMenuItem removeFormSession = new JMenuItem(_("vradi.offer.email.removeForm")); +// removeFormSession.addActionListener(new RemoveFormSessionListener(offerListUI)); + +// menu.add(new JSeparator()); +// menu.add(removeFormSession); + + menu.show(e.getComponent(), e.getX(), e.getY()); + } + + /** + * Il est possible de faire un clic droit dans la liste des résutats + * pour ajouter un appel d'offre directement dans la derniere session + * ouverte. + */ + protected abstract class AddSendingListener implements ActionListener { + protected OfferListUI offerListUI; + + protected List<String> formsIdsToUpdate = new ArrayList<String>(); + + protected AddSendingListener(OfferListUI offerListUI) { + this.offerListUI = offerListUI; + + int[] selectedRows = offerListUI.getListTable().getSelectedRows(); + + for (int row : selectedRows) { + JXTable listTable = offerListUI.getListTable(); + OfferListTableModel tableModel = offerListUI.getOfferListTableModel(); + row = listTable.convertRowIndexToModel(row); + + FormPagedResult formPage = tableModel.getFormPagedResult(); + List<String> formsIdsToShow = formPage.getFormsIdsToShow(); + + String formId = formsIdsToShow.get(row); + if (formId != null) { + formsIdsToUpdate.add(formId); + } + } + } + + protected AdminHandler getAdminHandler() { + return UIHelper.getHandler(offerListUI, AdminHandler.class); + } + + protected <E extends BusinessEntity> void openUI(final Class<E> clazz, String title, List<E> all) { + + try { + + Session currentSession = VradiService.getVradiDataService().getLastOpenSession(); + + if (currentSession == null) { + JOptionPane.showMessageDialog(offerListUI, + _("Can't found any opened mail session, please create a new session in mail management"), + _("Error"), JOptionPane.ERROR_MESSAGE); + } else { + List<Form> forms = VradiService.getWikittyProxy().restore(Form.class, formsIdsToUpdate); + Status selectionne = VradiHelper.getSelectionneStatus(); + + int responce = JOptionPane.showConfirmDialog( + getUI(offerListUI), + _("vradi.email.confirmSelectionForm", EmailDataHelper.convertFormsToString(forms)), + _("vradi.email.confirmSelectionForm.title"), + JOptionPane.YES_NO_OPTION); + + if (responce == JOptionPane.YES_OPTION) { + changeAllStatus(getUI(offerListUI), forms, selectionne); + } else { + return; + } + + VradiMainUI mainUI = VradiContext.MAIN_UI_ENTRY_DEF.getContextValue(offerListUI); + final JDialog ui = new JDialog(mainUI, _(title)); + ui.setLayout(new BorderLayout()); + + final QueryMakerViewUI<E> makerViewUI = new QueryMakerViewUI<E>(offerListUI); + makerViewUI.setSession(currentSession); + + makerViewUI.setFormsIds(formsIdsToUpdate); + makerViewUI.setClazz(clazz); + + makerViewUI.init(all, new ArrayList<E>()); + + ui.add(makerViewUI, BorderLayout.CENTER); + JButton validButton = new JButton(_("vradi.action.valid")); + validButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + addUserAndGroupSending(makerViewUI, clazz); + + ui.setVisible(false); + ui.dispose(); + } + }); + ui.add(validButton, BorderLayout.SOUTH); + ui.setModal(true); + ui.setSize(800, 600); + ui.setLocationRelativeTo(mainUI); + ui.setVisible(true); + } + } catch (VradiException ex) { + if (log.isErrorEnabled()) { + log.error("Can't get current opened session", ex); + } + } + } + } + + protected <E extends BusinessEntity> void addUserAndGroupSending(final QueryMakerViewUI<E> ui, final Class<E> clazz) { + + VradiTask<Void> addUserAndGroupSendingTask = new VradiTask<Void>(ui, false) { + @Override + public Void doAction() throws Exception { + + try { + Form form = ui.getForm(); + Session session = ui.getSession(); + EmailHandler handler = ui.getHandler(); + + if (form != null) { + if (clazz == User.class) { + handler.addAllUserSending(ui, session, form.getWikittyId(), ui.getQueryMakerForm().getListDatas()); + } else { + handler.addAllGroupSending(ui, session, form.getWikittyId(), ui.getQueryMakerForm().getListDatas()); + } + } else { + List<String> formsIds = ui.getFormsIds(); + if (clazz == User.class) { + handler.addAllUserSending(ui, session, formsIds, ui.getQueryMakerForm().getListDatas()); + } else { + handler.addAllGroupSending(ui, session, formsIds, ui.getQueryMakerForm().getListDatas()); + } + } + } catch (Exception eee) { + log.error("Cant add group or user to session : ", eee); + ErrorDialogUI.showError(eee); + } + return null; + } + }; + + addUserAndGroupSendingTask.execute(); + } + + protected class GroupAddSendingListener extends AddSendingListener { + + public GroupAddSendingListener(OfferListUI offerListUI) { + super(offerListUI); + } + + @Override + public void actionPerformed(ActionEvent e) { + openUI(Group.class, "vradi.email.addGroup", getAdminHandler().getAllGroups()); + } + } + + protected class UserAddSendingListener extends AddSendingListener { + + public UserAddSendingListener(OfferListUI offerListUI) { + super(offerListUI); + } + + @Override + public void actionPerformed(ActionEvent e) { + openUI(User.class, "vradi.email.addUser", getAdminHandler().getAllUsers()); + } + } + + protected class StatusActionListener implements ActionListener { + protected Status status; + + protected OfferListUI offerListUI; + + public StatusActionListener(OfferListUI offerListUI, Status status) { + this.offerListUI = offerListUI; + this.status = status; + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + int confirm = JOptionPane.showConfirmDialog(offerListUI, + _("vradi.offerList.status.change.confirmation.message", _(status.getName())), + _("vradi.offerList.status.change.confirmation.title"), + JOptionPane.YES_NO_OPTION); + + if (confirm == JOptionPane.YES_OPTION) { + offerListUI.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + try { + int[] selectedRows = offerListUI.getListTable().getSelectedRows(); + + List<String> formIds = new ArrayList<String>(); + JXTable listTable = offerListUI.getListTable(); + OfferListTableModel tableModel = offerListUI.getOfferListTableModel(); + FormPagedResult formPageDTO = tableModel.getFormPagedResult(); + List<String> formsIdsToShow = formPageDTO.getFormsIdsToShow(); + + for (int row : selectedRows) { + row = listTable.convertRowIndexToModel(row); + String formId = formsIdsToShow.get(row); + if (formId != null) { + formIds.add(formId); + } + } + + List<Form> forms = VradiService.getWikittyProxy().restore(Form.class, formIds); + changeAllStatus(offerListUI, forms, status); + + } catch (WikittyException eee) { + if (log.isErrorEnabled()) { + log.error("Can't change offer status", eee); + } + ErrorDialogUI.showError(eee); + } finally { + offerListUI.setCursor(null); + } + } + } + } + + protected void changeAllStatus(JAXXContext context, List<Form> forms, Status status) { + + try { + + List<Form> formToSave = new ArrayList<Form>(); + for (Form form : forms) { + formToSave.add(prepareChangeStatus(context, form, status)); + VradiService.getWikittyProxy().store(form); + } + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't change status", eee); + } + } + } + + protected void changeStatus(JAXXContext context, String formId, Status status) { + + try { + Form form = VradiService.getWikittyProxy().restore(Form.class, formId); + form = prepareChangeStatus(context, form, status); + VradiService.getWikittyProxy().store(form); + + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't change status", eee); + } + } + } + + protected Form prepareChangeStatus(JAXXContext context, Form form, Status status) { + String initialStatus = form.getStatus(); + String updateStatus = status.getWikittyId(); + + if (initialStatus == null || !updateStatus.equals(initialStatus)) { + VradiUser vradiUser = context.getContextValue(VradiUser.class); + String statusModifier = vradiUser != null ? vradiUser.getLogin() : null; + + // add modification info + ModificationTag formTag = VradiService.getWikittyProxy().cast(form, ModificationTag.class); + formTag.setLastModified(new Date()); + formTag.setLastModifier(statusModifier); + formTag.setLastStatusModifier(statusModifier); + + if (log.isDebugEnabled()) { + log.debug(String.format("Updating: statusModifier=%s on form: %s", statusModifier, form.getWikittyId())); + log.debug(String.format("New Status: %s, Old Status: %s", initialStatus, updateStatus)); + } + } + + form.setStatus(updateStatus); + return form; + } + + public void addEditPane(JAXXContext context, String formId) { + Form form = VradiService.getWikittyProxy().restore(Form.class, formId); + addEditPane(context, form); + } + + public OfferEditUI addEditPane(JAXXContext context, final Form form) { + OfferListUI ui = getUI(context); + + // Fill free space + ui.setDividerLocation(0); + ui.setResizeWeight(0); + ui.setDividerSize(12); + + // Get tab + JTabbedPane contentTabbedPane = ui.getEditTabs(); + + String formId = form.getWikittyId(); + + OfferEditUI editUi = null; + // Exist ? + if (contentTabbedPane.indexOfTab(formId) < 0) { + + // Open new + final OfferEditHandler handler = UIHelper.getHandler(context, OfferEditHandler.class); + try { + editUi = handler.initUI(context, form); + } catch (Exception eee) { + // Do nothing on fail + if (log.isErrorEnabled()) { + log.error("Can't init UI", eee); + } + ErrorDialogUI.showError(eee); + return null; + } + + // Do nothing on fail + if (editUi == null) { + return null; + } + + final OfferEditUI editUiFinal = editUi; + contentTabbedPane.add(formId, editUiFinal); + + final VradiTabHeader panel = new VradiTabHeader(); + + if (form.getObjet() != null) { + String panelLabel = form.getObjet().length() < TABPANEL_LABEL_MAX_CHAR_NB ? + form.getObjet() : form.getObjet().substring(0, TABPANEL_LABEL_MAX_CHAR_NB) + "..."; + panel.getLabel().setText(panelLabel); + } + panel.setId(formId); + + // Table closeable + contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(formId), panel); + panel.getCloseTab().addMouseListener(new MouseInputAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + closePane(editUiFinal, panel.getId()); + } + }); + + // Detachable + panel.getDetachTab().addMouseListener(new MouseInputAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + detachPane(e); + } + }); + + // Get all status + List<Status> statuses = AdminHandler.getAllStatuses(); + + // New modifiable list + List<Status> orderedStatus = new ArrayList<Status>(statuses); + + // Sort by value + Collections.sort(orderedStatus, VradiComparators.STATUSES_COMPARATOR); + + // Add all buttons + JPanel buttonPanel = editUiFinal.getStatusButtonPanel(); + for (final Status status : orderedStatus) { + JButton statusButton = new JButton(_(status.getName())); + statusButton.setToolTipText(status.getDescription()); + if (status.getWikittyId().equals(form.getStatus())) { + Color newColor = new Color(110, 150, 200, + statusButton.getBackground().getAlpha()); + statusButton.setBackground(newColor); + } + statusButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionEvent) { + closePane(editUiFinal, panel.getId()); + handler.changeStatusAndSave(editUiFinal, form, status); + } + }); + buttonPanel.add(statusButton); + } + + // Register to save disposition + UIHelper.registerComponentToSaveDispositionConfig(editUiFinal); + + // Cancel + editUiFinal.getAnnuler().addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + closePane(editUiFinal, panel.getId()); + } + }); + + // Update + /*editUiFinal.getValidate().addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionEvent) { + handler.save(editUiFinal, data); + closePane(editUiFinal, panel.getId()); + + SearchHandler handler = UIHelper.getHandler(editUiFinal, SearchHandler.class); + handler.executeQueries(ui); + } + });*/ + + } + + // Select + contentTabbedPane.setSelectedIndex(contentTabbedPane.indexOfTab(formId)); + + return editUi; + } + + protected VradiTabHeader getTabHeader(MouseEvent e) { + JButton button = (JButton) e.getSource(); + return (VradiTabHeader) button.getParent(); + } + + public void closeAllTabs() { + OfferListUI ui = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + JTabbedPane contentTabbedPane = getContentPane(ui); + contentTabbedPane.removeAll(); + allEditPanelRemoved(contentTabbedPane, ui); + } + + protected void closePane(JAXXContext context, String id) { + + // Save ui disposition before close pane to keep conf of offerEditHandler + UIHelper.saveComponentDispositionConfig(); + + // Remove listener + ThesaurusSelectionManager selectionManager = context.getContextValue(ThesaurusSelectionManager.class); + + OfferListUI ui = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + JTabbedPane contentTabbedPane = getContentPane(ui); + int index = contentTabbedPane.indexOfTab(id); + if (index > -1) { + contentTabbedPane.remove(index); + } + allEditPanelRemoved(contentTabbedPane, ui); + } + + // Detach editUI + protected void detachPane(MouseEvent e) { + // Get panel + VradiTabHeader mytab = getTabHeader(e); + String id = mytab.getId(); + String name = mytab.getLabel().getText(); + + OfferListUI ui = mytab.getParentContainer(OfferListUI.class); + JTabbedPane contentTabbedPane = getContentPane(ui); + OfferEditUI content = getOfferEdit(contentTabbedPane, id); + + // Create popups + final JFrame frame = new JFrame(name); + + JPanel buttonPanel = content.getStatusButtonPanel(); + for (Component c : buttonPanel.getComponents()) { + + if (c instanceof JButton) { + JButton button = (JButton) c; + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + closeDetachedPane(frame); + } + }); + } + } + + // Close + /*content.getValidate().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + closeDetachedPane(frame, content); + } + });*/ + + // Cancel + content.getAnnuler().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + closeDetachedPane(frame); + } + }); + + // Remove default listener + frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + + // Add listener + frame.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent e) { + closeDetachedPane(frame); + } + }); + + frame.setLayout(new BorderLayout()); + frame.add(content, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + + UIHelper.registerComponentToSaveDispositionConfig(frame); + + // Remove + allEditPanelRemoved(contentTabbedPane, ui); + } + + protected OfferEditUI getOfferEdit(JTabbedPane contentTabbedPane, String id) { + return (OfferEditUI) contentTabbedPane.getComponentAt(contentTabbedPane.indexOfTab(id)); + } + + protected void closeDetachedPane(JFrame f) { + // Store disposition for this frame + UIHelper.saveComponentDispositionConfig(); + + // Close + f.setVisible(false); + f.dispose(); + } + + public void addEditPane(JAXXContext context, List<Form> datas) { + for (Form data : datas) { + addEditPane(context, data.getWikittyId()); + } + } + + protected void allEditPanelRemoved(JTabbedPane contentTabbedPane, OfferListUI ui) { + if (contentTabbedPane.getTabCount() == 0) { + ui.setDividerLocation(Integer.MAX_VALUE); + ui.setResizeWeight(1); + ui.setDividerSize(0); + } + } + + public OfferListUI getUI(JAXXContext context) { + if (context instanceof OfferListUI) { + return (OfferListUI) context; + } + OfferListUI ui = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + return ui; + } + + protected JTabbedPane getContentPane(JAXXContext context) { + OfferListUI ui = getUI(context); + return ui.getEditTabs(); + } + + protected JTabbedPane getContentPane(OfferListUI ui) { + return ui.getEditTabs(); + } + + protected void selectOffer(JAXXContext context, JTable listTable) { + OfferListTableModel tableModel = (OfferListTableModel) listTable.getModel(); + int selectedRow = listTable.getSelectedRow(); + + if (selectedRow >= 0 && selectedRow < tableModel.getRowCount()) { + selectedRow = listTable.convertRowIndexToModel(selectedRow); + + FormPagedResult formPageDTO = tableModel.getFormPagedResult(); + List<String> formsToShow = formPageDTO.getFormsIdsToShow(); + + String formId = formsToShow.get(selectedRow); + if (formId != null) { + if (log.isDebugEnabled()) { + Form form = VradiService.getWikittyProxy().restore(Form.class, formId); + log.debug("Show Form: " + form.getObjet()); + } + addEditPane(context, formId); + } + } + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,148 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JSplitPane id='offerList' constraints='BorderLayout.CENTER' + oneTouchExpandable='true' orientation='{JSplitPane.VERTICAL_SPLIT}' + dividerLocation='{Integer.MAX_VALUE}' dividerSize='{0}' + resizeWeight='{1}'> + + <style source='../VradiMainUI.css'/> + + <import> + java.awt.Color + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + + javax.swing.table.JTableHeader + javax.swing.table.TableColumn + javax.swing.table.TableColumnModel + javax.swing.table.TableRowSorter + javax.swing.text.MaskFormatter + + jaxx.runtime.binding.SimpleJAXXObjectBinding + jaxx.runtime.binding.DefaultJAXXBinding + + org.chorem.vradi.ui.search.SearchHandler + org.chorem.vradi.ui.search.SearchUI + org.chorem.vradi.ui.search.PaginationUI + org.chorem.vradi.ui.offer.models.OfferListTableModel + </import> + + <!-- le modèle du tableau --> + <OfferListColumnFactory id='offerListColumnFactory' + javaBean='getContextValue(OfferListColumnFactory.class)'/> + + <OfferListTableModel id='offerListTableModel' + javaBean='getContextValue(OfferListTableModel.class)' + nbFormsPerPage='{10}' pageToShow='{1}'/> + + <Boolean id='advancedSearchCollapsed' javaBean='false'/> + + <script><![CDATA[ +protected SearchUI searchUI; + +public OfferListHandler getHandler() { + return getContextValue(OfferListHandler.class); +} + +public SearchHandler getSearchHandler() { + return getContextValue(SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public void setSearchUI(SearchUI searchUI) { + this.searchUI = searchUI; + searchPanel.add(searchUI, BorderLayout.CENTER); +} + +public SearchUI getSearchUI() { + return searchUI; +} + +void $afterCompleteSetup() { + final JTableHeader header = listTable.getTableHeader(); + header.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + // Get column selected + TableColumnModel columnModel = ((JTableHeader)e.getSource()).getColumnModel(); + int columnIndex = columnModel.getColumnIndexAtX(e.getX()); + TableColumn column = columnModel.getColumn(columnIndex); + + final String fqName = offerListTableModel.getColumnFqName(columnIndex); + offerListTableModel.setAscending(!offerListTableModel.isAscending()); + offerListTableModel.setFieldToSort(fqName); + } + } + }); + + OfferListTableModel.OfferListTableModelBinding djb = new OfferListTableModel.OfferListTableModelBinding(this, + "offerListTableModel", offerListTableModel) { + @Override + public void processDataBinding() { + if (offerListTableModel != null) { + getSearchHandler().executeQuery(searchUI); + } + } + }; + + registerDataBinding(djb); + djb.applyDataBinding(); + + validate(); +} + +]]> + </script> + + <JPanel layout='{new BorderLayout()}'> + <JPanel id='searchPanel' layout='{new BorderLayout()}' + constraints='BorderLayout.NORTH'/> + + <JScrollPane constraints='BorderLayout.CENTER'> + <OfferTable id='listTable' + columnFactory='{offerListColumnFactory}' + model='{offerListTableModel}' + autoResizeMode='{2}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + showGrid='{true}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + + <JPanel id='paginationPanel' layout='{new BorderLayout()}' + constraints='BorderLayout.SOUTH'> + <PaginationUI id='paginationUI' constructorParams='this' + constraints='BorderLayout.NORTH'/> + <JButton id='exportButton' text='vradi.export.cvs' + onActionPerformed='getSearchHandler().exportToCSV(offerListTableModel)' + constraints='BorderLayout.SOUTH'/> + </JPanel> + </JPanel> + <JTabbedPane id='editTabs'/> +</JSplitPane> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferListUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferTable.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferTable.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferTable.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,86 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import org.apache.commons.lang.StringUtils; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.jdesktop.swingx.JXTable; +import org.nuiton.widget.tooltip.FocusableTip; + +import java.awt.event.MouseEvent; + +/** + * Offer table. + * <p/> + * Extends default JXTable with: + * <ul> + * <li>Persistent tooltip support + * </ul> + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class OfferTable extends JXTable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 4554858117023580350L; + + /** Single tooltip instance. */ + protected FocusableTip focusableTip; + + /* + * @see javax.swing.JComponent#getToolTipText() + */ + @Override + public String getToolTipText(MouseEvent e) { + + // Get row concerned + int row = rowAtPoint(e.getPoint()); + if (row == -1) { + return null; + } + + // get original text + String text = ((OfferListTableModel) getModel()).getToolTip(convertRowIndexToModel(row)); + + // Dont display toolTip if empty + if (text == null || StringUtils.isEmpty(text.trim())) { + return null; + } + + // display it into persistant tooltip + if (focusableTip == null) { + focusableTip = new FocusableTip(this, true); + focusableTip.setSize(600, 400); + } + + focusableTip.toolTipRequested(e, text); + + return null; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/OfferTable.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,335 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.context.JAXXInitialContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.VradiStorageService; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableModel; +import org.nuiton.i18n.I18n; + +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +/** + * RequestFormViewHandler. + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 19 mars 2010 14:42:03 + */ +public class RequestFormViewHandler { + private static Log log = LogFactory.getLog(RequestFormViewHandler.class); + + private VradiStorageService vradiStorageService; + + protected VradiStorageService getVradiStorageService() { + if (vradiStorageService == null) { + vradiStorageService = VradiService.getVradiStorageService(); + } + return vradiStorageService; + } + + public RequestFormViewUI initUI(JAXXContext rootContext, Map<Group, List<QueryBean>> queries) { + JAXXInitialContext context = new JAXXInitialContext().add(rootContext).add(this); + context.add("queries", queries); + + RequestFormViewUI requestFormViewUI = new RequestFormViewUI(context); + JXTreeTable resultTreeTable = requestFormViewUI.getResultTreeTable(); + JXTable resultTable = requestFormViewUI.getResultTable(); + resultTreeTable.expandAll(); + + Highlighter highlighter = HighlighterFactory.createAlternateStriping( + HighlighterFactory.NOTEPAD, HighlighterFactory.GENERIC_GRAY); + resultTable.addHighlighter(highlighter); + resultTreeTable.addHighlighter(highlighter); + + return requestFormViewUI; + } + + public TableModel getResultTableModel(RequestFormViewUI context) { + QueryTableModel tableModel = context.getContextValue(QueryTableModel.class); + if (tableModel == null) { + Map<Group, List<QueryBean>> queries = context.getContextValue(Map.class, "queries"); + tableModel = new QueryTableModel(queries); + context.setContextValue(tableModel); + + final JXTable resultTable = context.getResultTable(); + tableModel.addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + resultTable.packAll(); + } + }); + } + return tableModel; + } + + public TreeTableModel getResultTreeTableModel(RequestFormViewUI context) { + QueryTreeTableModel treeTableModel = context.getContextValue(QueryTreeTableModel.class); + if (treeTableModel == null) { + Map<Group, List<QueryBean>> queries = context.getContextValue(Map.class, "queries"); + treeTableModel = new QueryTreeTableModel(queries); + context.setContextValue(treeTableModel); + + JXTreeTable resultTreeTable = context.getResultTreeTable(); + QueryTreeTableModelListener treeModelListener = new QueryTreeTableModelListener(resultTreeTable); + treeTableModel.addTreeModelListener(treeModelListener); + } + return treeTableModel; + } + + void close(RequestFormViewUI context) { + context.setVisible(false); + UIHelper.saveComponentDispositionConfig(); + context.dispose(); + } + + class QueryTreeTableModelListener implements TreeModelListener { + final JXTreeTable treeTable; + + public QueryTreeTableModelListener(JXTreeTable treeTable) { + this.treeTable = treeTable; + } + + @Override + public void treeNodesChanged(TreeModelEvent e) { + } + + @Override + public void treeNodesInserted(TreeModelEvent e) { + } + + @Override + public void treeNodesRemoved(TreeModelEvent e) { + } + + @Override + public void treeStructureChanged(TreeModelEvent e) { + treeTable.packAll(); + } + } + + class QueryTreeTableModel extends AbstractTreeTableModel { + /** clients and groups */ + final ArrayList<Group> topLevels = new ArrayList<Group>(); + + /** queries indexed by wikittyId */ + final HashMap<String, List<QueryBean>> queryBeanMap = new HashMap<String, List<QueryBean>>(); + + public QueryTreeTableModel(Map<Group, List<QueryBean>> queryMap) { + super(1L); + + HashMap<String, Group> groupMap = new HashMap<String, Group>(); + + for (Map.Entry<Group, List<QueryBean>> entry : queryMap.entrySet()) { + Group group = entry.getKey(); + List<QueryBean> queries = entry.getValue(); + + String wikittyId = group.getWikittyId(); + + // client + groupMap.put(wikittyId, group); + + // queries + queryBeanMap.put(wikittyId, queries); + } + List<Group> groupList = new ArrayList<Group>(groupMap.values()); + + Collections.sort(groupList, VradiComparators.GROUP_COMPARATOR); + + topLevels.addAll(groupList); + } + + @Override + public int getColumnCount() { + return 3; + } + + @Override + public Object getValueAt(Object node, int column) { + if (node instanceof Group) { + if (column == 0) { + Group group = (Group) node; + return group.getName(); + } + + } else if (node instanceof QueryBean) { + QueryBean bean = (QueryBean) node; + if (column == 0) { + return bean.getName(); + + } else if (column == 1) { + return bean.getDescription(); + + } else if (column == 2) { + return bean.getQuery(); + } + } + + return null; + } + + @Override + public Object getChild(Object parent, int index) { + if (parent instanceof Long) { + return topLevels.get(index); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + QueryBean bean = list.get(index); + return bean; + } + + return null; + } + + @Override + public int getChildCount(Object parent) { + if (parent instanceof Long) { + return topLevels.size(); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + return list.size(); + } + + return 0; + } + + @Override + public int getIndexOfChild(Object parent, Object child) { + if (parent instanceof Long) { + return topLevels.indexOf(child); + + } else if (parent instanceof Group) { + Group group = (Group) parent; + List<QueryBean> list = queryBeanMap.get(group.getWikittyId()); + return list.indexOf(child); + } + + return 0; + } + + @Override + public String getColumnName(int column) { + String columnName = null; + if (column == 0) { + columnName = I18n._("vradi.requestFormView.resultTable.name"); + } else if (column == 1) { + columnName = I18n._("vradi.requestFormView.resultTable.description"); + } else if (column == 2) { + columnName = I18n._("vradi.requestFormView.resultTable.query"); + } + return columnName; + } + } + + /** QueryTableModel. */ + class QueryTableModel extends AbstractTableModel { + private static final long serialVersionUID = 1L; + + final QueryBean[] queries; + + public QueryTableModel(Map<Group, List<QueryBean>> queryMap) { + HashSet<QueryBean> querySet = new HashSet<QueryBean>(); + Collection<List<QueryBean>> lists = queryMap.values(); + + for (List<QueryBean> list : lists) { + querySet.addAll(list); + } + + queries = new QueryBean[querySet.size()]; + querySet.toArray(queries); + } + + @Override + public String getColumnName(int column) { + String columnName = null; + if (column == 0) { + columnName = I18n._("vradi.requestFormView.resultTable.name"); + } else if (column == 1) { + columnName = I18n._("vradi.requestFormView.resultTable.description"); + } else if (column == 2) { + columnName = I18n._("vradi.requestFormView.resultTable.query"); + } + return columnName; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + /* + * columnIndex | Model | VradiQueryBean + * -------------+---------------+------------------ + * 0 | name | query + * 1 | description | name + * 2 | query | description + */ + QueryBean queryBean = queries[rowIndex]; + String[] queryArray = queryBean.toArray(); + + if (columnIndex < 2) { + return queryArray[columnIndex + 1]; + } else { + return queryArray[0]; + } + } + + @Override + public int getRowCount() { + return queries.length; + } + + @Override + public int getColumnCount() { + return 3; + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<JFrame id='requestFormView' + title='vradi.requestFormView.title' + layout='{new BorderLayout()}'> + + <style source='../VradiMainUI.css'/> + + <import> + java.awt.Color + javax.swing.ListSelectionModel + javax.swing.JTable + org.jdesktop.swingx.JXTable + org.jdesktop.swingx.JXTreeTable + </import> + + <script><![CDATA[ + +void $afterCompleteSetup() { + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected RequestFormViewHandler getHandler() { + return getContextValue(RequestFormViewHandler.class); +} + ]]></script> + + <JTabbedPane constraints='BorderLayout.CENTER'> + <tab title='vradi.requestFormView.tab.table'> + <JScrollPane> + <JXTable id='resultTable' + model='{getHandler().getResultTableModel(this)}' + autoResizeMode='{JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + showGrid='{false}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + </tab> + <tab title='vradi.requestFormView.tab.treetable'> + <JScrollPane> + <JXTreeTable id='resultTreeTable' + treeTableModel='{getHandler().getResultTreeTableModel(this)}' + autoResizeMode='{JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + selectionMode='{ListSelectionModel.SINGLE_SELECTION}' + showGrid='{false}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + </tab> + </JTabbedPane> + + <JButton id='close' constraints='BorderLayout.SOUTH' text='vradi.action.close' + onActionPerformed='getHandler().close(this)'/> +</JFrame> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/RequestFormViewUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusCartographyUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusCartographyUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusCartographyUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,124 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JFrame id='thesaurusCartographyUI' + title='vradi.thesaurusCartographyUI.title' + layout='{new BorderLayout()}' + defaultCloseOperation='{JFrame.DO_NOTHING_ON_CLOSE}' + onWindowClosing='this.dispose()'> + + <import> + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + + javax.swing.Action + javax.swing.JPopupMenu + javax.swing.ListSelectionModel + + jaxx.runtime.JAXXContext + jaxx.runtime.SwingUtil + org.jdesktop.swingx.JXTreeTable + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper + org.chorem.vradi.ui.renderers.ThesaurusHighlighter + org.chorem.vradi.ui.admin.content.AdminThesaurusHandler + </import> + + <script><![CDATA[ + +protected ThesaurusTreeTableHelper helper; +protected ThesaurusHighlighter highlighter; + + +public ThesaurusCartographyUI(JAXXContext parentContext, ThesaurusTreeTableHelper helper) { + SwingUtil.initContext(this, parentContext); + this.helper = helper; + setContextValue(helper); + highlighter = new ThesaurusHighlighter(helper.getDataProvider()); +} + +void $afterCompleteSetup() { + thesaurus.putClientProperty("JTree.lineStyle", "Angled"); + final Action copyToClipboard = new AdminThesaurusHandler.CopyToClipboard(this); + + // Adding ridht clic menu + thesaurus.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(final MouseEvent mouseEvent) { + + + JPopupMenu popup = new JPopupMenu(); + + // Add mouse listener to enable menus + if (mouseEvent.getButton() == MouseEvent.BUTTON3){ + + popup.add(copyToClipboard); + + popup.show(thesaurus, mouseEvent.getX(), mouseEvent.getY()); + } + } + }); + + // Register tree table + helper.setUI(thesaurus, true, false, null); + + // Single selection mode + thesaurus.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + // Expend on click + UIHelper.addThesaurusExpandOnClickListener(thesaurus); + + // Render + thesaurus.setTreeCellRenderer(highlighter); + + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +public ThesaurusTreeTableHelper getHelper() { + return helper; +} + +protected void close() { + UIHelper.saveComponentDispositionConfig(); + this.dispose(); +} + +]]></script> + + <JScrollPane constraints='BorderLayout.CENTER'> + + <JXTreeTable id="thesaurus" + font-size='11' + rootVisible='false' + showsRootHandles='true' + treeTableModel='{helper.createTreeModel()}' + highlighters='{highlighter}'/> + </JScrollPane> + + <JButton text='vradi.common.close' constraints='BorderLayout.SOUTH' + actionIcon='close' + onActionPerformed='close()'/> +</JFrame> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusCartographyUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,349 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer; + +import jaxx.runtime.JAXXContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.search.SearchHandler; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusSelectionManager; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeHelper; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.tree.TreePath; +import java.util.List; + +/** @author letellier */ +public class ThesaurusHandler { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(ThesaurusHandler.class); + + /** + * Init all thesaurus panel to attach to offer edit panel + * + * @param ui OfferEditUI + */ + public void initThesaurus(OfferEditUI ui) { + + JList propositionList = ui.getPropositionList(); + Form form = ui.getData(); + JPanel thesaurusPanel = ui.getThesaurus(); + + // Remove all thesaurus panels + thesaurusPanel.removeAll(); + + VradiDataProvider dataProvider = new VradiDataProvider(); + + // Create thesaurus manager + ThesaurusSelectionManager manager = new ThesaurusSelectionManager(propositionList, form); + + // Put it in context + ui.setContextValue(manager); + + // Display root thesaurus UI + ThesaurusTreeHelper rootHelper = new ThesaurusTreeHelper(dataProvider); + openThesaurusUI(ui, thesaurusPanel, manager, rootHelper, false); + + // Create helpers for saved root thesaurus + List<String> rootThesaurusIds = VradiHelper.getVradiListRootThesaurus(); + List<RootThesaurus> savedRootThesauruses = ThesaurusDataHelper.restoreRootThesaurus(rootThesaurusIds); + for (RootThesaurus savedRootThesaurus : savedRootThesauruses) { + if (savedRootThesaurus != null) { + ThesaurusTreeHelper helper = new ThesaurusTreeHelper(dataProvider, savedRootThesaurus); + openThesaurusUI(ui, thesaurusPanel, manager, helper, true); + } + } + + // Create helpers for saved thesaurus + List<String> thesaurusIds = VradiHelper.getVradiListThesaurus(); + List<Thesaurus> savedThesauruses = ThesaurusDataHelper.restoreThesaurus(thesaurusIds); + for (Thesaurus savedThesaurus : savedThesauruses) { + if (savedThesaurus != null) { + ThesaurusTreeHelper helper = new ThesaurusTreeHelper(dataProvider, savedThesaurus); + openThesaurusUI(ui, thesaurusPanel, manager, helper, true); + } + } + + // Update size thesaurus + ui.updateThesaurusSize(); + } + + protected void openThesaurusUI(JAXXContext context, JPanel thesaurusPanel, ThesaurusSelectionManager manager, ThesaurusTreeHelper helper, boolean deletable) { + thesaurusPanel.add(new ThesaurusUI(context, manager, helper, deletable)); + } + + /** + * Add thesaurus panel removable in offerEdit and save it in properties + * + * @param context jaxx context + * @param manager thesaurus selection manager + * @param path path of thesaurus to add + */ + public void newThesaurusUI(JAXXContext context, ThesaurusSelectionManager manager, TreePath path) { + if (path == null) { + return; + } + // Get selected thesaurus + VradiTreeNode parentNode = (VradiTreeNode) path.getLastPathComponent(); + if (parentNode == null) { + return; + } + + ThesaurusTreeHelper newHelper; + + RootThesaurus rootThesaurus = getRootThesaurus(parentNode); + if (rootThesaurus != null) { + newHelper = new ThesaurusTreeHelper(manager.getDataProvider(), rootThesaurus); + + // Save in properties + VradiHelper.addVradiListRootThesaurus(rootThesaurus); + + } else { + Thesaurus thesaurus = getThesaurus(parentNode); + newHelper = new ThesaurusTreeHelper(manager.getDataProvider(), thesaurus); + + // Save in properties + VradiHelper.addVradiListThesaurus(thesaurus); + } + + openThesaurusUI(context, getThesaurusContainer(context), manager, newHelper, true); + + getEditUI(context).updateThesaurusSize(); + + } + + /** + * Remove thesaurus ui and save it in properties + * + * @param context to removed + */ + public void closeThesaurus(JAXXContext context) { + + ThesaurusUI thesaurusUI = getUI(context); + OfferEditUI ui = thesaurusUI.getParentContainer(OfferEditUI.class); + getThesaurusContainer(context).remove(thesaurusUI); + + // Save in properties + VradiTreeNode rootNode = thesaurusUI.helper.getRootNode(); + + Thesaurus thesaurus = getThesaurus(rootNode); + if (thesaurus != null) { + VradiHelper.removeVradiListThesaurus(thesaurus); + } else { + RootThesaurus rootThesaurus = getRootThesaurus(rootNode); + VradiHelper.removeVradiListRootThesaurus(rootThesaurus); + } + + ui.updateThesaurusSize(); + } + + /** + * Add criteria in search panel and save it in properties + * + * @param context jaxx context + * @param helper helper concerned + * @param path path of thesaurus to transform to criteria + */ + public void addCriteria(JAXXContext context, ThesaurusTreeHelper helper, TreePath path) { + OfferListUI ui = getListUI(context); + + // Get selected thesaurus + VradiTreeNode parentNode = getParentNode(helper, path); + + Thesaurus thesaurus = getThesaurus(parentNode); + + // Adding to offerListUI + UIHelper.getHandler(context, SearchHandler.class).addAndPersistCriteria(context, thesaurus); + + ui.validate(); + } + + /** + * Return selected node + * + * @param helper helper of tree + * @return selected node + */ + protected VradiTreeNode getSelectedNode(ThesaurusTreeHelper helper) { + + // Get selected thesaurus + VradiTreeNode selectedNode = helper.getSelectedNode(); + if (selectedNode == null) { + selectedNode = helper.getRootNode(); + } + return selectedNode; + } + + protected RootThesaurus getRootThesaurus(VradiTreeNode node) { + Class<?> internalClass = node.getInternalClass(); + if (!internalClass.equals(RootThesaurus.class)) { + return null; + } + String id = node.getId(); + + return ThesaurusDataHelper.restoreRootThesaurus(id); + } + + public String getNamePath(VradiTreeNode node) { + if (node == null) { + return ""; + } + // If its root node of all root thesaurus + if (node.isStringNode()) { + return ""; + } + String id = node.getId(); + Class<?> internalClass = node.getInternalClass(); + if (internalClass.equals(RootThesaurus.class)) { + RootThesaurus rootThesaurus = ThesaurusDataHelper.restoreRootThesaurus(id); + return rootThesaurus.getName(); + } + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + return ThesaurusDataHelper.getNamePath(thesaurus, "/"); + } + + protected Thesaurus getThesaurus(VradiTreeNode node) { + Class<?> internalClass = node.getInternalClass(); + if (!internalClass.equals(Thesaurus.class)) { + return null; + } + String id = node.getId(); + + return ThesaurusDataHelper.restoreThesaurus(id); + } + + /** + * Find thesaurusUI in context + * + * @param context jaxx context + * @return thesaurusUI in context + */ + public ThesaurusUI getUI(JAXXContext context) { + if (context instanceof ThesaurusUI) { + return (ThesaurusUI) context; + } + return null; + } + + /** + * Get thesaurus panel from OfferEditUI + * + * @param context jaxx context + * @return thesaurus panel + */ + protected JPanel getThesaurusContainer(JAXXContext context) { + return getUI(context).getParentContainer(OfferEditUI.class).getThesaurus(); + } + + /** + * Get OfferEditUI + * + * @param context jaxx context + * @return offer edit panel + */ + protected OfferEditUI getEditUI(JAXXContext context) { + return getUI(context).getParentUI(); + } + + /** + * Get OfferListUI + * + * @param context jaxx context + * @return offer list panel + */ + protected OfferListUI getListUI(JAXXContext context) { + return UIHelper.getHandler(context, OfferListHandler.class).getUI(context); + } + + /** + * Get parent node + * + * @param helper thesaurus helper + * @param path concerned path + * @return parent node + */ + protected VradiTreeNode getParentNode(ThesaurusTreeHelper helper, TreePath path) { + if (path == null) { + return helper.getRootNode(); + } else { + return (VradiTreeNode) path.getLastPathComponent(); + } + } + + /** + * Refresh all thesaurus displayed + * + * @param context + */ +// public void refreshAllThesaurus(JAXXContext context) { +// List<OfferEditUI> editUIs = VradiContext.OFFERT_EDIT_UI_ENTRY_DEF.getContextValue(VradiContext.get()); +// if (log.isDebugEnabled()) { +// log.debug("Refresh ui : " + (editUIs == null ? "is null" : editUIs.size())); +// } +// if (editUIs != null) { +// for (OfferEditUI editUI : editUIs) { +// if (log.isDebugEnabled()) { +// log.debug("Refresh ui : " + editUI.getData().getObjet()); +// } +// initThesaurus(context, editUI); +// } +// } +// } + + /** + * Refresh all other thesaurus displayed + * + * @param context + * @param ui + */ +// public void refreshOtherThesaurus(JAXXContext context, OfferEditUI ui) { +// List<OfferEditUI> editUIs = VradiContext.OFFERT_EDIT_UI_ENTRY_DEF.getContextValue(VradiContext.get()); +// if (log.isDebugEnabled()) { +// log.debug("Refresh ui : " + (editUIs == null ? "is null" : editUIs.size())); +// } +// if (editUIs != null) { +// for (OfferEditUI editUI : editUIs) { +// if (!editUI.equals(ui)){ +// if (log.isDebugEnabled()) { +// log.debug("Refresh ui : " + editUI.getData().getObjet()); +// } +// initThesaurus(context, editUI); +// } +// } +// } +// } + +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,290 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='thesaurusUI'> + + <style source='../VradiMainUI.css'/> + + <import> + java.awt.Dimension + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + + java.beans.PropertyChangeListener + java.beans.PropertyChangeEvent + + javax.swing.DefaultListModel + javax.swing.JPopupMenu + javax.swing.JMenuItem + + javax.swing.event.TreeSelectionListener + javax.swing.event.TreeSelectionEvent + + javax.swing.tree.TreePath + + jaxx.runtime.JAXXContext + jaxx.runtime.SwingUtil + jaxx.runtime.swing.JAXXTree + jaxx.runtime.swing.JAXXTree.JAXXTreeModel + org.chorem.vradi.VradiHelper + org.chorem.vradi.entities.Thesaurus + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeHelper + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusSelectionManager + org.apache.commons.lang.StringUtils + org.jdesktop.swingx.JXTreeTable + javax.swing.tree.DefaultTreeCellRenderer + javax.swing.tree.TreeSelectionModel + org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper + org.chorem.vradi.ui.tree.VradiTreeNode + javax.swing.tree.DefaultTreeSelectionModel + org.chorem.vradi.ui.offer.OfferEditUI + org.chorem.vradi.ui.renderers.ThesaurusHighlighter + + java.util.Arrays + </import> + + <script><![CDATA[ + +protected DefaultListModel thesaurusSelectedModel = new DefaultListModel(); +protected ThesaurusSelectionManager manager; +protected ThesaurusTreeHelper helper; +protected boolean deletable; + +public ThesaurusUI(JAXXContext parentContext, ThesaurusSelectionManager manager, ThesaurusTreeHelper helper, boolean deletable) { + SwingUtil.initContext(this, parentContext); + this.deletable = deletable; + this.helper = helper; + this.manager = manager; +} + +public OfferEditUI getParentUI(){ + return getParentContainer(OfferEditUI.class); +} + +protected ThesaurusHandler getHandler() { + return getContextValue(ThesaurusHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public ThesaurusTreeHelper getHelper() { + return helper; +} + +void $afterCompleteSetup() { + + // Remove on double click + thesaurusSelected.addMouseListener(new MouseAdapter(){ + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + Thesaurus toUnselect = (Thesaurus)thesaurusSelected.getSelectedValue(); + manager.tryToUnSelect(toUnselect); + } + } + }); + + // Adding ridht clic menu + thesaurus.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(final MouseEvent mouseEvent) { + JTree tree = (JTree) mouseEvent.getSource(); + TreePath path = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); + + // If node is selected + boolean isSelected = path != null; + if (mouseEvent.getButton() == MouseEvent.BUTTON3){ + JPopupMenu popup = new JPopupMenu(); + +// JMenuItem menuAddCriteria = new JMenuItem(); +// menuAddCriteria.setText(_("vradi.menu.addCriteria")); +// menuAddCriteria.addActionListener(new ActionListener() { + +// @Override +// public void actionPerformed(ActionEvent actionEvent) { +// addCriteriaSelected(getPathSelected(mouseEvent)); +// } +// }); +// popup.add(menuAddCriteria); + +// JMenuItem menuAddColumns = new JMenuItem(); +// menuAddColumns.setText(_("vradi.menu.addColumns")); +// menuAddColumns.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent actionEvent) { +// addColumnSelected(getPathSelected(mouseEvent)); +// } +// }); +// popup.add(menuAddColumns); + + if (isSelected){ + JMenuItem menuAddThesaurus = new JMenuItem(); + menuAddThesaurus.setText(_("vradi.menu.addThesaurus")); + menuAddThesaurus.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionEvent) { + addThesaurusSelected(getPathSelected(mouseEvent)); + } + }); + popup.add(menuAddThesaurus); + } + + popup.show(thesaurus, mouseEvent.getX(), mouseEvent.getY()); + } + } + }); + UIHelper.addThesaurusExpandOnClickListener(thesaurus); + + TreeSelectionListener selectionListener = new TreeSelectionListener() { + + @Override + public void valueChanged(TreeSelectionEvent e) { + thsaurusSelected(); + } + }; + thesaurus.addTreeSelectionListener(selectionListener); + + // Expends root + thesaurus.expandRow(0); + + // Override default selection model to enable one click selection + thesaurus.setSelectionModel(new DefaultTreeSelectionModel() { + + @Override + public void setSelectionPath(TreePath path) { + TreePath[] treePaths = getSelectionPaths(); + if (treePaths == null || !Arrays.asList(treePaths).contains(path)) { + addSelectionPath(path); + } else { + removeSelectionPath(path); + } + } + }); + + // If not root thesaurusUI + if (deletable) { + manager.registerTreeHelper(helper, thesaurus); + } else { + manager.registerRootTreeHelper(helper, thesaurus); + } + + // Tooltip is not active without this code... + javax.swing.ToolTipManager.sharedInstance().registerComponent(thesaurus); +} + +public DefaultListModel getThesaurusSelectedModel(){ + return thesaurusSelectedModel; +} + +protected void thsaurusSelected(){ + TreePath[] treePaths = thesaurus.getSelectionPaths(); + thesaurusSelectedModel = new DefaultListModel(); + if (treePaths != null){ + for (TreePath path : treePaths){ + VradiTreeNode selected = (VradiTreeNode)path.getLastPathComponent(); + if (selected.getInternalClass().equals(Thesaurus.class)) { + Thesaurus thesaurusSelected = ThesaurusDataHelper.restoreThesaurus(selected.getId()); + thesaurusSelectedModel.addElement(thesaurusSelected); + } + + } + } + thesaurusSelected.setModel(thesaurusSelectedModel); +} + +protected TreePath getPathSelected(MouseEvent mouseEvent){ + JTree tree = (JTree) mouseEvent.getSource(); + + // Recuperation du path selectionne + TreePath path = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); + + return path; +} + +protected void addCriteriaSelected(TreePath path){ + log.debug("addCriteriaSelected " + path); + // Ajout dun nouveau thesaurus + getHandler().addCriteria(this, helper, path); +} + +protected void addThesaurusSelected(TreePath path){ + log.debug("addThesaurusSelected " + path); + // Ajout dun nouveau thesaurus + getHandler().newThesaurusUI(this, manager, path); +} + +protected void addColumnSelected(TreePath path){ + log.debug("addColumnSelected " + path); + // Ajout dune nouvelle column +// getHandler().addColumn(this, helper, path); +} + +protected String getRootNamePath(){ + String path = getHandler().getNamePath(helper.getRootNode()); + return StringUtils.abbreviate(path, path.length() - 20, 23); +} +]]> + </script> + + <row> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JLabel text='{getRootNamePath()}' + toolTipText='{getHandler().getNamePath(helper.getRootNode())}'/> + </cell> + <cell insets='0,0,0,0'> + <JButton actionIcon="closeTab" + verticalAlignment='0' verticalTextPosition='0' opaque='true' + borderPainted='false' focusPainted='false' + horizontalTextPosition='0' size='{new Dimension(16, 16)}' + visible='{deletable}' + onActionPerformed='getHandler().closeThesaurus(this)'/> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='0.3'> + <JScrollPane> + <JList id='thesaurusSelected' + cellRenderer='{new ThesaurusHighlighter()}'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill='both' columns='2' weightx='1' weighty='0.7'> + <JScrollPane> + + <JTree id="thesaurus" + rootVisible='false' + showsRootHandles='true' + model='{helper.createTreeModel()}' + cellRenderer='{new ThesaurusHighlighter()}'/> + </JScrollPane> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/ThesaurusUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/VradiTabHeader.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/VradiTabHeader.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/VradiTabHeader.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,60 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table insets='0,0,0,0' opaque='false'> + <import> + java.awt.Dimension + </import> + <String id='id' javaBean='null'/> + <row fill='both'> + <cell anchor='west' weightx="1" insets='0,0,0,0'> + <JLabel id='label' opaque='false' font-size='12' + verticalAlignment='center' verticalTextPosition='0'/> + </cell> + <cell anchor='east' insets='2,15,0,0' weighty='0'> + <JButton id='detachTab' preferredSize='{new Dimension(16,16)}' + verticalAlignment='0' + verticalTextPosition='0' + opaque='true' + borderPainted='false' + focusPainted='false' + enabled='true' + horizontalTextPosition='0' + actionIcon='detach' + /> + </cell> + <cell anchor='east' insets='2,15,0,0' weighty='0'> + <JButton id='closeTab' preferredSize='{new Dimension(16,16)}' + verticalAlignment='0' + verticalTextPosition='0' + opaque='true' + borderPainted='false' + focusPainted='false' + enabled='true' + horizontalTextPosition='0' + actionIcon='closeTab' + /> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/VradiTabHeader.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,77 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, CurrencyEditorModel'> + + <!-- model --> + <CurrencyEditorModel id='model' javaBean='new CurrencyEditorModel()'/> + + <import> + java.awt.Dimension + javax.swing.DefaultComboBoxModel + org.chorem.vradi.entities.FieldTypeEnum + </import> + + <script><![CDATA[ + +@Override +public void init() { + super.init(); + editor.init(); +} + +@Override +void registerValidator() { +} + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}'> + + <NumberEditor id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.WEST' + bean='{model}' + modelType='{Float.class}' + property='amount' + model='{model.getAmount()}' + useFloat='{true}' + useSign='{false}' + autoPopup='{true}' + showPopupButton='{true}' + showReset='{true}' + minimumSize='{new Dimension(0,28)}' + maximumSize='{new Dimension(Integer.MAX_VALUE,28)}'/> + + <JComboBox id='currencyComboBox' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + selectedItem='{FieldTypeEnum.getCurrency(model.getCurrency())}' + renderer='{UIHelper.getTranslationListCellRenderer()}' + model='{new DefaultComboBoxModel(FieldTypeEnum.Currency.values())}' + onActionPerformed='if(currencyComboBox.getSelectedItem() != null) + {model.setCurrency(currencyComboBox.getSelectedItem().toString());}' + minimumSize='{new Dimension(0,28)}' + maximumSize='{new Dimension(Integer.MAX_VALUE,28)}'/> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,96 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class CurrencyEditorModel extends VradiEditorModel<String> { + /** Logger */ + static private final Log log = LogFactory.getLog(CurrencyEditorModel.class); + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_AMOUNT = "amount"; + + public static final String PROPERTY_CURRENCY = "currency"; + + protected Float amount; + + protected String currency; + + public Float getAmount() { + return amount; + } + + public void setAmount(Float amount) { + Float oldValue = this.amount; + this.amount = amount; + pcs.firePropertyChange(PROPERTY_AMOUNT, oldValue, amount); + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + String oldValue = this.currency; + this.currency = currency; + pcs.firePropertyChange(PROPERTY_CURRENCY, oldValue, currency); + } + + @Override + public String getValue() { + return amount + " " + currency; + } + + @Override + public void setValue(String value) { + String oldValue = getValue(); + if (value != null) { + String[] splitted = value.split("\\s+"); + try { + Float amount = Float.parseFloat(splitted[0]); + setAmount(amount); + StringBuffer currency = new StringBuffer(); + for (int i = 1; i < splitted.length; i++) { + currency.append(splitted[i]).append(" "); + } + setCurrency(currency.toString().trim()); + } catch (NumberFormatException eee) { + if (log.isErrorEnabled()) { + log.error("the first token is not a number : " + eee); + } + } + } + pcs.firePropertyChange(PROPERTY_VALUE, oldValue, value); + } + +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/CurrencyEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,60 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='Date, DateEditorModel'> + + <import> + java.awt.Dimension + java.util.Date + </import> + + <!-- model --> + <DateEditorModel id="model"/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + } + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + + <org.jdesktop.swingx.JXDatePicker id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + date='{model.getValue()}' + onActionPerformed='setValue(editor.getDate())' + minimumSize='{new Dimension(0,28)}'/> + + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,75 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class DateEditorModel extends VradiEditorModel<Date> { + + private static final long serialVersionUID = 1L; + + public int getHour() { + if (value == null) { + return 0; + } + Calendar cal = new GregorianCalendar(); + cal.setTime(value); + return cal.get(Calendar.HOUR_OF_DAY); + } + + public int getMinutes() { + if (value == null) { + return 0; + } + Calendar cal = new GregorianCalendar(); + cal.setTime(value); + return cal.get(Calendar.MINUTE); + } + + public void setHour(int hour) { + if (value != null) { + Calendar cal = new GregorianCalendar(); + cal.setTime(value); + cal.set(Calendar.HOUR_OF_DAY, hour); + setValue(cal.getTime()); + } + } + + public void setMinute(int minute) { + if (value != null) { + Calendar cal = new GregorianCalendar(); + cal.setTime(value); + cal.set(Calendar.MINUTE, minute); + setValue(cal.getTime()); + } + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateTimeEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateTimeEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateTimeEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,85 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='Date, DateEditorModel'> + + <import> + java.awt.Dimension + java.util.Date + </import> + + <!-- model --> + <DateEditorModel id="model"/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + } + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + <org.jdesktop.swingx.JXDatePicker id='editor' + enabled='{isEnabled()}' + date='{model.getValue()}' + onActionPerformed='setValue(editor.getDate())' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(0,28)}' + constraints='BorderLayout.CENTER'/> + + <JPanel layout='{new BorderLayout()}' + constraints='BorderLayout.EAST'> + + <JComboBox id='hour' selectedItem='{model.getHour()}' + enabled='{isEnabled()}' + model='{UIHelper.getHourModel()}' + renderer='{UIHelper.get2DigitsRenderer()}' + onActionPerformed='model.setHour((Integer)hour.getSelectedItem())' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(60,28)}' + constraints='BorderLayout.WEST'/> + + + <JLabel text='vradi.common.timeseparator' + constraints='BorderLayout.CENTER'/> + + <JComboBox id='minute' selectedItem='{model.getMinutes()}' + enabled='{isEnabled()}' + model='{UIHelper.getMinuteModel()}' + renderer='{UIHelper.get2DigitsRenderer()}' + onActionPerformed='model.setMinute((Integer)minute.getSelectedItem())' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(60,28)}' + constraints='BorderLayout.EAST'/> + </JPanel> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/DateTimeEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,85 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, EmailEditorModel'> + + <import> + java.awt.Dimension + jaxx.runtime.swing.ErrorDialogUI + </import> + <!-- model --> + <EmailEditorModel id='model'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + + void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + } + + protected void createEmail() { + try { + UIHelper.createEmail(editor.getText()); + } catch(java.io.IOException eee) { + if (log.isErrorEnabled()) { + log.error(eee); + } + ErrorDialogUI.showError(eee); + } catch(java.net.URISyntaxException eee) { + if (log.isErrorEnabled()) { + log.error(eee); + } + ErrorDialogUI.showError(eee); + } catch(java.lang.UnsupportedOperationException eee) { + if (log.isErrorEnabled()) { + log.error(eee); + } + ErrorDialogUI.showError(eee); + } + } + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}'> + + <JTextArea id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + text='{model.getValue()}' + onKeyReleased='setValue(editor.getText())' + minimumSize='{new Dimension(0,28)}'/> + + <JButton actionIcon="send" + constraints='BorderLayout.EAST' + enabled='{isEnabled() && getValue() != null && validator.isValid()}' + onActionPerformed='createEmail()'/> + + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class EmailEditorModel extends VradiEditorModel<String> { + + private static final long serialVersionUID = 1L; + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/EmailEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,86 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, IdEditorModel'> + + <import> + org.chorem.vradi.VradiConstants + java.awt.Dimension + </import> + + <!-- model --> + <IdEditorModel id='model'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + + void registerValidator() { + validator.setContext(model.getValidatorContext()); + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + + log.debug("registration : " + validator.getContext()); + } + + public String getModifiablePartOfValue(String value) { + if(value == null) { + return null; + } + String modifiablePart = org.nuiton.util.StringUtil.substring(value, 0, -VradiConstants.UUID_LENGTH); + return modifiablePart; + } + + public String getUnmodifiablePartOfValue(String value) { + if(value == null) { + return null; + } + String unmodifiablePart = org.nuiton.util.StringUtil.substring(value, -VradiConstants.UUID_LENGTH); + return unmodifiablePart; + } + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + + <JTextField id='editor' + constraints='BorderLayout.WEST' + columns='8' + text='{getModifiablePartOfValue(model.getValue())}' + onKeyReleased='setValue(editor.getText() + getUnmodifiablePartOfValue(model.getValue()))' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(0,28)}'/> + + <JTextField id='wikittyId' + editable='false' + constraints='BorderLayout.CENTER' + text='{getUnmodifiablePartOfValue(model.getValue())}' + minimumSize='{new Dimension(0,28)}'/> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class IdEditorModel extends VradiEditorModel<String> { + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/IdEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/JListCellEditor.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/JListCellEditor.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/JListCellEditor.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,139 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +import jaxx.runtime.swing.OneClicListSelectionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.ui.helpers.UIHelper; + +import javax.swing.AbstractCellEditor; +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.table.TableCellEditor; +import java.awt.Component; +import java.util.Arrays; +import java.util.EventObject; +import java.util.List; + + +/** + * Un éditeur de {@link JList} dans une cellule de tableau. + * <p/> + * Les objects sélectionnés de la liste sont ceux renvoyés par l'éditeur. + * <p/> + * User: chemit + * Date: 15 nov. 2009 + * Time: 21:15:39 + */ +public class JListCellEditor extends AbstractCellEditor implements TableCellEditor { + + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = LogFactory.getLog(JListCellEditor.class); + + /** le composant pour éditer */ + protected JList list; + + /** l'editeur de délégation, pour obtenir certaines informations sur le rendu visuel */ + protected TableCellEditor delegate; + + + public JListCellEditor(TableCellEditor delegate, ListCellRenderer listRenderer, boolean singleSelection) { + this.delegate = delegate; + list = new JList(new DefaultListModel()); + OneClicListSelectionModel selectModel = new OneClicListSelectionModel(list.getSelectionModel(), list.getModel()); + if (singleSelection) { + selectModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + list.setSelectionModel(selectModel); + if (listRenderer != null) { + list.setCellRenderer(listRenderer); + } + list.setBorder(BorderFactory.createLoweredBevelBorder()); + } + + public JListCellEditor() { + this(new DefaultCellEditor(new JTextField()), null, false); + } + + public JListCellEditor(boolean singleSelection) { + this(new DefaultCellEditor(new JTextField()), null, singleSelection); + } + + public JListCellEditor(ListCellRenderer listRenderer, boolean singleSelection) { + this(new DefaultCellEditor(new JTextField()), listRenderer, singleSelection); + } + + /** + * Pour mettre à jour la liste des valeurs sélectionnables. + * + * @param values les valeurs sélectionnables (à placer dans le modèle de la liste) + */ + + public void updateUniverse(List<String> values) { + UIHelper.fillList(list, values, null); + } + + @Override + public boolean isCellEditable(EventObject e) { + boolean b = super.isCellEditable(e); + b &= ((Component) e.getSource()).hasFocus(); +// if (e instanceof MouseEvent) { +// return b && ((MouseEvent) e).getClickCount() > 1; +// } + return b; + } + + @Override + public Object getCellEditorValue() { + Object[] values = list.getSelectedValues(); + if (log.isDebugEnabled()) { + log.debug("selected values = " + Arrays.toString(values)); + } + return values; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (log.isDebugEnabled()) { + log.debug("editor value" + value); + } + + UIHelper.updateListSelection(list, value); + + // obtain visual render from delegate + list.setFont(table.getFont()); + + return list; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/JListCellEditor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,74 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='Float, NumEditorModel'> + + <import> + java.awt.Dimension + java.math.BigDecimal + jaxx.runtime.swing.editor.NumberEditor + </import> + + <NumEditorModel id='model' javaBean='new NumEditorModel()'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + +@Override +public void init() { + super.init(); + editor.init(); +} + +void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); +} +]]> + </script> + <JPanel id='editorContent' layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + + <NumberEditor id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + bean='{model}' + modelType='{Float.class}' + property='value' + model='{model.getValue()}' + useFloat='{true}' + useSign='{false}' + autoPopup='{true}' + showPopupButton='{true}' + showReset='{true}' + minimumSize='{new Dimension(0,28)}'/> + + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,37 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class NumEditorModel extends VradiEditorModel<Float> { + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/NumEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,65 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, StringEditorModel'> + + <import> + java.awt.Dimension + </import> + + <!-- model --> + <StringEditorModel id='model'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + void registerValidator() { + validator.setContext(model.getValidatorContext()); + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + + if (log.isDebugEnabled()){ + log.debug("registration : " + validator.getContext()); + } + } + ]]></script> + + <JPanel id='editorContent' + layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + + <JTextField id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + text='{model.getValue()}' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(0, 28)}' + onKeyReleased='setValue(editor.getText())'/> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class StringEditorModel extends VradiEditorModel<String> { + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/StringEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,92 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, TextEditorModel'> + + <import> + java.awt.Dimension + </import> + + <!-- model --> + <TextEditorModel id='model'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ + void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); + } + void $afterCompleteSetup() { + // scroll more efficiently + editorScrollPane.getVerticalScrollBar().setBlockIncrement(100); + editorScrollPane.getVerticalScrollBar().setUnitIncrement(50); + } + ]]></script> + + <JPanel id='editorContent' layout='{new BorderLayout()}'> + + <JScrollPane id='editorScrollPane' + horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' + constraints='BorderLayout.CENTER'> + <JTextArea id='editor' + enabled='{isEnabled()}' + text='{model.getValue()}' + minimumSize='{new Dimension(0,56)}' + onKeyReleased='setValue(editor.getText());revalidate();'/> + </JScrollPane> + <VBox constraints='BorderLayout.EAST'> + <JButton id='removeEndLineButton' + text='vradi.editor.removeEndLine' + enabled='{isEnabled() && getValue() != null && !getValue().isEmpty()}' + toolTipText='vradi.editor.removeEndLineToolTip' + onActionPerformed='model.removeEndLine()'/> + <JButton id='convertToIso' + text='vradi.editor.convertToIso' + enabled='{isEnabled() && getValue() != null && !getValue().isEmpty()}' + toolTipText='vradi.editor.convertToIsoToolTip' + onActionPerformed='model.convertToIso()'/> + <JButton id='convertToUtf' + text='vradi.editor.convertToUtf' + enabled='{isEnabled() && getValue() != null && !getValue().isEmpty()}' + toolTipText='vradi.editor.convertToUtfToolTip' + onActionPerformed='model.convertToUtf()'/> + <JButton id='removeXML' + text='vradi.editor.removeXML' + enabled='{isEnabled() && getValue() != null && !getValue().isEmpty()}' + toolTipText='vradi.editor.removeXMLToolTip' + onActionPerformed='model.removeXML()'/> + <JButton id='unescapeXML' + text='vradi.editor.unescapeXML' + enabled='{isEnabled() && getValue() != null && !getValue().isEmpty()}' + toolTipText='vradi.editor.unescapeXMLToolTip' + onActionPerformed='model.unescapeXML()'/> + </VBox> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,103 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.UnsupportedEncodingException; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class TextEditorModel extends VradiEditorModel<String> { + + private static final long serialVersionUID = 1L; + + private static Log log = LogFactory.getLog(TextEditorModel.class); + + public void removeEndLine() { + String text = getValue(); + if (text == null) { + return; + } + setValue(text.replace('\n', ' ')); + } + + public void convertToIso() { + String text = getValue(); + if (text == null) { + return; + } + text = convertTo(text, "ISO-8859-1"); + setValue(text); + } + + public void convertToUtf() { + String text = getValue(); + if (text == null) { + return; + } + try { + text = new String(text.getBytes("ISO-8859-1"), "UTF-8"); + } catch (UnsupportedEncodingException eee) { + log.error("Cant convert '" + text + "' to UTF8", eee); + ErrorDialogUI.showError(eee); + } + setValue(text); + } + + public void removeXML() { + String text = getValue(); + if (text == null) { + return; + } + text = text.replaceAll("<[^>]+>", ""); + setValue(text); + } + + public void unescapeXML() { + String text = getValue(); + if (text == null) { + return; + } + text = StringEscapeUtils.unescapeHtml(text); + setValue(text); + } + + protected String convertTo(String text, String encoding) { + try { + text = new String(text.getBytes(), encoding); + } catch (UnsupportedEncodingException eee) { + log.error("Cant convert '" + text + "' to " + encoding, eee); + ErrorDialogUI.showError(eee); + } + return text; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/TextEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,81 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<VradiEditor superGenericType='String, UrlEditorModel'> + + <import> + java.awt.Dimension + + java.io.IOException + javax.swing.JOptionPane + + static org.nuiton.i18n.I18n._ + </import> + + <!-- model --> + <UrlEditorModel id='model'/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="value" component="editor"/> + </BeanValidator> + + <script><![CDATA[ +void registerValidator() { + validator.setBean(model); + getContextValue(jaxx.runtime.validator.swing.SwingValidatorMessageTableModel.class,"errorEditorTable") + .registerValidator(validator); +} + +protected void browseURI() { + try { + UIHelper.browseURI(editor.getText().trim()); + } catch (IOException eee){ + log.error("Cannot display URL : " + editor.getText().trim()); + JOptionPane.showMessageDialog(null, + _("vradi.message.cannot.display.url")); + + } +} + ]]></script> + + <JPanel id='editorContent' + layout='{new BorderLayout()}' + maximumSize='{new Dimension(0, 28)}'> + + <JTextField id='editor' + enabled='{isEnabled()}' + constraints='BorderLayout.CENTER' + text='{model.getValue()}' + onKeyReleased='setValue(editor.getText())' + minimumSize='{new Dimension(0,28)}' + maximumSize='{new Dimension(Integer.MAX_VALUE,28)}'/> + + <JButton actionIcon="site" + enabled='{isEnabled()}' + constraints='BorderLayout.EAST' + onActionPerformed='browseURI()'/> + </JPanel> +</VradiEditor> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +/** + * @author morin + * Date: 26 nov. 2009 + * Time: 19:05:06 + */ +public class UrlEditorModel extends VradiEditorModel<String> { + + private static final long serialVersionUID = 1L; + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/UrlEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,110 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel abstract='true' + layout='{new BorderLayout()}' + genericType='O extends Serializable, M extends VradiEditorModel<O>'> + + <import> + java.io.Serializable + java.awt.Dimension + </import> + + <script><![CDATA[ + +/** + * Initialize the editor, must be call before any use of it. + */ +public void init() { + // model is null, when coming here from parent + applyDataBinding("fieldNameLabel.text"); +} + +public abstract VradiEditorModel<O> getModel(); + +public String getFieldName() { + return getModel().getFieldName(); +} + +public void setFieldName(String newValue) { + getModel().setFieldName(newValue); +} + +public String getFieldDescription() { + return getModel().getFieldDescription(); +} + +public void setFieldDescription(String newValue) { + getModel().setFieldDescription(newValue); +} + +public String getExtensionName() { + return getModel().getExtensionName(); +} + +public void setExtensionName(String newValue) { + getModel().setExtensionName(newValue); +} + +public String getExtensionFieldName() { + return getModel().getExtensionFieldName(); +} + +public void setExtensionFieldName(String newValue) { + getModel().setExtensionFieldName(newValue); +} + +public O getValue() { + return getModel().getValue(); +} + +public void setValue(O newValue) { + getModel().setValue(newValue); +} + +public String getValidatorContext() { + return getModel().getValidatorContext(); +} + +public void setValidatorContext(String newValue) { + getModel().setValidatorContext(newValue); + registerValidator(); +} + +abstract void registerValidator(); +]]> + </script> + <JLabel id="fieldNameLabel" + enabled='{isEnabled()}' + constraints='BorderLayout.WEST' + text='{getModel().getFieldName()}' + toolTipText='{getModel().getFieldDescription() != null ? + SwingUtil.getStringValue(getModel().getFieldDescription()) : + SwingUtil.getStringValue(getModel().getFieldName())}' + minimumSize='{new Dimension(0,28)}' + preferredSize='{new Dimension(140,28)}'/> + + <JPanel id='editorContent' + constraints='BorderLayout.CENTER'/> +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditorModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditorModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditorModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,144 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.editors; + +import org.chorem.vradi.VradiHelper; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; + +/** + * User: chemit + * Date: 26 nov. 2009 + * Time: 21:48:47 + */ +public class VradiEditorModel<O extends Serializable> implements Serializable { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_VALUE = "value"; + + public static final String PROPERTY_FIELD_NAME = "fieldName"; + + public static final String PROPERTY_FIELD_DESCRIPTION = "fieldDescription"; + + public static final String PROPERTY_EXTENSION_NAME = "extensionName"; + + public static final String PROPERTY_EXTENSION_FIELD_NAME = "extensionFieldName"; + + public static final String PROPERTY_VALIDATOR_CONTEXT = "validatorContext"; + + protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + protected O value; + + protected String fieldName; + + protected String fieldDescription; + + protected String extensionName; + + protected String extensionFieldName; + + protected String validatorContext; + + public O getValue() { + return value; + } + + public String getExtensionName() { + return extensionName; + } + + public String getExtensionFieldName() { + return extensionFieldName; + } + + public String getFieldName() { + return fieldName; + } + + public String getFieldDescription() { + return fieldDescription; + } + + public String getValidatorContext() { + return validatorContext; + } + + public void setValue(O value) { + O oldValue = this.value; + this.value = value; + pcs.firePropertyChange(PROPERTY_VALUE, oldValue, value); + } + + public void setExtensionName(String extensionName) { + String oldValue = this.extensionName; + this.extensionName = extensionName; + pcs.firePropertyChange(PROPERTY_EXTENSION_NAME, oldValue, extensionName); + } + + public void setExtensionFieldName(String extensionFieldName) { + String oldValue = this.extensionFieldName; + this.extensionFieldName = extensionFieldName; + pcs.firePropertyChange(PROPERTY_EXTENSION_FIELD_NAME, oldValue, extensionFieldName); + } + + public void setFieldName(String fieldName) { + String oldValue = this.fieldName; + this.fieldName = VradiHelper.getTraduction(fieldName); + pcs.firePropertyChange(PROPERTY_FIELD_NAME, oldValue, fieldName); + } + + public void setFieldDescription(String fieldDescription) { + String oldValue = this.fieldDescription; + this.fieldDescription = fieldDescription; + pcs.firePropertyChange(PROPERTY_FIELD_DESCRIPTION, oldValue, fieldDescription); + } + + public void setValidatorContext(String validatorContext) { + String oldValue = this.validatorContext; + this.validatorContext = validatorContext; + pcs.firePropertyChange(PROPERTY_FIELD_NAME, oldValue, validatorContext); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/editors/VradiEditorModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/OfferListTableModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/OfferListTableModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/OfferListTableModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,651 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.models; + +import jaxx.runtime.JAXXObject; +import jaxx.runtime.binding.DefaultJAXXBinding; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormImpl; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.InfogeneImpl; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.ToolTipHelper; +import org.nuiton.i18n.I18n; +import org.nuiton.wikitty.WikittyException; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Component; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.text.DateFormat; +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.Set; + +import static org.nuiton.i18n.I18n._; + +/** + * OfferListTableModel is the data model for search results table. + * Its column model is based on the Infogene fields. + * + * @author letellier + * @version $Revision$ $Date$ + */ +public class OfferListTableModel extends AbstractTableModel { + + static private final Log log = LogFactory.getLog(OfferListTableModel.class); + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_PAGE_TO_SHOW = "pageToShow"; + + public static final String PROPERTY_NB_FORMS_PER_PAGE = "nbFormsPerPage"; + + /** + * serves as a unique binding for either PROPERTY_PAGE_TO_SHOW or + * PROPERTY_NB_FORMS_PER_PAGE or the two. + */ + public static final String PROPERTY_BINDING_CHANGE = "bindings"; + + public static final String PROPERTY_TOTAL_FORMS = "totalFoundFormNb"; + + public static final String PROPERTY_NB_PAGES = "nbPagesAsText"; + + public static final String PROPERTY_LAST_PAGE = "lastPage"; + + protected final PropertyChangeSupport propertyChangeSupport = + new PropertyChangeSupport(this); + + protected final List<Column> columns = new ArrayList<Column>(); + + protected FormPagedResult formPagedResult = new FormPagedResult(); + + // Add cache to refresh table + protected Map<String, String> toolTipCached = new HashMap<String, String>(); + + protected Map<String, Status> statusesCached = new HashMap<String, Status>(); + + protected Map<String, XmlStream> streamsCached = new HashMap<String, XmlStream>(); + + protected Map<String, Form> formsCached = new HashMap<String, Form>(); + + // Show thesaurus tooltip + protected boolean showThesaurusToolTip = false; + + public OfferListTableModel() { + this(false); + } + + public OfferListTableModel(boolean showThesaurusToolTip) { + initListeners(); + initColumns(); + formPagedResult.setPageToShow(1); + formPagedResult.setNbFormsToShow(10); + this.showThesaurusToolTip = showThesaurusToolTip; + } + + public OfferListTableModel(FormPagedResult formPage) { + this(formPage, false); + } + + public OfferListTableModel(FormPagedResult formPagedResult, boolean showThesaurusToolTip) { + initListeners(); + initColumns(); + formPagedResult.setPageToShow(formPagedResult.getPageToShow()); + formPagedResult.setNbFormsToShow(formPagedResult.getNbFormsToShow()); + setFormPagedResult(formPagedResult); + this.showThesaurusToolTip = showThesaurusToolTip; + + } + + protected VradiEntitiesListener<Status> statusVradiEntitiesListener; + + protected VradiEntitiesListener<XmlStream> streamVradiEntitiesListener; + + protected VradiEntitiesListener<Form> formVradiEntitiesListener; + + protected void initListeners() { + + // Status + statusVradiEntitiesListener = new VradiEntitiesListener<Status>() { + + @Override + public void entitiesAdded(Set<Status> added) { + for (Status status : added) { + statusesCached.put(status.getWikittyId(), status); + } + fireTableDataChanged(); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + for (String wikittyId : removed) { + statusesCached.remove(wikittyId); + } + fireTableDataChanged(); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(Status.class, statusVradiEntitiesListener); + + // XmlStream + streamVradiEntitiesListener = new VradiEntitiesListener<XmlStream>() { + + @Override + public void entitiesAdded(Set<XmlStream> added) { + for (XmlStream stream : added) { + streamsCached.put(stream.getWikittyId(), stream); + } + fireTableDataChanged(); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + for (String wikittyId : removed) { + streamsCached.remove(wikittyId); + } + fireTableDataChanged(); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(XmlStream.class, streamVradiEntitiesListener); + + formVradiEntitiesListener = new VradiEntitiesListener<Form>() { + + @Override + public void entitiesAdded(Set<Form> added) { + for (Form form : added) { + String wikittyId = form.getWikittyId(); + formsCached.put(wikittyId, form); + + // Remove toolTip cached + toolTipCached.remove(wikittyId); + } + fireTableDataChanged(); + } + + @Override + public void entitiesRemoved(Set<String> removed) { + for (String wikittyId : removed) { + formsCached.remove(wikittyId); + + // Remove toolTip cached + toolTipCached.remove(wikittyId); + } + fireTableDataChanged(); + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(Form.class, formVradiEntitiesListener); + } + + /** + * Raises property change event for PROPERTY_TOTAL_FORMS, + * PROPERTY_NB_PAGES, PROPERTY_LAST_PAGE. + * <p/> + * Plus, the method <code>AbstractTableModel.fireTableDataChanged()</code> is invoked. + * + * @param formPagedResult + */ + public void setFormPagedResult(FormPagedResult formPagedResult) { + if (formPagedResult == null) { + throw new IllegalArgumentException("formPage is null"); + } + + this.formPagedResult = formPagedResult; + + // Put in cache + formsCached.clear(); + WikittyProxy proxy = VradiService.getWikittyProxy(); + List<Form> forms = proxy.restore(Form.class, formPagedResult.getFormsIdsToShow()); + for (Form form : forms) { + formsCached.put(form.getWikittyId(), form); + } + + propertyChangeSupport.firePropertyChange(PROPERTY_TOTAL_FORMS, null, + formPagedResult.getTotalFoundFormNb()); + + propertyChangeSupport.firePropertyChange(PROPERTY_NB_PAGES, null, + getNbPages()); + + propertyChangeSupport.firePropertyChange(PROPERTY_LAST_PAGE, null, + isLastPage()); + + fireTableDataChanged(); + } + + public FormPagedResult getFormPagedResult() { + return formPagedResult; + } + + /** Column. */ + static class Column { + private static final String I18N_COLUMN_PREFIX = "vradi.offer."; + + final String i18name; + + final Class<?> columnClass; + + final String fqName; + + Column(String extension, String name, Class<?> columnClass) { + fqName = extension + "." + name; + this.columnClass = columnClass; + i18name = I18n._(I18N_COLUMN_PREFIX + fqName); + } + } + + protected void initColumns() { + // FIXME: retrieve extension from service + + // la liste des colonnes contient tout les champs de l'infogene + List<String> fieldNames = new ArrayList<String>(); + for (String fieldName : InfogeneImpl.extensionInfogene.getFieldNames()) { + fieldNames.add(Infogene.EXT_INFOGENE + "." + fieldName); + } + + // plus datePeremption, datePub, xmlStreamURL + fieldNames.add(Form.FQ_FIELD_FORM_DATEPUB); + fieldNames.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + fieldNames.add(Form.FQ_FIELD_FORM_XMLSTREAM); + + for (String fqFieldName : fieldNames) { + int dot = fqFieldName.lastIndexOf("."); + String extensionName = fqFieldName.substring(0, dot); + String fieldName = fqFieldName.substring(dot + 1); + WikittyExtension extension = + extensionName.equals(Infogene.EXT_INFOGENE) ? + InfogeneImpl.extensionInfogene : + FormImpl.extensionForm; + + FieldType fieldType = extension.getFieldType(fieldName); + + Class<?> columnClass; + if (fieldType.getType() == FieldType.TYPE.BOOLEAN) { + columnClass = Boolean.class; + + } else if (fieldType.getType() == FieldType.TYPE.DATE) { + columnClass = Date.class; + + } else if (fieldType.getType() == FieldType.TYPE.NUMERIC) { + columnClass = Double.class; + + } else if (fieldName.equals(Infogene.FIELD_INFOGENE_STATUS)) { + columnClass = Status.class; + + } else if (fieldName.equals(Form.FIELD_FORM_XMLSTREAM)) { + columnClass = XmlStream.class; + + } else { + columnClass = String.class; + } + + Column column = new Column(extensionName, fieldName, + columnClass); + columns.add(column); + } + } + + public Integer getNbFormsPerPage() { + return formPagedResult.getNbFormsToShow(); + } + + /** + * Raises property change event for PROPERTY_NB_FORMS_PER_PAGE and + * PROPERTY_PAGE_TO_SHOW, PROPERTY_BINDING_CHANGE. + * <p/> + * As PROPERTY_BINDING_CHANGE property is changed, a new search is executed. + * + * @param nbFormsPerPage + */ + public void setNbFormsPerPage(Integer nbFormsPerPage) { + Integer nbFormsToShow = formPagedResult.getNbFormsToShow(); + + int topRow = nbFormsToShow * (formPagedResult.getPageToShow() - 1); + topRow = topRow + 1; + + Integer pageToShow = (int) Math.ceil(topRow / nbFormsPerPage.doubleValue()); + if (pageToShow < 1) { + pageToShow = 1; + } + + formPagedResult.setNbFormsToShow(nbFormsPerPage); + propertyChangeSupport.firePropertyChange(PROPERTY_NB_FORMS_PER_PAGE, nbFormsToShow, + nbFormsPerPage); + + setPageToShow(pageToShow); + } + + public int getPageToShow() { + return formPagedResult.getPageToShow(); + } + + /** + * Raises property change event for PROPERTY_PAGE_TO_SHOW, PROPERTY_BINDING_CHANGE. + * <p/> + * As PROPERTY_BINDING_CHANGE property is changed, a new search is executed. + * + * @param pageToShow + */ + public void setPageToShow(int pageToShow) { + int oldValue = formPagedResult.getPageToShow(); + formPagedResult.setPageToShow(pageToShow); + + propertyChangeSupport.firePropertyChange(PROPERTY_PAGE_TO_SHOW, oldValue, + pageToShow); + + propertyChangeSupport.firePropertyChange(PROPERTY_BINDING_CHANGE, Boolean.FALSE, + Boolean.TRUE); + } + + public boolean isLastPage() { + int nbPages = getNbPages(); + int pageToShow = formPagedResult.getPageToShow(); + + boolean result = nbPages == pageToShow; + return result; + } + + public String getNbPagesAsText() { + int nbPages = getNbPages(); + return " / " + String.valueOf(nbPages); + } + + protected int getNbPages() { + int totalFoundFormNb = formPagedResult.getTotalFoundFormNb(); + int nbFormsPerPage = formPagedResult.getNbFormsToShow(); + + int nbPages = (int) Math.ceil(totalFoundFormNb / (double) nbFormsPerPage); + + // can be negative if all (-1) result per page is selected + if (nbPages <= 0) { + nbPages = 1; + } + + return nbPages; + } + + public String getFieldToSort() { + return formPagedResult.getFieldToSort(); + } + + public void setFieldToSort(String fieldToSort) { + if (fieldToSort != null) { + formPagedResult.setFieldToSort(fieldToSort); + } + } + + public boolean isAscending() { + return formPagedResult.isAscending(); + } + + public void setAscending(boolean ascending) { + formPagedResult.setAscending(ascending); + } + + public int getTotalFoundFormNb() { + return formPagedResult.getTotalFoundFormNb(); + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + @Override + public String getColumnName(int col) { + Column column = columns.get(col); + return column.i18name; + } + + @Override + public int getRowCount() { + return formPagedResult.getFormsIdsToShow() != null ? + formPagedResult.getFormsIdsToShow().size() : + 0; + } + + @Override + public int getColumnCount() { + return columns.size(); + } + + public String getFormIdAt(int row) { + List<String> formsToShow = formPagedResult.getFormsIdsToShow(); + if (formsToShow == null) { + return null; + } + if (row >= formsToShow.size()) { + return null; + } + + return formsToShow.get(row); + } + + @Override + public Object getValueAt(int row, int col) { + Object result; + List<String> formsToShow = formPagedResult.getFormsIdsToShow(); + if (formsToShow == null) { + return null; + } + if (row >= formsToShow.size()) { + return null; + } + + String formId = formsToShow.get(row); + if (formId == null) { + return null; + } + + try { + // Get proxy + WikittyProxy proxy = VradiService.getWikittyProxy(); + + // Get from cache + Form form = formsCached.get(formId); + + if (form == null) { + form = VradiService.getWikittyProxy().restore(Form.class, formId); + formsCached.put(formId, form); + } + + // Except for status + String fqColumnName = getColumnFqName(col); + + int indexOf = fqColumnName.indexOf('.'); + + String extension = fqColumnName.substring(0, indexOf); + String fieldName = fqColumnName.substring(indexOf + 1); + + if (Infogene.FIELD_INFOGENE_STATUS.equals(fieldName)) { + String statusId = form.getStatus(); + Status statusCached = statusesCached.get(statusId); + if (statusCached == null) { + + // If not found restor it + statusCached = proxy.restore(Status.class, statusId); + + // Put in cache + statusesCached.put(statusId, statusCached); + } + result = statusCached; + } + // Except for stream + else if (Form.FIELD_FORM_XMLSTREAM.equals(fieldName)) { + String xmlSreamId = form.getXmlStream(); + + // Get in cache + XmlStream streamCached = streamsCached.get(xmlSreamId); + if (streamCached == null) { + + // If not found restor it + streamCached = proxy.restore(XmlStream.class, xmlSreamId); + + // Put in cache + streamsCached.put(xmlSreamId, streamCached); + } + + result = streamCached; + } else { + + Object field = form.getField(extension, fieldName); + FieldType fieldType = proxy.getWikitty(form).getFieldType(fqColumnName); + result = fieldType.getValidValue(field); + } + } catch (WikittyException eee) { + log.error("Failled to load columns : ", eee); + ErrorDialogUI.showError(eee); + return null; + } + return result; + } + + @Override + public Class<?> getColumnClass(int col) { + Column column = columns.get(col); + return column.columnClass; + } + + public String getColumnFqName(int col) { + Column column = columns.get(col); + return column.fqName; + } + + public String getToolTip(int row) { + List<String> formsIdsToShow = formPagedResult.getFormsIdsToShow(); + if (formsIdsToShow == null) { + return null; + } + if (row >= formsIdsToShow.size()) { + return null; + } + + String formId = formsIdsToShow.get(row); + + String toolTip = toolTipCached.get(formId); + if (toolTip == null) { + // Get in cache + Form form = VradiService.getWikittyProxy().restore(Form.class, formId); + if (showThesaurusToolTip) { + toolTip = ToolTipHelper.getEmailThesaurusToolTip(form); + } else { + toolTip = ToolTipHelper.getToolTip(form); + } + + // Set in cache + toolTipCached.put(formId, toolTip); + } + return toolTip; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + propertyChangeSupport.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + propertyChangeSupport.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + propertyChangeSupport.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + propertyChangeSupport.removePropertyChangeListener(propertyName, listener); + } + + static public abstract class OfferListTableModelBinding + extends DefaultJAXXBinding { + + protected OfferListTableModel model; + + public OfferListTableModelBinding(JAXXObject source, String id, + OfferListTableModel model) { + super(source, id, false); + this.model = model; + } + + @Override + public void applyDataBinding() { + if (model != null) { + model.addPropertyChangeListener(PROPERTY_BINDING_CHANGE, this); + } + } + + @Override + public void removeDataBinding() { + if (model != null) { + model.removePropertyChangeListener(PROPERTY_BINDING_CHANGE, this); + } + } + } + + static public class OfferListTableCellRenderer extends + DefaultTableCellRenderer { + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, boolean isSelected, boolean hasFocus, int row, + int column) { + + String stringValue; + + if (value == null) { + stringValue = null; + } else if (value instanceof Date) { + stringValue = DateFormat.getDateTimeInstance(DateFormat.SHORT, + DateFormat.SHORT, Locale.FRANCE).format((Date) value); + + } else if (value instanceof Status) { + stringValue = _(((Status) value).getName()); + } else if (value instanceof XmlStream) { + stringValue = _(((XmlStream) value).getName()); + } else { + stringValue = String.valueOf(value); + } + + return super.getTableCellRendererComponent(table, stringValue, + isSelected, hasFocus, row, column); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/models/OfferListTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/SimpleUrlValidator.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/SimpleUrlValidator.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/SimpleUrlValidator.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,59 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.validators; + +import com.opensymphony.xwork2.util.URLUtil; +import com.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.URLValidator; + +/** + * UrlValidator of XWork check if value start with "http://" + * This one check if it's an valid simple url (like : www.codelutin.com) + */ +public class SimpleUrlValidator extends URLValidator { + + public void validate(Object object) throws ValidationException { + String fieldName = getFieldName(); + Object value = getFieldValue(fieldName, object); + + // if there is no value - don't do comparison + // if a value is required, a required validator should be added to the field + if (value == null || value.toString().length() == 0) { + return; + } + + // To allow www.codelutin.com for exemple + String urlString = (String) value; + if (!urlString.matches("[a-z]+://.+")) { + urlString = "http://" + urlString; + } + + // TODO SLE 11/08/2010: Write better validator base on regex + if (!value.getClass().equals(String.class) || !URLUtil.verifyUrl(urlString)) { + addFieldError(fieldName, object); + } + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/validators/SimpleUrlValidator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/AttachmentFileHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/AttachmentFileHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/AttachmentFileHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,72 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.widgets; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.offer.OfferEditHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionFileHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n_; + +/** @author sletellier */ +public class AttachmentFileHandler extends MultipleSelectionFileHandler<Form, OfferEditHandler> { + + + /** log. */ + private static final Log log = LogFactory.getLog(AttachmentFileHandler.class); + + public AttachmentFileHandler(MultipleSelectionPane ui) { + super(ui, OfferEditHandler.class, n_("vradi.offerEdit.attachedfile")); + } + + @Override + public File downloadFile(String selected, String wikittyId) throws VradiException { + return VradiService.getFileService().downloadFormAttachment(selected, getBean().getWikittyId()); + } + + @Override + public List<String> removeFiles(Form bean, List<String> selectedInList) { + return getHandler().removeAttachmentFile(getBean(), getSelectedInList()); + } + + @Override + public Set<String> getFiles() { + return getBean().getAttachments(); + } + + @Override + public File addFiles(MultipleSelectionPane ui, Form bean) { + return getHandler().addAttachmentFile(ui, getBean()); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/AttachmentFileHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/EmbeddedFileHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/EmbeddedFileHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/EmbeddedFileHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,71 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.widgets; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.offer.OfferEditHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionFileHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n_; + +/** @author sletellier */ +public class EmbeddedFileHandler extends MultipleSelectionFileHandler<Form, OfferEditHandler> { + + /** log. */ + private static final Log log = LogFactory.getLog(AttachmentFileHandler.class); + + public EmbeddedFileHandler(MultipleSelectionPane ui) { + super(ui, OfferEditHandler.class, n_("vradi.offerEdit.embeddedfile")); + } + + @Override + public File downloadFile(String selected, String wikittyId) throws VradiException { + return VradiService.getFileService().downloadFormEmbeddedFile(selected, getBean().getWikittyId()); + } + + @Override + public List<String> removeFiles(Form bean, List<String> selectedInList) { + return getHandler().removeEmbeddedFile(getBean(), getSelectedInList()); + } + + @Override + public Set<String> getFiles() { + return getBean().getFiles(); + } + + @Override + public File addFiles(MultipleSelectionPane ui, Form bean) { + return getHandler().addEmbeddedFile(ui, getBean()); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/EmbeddedFileHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/FormLinkCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/FormLinkCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/FormLinkCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,121 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.widgets; + +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.ToolTipHelper; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; +import org.nuiton.widget.tooltip.FocusableTip; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; + +/** @author sletellier */ +public class FormLinkCellRenderer extends DefaultListCellRenderer { + + protected FocusableTip focusableTip = null; + + protected MultipleSelectionPane ui; + + protected Map<String, String> cachedRendered = new HashMap<String, String>(); + + protected Map<String, String> cachedToolTip = new HashMap<String, String>(); + + public FormLinkCellRenderer(MultipleSelectionPane ui) { + super(); + this.ui = ui; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + String rendered = " "; + String formToolTip = null; + String formLinkId = (String) value; + if (formLinkId != null) { + rendered = cachedRendered.get(formLinkId); + formToolTip = cachedToolTip.get(formLinkId); + if (rendered == null) { + FormLink formLink = VradiService.getWikittyProxy().restore(FormLink.class, formLinkId); + if (formLink != null) { + rendered = formLink.getName(); + cachedRendered.put(formLinkId, rendered); + + // ToolTip + formToolTip = loadFormToolTip(formLink); + } + } + } + + JLabel renderedComponant = (JLabel) super.getListCellRendererComponent(list, rendered, index, isSelected, cellHasFocus); + + if (formToolTip != null) { + renderedComponant.setToolTipText(formToolTip); + } + + return renderedComponant; + } + + public void addAdded(FormLink formLink) { + cachedRendered.put(formLink.getWikittyId(), formLink.getName()); + + // ToolTip + loadFormToolTip(formLink); + } + + protected String loadFormToolTip(FormLink formLink) { + + Form form = VradiService.getWikittyProxy().restore(Form.class, formLink.getToForm()); + String formToolTip = ToolTipHelper.getToolTip(form); + cachedToolTip.put(formLink.getWikittyId(), formToolTip); + + return formToolTip; + } + + /* + * @see javax.swing.JComponent#getToolTipText() + */ + @Override + public String getToolTipText(MouseEvent e) { + + // get original text + String text = super.getToolTipText(e); + + // display it into persistant tooltip + if (focusableTip == null) { + focusableTip = new FocusableTip(ui, true); + focusableTip.setSize(600, 400); + } + focusableTip.toolTipRequested(e, text); + + return null; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/FormLinkCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/RelatedFormHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/RelatedFormHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/RelatedFormHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,104 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.widgets; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.OfferEditHandler; +import org.chorem.vradi.ui.offer.OfferListHandler; +import org.chorem.vradi.ui.offer.OfferListUI; +import org.chorem.vradi.ui.widgets.MultipleSelectionHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; + +import java.util.ArrayList; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier */ +public class RelatedFormHandler extends MultipleSelectionHandler<FormLink, Form, OfferEditHandler> { + + /** Logger */ + static private final Log log = LogFactory.getLog(RelatedFormHandler.class); + + protected FormLinkCellRenderer linkCellRenderer; + + protected List<FormLink> toSave = new ArrayList<FormLink>(); + + public RelatedFormHandler(MultipleSelectionPane ui) { + super(ui, OfferEditHandler.class); + ui.setLbl(_("vradi.offerEdit.relatedForm")); + linkCellRenderer = new FormLinkCellRenderer(ui); + ui.getList().setCellRenderer(linkCellRenderer); + } + + @Override + public void init() { + List<String> relatedFormsLinkIds = null; + String wikittyId = getBean().getWikittyId(); + try { + relatedFormsLinkIds = VradiService.getVradiDataService().getRelatedFormsLinkIds(wikittyId); + } catch (VradiException eee) { + log.error("Cant get related form for form id : " + wikittyId, eee); + ErrorDialogUI.showError(eee); + } + fillList(relatedFormsLinkIds); + } + + @Override + public void add() { + FormLink formLink = getHandler().addRelatedForm(ui, getBean()); + if (formLink != null) { + addToList(formLink, formLink.getWikittyId()); + linkCellRenderer.addAdded(formLink); + } + } + + @Override + public void remove() { + List<String> formLinkIds = getHandler().removeLinkForm(getSelectedInList()); + removeFromList(formLinkIds); + } + + @Override + public void openSelected(String selected) { + OfferListHandler listHandler = UIHelper.getHandler(ui, OfferListHandler.class); + if (selected != null) { + FormLink formLink = VradiService.getWikittyProxy().restore(FormLink.class, selected); + if (formLink == null) { + formLink = getAddedData(selected); + } + OfferListUI offerListUI = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + listHandler.addEditPane(offerListUI, formLink.getToForm()); + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/RelatedFormHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ReplaceFormHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ReplaceFormHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ReplaceFormHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,102 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.offer.widgets; + +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.FormLink; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.offer.OfferEditHandler; +import org.chorem.vradi.ui.offer.OfferListHandler; +import org.chorem.vradi.ui.offer.OfferListUI; +import org.chorem.vradi.ui.widgets.MultipleSelectionHandler; +import org.chorem.vradi.ui.widgets.MultipleSelectionPane; + +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier */ +public class ReplaceFormHandler extends MultipleSelectionHandler<FormLink, Form, OfferEditHandler> { + + /** Logger */ + static private final Log log = LogFactory.getLog(ReplaceFormHandler.class); + + protected FormLinkCellRenderer linkCellRenderer; + + public ReplaceFormHandler(MultipleSelectionPane ui) { + super(ui, OfferEditHandler.class); + ui.setLbl(_("vradi.offerEdit.replaceForm")); + linkCellRenderer = new FormLinkCellRenderer(ui); + ui.getList().setCellRenderer(linkCellRenderer); + } + + @Override + public void init() { + List<String> replaceFormsLinkIds = null; + String wikittyId = getBean().getWikittyId(); + try { + replaceFormsLinkIds = VradiService.getVradiDataService().getReplaceFormsLinkIds(wikittyId); + } catch (VradiException eee) { + log.error("Cant get replace form for form id : " + wikittyId, eee); + ErrorDialogUI.showError(eee); + } + fillList(replaceFormsLinkIds); + } + + @Override + public void add() { + FormLink formLink = getHandler().addReplaceForm(ui, getBean()); + if (formLink != null) { + addToList(formLink, formLink.getWikittyId()); + linkCellRenderer.addAdded(formLink); + } + } + + @Override + public void remove() { + List<String> formLinkIds = getHandler().removeLinkForm(getSelectedInList()); + removeFromList(formLinkIds); + } + + @Override + public void openSelected(String selected) { + OfferListHandler listHandler = UIHelper.getHandler(ui, OfferListHandler.class); + if (selected != null) { + FormLink formLink = VradiService.getWikittyProxy().restore(FormLink.class, selected); + if (formLink == null) { + formLink = getAddedData(selected); + } + OfferListUI offerListUI = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + listHandler.addEditPane(offerListUI, formLink.getToForm()); + } + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/ReplaceFormHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/SelectFormUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/SelectFormUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/SelectFormUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,161 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='selectFormUI' + modal='true' + title='vradi.selectForm.title' + layout='{new BorderLayout()}'> + + <style source='../../VradiMainUI.css'/> + + <import> + java.awt.Color + + javax.swing.ListSelectionModel + javax.swing.event.ListSelectionListener + javax.swing.event.ListSelectionEvent + + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.ui.offer.models.OfferListTableModel + org.chorem.vradi.ui.offer.OfferListColumnFactory + org.chorem.vradi.ui.search.SearchUI + org.chorem.vradi.ui.search.SearchHandler + org.chorem.vradi.ui.search.PaginationUI + </import> + + <String id='formId' javaBean='null'/> + + <Boolean id='selected' javaBean='false'/> + + <!-- le modèle du tableau --> + <OfferListColumnFactory id='offerListColumnFactory' + javaBean='getContextValue(OfferListColumnFactory.class)'/> + + <OfferListTableModel id='resultTableModel' + javaBean='getContextValue(OfferListTableModel.class)' + nbFormsPerPage='{10}' pageToShow='{1}'/> + + <script><![CDATA[ + +protected AdminHandler getHandler() { + return getContextValue(AdminHandler.class); +} + +public SearchHandler getSearchHandler() { + return UIHelper.getHandler(this, SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public SearchUI getSearchUI() { + return (SearchUI) searchPanel.getComponent(0); +} + +void $afterCompleteSetup() { + OfferListTableModel.OfferListTableModelBinding djb = new OfferListTableModel.OfferListTableModelBinding(this, + "resultTableModel", resultTableModel) { + + @Override + public void processDataBinding() { + if (resultTableModel != null) { + SearchUI searchUI = getSearchUI(); + getSearchHandler().executeQuery(searchUI); + } + } + }; + + // Add listener select + resultTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + ListSelectionModel selectionModel = (ListSelectionModel)e.getSource(); + int selectionIndex = selectionModel.getLeadSelectionIndex(); + setSelected(selectionIndex != -1); + } + }); + + registerDataBinding(djb); + djb.applyDataBinding(); + + validate(); + this.pack(); + + // Register for save disposition + UIHelper.registerComponentToSaveDispositionConfig(this); +} + +protected void selectAndClose() { + int selectedRow = resultTable.getSelectedRow(); + setFormId(resultTableModel.getFormIdAt(selectedRow)); + close(); +} + +protected void close() { + setVisible(false); + dispose(); +} +]]> + </script> + + <JPanel id='searchPanel' + layout='{new BorderLayout()}' constraints='BorderLayout.NORTH'/> + + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> + <JScrollPane constraints='BorderLayout.CENTER'> + <org.chorem.vradi.ui.offer.OfferTable id='resultTable' + columnFactory='{offerListColumnFactory}' + model='{resultTableModel}' + selectionMode='{ListSelectionModel.SINGLE_SELECTION}' + autoResizeMode='{2}' + columnControlVisible='{true}' + horizontalScrollEnabled='{true}' + showGrid='{true}' + gridColor='{Color.GRAY}'/> + </JScrollPane> + + <PaginationUI id='paginationUI' + constructorParams='this' + constraints='BorderLayout.SOUTH'/> + </JPanel> + + <Table constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.common.close' + actionIcon='close' + onActionPerformed='close()'/> + </cell> + <cell fill='horizontal' insets='0,0,0,0' weightx='0.5'> + <JButton text='vradi.action.select' + actionIcon='accept' + enabled='{isSelected()}' + onActionPerformed='selectAndClose()'/> + </cell> + </row> + </Table> + +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/offer/widgets/SelectFormUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ColorsMap.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ColorsMap.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ColorsMap.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,62 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.renderers; + +import org.chorem.vradi.VradiHelper; + +import java.awt.Color; +import java.util.Map; + +/** + * All renderer instance can use the singleton to render thesaurus + * + * @author letellier + */ +public class ColorsMap { + + protected Map<Integer, Color> colors; + + private static ColorsMap instance = null; + + public ColorsMap() { + updateColors(); + } + + public static ColorsMap getInstance() { + if (instance == null) { + instance = new ColorsMap(); + } + return instance; + } + + public void updateColors() { + colors = VradiHelper.getColorsThesaurus(); + } + + public Color get(int depth) { + return colors.get(depth); + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ColorsMap.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/EntityRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/EntityRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/EntityRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,84 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.renderers; + +import org.chorem.vradi.entities.Client; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.User; +import org.chorem.vradi.services.VradiService; +import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import java.awt.Component; + +/** @author sletellier <letellier@codelutin.com> */ +public class EntityRenderer extends ObjectToStringConverter implements + ListCellRenderer { + + private static EntityRenderer instance = null; + + protected DefaultListCellRenderer delegate = new DefaultListCellRenderer(); + + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null) { + + if (item instanceof User) { + User user = (User) item; + String clientId = user.getClient(); + Client client = VradiService.getWikittyProxy().restore( + Client.class, clientId); + String clientString = ""; + if (client != null) { + clientString = client.getName() + " - "; + } + result = clientString + user.getName(); + } else if (item instanceof Group) { + Group group = (Group) item; + result = group.getName(); + } + } + return result; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + return delegate.getListCellRendererComponent(list, + getPreferredStringForItem(value), index, isSelected, + cellHasFocus); + } + + public static EntityRenderer getInstance() { + if (instance == null) { + instance = new EntityRenderer(); + } + return instance; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/EntityRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/NumberListCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/NumberListCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/NumberListCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,60 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.renderers; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import java.awt.Component; + +import static org.nuiton.i18n.I18n._; + +/** + * NumberListCellRenderer. + * <p/> + * Display a special string for "-1" value; + * + * @author schorlet + * @version $Revision$ $Date$ + * @since 24 mars 2010 12:26:58 + */ +public class NumberListCellRenderer extends DefaultListCellRenderer { + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + Number number = (Number) value; + Object newValue = number; + + // -1 means no search restriction + if (number.intValue() == -1) { + newValue = _("vradi.common.alls"); + } + + return super.getListCellRendererComponent(list, newValue, index, isSelected, + cellHasFocus); + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/NumberListCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ThesaurusHighlighter.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ThesaurusHighlighter.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ThesaurusHighlighter.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,290 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.renderers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.helpers.ToolTipHelper; +import org.chorem.vradi.ui.thesaurus.ThesaurusDataProvider; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; +import org.jdesktop.swingx.decorator.AbstractHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.renderer.StringValue; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JTree; +import javax.swing.ListCellRenderer; +import javax.swing.tree.TreeCellRenderer; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; + + +/** @author letellier */ +public class ThesaurusHighlighter extends AbstractHighlighter implements TreeCellRenderer, ListCellRenderer { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusHighlighter.class); + + protected DefaultListCellRenderer delegate = null; + + protected HighlighterType type; + + protected ThesaurusDataProvider dataProvider; + + // Use cache only for cartographie + protected Map<Thesaurus, String> toolTipCache; + + public enum HighlighterType { + DEFAULTS, + EDIT, + PROPOSITION, + CARTOGRAHY, + MOVE + } + + public ThesaurusHighlighter() { + this(HighlighterType.DEFAULTS); + } + + public ThesaurusHighlighter(HighlighterType type) { + super(HighlightPredicate.ALWAYS); + this.type = type; + delegate = new DefaultListCellRenderer(); + } + + // For cartographie + public ThesaurusHighlighter(ThesaurusDataProvider dataProvider) { + super(HighlightPredicate.ALWAYS); + delegate = new DefaultListCellRenderer(); + type = HighlighterType.CARTOGRAHY; + this.dataProvider = dataProvider; + toolTipCache = new HashMap<Thesaurus, String>(); + } + + protected boolean isDefault() { + return type.equals(HighlighterType.DEFAULTS); + } + + protected boolean isEdit() { + return type.equals(HighlighterType.EDIT); + } + + protected boolean isMove() { + return type.equals(HighlighterType.MOVE); + } + + protected boolean isProposition() { + return type.equals(HighlighterType.PROPOSITION); + } + + protected boolean isCartography() { + return type.equals(HighlighterType.CARTOGRAHY); + } + + @Override + protected Component doHighlight(Component component, ComponentAdapter adapter) { + int depth = adapter.getDepth(); + Color color = getDepthColor(depth); + if (color != null) { + component.setForeground(color); + } + + return component; + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + + int depth = 0; + String text = null; + Thesaurus thesaurus = null; + RootThesaurus rootThesaurus; + + // Get real data + if (value instanceof VradiTreeNode) { + VradiTreeNode node = (VradiTreeNode) value; + + rootThesaurus = ThesaurusTreeHelper.getRootThesaurus(node); + if (rootThesaurus == null) { + thesaurus = ThesaurusTreeHelper.getThesaurus(node); + } + + } else if (value instanceof VradiTreeTableNode) { + VradiTreeTableNode node = (VradiTreeTableNode) value; + + rootThesaurus = ThesaurusTreeTableHelper.getRootThesaurus(node); + if (rootThesaurus == null) { + thesaurus = ThesaurusTreeTableHelper.getThesaurus(node); + } + } else { + return new JLabel(value.toString()); + } + JLabel jLabel = null; + if (rootThesaurus != null) { + text = rootThesaurus.getName(); + jLabel = new JLabel(text); + } else if (thesaurus != null) { + depth = ThesaurusDataHelper.getDepth(thesaurus); + text = ThesaurusDataHelper.concateOrderName(thesaurus); + jLabel = new ToolTipLbl(text, thesaurus); + } + if (text == null) { + return new JLabel(value.toString()); + } + Color color = getDepthColor(depth); + if (color != null) { + jLabel.setForeground(color); + } + + return jLabel; + } + + protected class ToolTipLbl extends JLabel { + + protected Thesaurus thesaurus; + + public ToolTipLbl(String text, Thesaurus thesaurus) { + super(text); + this.thesaurus = thesaurus; + } + + @Override + public String getToolTipText(MouseEvent event) { + return getThesaurusToolTipText(thesaurus); + } + } + + protected String getThesaurusToolTipText(Thesaurus thesaurus) { + String tooltip; + if (isMove() || isEdit()) { + tooltip = ToolTipHelper.getThesaurusDescriptionToolTip(thesaurus); + } else if (isCartography()) { + tooltip = toolTipCache.get(thesaurus); + if (tooltip == null) { + tooltip = dataProvider.getCartographyToolTip(thesaurus); + toolTipCache.put(thesaurus, tooltip); + } + } else { + tooltip = ToolTipHelper.getThesaurusToolTip(thesaurus); + } + if (tooltip != null && !tooltip.trim().isEmpty()) { + return tooltip; + } + return null; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + int depth = 0; + String text; + String namePath = null; + Thesaurus thesaurus = null; + if (value instanceof VradiTreeNode) { + VradiTreeNode node = (VradiTreeNode) value; + + RootThesaurus rootThesaurus = ThesaurusTreeHelper.getRootThesaurus(node); + if (rootThesaurus != null) { + text = rootThesaurus.getName(); + } else { + thesaurus = ThesaurusTreeHelper.getThesaurus(node); + if (thesaurus == null) { + return new JLabel(value.toString()); + } + depth = ThesaurusDataHelper.getDepth(thesaurus); + text = ThesaurusDataHelper.concateOrderName(thesaurus); + } + + } else if (value instanceof Thesaurus) { + thesaurus = (Thesaurus) value; + depth = ThesaurusDataHelper.getDepth(thesaurus); + text = ThesaurusDataHelper.concateOrderName(thesaurus); + namePath = ThesaurusDataHelper.getNamePath(thesaurus, "/"); + } else { + return new JLabel(value.toString()); + } + if (text == null) { + return new JLabel(value.toString()); + } + Color color = getDepthColor(depth); + if (isProposition()) { + text = namePath; + } + JLabel jLabel = (JLabel) delegate.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); + if (color != null) { + jLabel.setForeground(color); + } + + // Show tooltip for thesaurus proposition and thesaurus selected list + if (thesaurus != null) { + jLabel.setToolTipText(ToolTipHelper.getThesaurusToolTip(thesaurus)); + } + return jLabel; + } + + protected class ToolTipStringValue implements StringValue { + + @Override + public String getString(Object value) { + + if (value instanceof Thesaurus) { + Thesaurus thesaurus = (Thesaurus) value; + String toolTipText = getThesaurusToolTipText(thesaurus); + return toolTipText; + } + return null; + } + } + + /** + * Get colors for depth in map. + * <p/> + * Default to black. + * + * @param depth depth to get color + * @return color at depth + */ + public Color getDepthColor(int depth) { + Color color = ColorsMap.getInstance().get(depth); + + // default color + if (color == null) { + color = Color.BLACK; + } + return color; + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/ThesaurusHighlighter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/VradiI18nTableCellRenderer.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/VradiI18nTableCellRenderer.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/VradiI18nTableCellRenderer.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,57 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.renderers; + +import jaxx.runtime.swing.renderer.I18nTableCellRenderer; + +import javax.swing.JComponent; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import java.awt.Component; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class VradiI18nTableCellRenderer extends I18nTableCellRenderer { + + public VradiI18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) { + super(delegate, keysAndTips); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + TableColumn col = table.getColumn(table.getColumnName(column)); + int index = col.getModelIndex(); + if (index < keys.length) { + value = _(keys[index]); + JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + rendererComponent.setToolTipText(_(tips[index])); + return rendererComponent; + } + return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column); + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/renderers/VradiI18nTableCellRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaField.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaField.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaField.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,110 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table id='vradiCriteriaField'> + + <import> + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + java.awt.event.ActionListener + java.awt.event.ActionEvent + + javax.swing.JPopupMenu + javax.swing.JMenuItem + + jaxx.runtime.swing.Item + </import> + + <String id='labelName' javaBean='""'/> + + <Thesaurus id='thesaurus' javaBean='null'/> + + <RootThesaurus id='rootThesaurus' javaBean='null'/> + + <Boolean id='deletable' javaBean='false'/> + + <Boolean id='actif' javaBean='true'/> + + <script><![CDATA[ + +protected Item rootItem = null; + +protected SearchHandler getHandler() { + return UIHelper.getHandler(this, SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { +} + +public void init(){ + if (isDeletable()){ + addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(final MouseEvent mouseEvent) { + if (mouseEvent.getButton() == MouseEvent.BUTTON3){ + + JPopupMenu popup = new JPopupMenu(); + JMenuItem menuRemoveCriteria = new JMenuItem(); + menuRemoveCriteria.setText(_("vradi.menu.removeCriteria")); + menuRemoveCriteria.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionEvent) { + removeCriteriaSelected(); + } + }); + popup.add(menuRemoveCriteria); + popup.show(vradiCriteriaField, mouseEvent.getX(), mouseEvent.getY()); + } + } + }); + } +} + +protected void removeCriteriaSelected(){ + if (getThesaurus() != null) { + getHandler().removeCriteriaAndPersist(this, getThesaurus()); + } else { + getHandler().removeRootCriteriaAndPersist(this, getRootThesaurus()); + } +} + +]]> + </script> + <row> + <cell fill='horizontal' insets='0,2,0,0'> + <JLabel id='label' text='{getLabelName()}' enabled='{isActif()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='combo' enabled='{isActif()}'/> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaField.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,228 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<Table id='filter'> + + <import> + java.awt.Dimension + java.util.Calendar + java.util.Date + org.chorem.vradi.entities.Form + org.apache.commons.lang.time.DateUtils + org.jdesktop.swingx.JXDatePicker + org.jdesktop.swingx.JXTable + org.nuiton.wikitty.entities.WikittyExtension + javax.swing.plaf.basic.BasicSplitPaneDivider + javax.swing.table.TableCellRenderer + javax.swing.plaf.basic.BasicSplitPaneUI + jaxx.runtime.swing.OneClicListSelectionModel + org.chorem.vradi.ui.admin.AdminHandler + org.chorem.vradi.entities.Status + org.chorem.vradi.entities.XmlStream + </import> + + <DefaultComboBoxModel id='dateSelectionModel' + javaBean='new DefaultComboBoxModel()'/> + + <ComboBoxModel id='formTypeSelectionModel' + javaBean='UIHelper.getFormTypesModel(true)'/> + + <!--ComboBoxModel id='xmlStreamsSelectionModel' javaBean='UIHelper.getXmlStreamsModel()'/--> + + <!--ListModel id='statusSelectionModel' javaBean='UIHelper.getStatusesModel(false)'/--> + + <script><![CDATA[ + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +public SearchHandler getHandler() { + return UIHelper.getHandler(this, SearchHandler.class); +} + +void $afterCompleteSetup() { + updateDateSelectionModel(); +} +protected void updateDateSelectionModel() { + setDateSelectionModel(getHandler().updateDateSelectionModel( + (WikittyExtension)formTypeSelection.getSelectedItem())); + if (log.isDebugEnabled()) { + for(int i = 0 ; i < dateSelectionModel.getSize() ; i++) { + log.debug(dateSelectionModel.getElementAt(i)); + } + } +} + +]]></script> + <row anchor='north'> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='horizontal' weightx='0' insets='0,0,0,0'> + <JLabel text="vradi.criteria.from"/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JXDatePicker id='fromDate' date='{new java.util.Date()}'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='fromHour' selectedItem='{0}' + model='{UIHelper.getHourModel()}' + renderer='{UIHelper.get2DigitsRenderer()}'/> + </cell> + <cell fill='horizontal' weightx='0' insets='0,0,0,0'> + <JLabel text='vradi.common.timeseparator'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='fromMinute' selectedItem='{0}' + model='{UIHelper.getMinuteModel()}' + renderer='{UIHelper.get2DigitsRenderer()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0' insets='0,0,0,0'> + <JLabel text="vradi.criteria.to"/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JXDatePicker id='toDate' date='{new java.util.Date()}'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='toHour' selectedItem='{23}' + model='{UIHelper.getHourModel()}' + renderer='{UIHelper.get2DigitsRenderer()}'/> + </cell> + <cell fill='horizontal' weightx='0' insets='0,0,0,0'> + <JLabel text='vradi.common.timeseparator'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='toMinute' selectedItem='{59}' + model='{UIHelper.getMinuteModel()}' + renderer='{UIHelper.get2DigitsRenderer()}'/> + </cell> + </row> + </Table> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JButton id='ToDay' text='vradi.criteria.searchToDay' + onActionPerformed='fromDate.setDate(new Date()); fromHour.setSelectedItem(0); fromMinute.setSelectedItem(0); + toDate.setDate(new Date()); toHour.setSelectedItem(23); toMinute.setSelectedItem(59);'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JButton id='lastDay' text='vradi.criteria.searchLastDay' + onActionPerformed='fromDate.setDate(DateUtils.truncate(DateUtils.addDays(new Date(), -1), Calendar.DAY_OF_MONTH)); fromHour.setSelectedItem(0); fromMinute.setSelectedItem(0); + toDate.setDate(DateUtils.truncate(DateUtils.addDays(new Date(), -1), Calendar.DAY_OF_MONTH)); toHour.setSelectedItem(23); toMinute.setSelectedItem(59);'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JButton id='lastMonth' text='vradi.criteria.searchThisMonth' + onActionPerformed='fromDate.setDate(DateUtils.truncate(new Date(), Calendar.MONTH)); fromHour.setSelectedItem(0); fromMinute.setSelectedItem(0); + toDate.setDate(new Date()); toHour.setSelectedItem(23); toMinute.setSelectedItem(59);'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JButton id='last30days' text='vradi.criteria.searchLast30days' + onActionPerformed='fromDate.setDate(DateUtils.addDays(new Date(), -30)); fromHour.setSelectedItem(0); fromMinute.setSelectedItem(0); + toDate.setDate(new Date()); toHour.setSelectedItem(23); toMinute.setSelectedItem(59);'/> + </cell> + </row> + </Table> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='horizontal' weightx='0' insets='0,0,0,0' anchor='east'> + <JLabel text='vradi.criteria.formType' + minimumSize='{new Dimension(0,0)}'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='formTypeSelection' + model='{formTypeSelectionModel}' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}' + maximumRowCount='30' + onActionPerformed='updateDateSelectionModel()'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0' insets='0,0,0,0' anchor='east'> + <JLabel text='vradi.criteria.typeDate' + minimumSize='{new Dimension(0,0)}'/> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <JComboBox id='dateTypeSelection' model='{getDateSelectionModel()}' + renderer='{getHandler().getDateTypeComboBoxRenderer()}'/> + </cell> + </row> + </Table> + </cell> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='horizontal' insets='0,0,0,0' anchor='east'> + <JLabel text='vradi.criteria.xmlStream' + minimumSize='{new Dimension(0,0)}'/> + </cell> + <cell fill='horizontal' weightx='0.5' weighty='0'> + <!--JComboBox id='xmlStreamSelection' model='{xmlStreamsSelectionModel}' + maximumRowCount='30' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}'/--> + <MultipleSelectionEditor id='xmlStreamSelection' + genericType='XmlStream' + beanClass='{XmlStream.class}' + allValues='{getHandler().getAllStreams()}'/> + </cell> + </row> + <row> + <cell fill='horizontal' insets='0,0,0,0' anchor='east'> + <JLabel text='vradi.criteria.status' + minimumSize='{new Dimension(0,0)}'/> + </cell> + <cell fill='horizontal' weightx='0.5' weighty='0'> + <!--JScrollPane> + <JList id='statusSelection' visibleRowCount='4' + model='{statusSelectionModel}' + selectionModel='{new OneClicListSelectionModel(statusSelection.getSelectionModel(), + statusSelection.getModel())}' + cellRenderer='{UIHelper.getStatusCellRenderer()}'/> + + </JScrollPane--> + <MultipleSelectionEditor id='statusSelection' + genericType='Status' + beanClass='{Status.class}' + allValues='{getHandler().getAllStatuses()}'/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='0' insets='0,0,0,0'> + <!--JPanel id='criteriaPanel' layout='{new GridLayout(0,1)}'/--> + <HBox id='criteriaPanel'/> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/CriteriaUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/MultipleSelectionEditor.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/MultipleSelectionEditor.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/MultipleSelectionEditor.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,98 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JLabel genericType='B extends BusinessEntity' + id='lbl' + text='{handler.getValuesAsString(getSelectedValues())}'> + + <import> + java.awt.event.MouseEvent + org.nuiton.wikitty.entities.BusinessEntity + org.nuiton.widget.tooltip.FocusableTip + </import> + + <Class id='beanClass' javaBean='null'/> + + <!-- ui handler --> + <org.chorem.vradi.ui.search.SearchMultipleSelectionHandler + id='handler' + genericType='B' + constructorParams='this'/> + + <script><![CDATA[ +protected java.util.List<B> allValues; +protected java.util.List<B> selectedValues; +protected FocusableTip focusableTip; + +@Override +public String getToolTipText(MouseEvent event) { + super.getToolTipText(event); + + // display it into persistant tooltip + if (focusableTip == null) { + focusableTip = new FocusableTip(this, true); + } + focusableTip.toolTipRequested(event, handler.getPopupUI()); + + return null; +} + +void $afterCompleteSetup() { + selectedValues = new ArrayList<B>(); + setToolTipText(FocusableTip.DUMMY_TOOL_TIP); +} + +public void setHandler(org.chorem.vradi.ui.search.SearchMultipleSelectionHandler handler) { + this.handler = handler; +} + +public java.util.List<B> getAllValues() { + return allValues; +} + +public void setAllValues(java.util.List<B> allValues) { + this.allValues = allValues; +} + +public java.util.List<B> getSelectedValues() { + return selectedValues; +} + +public void setSelectedValues(java.util.List<B> selectedValues) { + this.selectedValues = selectedValues; +} + +public void addSelectedValue(B selected) { + selectedValues.add(selected); + lbl.setText(handler.getValuesAsString(selectedValues)); +} + +public void removeSelectedValue(B unselected) { + selectedValues.remove(unselected); + lbl.setText(handler.getValuesAsString(selectedValues)); +} + + ]]></script> + +</JLabel> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/MultipleSelectionEditor.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/PaginationUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/PaginationUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/PaginationUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,97 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel layout='{new BorderLayout()}'> + + <import> + java.awt.event.KeyAdapter + java.awt.event.KeyEvent + + javax.swing.SwingConstants + javax.swing.DefaultComboBoxModel + javax.swing.text.MaskFormatter + static jaxx.runtime.SwingUtil.getStringValue + org.chorem.vradi.ui.offer.models.OfferListTableModel + org.chorem.vradi.ui.renderers.NumberListCellRenderer + </import> + + <OfferListTableModel id='offerListTableModel' + javaBean='getContextValue(OfferListTableModel.class)'/> + + <script><![CDATA[ + +public SearchHandler getHandler() { + return UIHelper.getHandler(this, SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + pageWanted.addKeyListener(new KeyAdapter(){ + @Override + public void keyReleased(KeyEvent keyEvent) { + if(keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { + offerListTableModel.setPageToShow((Integer) pageWanted.getValue()); + } + } + }); +} + +]]> + </script> + + <HBox constraints='BorderLayout.WEST' + verticalAlignment='{SwingConstants.CENTER}'> + <JLabel id='formNbLabel' + text='{getStringValue(offerListTableModel.getTotalFoundFormNb())}'/> + <JLabel text='vradi.forms.returned'/> + </HBox> + + <HBox constraints='BorderLayout.CENTER' + verticalAlignment='{SwingConstants.CENTER}' + horizontalAlignment='{SwingConstants.CENTER}'> + <JLabel text='vradi.forms.shown'/> + <JComboBox id='formsByPageComboBox' + model='{new DefaultComboBoxModel(new Object[]{10,20,50,100,1000,-1})}' + renderer='{getVradiContext().getContextValue(NumberListCellRenderer.class)}' + onActionPerformed='offerListTableModel.setNbFormsPerPage((Integer)formsByPageComboBox.getSelectedItem());'/> + </HBox> + + <HBox constraints='BorderLayout.EAST' + verticalAlignment='{SwingConstants.CENTER}'> + <JButton id='previousPage' actionIcon='arrowLeft' + visible='{offerListTableModel.getPageToShow() > 1}' + onActionPerformed='offerListTableModel.setPageToShow(offerListTableModel.getPageToShow() - 1);'/> + <JFormattedTextField id='pageWanted' columns='3' + text='{getStringValue(offerListTableModel.getPageToShow())}' + constructorParams='new UIHelper.NumberFormatterFactory()'/> + <JLabel id='pageNumber' + text='{getStringValue(offerListTableModel.getNbPagesAsText())}'/> + <JButton id='nextPage' actionIcon='arrowRight' + visible='{!offerListTableModel.isLastPage()}' + onActionPerformed='offerListTableModel.setPageToShow(offerListTableModel.getPageToShow() + 1);'/> + </HBox> +</JPanel> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/PaginationUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,711 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.search; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.context.JAXXInitialContext; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiHelper; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryBean; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Group; +import org.chorem.vradi.entities.Infogene; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Status; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.entities.XmlStream; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.admin.AdminHandler; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.chorem.vradi.ui.models.EntityModel; +import org.chorem.vradi.ui.offer.OfferListUI; +import org.chorem.vradi.ui.offer.ThesaurusCartographyUI; +import org.chorem.vradi.ui.offer.models.OfferListTableModel; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper; +import org.nuiton.wikitty.entities.FieldType; +import org.nuiton.wikitty.entities.WikittyExtension; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import javax.swing.SwingUtilities; +import java.awt.Component; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** @author letellier */ +public class SearchHandler { + + static private final Log log = LogFactory.getLog(SearchHandler.class); + + static public final String CSV_FILE_EXTENSION = ".csv"; + + /** Prefix i18n des valeurs dynamiques suivant l'infogene. */ + static public final String DATE_CRITERIA_I18N_PREFIX = "vradi.criteria.typeDate."; + + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param rootContext le context applicatif + * @param resultTableModel + * @return l'ui instancie et initialisee mais non visible encore + */ + public SearchUI initUI(JAXXContext rootContext, OfferListTableModel resultTableModel) { + + JAXXInitialContext context = new JAXXInitialContext().add(rootContext); + + // show main ui + context.add(this); + context.add(resultTableModel); + + SearchUI ui = new SearchUI(context); + + initCriteria(ui); + + return ui; + } + + public SearchUI initCloneUI(JAXXContext rootContext, OfferListTableModel resultTableModel) { + return initCloneUI(rootContext, resultTableModel, null); + } + + public SearchUI initCloneUI(JAXXContext rootContext, OfferListTableModel resultTableModel, Thesaurus thesaurus) { + + JAXXInitialContext context = new JAXXInitialContext().add(rootContext); + + // show main ui + context.add(this); + context.add(resultTableModel); + + SearchUI ui = new SearchUI(context); + + if (thesaurus != null) { + List<Thesaurus> criteriaList = new ArrayList<Thesaurus>(); + criteriaList.add(thesaurus); + initCriteria(ui, criteriaList); + } + + return ui; + } + + SearchUI getUI(JAXXContext context) { + if (context instanceof SearchUI) { + return (SearchUI) context; + } + SearchUI ui = null; + if (context instanceof JAXXObject) { + JAXXObject o = (JAXXObject) context; + ui = o.getParentContainer(SearchUI.class); + } + + if (ui != null) { + ui = context.getContextValue(SearchUI.class); + } + return ui; + } + + public List<Status> getAllStatuses() { + return AdminHandler.getAllStatuses(); + } + + public List<XmlStream> getAllStreams() { + return VradiService.getVradiDataService().findAllXmlStreams(); + } + + // From Admin Handler + public void executeQuery(SearchUI searchUI) { + + String query = searchUI.getRequest(); + JComboBox combo = searchUI.isOfferListUI() ? searchUI.getRequests() : null; + CriteriaUI criterias = searchUI.getCriterias().isVisible() ? searchUI.getCriterias() : null; + + OfferListTableModel listTableModel = searchUI.getResultTableModel(); + FormPagedResult formPageDTO = listTableModel.getFormPagedResult(); + + /* chatellier 20110221 task disabled because of + * array navigation goes out of bound + VradiTask<FormPagedResult> task = new VradiTask<FormPagedResult>(searchUI, false) { + @Override + public FormPagedResult doAction() throws Exception { + return executeQuery(searchUI, criterias, formPageDTO, combo, query); + } + + @Override + public void doWhenDone() throws Exception { + searchUI.getRootPane().setCursor(null); + FormPagedResult formPageDTO2 = get(); + listTableModel.setFormPagedResult(formPageDTO2); + } + }; + + task.execute();*/ + + FormPagedResult result = executeQuery(searchUI, criterias, formPageDTO, combo, query); + listTableModel.setFormPagedResult(result); + } + + public void executeQuery(SearchUI searchUI, int pageToShow) { + //executeQueries(context); + OfferListTableModel listTableModel = searchUI.getResultTableModel(); + listTableModel.setPageToShow(pageToShow); + } + + public List<String> loadRequests() { + return VradiHelper.loadRequests(); + } + + public JPanel getCriteriaPanel(SearchUI searchUI) { + CriteriaUI criterias = searchUI.getCriterias(); + return criterias.getCriteriaPanel(); + } + + public CriteriaUI getCriterias(JAXXContext context) { + return getUI(context).getCriterias(); + } + + public void initCriteria(SearchUI searchUI) { + initCriteria(searchUI, null); + } + + public void initCriteria(SearchUI searchUI, List<Thesaurus> thesaurus) { + // Remove existing + getCriteriaPanel(searchUI).removeAll(); + + // Adding saved root thesaurus criteria + List<String> rootThesaurusListCriteria = VradiHelper.getVradiListRootCriteria(); + for (String value : rootThesaurusListCriteria) { + addCriteria(searchUI, value, true); + } + + // Adding saved thesaurus criteria + List<String> thesaurusListCriteria = VradiHelper.getVradiListCriteria(); + for (String value : thesaurusListCriteria) { + addCriteria(searchUI, value, true); + } + + // Adding thesaurus suppl + if (thesaurus != null) { + for (Thesaurus t : thesaurus) { + addUnmodifiableCriteria(searchUI, t); + } + } + } + + public void removeCriteria(SearchUI searchUI, CriteriaField criteriaField) { + getCriteriaPanel(searchUI).remove(criteriaField); + searchUI.validate(); + } + + public void removeCriteriaAndPersist(CriteriaField criteriaField, Thesaurus bean) { + removeCriteriaAndPersist(getUI(criteriaField), criteriaField, bean); + } + + public void removeCriteriaAndPersist(SearchUI searchUI, CriteriaField criteriaField, Thesaurus bean) { + VradiHelper.removeVradiListCriteria(bean); + removeCriteria(searchUI, criteriaField); + searchUI.validate(); + } + + public void removeRootCriteriaAndPersist(CriteriaField criteriaField, RootThesaurus bean) { + removeRootCriteriaAndPersist(getUI(criteriaField), criteriaField, bean); + } + + public void removeRootCriteriaAndPersist(SearchUI searchUI, CriteriaField criteriaField, RootThesaurus bean) { + VradiHelper.removeVradiListRootCriteria(bean); + removeCriteria(searchUI, criteriaField); + searchUI.validate(); + } + + public void addUnmodifiableCriteria(SearchUI searchUI, Thesaurus thesaurus) { + + CriteriaField criteriaField; + if (ThesaurusDataHelper.isFirstChild(thesaurus)) { + RootThesaurus root = ThesaurusDataHelper.restoreRootThesaurus(thesaurus.getRootThesaurus()); + criteriaField = addCriteria(searchUI, root, false, false); + } else { + Thesaurus parent = ThesaurusDataHelper.restoreThesaurus(thesaurus.getParent()); + criteriaField = addCriteria(searchUI, parent, false, false); + } + + // Get combo + JComboBox combo = criteriaField.getCombo(); + + // Select thesaurus + combo.getModel().setSelectedItem(thesaurus); + combo.setSelectedItem(thesaurus); + } + + public void addAndPersistCriteria(JAXXContext context, Thesaurus thesaurus) { + addAndPersistCriteria(getUI(context), thesaurus); + } + + public void addAndPersistCriteria(SearchUI searchUI, Thesaurus thesaurus) { + VradiHelper.addVradiListCriteria(thesaurus); + addCriteria(searchUI, thesaurus, true, true); + } + + protected void addRootCriteria(SearchUI searchUI, String wikittyId, boolean deletable) { + + if (wikittyId == null || wikittyId.isEmpty()) { + return; + } + + RootThesaurus criteriaThe = ThesaurusDataHelper.restoreRootThesaurus(wikittyId); + + if (criteriaThe != null) { + addCriteria(searchUI, criteriaThe, deletable, true); + } + } + + protected void addCriteria(SearchUI searchUI, String wikittyId, boolean deletable) { + + if (wikittyId == null || wikittyId.isEmpty()) { + return; + } + + Thesaurus criteriaThe = ThesaurusDataHelper.restoreThesaurus(wikittyId); + + if (criteriaThe != null) { + addCriteria(searchUI, criteriaThe, deletable, true); + } + } + + protected CriteriaField addCriteria(SearchUI searchUI, RootThesaurus thesCriteria, boolean deletable, boolean enabled) { + // New criteria field + CriteriaField criteriaField = new CriteriaField(searchUI); + + // Set Name + criteriaField.setLabelName(thesCriteria.getName()); + + // Set bean + criteriaField.setRootThesaurus(thesCriteria); + + // Get children treeNode + try { + List<Thesaurus> children = VradiService.getVradiDataService().getChildrenThesaurus(thesCriteria.getWikittyId()); + initCriteriaField(searchUI, criteriaField, children, deletable, enabled); + } catch (VradiException ex) { + throw new RuntimeException("Can't get children thesaurus", ex); + } + + return criteriaField; + } + + protected CriteriaField addCriteria(SearchUI searchUI, Thesaurus thesCriteria, boolean deletable, boolean enabled) { + // New criteria field + CriteriaField criteriaField = new CriteriaField(searchUI); + + // Set Name + criteriaField.setLabelName(thesCriteria.getName()); + + // Set bean + criteriaField.setThesaurus(thesCriteria); + + // Get children treeNode + List<Thesaurus> children = null; + String thesaurusId = thesCriteria.getWikittyId(); + try { + children = VradiService.getVradiDataService().getChildrenThesaurus(thesaurusId); + } catch (VradiException eee) { + log.error("Can't restore children of thesaurus '" + thesaurusId + "' : ", eee); + ErrorDialogUI.showError(eee); + } + + initCriteriaField(searchUI, criteriaField, children, deletable, enabled); + + return criteriaField; + } + + protected void initCriteriaField(SearchUI searchUI, CriteriaField criteriaField, List<Thesaurus> children, boolean deletable, boolean enabled) { + // Deletable + criteriaField.setDeletable(deletable); + criteriaField.setActif(enabled); + + // Get combo + JComboBox combo = criteriaField.getCombo(); + + // Apply model + combo.setModel(new EntityModel<Thesaurus>(Thesaurus.class, children, true)); + combo.setMaximumRowCount(30); + + // Apply renderer + combo.setRenderer(VradiContext.get().getDecoratorProviderListCellRenderer()); + + // Adding to ui + criteriaField.init(); + + JPanel criteriaPanel = getCriteriaPanel(searchUI); + criteriaPanel.add(criteriaField); + + searchUI.validate(); + } + + protected List<String> getDateFormType(WikittyExtension formType) { + List<String> result = new ArrayList<String>(); + result.add(Form.FQ_FIELD_INFOGENE_CREATIONDATE); + result.add(Form.FQ_FIELD_FORM_DATEPUB); + result.add(Form.FQ_FIELD_FORM_DATEPEREMPTION); + if (formType != null) { + for (String name : formType.getFieldNames()) { + FieldType type = formType.getFieldType(name); + if (type.getType() == FieldType.TYPE.DATE) { + result.add(formType.getName() + "." + name); + } + } + } + return result; + } + + public DefaultComboBoxModel updateDateSelectionModel(WikittyExtension selected) { + List<String> datas = getDateFormType(selected); + return new DefaultComboBoxModel(datas.toArray(new String[datas.size()])); + } + + /** + * Execute query. + * + * @param searchUI + * @param criterias + * @param formPagedResult + * @param combo + * @param request + * @return paged result + */ + public FormPagedResult executeQuery(final SearchUI searchUI, CriteriaUI criterias, FormPagedResult formPagedResult, final JComboBox combo, final String request) { + if (criterias == null) { + // Criteria panel is hidden + QueryParameters queryParameters = new QueryParameters(request); + formPagedResult = VradiHelper.executeQuery(queryParameters, formPagedResult); + } else { + // Apply criterian search + Component[] thesaurusCriteria = getCriteriaPanel(searchUI).getComponents(); + List<Thesaurus> thesaurus = new ArrayList<Thesaurus>(); + for (Component aThesaurusCriteria : thesaurusCriteria) { + + // Get selected + Thesaurus tn = (Thesaurus) ((CriteriaField) aThesaurusCriteria) + .getCombo().getSelectedItem(); + + // If is not empty + if (tn != null && StringUtils.isNotBlank(tn.getName())) { + + // Add parent + String wikittyId = tn.getWikittyId(); + + // Find thesaurus corresponding in context + Thesaurus parent = ThesaurusDataHelper.restoreThesaurus(wikittyId); + + // Get children recursivly + thesaurus.add(parent); + } + } + formPagedResult = executeQuery(request, criterias, thesaurus, formPagedResult); + } + + if (log.isInfoEnabled()) { + log.info("Total forms found : " + formPagedResult.getTotalFoundFormNb()); + log.info("Number of forms per page : " + formPagedResult.getNbFormsToShow()); + log.info("Actual page : " + formPagedResult.getPageToShow()); + } + + // TODO SLE 06082010 : Refactor search to have a better way + // If it's offer edit it's calling search + if (searchUI.getParentContainer(OfferListUI.class) != null) { + + // Store request in properties + VradiHelper.addRequestToProperties(request); + } + + // Update models + if (combo != null) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + DefaultComboBoxModel model = searchUI.getRequestModel(); + model.removeElement(request); + model.insertElementAt(request, 0); + combo.setSelectedItem(request); + } + }); + } + + return formPagedResult; + } + + public DefaultComboBoxModel getRequestModel() { + List<String> queries = loadRequests(); + DefaultComboBoxModel model = new DefaultComboBoxModel(queries.toArray()); + return model; + } + + public void updateRequests(SearchUI searchUI) { + JComboBox groupsCombo = searchUI.getGroups(); + Group selected = (Group) groupsCombo.getSelectedItem(); + JComboBox requestCombo = searchUI.getRequests(); + if (selected == null) { + + // Use saved request model + requestCombo.setModel(searchUI.getRequestModel()); + return; + } + + // Use group request + Set<String> queries = selected.getQueries(); + + // Extract queries + List<QueryBean> queriesBean = new ArrayList<QueryBean>(); + if (queries != null) { + for (String query : queries) { + try { + QueryBean queryBean = new QueryBean(query); + queriesBean.add(queryBean); + } catch (IOException eee) { + log.error("Cant parse query : " + query, eee); + ErrorDialogUI.showError(eee); + } + } + } + + // Use group requests model + requestCombo.setModel(new DefaultComboBoxModel(queriesBean.toArray())); + + // Try to select updated + requestCombo.setSelectedItem(searchUI.getRequest()); + } + + /** + * Affiche une fenetre contenant la catographie pour une requete en cours. + * + * @param searchUI + */ + public void executeCartography(SearchUI searchUI) { + + QueryParameters queryParameters = getQueryParameters(searchUI); + ThesaurusTreeTableHelper thesaurusTreeTableHelper = new ThesaurusTreeTableHelper(queryParameters); + ThesaurusCartographyUI cartographyUI = new ThesaurusCartographyUI(searchUI, thesaurusTreeTableHelper); + cartographyUI.setLocationRelativeTo(searchUI); + cartographyUI.setVisible(true); + } + + protected QueryParameters getQueryParameters(SearchUI searchUI) { + + String request = searchUI.getRequest(); + JComboBox combo = searchUI.isOfferListUI() ? searchUI.getRequests() : null; + CriteriaUI criterias = searchUI.getCriterias().isVisible() ? searchUI.getCriterias() : null; + + QueryParameters queryParameters = new QueryParameters(request); + + // Criteria panel not hidden + if (criterias != null) { + // Apply criteria search + Component[] thesaurusCriteria = getCriteriaPanel(searchUI).getComponents(); + List<Thesaurus> thesaurus = new ArrayList<Thesaurus>(); + for (Component aThesaurusCriteria : thesaurusCriteria) { + // Get selected + Thesaurus tn = (Thesaurus) ((CriteriaField) aThesaurusCriteria) + .getCombo().getSelectedItem(); + thesaurus.add(tn); + } + queryParameters.setThesaurus(thesaurus); + + // begin date + Calendar beginDate = Calendar.getInstance(); + beginDate.setTime(criterias.getFromDate().getDate()); + beginDate.set(Calendar.HOUR_OF_DAY, (Integer) criterias + .getFromHour().getSelectedItem()); + beginDate.set(Calendar.MINUTE, (Integer) criterias + .getFromMinute().getSelectedItem()); + queryParameters.setBeginDate(beginDate.getTime()); + + // end date + Calendar endDate = Calendar.getInstance(); + endDate.setTime(criterias.getToDate().getDate()); + endDate.set(Calendar.HOUR_OF_DAY, (Integer) criterias.getToHour() + .getSelectedItem()); + endDate.set(Calendar.MINUTE, (Integer) criterias.getToMinute() + .getSelectedItem()); + queryParameters.setEndDate(endDate.getTime()); + + // form type + WikittyExtension extension = (WikittyExtension) criterias + .getFormTypeSelection().getSelectedItem(); + queryParameters.setExtension(extension); + + // date field name + String dateFieldName = (String) criterias.getDateTypeSelection() + .getSelectedItem(); + queryParameters.setDateFieldName(dateFieldName); + + // status + List<Status> statuses = criterias.getStatusSelection().getSelectedValues(); + List<String> statusIds = VradiHelper.extractIds(statuses); + queryParameters.setStatusIds(statusIds); + + // xml streams id + List<XmlStream> xmlStreams = criterias.getXmlStreamSelection() + .getSelectedValues(); + List<String> streamIds = VradiHelper.extractIds(xmlStreams); + queryParameters.setStreamIds(streamIds); + } + + return queryParameters; + } + + /** + * Execute query methods (called by double clic on thesaurus catography + * treetable). + * <p/> + * FIXME EC20100920 code duplicated with getQueryParameters(SearchUI, CriteriaUI, JComboBox, String ) + * + * @param request + * @param criterias + * @param thesauruses + * @param formPagedResult + * @return + */ + public FormPagedResult executeQuery(String request, CriteriaUI criterias, List<Thesaurus> thesauruses, FormPagedResult formPagedResult) { + + QueryParameters queryParameters = new QueryParameters(request); + + // Criteria panel not hidden + if (criterias != null) { + // begin date + Calendar beginDate = Calendar.getInstance(); + beginDate.setTime(criterias.getFromDate().getDate()); + beginDate.set(Calendar.HOUR_OF_DAY, (Integer) criterias + .getFromHour().getSelectedItem()); + beginDate.set(Calendar.MINUTE, (Integer) criterias + .getFromMinute().getSelectedItem()); + queryParameters.setBeginDate(beginDate.getTime()); + + // end date + Calendar endDate = new GregorianCalendar(); + endDate.setTime(criterias.getToDate().getDate()); + endDate.set(Calendar.HOUR_OF_DAY, (Integer) criterias.getToHour() + .getSelectedItem()); + endDate.set(Calendar.MINUTE, (Integer) criterias.getToMinute() + .getSelectedItem()); + queryParameters.setEndDate(endDate.getTime()); + + // form type + WikittyExtension extension = (WikittyExtension) criterias + .getFormTypeSelection().getSelectedItem(); + queryParameters.setExtension(extension); + + // date field + String dateFieldName = (String) criterias.getDateTypeSelection() + .getSelectedItem(); + queryParameters.setDateFieldName(dateFieldName); + + // status (traité/non traité) + List<Status> statuses = criterias.getStatusSelection().getSelectedValues(); + List<String> statusIds = VradiHelper.extractIds(statuses); + queryParameters.setStatusIds(statusIds); + + // xml stream id + List<XmlStream> xmlStreams = criterias.getXmlStreamSelection().getSelectedValues(); + List<String> streamIds = VradiHelper.extractIds(xmlStreams); + queryParameters.setStreamIds(streamIds); + } + + // thesaurus is + queryParameters.setThesaurus(thesauruses); + + // execute query + FormPagedResult result = VradiHelper.executeQuery(queryParameters, formPagedResult); + return result; + } + + /** + * Criteria UI date sort renderer. + * <p/> + * Prefix i18n translation with {@link #DATE_CRITERIA_I18N_PREFIX}. + * + * @return ListCellRenderer + */ + public ListCellRenderer getDateTypeComboBoxRenderer() { + + // List of translated criteria : (don't remove this comment) : + // + // _("vradi.criteria.typeDate.Form.datePeremption"); + // _("vradi.criteria.typeDate.Form.datePub"); + // _("vradi.criteria.typeDate.Infogene.creationDate"); + // + + return new DefaultListCellRenderer() { + /** serialVersionUID. */ + private static final long serialVersionUID = -1967943679031854092L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + String stringValue = null; + if (value != null) { + stringValue = value.toString(); + int dot = stringValue.lastIndexOf("."); + String extName = stringValue.substring(0, dot); + if (Infogene.EXT_INFOGENE.equals(extName) + || Form.EXT_FORM.equals(extName)) { + stringValue = _(DATE_CRITERIA_I18N_PREFIX + stringValue); + } else { + stringValue = stringValue.substring(dot + 1); + } + } + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); + } + }; + } + + public void exportToCSV(OfferListTableModel offerListTableModel) { + + OfferListUI ui = VradiContext.OFFERT_LIST_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + + File file = UIHelper.openFileChooser(CSV_FILE_EXTENSION, _("vradi.export.filter.csv"), + ui, _("vradi.export.validate.label")); + + if (file != null) { + + UIHelper.exportToCSV(file, offerListTableModel); + } + } +} + Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchMultipleSelectionHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchMultipleSelectionHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchMultipleSelectionHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,133 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.search; + +import jaxx.runtime.decorator.Decorator; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.BoxLayout; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** @author sletellier */ +public class SearchMultipleSelectionHandler<B extends BusinessEntity> { + + public static final Log log = LogFactory.getLog(SearchMultipleSelectionHandler.class); + + public static final String VRADI_LIST_EMPTY = n_("vradi.criteria.empty"); + + public static final String WIKITTY_ID = "wikittyId"; + + protected Map<String, B> valuesAsMap; + + protected MultipleSelectionEditor<B> editor; + + protected Decorator<B> decorator; + + public SearchMultipleSelectionHandler(MultipleSelectionEditor<B> editor) { + this.editor = editor; + valuesAsMap = new HashMap<String, B>(); + decorator = VradiContext.get().getDecoratorProvider().getDecorator(editor.getBeanClass()); + } + + public String getValueAsString(B value) { + return _(decorator.toString(value)); + } + + public String getValuesAsString(List<B> values) { + StringBuilder builder = new StringBuilder(); + if (values != null) { + for (B value : values) { + builder.append(getValueAsString(value)); + builder.append(", "); + } + } + String result = builder.toString(); + if (!StringUtils.isEmpty(result)) { + result = result.substring(0, result.length() - 2); + } else { + result = _(VRADI_LIST_EMPTY); + } + + // Abreviate long tool tips + // TODO sletellier 13/12/10 : make it configurable + result = StringUtils.abbreviate(result, 70); + + return getBold(result); + } + + protected String getBold(String toBold) { + StringBuilder result = new StringBuilder(); + result.append("<html><strong>").append(toBold).append("</strong></html>"); + return result.toString(); + } + + public Component getPopupUI() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + List<B> values = editor.getAllValues(); + List<B> selectedValues = editor.getSelectedValues(); + for (B value : values) { + String valueAsString = getValueAsString(value); + String id = value.getWikittyId(); + valuesAsMap.put(id, value); + + final JCheckBox checkBox = new JCheckBox(valueAsString); + checkBox.putClientProperty(WIKITTY_ID, id); + checkBox.setSelected(selectedValues.contains(value)); + checkBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + String id = (String) checkBox.getClientProperty(WIKITTY_ID); + B bean = valuesAsMap.get(id); + if (checkBox.isSelected()) { + editor.addSelectedValue(bean); + } else { + editor.removeSelectedValue(bean); + } + } + }); + + panel.add(checkBox); + } + return new JScrollPane(panel); + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchMultipleSelectionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,240 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table constraints='BorderLayout.NORTH'> + + <import> + java.awt.Component + + javax.swing.JList + javax.swing.JPopupMenu + javax.swing.JSeparator + + javax.swing.ListCellRenderer + javax.swing.event.DocumentEvent + javax.swing.event.DocumentListener + + org.chorem.vradi.ui.offer.models.OfferListTableModel + javax.swing.table.AbstractTableModel + jaxx.runtime.swing.HidorButton + org.chorem.vradi.beans.QueryBean + static jaxx.runtime.SwingUtil.getStringValue + org.apache.commons.lang.StringUtils + org.nuiton.widget.editor.Editor + org.fife.ui.rsyntaxtextarea.RSyntaxTextArea + org.fife.ui.rsyntaxtextarea.SyntaxConstants + org.chorem.vradi.ui.models.RequestFieldMenu + </import> + + <String id='request' javaBean='""'/> + + <Boolean id='offerListUI' javaBean='false'/> + + <Boolean id='hidable' javaBean='true'/> + + <OfferListTableModel id='resultTableModel' + javaBean='getContextValue(OfferListTableModel.class)'/> + + <DefaultComboBoxModel id='requestModel' + javaBean='getHandler().getRequestModel()'/> + + <script><![CDATA[ + +public SearchHandler getHandler() { + return getContextValue(SearchHandler.class); +} + +protected VradiContext getVradiContext() { + return VradiContext.get(); +} + +void $afterCompleteSetup() { + requestArea.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void insertUpdate(DocumentEvent e) { + textAsChanged(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + textAsChanged(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + textAsChanged(); + } + }); + requests.setRenderer(new ListCellRenderer(){ + + public static final int TEXT_LENGTH_LIMIT = 130; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + String text; + JLabel label = new JLabel(); + if (value instanceof String) { + text = (String)value; + } else { + + QueryBean bean = (QueryBean) value; + + if (bean == null) { + return new JLabel(""); + } + + StringBuffer buf = new StringBuffer(); + buf.append("["); + buf.append(bean.getName()); + buf.append("] "); + buf.append(bean.getQuery()); + + text = buf.toString(); + label.setToolTipText(bean.getDescription()); + } + text = StringUtils.abbreviate(text, TEXT_LENGTH_LIMIT); + label.setText(text); + + return label; + } + }); + + // Add items to menu + JPopupMenu popupMenu = requestArea.getPopupMenu(); + popupMenu.add(new JSeparator()); + popupMenu.add(new RequestFieldMenu(this)); +} + +protected void textAsChanged() { + setRequest(requestArea.getText()); +} + +protected void keyReleased(KeyEvent keyEvent) { + if(keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { + executeQuery(); + } +} + +public void executeQuery() { + getHandler().executeQuery(this, 1); +} + +protected void executeCartography() { + getHandler().executeCartography(this); +} + +protected void updateRequests() { + getHandler().updateRequests(this); +} + +protected String getRequestAsString(Object selected) { + if (selected == null) { + return null; + } + if (selected instanceof String) { + return (String)selected; + } + QueryBean queryBean = (QueryBean) selected; + return queryBean.getQuery(); +} +]]> + </script> + + <row> + <cell insets='0,0,0,0'> + <JLabel text="vradi.list.requests" visible='{isOfferListUI()}'/> + </cell> + <cell fill='horizontal' weightx='0.3' insets='0,0,0,0'> + <JComboBox id='groups' + onActionPerformed='updateRequests()' + visible='{isOfferListUI()}' + model='{UIHelper.getGroupModel(true)}' + renderer='{VradiContext.get().getDecoratorProviderListCellRenderer()}'/> + </cell> + <cell fill='horizontal' weightx='0.7' insets='0,0,0,0'> + <JComboBox id='requests' + onActionPerformed='setRequest(getRequestAsString(requests.getSelectedItem()))' + visible='{isOfferListUI()}' + model='{requestModel}'/> + </cell> + </row> + <row> + <cell fill='both' columns='3' weightx='1' weighty='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='both' weightx='0.9' weighty='1' insets='0,0,0,0'> + <JScrollPane> + <!--JTextArea id='requestArea' rows='3' text='{getRequest()}' + onKeyReleased='keyReleased(event)' + onMouseClicked='getHandler().showRequestAreaContextMenu(this, event)'/--> + <RSyntaxTextArea id='requestArea' + text='{getRequest()}' + syntaxEditingStyle='{SyntaxConstants.SYNTAX_STYLE_SQL}' + onKeyReleased='keyReleased(event)'/> + </JScrollPane> + </cell> + <cell fill='both' weightx='0.1' weighty='1' insets='0,0,0,0'> + <Table> + <row> + <cell fill='both' weightx='1' weighty='1' insets='0,0,0,0'> + <JButton id='search' text='vradi.criteria.search' + actionIcon='search' + onActionPerformed='executeQuery()'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='1' insets='0,0,0,0'> + <JButton id='cartography' text='vradi.criteria.cartography' + actionIcon='search' + onActionPerformed='executeCartography()'/> + </cell> + </row> + <row> + <cell fill='both' weightx='1' weighty='1' insets='0,0,0,0'> + <JButton id='clear' text='vradi.criteria.clear' + onActionPerformed='setRequest("")'/> + </cell> + </row> + <row> + <cell fill='horizontal' weightx='1' insets='0,0,0,0'> + <HidorButton target='{criterias}' + hideTip='{_("vradi.criteria.collapse")}' + showTip='{_("vradi.criteria.notCollapse")}' + visible='{isHidable()}' + targetVisible='{true}'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='horizontal' columns='3' weightx='1'> + <CriteriaUI id='criterias' constructorParams='this'/> + </cell> + </row> +</Table> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/search/SearchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/AbstractProgressBarUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/AbstractProgressBarUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/AbstractProgressBarUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,58 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog id='abstractProgressBarUI' + abstract='true' + title='vradi.progressBar.title' + layout='{new BorderLayout()}' + defaultCloseOperation='{JDialog.DO_NOTHING_ON_CLOSE}' + onWindowClosing='dispose()'> + + <Boolean id='showCancelButton' javaBean='true'/> + + <String id='msg' javaBean='null'/> + + <script> + <![CDATA[ + + public abstract void cancel(); + +]]> + </script> + + <JLabel id='msgLabel' text='{getMsg()}' + visible='{getMsg() != null}' + constraints='BorderLayout.NORTH'/> + + <JProgressBar id='progressBar' + constraints='BorderLayout.CENTER' + indeterminate='true'/> + + <JButton id='cancelButton' + constraints='BorderLayout.SOUTH' + text='vradi.common.cancel' + actionIcon='cancel' + visible='{isShowCancelButton()}' + onActionPerformed='cancel()'/> +</JDialog> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/AbstractProgressBarUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ProgressBarUI.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ProgressBarUI.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ProgressBarUI.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,39 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<AbstractProgressBarUI> + + <script><![CDATA[ + + public void $afterCompleteSetup() { + super.setShowCancelButton(false); + } + + public void cancel(){ + // do nothing + } + +]]> + </script> +</AbstractProgressBarUI> Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/ProgressBarUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/VradiTask.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/VradiTask.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/VradiTask.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,180 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.task; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.ErrorDialogUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.ui.helpers.UIHelper; + +import javax.swing.JFrame; +import javax.swing.SwingWorker; +import java.awt.Component; +import java.awt.Cursor; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier */ +public abstract class VradiTask<T> extends SwingWorker<T, Void> { + + static private final Log log = LogFactory.getLog(VradiTask.class); + + protected JAXXContext context; + + protected String i18nKey; + + protected AbstractProgressBarUI pb = null; + + protected boolean showErrorDialog = true; + + public VradiTask(JAXXContext context) { + this.context = context; + i18nKey = null; + pb = new ProgressBarUI(context); + } + + public VradiTask(JAXXContext context, boolean showProgressBar) { + this.context = context; + i18nKey = null; + if (showProgressBar) { + pb = new ProgressBarUI(context); + } + } + + public VradiTask(JAXXContext context, String i18nKey) { + this.context = context; + this.i18nKey = i18nKey; + pb = new ProgressBarUI(context); + } + + public VradiTask(JAXXContext context, boolean showProgressBar, String i18nKey) { + this.context = context; + this.i18nKey = i18nKey; + if (showProgressBar) { + pb = new ProgressBarUI(context); + } + } + + public VradiTask(JAXXContext context, AbstractProgressBarUI pb, String i18nKey) { + this.context = context; + this.i18nKey = i18nKey; + this.pb = pb; + } + + public VradiTask(JAXXContext context, AbstractProgressBarUI pb, String i18nKey, boolean showErrorDialog) { + this.context = context; + this.i18nKey = i18nKey; + this.pb = pb; + this.showErrorDialog = showErrorDialog; + } + + /* + * Main task. Executed in background thread. + */ + @Override + protected T doInBackground() { + Component component = (Component) context; + component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + if (pb != null) { + if (i18nKey != null) { + pb.setTitle(getTitleMsg()); + pb.setMsg(getMsg()); + } + JFrame frame = context.getContextValue(JFrame.class, "parent"); + if (frame != null) { + SwingUtil.center(frame, pb); + } else { + SwingUtil.center(component, pb); + } + pb.pack(); + pb.setVisible(true); + UIHelper.registerComponentToSaveDispositionConfig(pb); + } + try { + return doAction(); + } catch (Exception eee) { + if (log.isErrorEnabled()) { + log.error(getErrorMsg(), eee); + if (showErrorDialog) { + ErrorDialogUI.showError(eee); + } + doWhenError(eee); + } + } + return null; + } + + /* + * Executed in event dispatching thread + */ + @Override + protected void done() { + try { + doWhenDone(); + } catch (Exception eee) { + log.error(getErrorMsg(), eee); + if (showErrorDialog) { + ErrorDialogUI.showError(eee); + } + } finally { + if (pb != null) { + pb.dispose(); + } + ((Component) context).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } + + protected String getTitleMsg() { + // FIXME EC20100910 ce n'est pas du i18n correct (pas parseable) + return _(i18nKey + ".title"); + } + + protected String getMsg() { + // FIXME EC20100910 ce n'est pas du i18n correct (pas parseable) + return _(i18nKey + ".msg"); + } + + protected String getErrorMsg() { + if (i18nKey != null) { + + // FIXME EC20100910 ce n'est pas du i18n correct (pas parseable) + return _(i18nKey + ".error"); + } + return _("vradi.error.executeTask"); + } + + public abstract T doAction() throws Exception; + + public void doWhenDone() throws Exception { + // Do nothing + } + + public void doWhenError(Exception eee) { + // Do nothing + } + +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/task/VradiTask.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ThesaurusDataProvider.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ThesaurusDataProvider.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ThesaurusDataProvider.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,148 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.beans.FormPagedResult; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.services.search.UnsupportedQueryException; +import org.chorem.vradi.ui.helpers.ToolTipHelper; +import org.chorem.vradi.ui.helpers.VradiComparators; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.tree.VradiDataProvider; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** @author sletellier */ +public class ThesaurusDataProvider extends VradiDataProvider { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusDataProvider.class); + + protected QueryParameters queryParameters; + + protected Map<Thesaurus, Integer> cachedMap; + + public ThesaurusDataProvider() { + } + + public ThesaurusDataProvider(QueryParameters queryParameters) { + cachedMap = new HashMap<Thesaurus, Integer>(); + this.queryParameters = queryParameters; + } + + public boolean isCartography() { + return queryParameters != null; + } + + public Integer getNbFormsForThesaurus(Thesaurus thesaurus) { + int result = 0; + + if (isCartography()) { + Integer nb = cachedMap.get(thesaurus); + if (nb != null) { + result = nb; + } + } else { + result = ThesaurusDataHelper.getNbFormsForThesaurus(thesaurus); + } + return result; + } + + public Collection<Thesaurus> getChildrenThesaurus(String thesaurusId) { + if (isCartography()) { + Set<Thesaurus> thesauruses = getChildrenCartography(thesaurusId).keySet(); + + List<Thesaurus> sortedList = new ArrayList<Thesaurus>(thesauruses); + Collections.sort(sortedList, VradiComparators.THESAURUS_COMPARATOR); + return sortedList; + } + try { + return VradiService.getVradiDataService().getChildrenThesaurus(thesaurusId); + } catch (VradiException eee) { + log.error("Cant get thesaurus children of node " + thesaurusId, eee); + } + return null; + } + + protected Map<Thesaurus, Integer> getChildrenCartography(String thesaurusId) { + Map<Thesaurus, Integer> map = null; + try { + map = VradiService.getVradiDataService().getChildrenCartography(thesaurusId, queryParameters); + } catch (VradiException eee) { + log.error("Exception occured on get children cartography of node " + thesaurusId, eee); + } catch (UnsupportedQueryException eee) { + log.error("Exception occured on get children cartography of node " + thesaurusId, eee); + } + if (map != null) { + cachedMap.putAll(map); + } + return map; + } + + @Override + public boolean isEnabled() { + return true; + } + + public String getCartographyToolTip(Thesaurus thesaurus) { + + Integer formsForThesaurus = getNbFormsForThesaurus(thesaurus); + if (formsForThesaurus == null || formsForThesaurus == 0) { + return null; + } + + FormPagedResult pagedResult = new FormPagedResult(); + + // Search only for this thesaurus + List<Thesaurus> thesauruses = queryParameters.getThesaurus(); + queryParameters.clearThesaurus(); + queryParameters.addThesaurus(thesaurus); + try { + pagedResult = VradiService.getVradiDataService().findForms(queryParameters, pagedResult); + } catch (VradiException eee) { + log.error("Cant get tool tip for thesaurus " + thesaurus.getName(), eee); + } catch (UnsupportedQueryException eee) { + log.error("Cant get tool tip for thesaurus " + thesaurus.getName(), eee); + } + List<String> formToShow = pagedResult.getFormsIdsToShow(); + List<Form> formList = VradiService.getWikittyProxy().restore(Form.class, formToShow); + + // Revert + queryParameters.setThesaurus(thesauruses); + return ToolTipHelper.getToolTip(formList); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/ThesaurusDataProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusDataHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusDataHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusDataHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,240 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.helpers; + +import org.apache.commons.lang.xwork.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.nuiton.wikitty.WikittyProxy; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public class ThesaurusDataHelper { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusDataHelper.class); + + /** + * Get the wikitty proxy + * + * @return WikittyProxy + */ + public static WikittyProxy getProxy() { + return VradiService.getWikittyProxy(); + } + + /** + * Get corresponding thesaurus + * + * @param thesaurusId thesaurus id + * @return Thesaurus from base + */ + public static Thesaurus restoreThesaurus(String thesaurusId) { + return getProxy().restore(Thesaurus.class, thesaurusId); + } + + /** + * Get corresponding list of thesaurus + * + * @param thesaurusIds thesaurus ids + * @return List of thesaurus from base + */ + public static List<Thesaurus> restoreThesaurus(Collection<String> thesaurusIds) { + return getProxy().restore(Thesaurus.class, new ArrayList<String>(thesaurusIds)); + } + + /** + * Get corresponding root thesaurus + * + * @param rootThesaurusId root thesaurus id + * @return Thesaurus from base + */ + public static RootThesaurus restoreRootThesaurus(String rootThesaurusId) { + return getProxy().restore(RootThesaurus.class, rootThesaurusId); + } + + /** + * Get corresponding list root thesaurus + * + * @param rootThesaurusIds root thesaurus ids + * @return List root thesaurus from base + */ + public static List<RootThesaurus> restoreRootThesaurus(List<String> rootThesaurusIds) { + return getProxy().restore(RootThesaurus.class, rootThesaurusIds); + } + + /** + * Get the path with name of thesaurus ({@code root/thesaurus...}) + * + * @param thesaurus thesaurus concerned + * @param pathSeparator separator + * @return path with name + */ + public static String getNamePath(Thesaurus thesaurus, String pathSeparator) { + if (thesaurus == null) { + return ""; + } + String parentId = thesaurus.getParent(); + + // If root + if (isFirstChild(thesaurus)) { + return restoreRootThesaurus(thesaurus.getRootThesaurus()).getName() + pathSeparator + concateOrderName(thesaurus); + } + Thesaurus parentThesaurus = restoreThesaurus(parentId); + return getNamePath(parentThesaurus, pathSeparator) + pathSeparator + concateOrderName(thesaurus); + } + + /** + * Concatenate order and name of thesaurus in param ({@code order - name}} + * + * @param thesaurus thesaurus concerned + * @return concatenate order and name + */ + public static String concateOrderName(Thesaurus thesaurus) { + String result = thesaurus.getName(); + int order = thesaurus.getOrder(); + if (order != 0) { + result = order + " - " + result; + } + return result; + } + + /** + * Get tags as string ({@code tag1, tag2, ...}) + * + * @param thesaurus thesaurus concerned + * @return tags as string + */ + public static String getTagsAsString(Thesaurus thesaurus) { + if (thesaurus == null) { + return ""; + } + String result; + if (thesaurus.getTags() != null) { + result = StringUtils.join(thesaurus.getTags(), " ,"); + } else { + result = ""; + } + + return result; + } + + /** + * Set tags as string ({@code tag1, tag2, ...}) + * + * @param thesaurus thesaurus concerned + * @param tagsAsString tags as string + */ + public static void setTagsAsString(Thesaurus thesaurus, String tagsAsString) { + if (tagsAsString != null) { + + // Clear existing + thesaurus.clearTags(); + + // Resore tags from tags as string + for (String tag : tagsAsString.split(",")) { + thesaurus.addTags(tag.trim()); + } + } + } + + /** + * Return number of form associated to thesaurus pass in param + * + * @param thesaurus thesaurus concerned + * @return number of form associated + */ + public static int getNbFormsForThesaurus(Thesaurus thesaurus) { + String wikittyId = thesaurus.getWikittyId(); + + Map.Entry<Thesaurus, Integer> entry = + getProxy().restoreNode(Thesaurus.class, wikittyId, null); + + if (entry == null) { + return 0; + } + + return entry.getValue(); + } + + protected static List<String> getStringAsList(String s) { + List<String> result = new ArrayList<String>(); + result.add(s); + return result; + } + + public static String getParentPath(Thesaurus thesaurus, String pathSeparator) { + if (thesaurus == null) { + return pathSeparator; + } + if (isFirstChild(thesaurus)) { + RootThesaurus rootThesaurus = restoreRootThesaurus(thesaurus.getRootThesaurus()); + return rootThesaurus.getName(); + } + String parentId = thesaurus.getParent(); + Thesaurus parentThesaurus = restoreThesaurus(parentId); + return getParentPath(parentThesaurus, pathSeparator) + pathSeparator + concateOrderName(parentThesaurus); + } + + public static int getDepth(Thesaurus thesaurus) { + if (thesaurus == null) { + return 0; + } + if (isFirstChild(thesaurus)) { + return 2; + } + String parentId = thesaurus.getParent(); + Thesaurus parent = restoreThesaurus(parentId); + return 1 + getDepth(parent); + } + + public static boolean isFirstChild(Thesaurus thesaurus) { + String rootThesaurus = thesaurus.getRootThesaurus(); + String parent = thesaurus.getParent(); + return parent != null && parent.equals(rootThesaurus); + } + + public static String getRequestName(Thesaurus thesaurus) { + String rootId = thesaurus.getRootThesaurus(); + RootThesaurus rootThesaurus = restoreRootThesaurus(rootId); + return rootThesaurus.getName() + ":\"" + thesaurus.getName() + "\""; + } + + public static List<Thesaurus> getChildrenRecursivly(Thesaurus thesaurus) throws VradiException { + List<Thesaurus> childrenThesaurus = VradiService.getVradiDataService().getChildrenThesaurus(thesaurus.getWikittyId()); + List<Thesaurus> result = new ArrayList<Thesaurus>(childrenThesaurus); + for (Thesaurus child : childrenThesaurus) { + result.addAll(getChildrenRecursivly(child)); + } + return result; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusDataHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusSelectionManager.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusSelectionManager.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusSelectionManager.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,378 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.helpers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Form; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import javax.swing.DefaultListModel; +import javax.swing.DefaultListSelectionModel; +import javax.swing.JList; +import javax.swing.JTree; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Manager of selections models. All tree and helper are register here. + * On register, selection listener are attach. For thesaurus, when one + * is selected, all other thesaurus panel must select the same. + * <p/> + * It manage too the proposition list. + * + * @author sletellier <letellier@codelutin.com> + */ +public class ThesaurusSelectionManager { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusSelectionManager.class); + + protected JList propositionList; + + protected PropositionSelectionModel propositionSelectionModel; + + protected ThesaurusListener propositionListener; + + protected ThesaurusTreeHelper rootHelper; + + protected RootThesaurusListener rootListener; + + protected Map<ThesaurusTreeHelper, ThesaurusListener> helpers; + + protected Form form; + + protected boolean isRootListening = true; + + /** + * This class manage the proposition list pass in param and must + * know form concerned to select thesaurus + * + * @param propositionList proposition list + * @param form form concerned + */ + public ThesaurusSelectionManager(JList propositionList, Form form) { + this.form = form; + this.propositionList = propositionList; + + // Create selection model and register it + propositionSelectionModel = new PropositionSelectionModel(); + this.propositionList.setSelectionModel(propositionSelectionModel); + + helpers = new HashMap<ThesaurusTreeHelper, ThesaurusListener>(); + + // Register listeners + propositionListener = new ThesaurusListener(); + propositionList.getSelectionModel() + .addListSelectionListener(propositionListener); + } + + public VradiDataProvider getDataProvider() { + return rootHelper.getDataProvider(); + } + + public Form getForm() { + return form; + } + + /** + * Return root helper + * + * @return root helper + */ + public ThesaurusTreeHelper getRootHelper() { + return rootHelper; + } + + /** + * Return all helper less root one + * + * @return list of helper + */ + public List<ThesaurusTreeHelper> getHelpers() { + return new ArrayList<ThesaurusTreeHelper>(helpers.keySet()); + } + + /** + * Register the tree and root helper and attach {@link RootThesaurusListener} + * and select associated thesaurus + * + * @param rootHelper root helper to register + * @param tree tree to register + */ + public void registerRootTreeHelper(ThesaurusTreeHelper rootHelper, JTree tree) { + this.rootHelper = rootHelper; + useMultipleSelectionMode(tree); + rootListener = new RootThesaurusListener(); + rootHelper.setUI(tree, true, false, rootListener); + selectRootThesaurus(rootHelper); + } + + /** + * Register the tree and helper and attach {@link ThesaurusListener} + * + * @param helper helper to register + * @param tree tree to register + */ + public void registerTreeHelper(ThesaurusTreeHelper helper, JTree tree) { + registerListener(helper, tree); + selectThesaurus(helper); + } + + protected void registerListener(ThesaurusTreeHelper helper, JTree tree) { + useMultipleSelectionMode(tree); + ThesaurusListener listener = new ThesaurusListener(); + helpers.put(helper, listener); + helper.setUI(tree, true, false, listener); + } + + protected void useMultipleSelectionMode(JTree tree) { + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); + } + + protected void desactiveRootListener() { + isRootListening = false; + } + + protected void activeRootListener() { + isRootListening = true; + } + + protected void desactiveListener(ThesaurusTreeHelper helper) { + helpers.get(helper).desactiveListener(); + } + + protected void activeListener(ThesaurusTreeHelper helper) { + helpers.get(helper).activeListener(); + } + + protected void selectRootThesaurus(ThesaurusTreeHelper helper) { + try { + List<Thesaurus> thesauruses = VradiService.getVradiDataService().getThesaurusAttachedToForm(form); + + if (thesauruses != null) { + desactiveRootListener(); + helper.tryToSelect(thesauruses); + activeRootListener(); + propositionSelectionModel.tryToSelectObjects(thesauruses); + } + } catch (VradiException ex) { + throw new RuntimeException("Can't get form thesaurus", ex); + } + } + + protected void selectThesaurus(ThesaurusTreeHelper helper) { + desactiveListener(helper); + List<VradiTreeNode> nodes = rootHelper.getSelectedNodes(); + List<String> thesaurusIds = extractIds(nodes); + helper.tryToSelect(thesaurusIds); + activeListener(helper); + } + + protected List<String> extractIds(List<VradiTreeNode> nodes) { + List<String> ids = new ArrayList<String>(); + for (VradiTreeNode node : nodes) { + ids.add(node.getId()); + } + return ids; + } + + public void tryToSelect(Thesaurus thesaurus) { + if (thesaurus != null) { + rootHelper.tryToSelect(thesaurus); + } + } + + public void tryToUnSelect(Thesaurus thesaurus) { + if (thesaurus != null) { + rootHelper.tryToUnselect(thesaurus); + } + } + + protected class RootThesaurusListener implements TreeSelectionListener { + + @Override + public void valueChanged(TreeSelectionEvent e) { + if (!isRootListening) { + return; + } + TreePath[] paths = e.getPaths(); + + List<String> toAdd = new ArrayList<String>(); + List<String> toRemove = new ArrayList<String>(); + for (TreePath path : paths) { + VradiTreeNode node = (VradiTreeNode) path.getLastPathComponent(); + String id = node.getId(); + if (e.isAddedPath(path)) { + if (log.isDebugEnabled()) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + log.debug("[Root listener] try to add thesaurus : " + thesaurus.getName()); + } + toAdd.add(id); + } else { + if (log.isDebugEnabled()) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + log.debug("[Root listener] try to remove thesaurus : " + thesaurus.getName()); + } + toRemove.add(id); + } + } + + for (ThesaurusTreeHelper helper : helpers.keySet()) { + if (log.isDebugEnabled()) { + VradiTreeNode rootNode = helper.getRootNode(); + if (Thesaurus.class.equals(rootNode.getInternalClass())) { + Thesaurus rootThesaurus = ThesaurusDataHelper.restoreThesaurus(rootNode.getId()); + log.debug("[Root listener] Apply selection for helper with root " + rootThesaurus.getName()); + } + } + desactiveListener(helper); + helper.tryToSelect(toAdd); + helper.tryToUnselect(toRemove); + activeListener(helper); + } + + propositionListener.desactiveListener(); + propositionSelectionModel.tryToSelect(toAdd); + propositionSelectionModel.tryToUnSelect(toRemove); + propositionListener.activeListener(); + } + } + + protected class ThesaurusListener implements TreeSelectionListener, ListSelectionListener { + + protected List<Object> oldsPropositionsSelected; + + protected boolean isThesaurusListening = true; + + @Override + public void valueChanged(TreeSelectionEvent e) { + if (!isThesaurusListening) { + return; + } + TreePath[] paths = e.getPaths(); + + List<String> toAdd = new ArrayList<String>(); + List<String> toRemove = new ArrayList<String>(); + for (TreePath path : paths) { + VradiTreeNode node = (VradiTreeNode) path.getLastPathComponent(); + String id = node.getId(); + if (e.isAddedPath(path)) { + if (log.isDebugEnabled()) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + log.debug("[Listener] try to add thesaurus : " + thesaurus.getName()); + } + toAdd.add(id); + } else { + if (log.isDebugEnabled()) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + log.debug("[Listener] try to remove thesaurus : " + thesaurus.getName()); + } + toRemove.add(id); + } + } + rootHelper.tryToSelect(toAdd); + rootHelper.tryToUnselect(toRemove); + } + + @Override + public void valueChanged(ListSelectionEvent e) { + if (!isThesaurusListening) { + return; + } + + List<Object> newPropositionsSelected = Arrays.asList(propositionList.getSelectedValues()); + List<String> idsToAdd = new ArrayList<String>(); + List<String> idsToRemove = new ArrayList<String>(); + for (Object o : newPropositionsSelected) { + if (oldsPropositionsSelected == null || !oldsPropositionsSelected.contains(o)) { + Thesaurus proposition = (Thesaurus) o; + idsToAdd.add(proposition.getWikittyId()); + } + } + if (oldsPropositionsSelected != null) { + for (Object o : oldsPropositionsSelected) { + if (!newPropositionsSelected.contains(o)) { + Thesaurus proposition = (Thesaurus) o; + idsToRemove.add(proposition.getWikittyId()); + } + } + } + + rootHelper.tryToSelect(idsToAdd); + rootHelper.tryToUnselect(idsToRemove); + + // Cache + oldsPropositionsSelected = newPropositionsSelected; + } + + public void desactiveListener() { + isThesaurusListening = false; + } + + public void activeListener() { + isThesaurusListening = true; + } + } + + protected class PropositionSelectionModel extends DefaultListSelectionModel { + + protected void tryToSelect(List<String> thesaurusId) { + + List<Thesaurus> thesauruss = ThesaurusDataHelper.restoreThesaurus(thesaurusId); + tryToSelectObjects(thesauruss); + } + + protected void tryToSelectObjects(List<Thesaurus> thesauruses) { + + for (Thesaurus thesaurus : thesauruses) { + int toSelect = ((DefaultListModel) propositionList.getModel()).indexOf(thesaurus); + super.addSelectionInterval(toSelect, toSelect); + } + } + + protected void tryToUnSelect(List<String> thesaurusId) { + + List<Thesaurus> thesauruss = ThesaurusDataHelper.restoreThesaurus(thesaurusId); + for (Thesaurus thesaurus : thesauruss) { + int toSelect = ((DefaultListModel) propositionList.getModel()).indexOf(thesaurus); + super.removeSelectionInterval(toSelect, toSelect); + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusSelectionManager.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,504 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.helpers; + +import jaxx.runtime.swing.nav.tree.NavTreeHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.thesaurus.loadors.RootThesaurusNodeLoadors; +import org.chorem.vradi.ui.thesaurus.loadors.ThesaurusNodeLoadors; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.chorem.vradi.ui.tree.helpers.VradiTreeHelper; + +import javax.swing.tree.TreeModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * Navigation tree helpers. + * + * @author sletellier + * @see NavTreeHelper + */ +public class ThesaurusTreeHelper extends VradiTreeHelper<Thesaurus> { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusTreeHelper.class); + + protected RootThesaurus rootThesaurus; + + protected Thesaurus thesaurus; + + protected boolean listening = true; + + protected VradiEntitiesListener<RootThesaurus> thesaurusVradiEntitiesListener; + + /** + * Create helper with first nodes are the root thesaurus + * + * @param dataProvider data provider + */ + public ThesaurusTreeHelper(VradiDataProvider dataProvider) { + super(); + init(dataProvider); + } + + /** + * Create helper with root thesaurus for root node + * + * @param dataProvider data provider + * @param rootThesaurus root thesaurus for root node + */ + public ThesaurusTreeHelper(VradiDataProvider dataProvider, RootThesaurus rootThesaurus) { + super(); + this.rootThesaurus = rootThesaurus; + init(dataProvider); + } + + /** + * Create helper with thesaurus for root node + * + * @param dataProvider data provider + * @param thesaurus thesaurus for root node + */ + public ThesaurusTreeHelper(VradiDataProvider dataProvider, Thesaurus thesaurus) { + super(); + this.thesaurus = thesaurus; + init(dataProvider); + } + + protected void init(VradiDataProvider dataProvider) { + setDataProvider(dataProvider); + + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(Thesaurus.class, this); + thesaurusVradiEntitiesListener = new VradiEntitiesListener<RootThesaurus>() { + + @Override + public void entitiesAdded(Set<RootThesaurus> added) { + + if (rootThesaurus == null && thesaurus == null) { + + for (RootThesaurus rootThesaurus : added) { + + String wikittyId = rootThesaurus.getWikittyId(); + + // Find existing + VradiTreeNode existingNode = findRootThesaurusNode(wikittyId); + + // Modification case + if (existingNode != null) { + refresh(existingNode); + } else { + if (log.isDebugEnabled()) { + log.debug("Refresh root thesaurus : " + wikittyId); + } + + // Creation + VradiTreeNode newNode = getChildLoador(RootThesaurusNodeLoadors.class).createNode(wikittyId, getDataProvider()); + insertNode(getRootNode(), newNode); + } + } + + // If it's root concerned + } else if (rootThesaurus != null && added.contains(rootThesaurus)) { + refresh(getRootNode()); + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(RootThesaurus.class, thesaurusVradiEntitiesListener); + } + + public TreeModel createTreeModel() { + + VradiTreeNode root; + if (thesaurus != null) { + if (log.isDebugEnabled()) { + log.debug("[Root creation] thesaurus " + thesaurus.getName()); + } + + root = new VradiTreeNode( + Thesaurus.class, + thesaurus.getWikittyId(), + null, + getChildLoador(ThesaurusNodeLoadors.class) + ); + } else if (rootThesaurus != null) { + if (log.isDebugEnabled()) { + log.debug("[Root creation] root thesaurus " + rootThesaurus.getName()); + } + root = new VradiTreeNode( + RootThesaurus.class, + rootThesaurus.getWikittyId(), + null, + getChildLoador(ThesaurusNodeLoadors.class) + ); + } else { + if (log.isDebugEnabled()) { + log.debug("[Root creation] all root thesaurus"); + } + root = new VradiTreeNode( + String.class, + "Root node", + null, + getChildLoador(RootThesaurusNodeLoadors.class) + ); + } + + TreeModel model = createModel(root); + + // Populate childs nodes + root.populateChilds(getBridge(), getDataProvider()); + + registerLoadedIds(root); + + return model; + } + + /** + * Try to select thesaurus pass in param + * + * @param id of thesaurus to select + */ + public void tryToSelect(String id) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + tryToSelect(thesaurus); + } + + /** + * Try to select thesaurus pass in param + * + * @param thesaurus to select + */ + public void tryToSelect(Thesaurus thesaurus) { + // Skip if root + if (!thesaurus.getWikittyId().equals(getRootNode().getId())) { + + VradiTreeNode nodeFound = findThesaurusNode(thesaurus); + if (nodeFound != null) { + selectNode(nodeFound); + } + + } + } + + /** + * Try to select thesaurus ids pass in param + * + * @param thesaurusIds list of thesaurus ids to select + */ + public void tryToSelect(List<String> thesaurusIds) { + tryToSelect(ThesaurusDataHelper.restoreThesaurus(thesaurusIds)); + } + + /** + * Try to select thesaurus pass in param + * + * @param thesauruses list of thesaurus to select + */ + public void tryToSelect(Collection<Thesaurus> thesauruses) { + if (thesauruses == null) { + // Do nothing + return; + } + List<VradiTreeNode> nodes = new ArrayList<VradiTreeNode>(); + + // Find recursivly + for (Thesaurus thesaurus : thesauruses) { + + if (thesaurus != null) { + + String id = thesaurus.getWikittyId(); + + // Skip if root + if (!id.equals(getRootNode().getId())) { + + VradiTreeNode toSelect = findThesaurusNode(thesaurus); + + if (toSelect != null) { + nodes.add(toSelect); + } + } + } + } + + selectNodes(nodes); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param id of thesaurus to unselect + */ + public void tryToUnselect(String id) { + tryToUnselect(ThesaurusDataHelper.restoreThesaurus(id)); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param thesaurus to unselect + */ + public void tryToUnselect(Thesaurus thesaurus) { + tryToUnselect(thesaurus.getWikittyId()); + + // Find recursivly + VradiTreeNode nodeFound = findThesaurusNode(thesaurus); + if (nodeFound != null) { + unSelectNode(nodeFound); + } + } + + /** + * Try to unselect thesaurus ids pass in param + * + * @param thesaurusIds list of thesaurus ids to select + */ + public void tryToUnselect(List<String> thesaurusIds) { + tryToUnselect(ThesaurusDataHelper.restoreThesaurus(thesaurusIds)); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param thesauruses list of thesaurus to unselect + */ + public void tryToUnselect(Collection<Thesaurus> thesauruses) { + if (thesauruses == null) { + // Do nothing + return; + } + List<VradiTreeNode> nodes = new ArrayList<VradiTreeNode>(); + + // Find recursivly + for (Thesaurus thesaurus : thesauruses) { + + if (thesaurus != null) { + + String id = thesaurus.getWikittyId(); + + // Skip if root + if (!id.equals(getRootNode().getId())) { + + VradiTreeNode toSelect = findThesaurusNode(thesaurus); + + if (toSelect != null) { + nodes.add(toSelect); + } + } + } + } + + unSelectNodes(nodes); + } + + public VradiTreeNode findRootThesaurusNode(String rootThesaurusId) { + VradiTreeNode parentNode = getRootNode(); + return getChild(parentNode, rootThesaurusId); + } + + public VradiTreeNode findRootThesaurusNode(RootThesaurus rootThesaurus) { + return findRootThesaurusNode(rootThesaurus.getWikittyId()); + } + + protected VradiTreeNode findThesaurusNode(String thesaurusId) { + return findThesaurusNode(ThesaurusDataHelper.restoreThesaurus(thesaurusId)); + } + + protected VradiTreeNode findThesaurusNode(Thesaurus thesaurus) { + + VradiTreeNode parentNode = getRootNode(); + VradiTreeNode rootNode = getChild(parentNode, thesaurus.getRootThesaurus()); + + // If rootNode is rootThesaurus + if (rootNode != null) { + parentNode = rootNode; + } + + // To optimize thesaurus search + List<Thesaurus> parentList = getParentsPathThesaurus(thesaurus); + + // Find in depth for loading only necessary nodes + for (Thesaurus parent : parentList) { + VradiTreeNode nodeFound = getChild(parentNode, parent.getWikittyId()); + if (nodeFound != null) { + parentNode = nodeFound; + } + } + + // If not found + if (!parentNode.getId().equals(thesaurus.getWikittyId())) { + return null; + } + return parentNode; + } + + protected List<Thesaurus> getParentsPathThesaurus(Thesaurus thesaurus) { + + List<Thesaurus> parents = new ArrayList<Thesaurus>(); + if (!ThesaurusDataHelper.isFirstChild(thesaurus)) { + Thesaurus parent = ThesaurusDataHelper.restoreThesaurus(thesaurus.getParent()); + + if (parent != null) { + List<Thesaurus> thesauruses = getParentsPathThesaurus(parent); + parents.addAll(thesauruses); + } + } + parents.add(thesaurus); + + return parents; + } + + protected List<String> extractIds(List<Thesaurus> beans) { + List<String> ids = new ArrayList<String>(); + if (beans != null) { + for (Thesaurus bean : beans) { + if (bean != null) { + ids.add(bean.getWikittyId()); + } + } + } + return ids; + } + + public static RootThesaurus getRootThesaurus(VradiTreeNode node) { + if (!node.getInternalClass().equals(RootThesaurus.class)) { + return null; + } + return ThesaurusDataHelper.restoreRootThesaurus(node.getId()); + } + + public static Thesaurus getThesaurus(VradiTreeNode node) { + if (!node.getInternalClass().equals(Thesaurus.class)) { + return null; + } + return ThesaurusDataHelper.restoreThesaurus(node.getId()); + } + + @Override + public void createEntityNode(String wikittyId) { + } + + @Override + public void entitiesAdded(Set<Thesaurus> added) { + + for (Thesaurus thesaurusConcerned : added) { + + String wikittyId = thesaurusConcerned.getWikittyId(); + + // Search on parent to creation case + if (idsLoaded.contains(thesaurusConcerned.getParent())) { + + VradiTreeNode existingNode = findThesaurusNode(wikittyId); + + // cas modification + if (existingNode != null) { + + // Parent id + VradiTreeNode parent = existingNode.getParent(); + + // Move case + String newParentId = thesaurusConcerned.getParent(); + if (parent != null && !parent.getId().equals(newParentId)) { + + VradiTreeNode newParentNode = findThesaurusNode(newParentId); + + // Delete old + getBridge().removeNodeFromParent(existingNode); + + // Insert + // Verify that node is not already created + if (findThesaurusNode(wikittyId) == null) { + insertNode(newParentNode, existingNode); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("Modification case : " + thesaurusConcerned.getName()); + } + + // Modification case + refresh(existingNode); + } + } + + // Creation case + else { + + if (log.isDebugEnabled()) { + log.debug("Creation case : " + thesaurusConcerned.getName()); + } + + // Find parent node + VradiTreeNode parentNode = findThesaurusNode(thesaurusConcerned.getParent()); + + // Tri + VradiTreeNode newNode = getChildLoador(ThesaurusNodeLoadors.class).createNode(wikittyId, getDataProvider()); + // Verify that node is not already created + if (findThesaurusNode(wikittyId) == null) { + insertNode(parentNode, newNode); + } + } + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + + for (String wikittyId : removed) { + + // If wikitty id it's not loaded, the event dont concerne this tree + if (isLoadedId(wikittyId)) { + + VradiTreeNode node = findThesaurusNode(wikittyId); + + idsLoaded.remove(wikittyId); + if (node != null) { + + if (log.isDebugEnabled()) { + log.debug("Removing node " + wikittyId + " from parent"); + } + + VradiTreeNode parent = node.getParent(); + int index = parent.getIndex(node); + node.removeFromParent(); + getBridge().nodesWereRemoved(parent, new int[]{index}, new VradiTreeNode[]{node}); + } + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeTableHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeTableHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeTableHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,595 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.helpers; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.tree.NavTreeHelper; +import jaxx.runtime.swing.nav.treetable.NavTreeTableHelper; +import jaxx.runtime.swing.nav.treetable.NavTreeTableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.beans.QueryParameters; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.thesaurus.ThesaurusDataProvider; +import org.chorem.vradi.ui.thesaurus.loadors.RootThesaurusTreeTableNodeLoadors; +import org.chorem.vradi.ui.thesaurus.loadors.ThesaurusTreeTableNodeLoadors; +import org.chorem.vradi.ui.thesaurus.models.ThesaurusTreeTableModel; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; +import org.jdesktop.swingx.JXTreeTable; + +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeSelectionListener; +import javax.swing.event.TreeWillExpandListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.List; +import java.util.Set; + +/** + * Navigation tree helpers. + * + * @author sletellier + * @see NavTreeHelper + */ +public class ThesaurusTreeTableHelper extends NavTreeTableHelper<VradiTreeTableNode> implements VradiEntitiesListener<Thesaurus> { + + /** Logger */ + static private final Log log = LogFactory.getLog(ThesaurusTreeTableHelper.class); + + protected RootThesaurus rootThesaurus; + + protected List<String> idsLoaded = new ArrayList<String>(); + + protected VradiEntitiesListener<RootThesaurus> thesaurusVradiEntitiesListener; + + /** Create helper with first nodes are the root thesaurus */ + public ThesaurusTreeTableHelper() { + this(new ThesaurusDataProvider()); + } + + /** + * Create cartograpgy helper with first nodes are the root thesaurus + * + * @param queryParameters for cartography search + */ + public ThesaurusTreeTableHelper(QueryParameters queryParameters) { + super(); + init(new ThesaurusDataProvider(queryParameters)); + } + + /** + * Create helper with first nodes are the root thesaurus in parm (for move) + * + * @param rootThesaurus root thesaurus to display + */ + public ThesaurusTreeTableHelper(RootThesaurus rootThesaurus) { + this(new ThesaurusDataProvider()); + this.rootThesaurus = rootThesaurus; + } + + /** + * Create helper with first nodes are the root thesaurus + * + * @param dataProvider vradi data provider + */ + public ThesaurusTreeTableHelper(ThesaurusDataProvider dataProvider) { + super(); + init(dataProvider); + } + + protected void init(NavDataProvider dataProvider) { + setDataProvider(dataProvider); + + // register each tree on wikitty service + VradiContext.get().getVradiNotifier().addVradiListener(Thesaurus.class, this); + thesaurusVradiEntitiesListener = new VradiEntitiesListener<RootThesaurus>() { + + @Override + public void entitiesAdded(Set<RootThesaurus> added) { + + for (RootThesaurus rootThesaurus : added) { + String wikittyId = rootThesaurus.getWikittyId(); + + // Find existing + VradiTreeTableNode existingNode = findRootThesaurusNode(wikittyId); + + // Modification case + if (existingNode != null) { + refresh(existingNode); + } else { + if (log.isDebugEnabled()) { + log.debug("Refresh root thesaurus : " + wikittyId); + } + + // Creation + VradiTreeTableNode newNode = getChildLoador(RootThesaurusTreeTableNodeLoadors.class).createNode(wikittyId, getDataProvider()); + insertNode(getRootNode(), newNode); + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + } + }; + VradiContext.get().getVradiNotifier().addVradiListener(RootThesaurus.class, thesaurusVradiEntitiesListener); + } + + @Override + public void setUI(JXTreeTable tree, + boolean addExpandTreeListener, + boolean addOneClickSelectionListener, + TreeSelectionListener listener, + TreeWillExpandListener willExpandListener) { + super.setUI(tree, + addExpandTreeListener, + addOneClickSelectionListener, + listener, + willExpandListener); + + tree.addTreeExpansionListener(new TreeExpansionListener() { + @Override + public void treeExpanded(TreeExpansionEvent event) { + VradiTreeTableNode node = (VradiTreeTableNode) event.getPath().getLastPathComponent(); + registerLoadedIds(node); + } + + @Override + public void treeCollapsed(TreeExpansionEvent event) { + VradiTreeTableNode node = (VradiTreeTableNode) event.getPath().getLastPathComponent(); + Enumeration<VradiTreeTableNode> enumeration = node.children(); + while (enumeration.hasMoreElements()) { + VradiTreeTableNode child = enumeration.nextElement(); + idsLoaded.remove(child.getId()); + } + } + }); + } + + public void registerLoadedIds(VradiTreeTableNode node) { + idsLoaded.add(node.getId()); + Enumeration<VradiTreeTableNode> enumeration = node.children(); + while (enumeration.hasMoreElements()) { + VradiTreeTableNode child = enumeration.nextElement(); + idsLoaded.add(child.getId()); + } + } + + /** + * Try to select thesaurus pass in param + * + * @param id of thesaurus to select + */ + public void tryToSelect(String id) { + Thesaurus thesaurus = ThesaurusDataHelper.restoreThesaurus(id); + tryToSelect(thesaurus); + } + + /** + * Try to select thesaurus pass in param + * + * @param thesaurus to select + */ + public void tryToSelect(Thesaurus thesaurus) { + // Skip if root + if (!thesaurus.getWikittyId().equals(getRootNode().getId())) { + + VradiTreeTableNode nodeFound = findThesaurusNode(thesaurus); + if (nodeFound != null) { + selectNode(nodeFound); + } + + } + } + + /** + * Try to select thesaurus ids pass in param + * + * @param thesaurusIds list of thesaurus ids to select + */ + public void tryToSelect(List<String> thesaurusIds) { + tryToSelect(ThesaurusDataHelper.restoreThesaurus(thesaurusIds)); + } + + /** + * Try to select thesaurus pass in param + * + * @param thesauruses list of thesaurus to select + */ + public void tryToSelect(Collection<Thesaurus> thesauruses) { + if (thesauruses == null) { + // Do nothing + return; + } + List<VradiTreeTableNode> nodes = new ArrayList<VradiTreeTableNode>(); + + // Find recursivly + for (Thesaurus thesaurus : thesauruses) { + + if (thesaurus != null) { + + String id = thesaurus.getWikittyId(); + + // Skip if root + if (!id.equals(getRootNode().getId())) { + + VradiTreeTableNode toSelect = findThesaurusNode(thesaurus); + + if (toSelect != null) { + nodes.add(toSelect); + } + } + } + } + + selectNodes(nodes); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param id of thesaurus to unselect + */ + public void tryToUnselect(String id) { + tryToUnselect(ThesaurusDataHelper.restoreThesaurus(id)); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param thesaurus to unselect + */ + public void tryToUnselect(Thesaurus thesaurus) { + tryToUnselect(thesaurus.getWikittyId()); + + // Find recursivly + VradiTreeTableNode nodeFound = findThesaurusNode(thesaurus); + if (nodeFound != null) { + unSelectNode(nodeFound); + } + } + + /** + * Try to unselect thesaurus ids pass in param + * + * @param thesaurusIds list of thesaurus ids to select + */ + public void tryToUnselect(List<String> thesaurusIds) { + tryToUnselect(ThesaurusDataHelper.restoreThesaurus(thesaurusIds)); + } + + /** + * Try to unselect thesaurus pass in param + * + * @param thesauruses list of thesaurus to unselect + */ + public void tryToUnselect(Collection<Thesaurus> thesauruses) { + if (thesauruses == null) { + // Do nothing + return; + } + List<VradiTreeTableNode> nodes = new ArrayList<VradiTreeTableNode>(); + + // Find recursivly + for (Thesaurus thesaurus : thesauruses) { + + if (thesaurus != null) { + + String id = thesaurus.getWikittyId(); + + // Skip if root + if (!id.equals(getRootNode().getId())) { + + VradiTreeTableNode toSelect = findThesaurusNode(thesaurus); + + if (toSelect != null) { + nodes.add(toSelect); + } + } + } + } + + unSelectNodes(nodes); + } + + public VradiTreeTableNode findRootThesaurusNode(String rootThesaurusId) { + VradiTreeTableNode parentNode = getRootNode(); + return getChild(parentNode, rootThesaurusId); + } + + public VradiTreeTableNode findRootThesaurusNode(RootThesaurus rootThesaurus) { + return findRootThesaurusNode(rootThesaurus.getWikittyId()); + } + + public VradiTreeTableNode findThesaurusNode(String thesaurusId) { + Thesaurus thesaurusToFind = ThesaurusDataHelper.restoreThesaurus(thesaurusId); + if (thesaurusToFind == null) { + return null; + } + return findThesaurusNode(thesaurusToFind); + } + + public VradiTreeTableNode findThesaurusNode(Thesaurus thesaurus) { + + VradiTreeTableNode parentNode = getRootNode(); + VradiTreeTableNode rootNode = getChild(parentNode, thesaurus.getRootThesaurus()); + + // If rootNode is rootThesaurus + if (rootNode != null) { + parentNode = rootNode; + } + + // To optimize thesaurus search + List<Thesaurus> parentList = getParentsPathThesaurus(thesaurus); + + // Find in depth for loading only necessary nodes + for (Thesaurus parent : parentList) { + VradiTreeTableNode nodeFound = getChild(parentNode, parent.getWikittyId()); + if (nodeFound != null) { + parentNode = nodeFound; + } + } + + // If not found + if (!parentNode.getId().equals(thesaurus.getWikittyId())) { + return null; + } + return parentNode; + } + + protected List<Thesaurus> getParentsPathThesaurus(Thesaurus thesaurus) { + + List<Thesaurus> parents = new ArrayList<Thesaurus>(); + if (!ThesaurusDataHelper.isFirstChild(thesaurus)) { + Thesaurus parent = ThesaurusDataHelper.restoreThesaurus(thesaurus.getParent()); + + if (parent != null) { + List<Thesaurus> thesauruses = getParentsPathThesaurus(parent); + parents.addAll(thesauruses); + } + } + parents.add(thesaurus); + + return parents; + } + + protected List<String> extractIds(List<Thesaurus> beans) { + List<String> ids = new ArrayList<String>(); + if (beans != null) { + for (Thesaurus bean : beans) { + ids.add(bean.getWikittyId()); + } + } + return ids; + } + + @Override + public ThesaurusDataProvider getDataProvider() { + return (ThesaurusDataProvider) dataProvider; + } + + public NavTreeTableModel createTreeModel() { + + NavTreeTableModel model; + if (rootThesaurus != null) { + VradiTreeTableNode root = new VradiTreeTableNode( + String.class, + "Root node", + null, + null + ); + VradiTreeTableNode rootThesaurusNode = new VradiTreeTableNode( + RootThesaurus.class, + rootThesaurus.getWikittyId(), + null, + new ThesaurusTreeTableNodeLoadors() + ); + + root.add(rootThesaurusNode); + + model = createModel(root, new ThesaurusTreeTableModel(getDataProvider())); + + // Populate childs nodes + rootThesaurusNode.populateChilds(getBridge(), getDataProvider()); + + registerLoadedIds(root); + } else { + + VradiTreeTableNode root = new VradiTreeTableNode( + String.class, + "Root node", + null, + new RootThesaurusTreeTableNodeLoadors() + ); + + model = createModel(root, new ThesaurusTreeTableModel(getDataProvider())); + + // Populate childs nodes + root.populateChilds(getBridge(), getDataProvider()); + + registerLoadedIds(root); + } + + return model; + } + + public static RootThesaurus getRootThesaurus(VradiTreeTableNode node) { + if (!node.getInternalClass().equals(RootThesaurus.class)) { + return null; + } + return ThesaurusDataHelper.restoreRootThesaurus(node.getId()); + } + + public static Thesaurus getThesaurus(VradiTreeTableNode node) { + if (!node.getInternalClass().equals(Thesaurus.class)) { + return null; + } + return ThesaurusDataHelper.restoreThesaurus(node.getId()); + } + + protected void refresh(VradiTreeTableNode node) { + if (node == null) { + return; + } + getBridge().nodeChanged(node); + } + + public VradiTreeTableNode createRootThesaurusAndSelect(String rootThesaurusIdToAdd) { + VradiTreeTableNode newNode = createRootThesaurus(rootThesaurusIdToAdd); + selectNode(newNode); + + return newNode; + } + + public VradiTreeTableNode createRootThesaurus(String rootThesaurusIdToAdd) { + VradiTreeTableNode newNode = getChildLoador(RootThesaurusTreeTableNodeLoadors.class).createNode(rootThesaurusIdToAdd, getDataProvider()); + insertNode(getRootNode(), newNode); + + return newNode; + } + + public VradiTreeTableNode createThesaurusAndSelect(String parentId, String thesaurusIdToAdd) { + VradiTreeTableNode newNode = createThesaurus(parentId, thesaurusIdToAdd); + selectNode(newNode); + + return newNode; + } + + public VradiTreeTableNode createThesaurus(String parentId, String thesaurusIdToAdd) { + VradiTreeTableNode parentNode = findThesaurusNode(parentId); + VradiTreeTableNode newNode = getChildLoador(ThesaurusTreeTableNodeLoadors.class).createNode(thesaurusIdToAdd, getDataProvider()); + insertNode(parentNode, newNode); + + return newNode; + } + + public VradiTreeTableNode createThesaurusChildOfRootAndSelect(String rootThesaurusId, String thesaurusIdToAdd) { + VradiTreeTableNode newNode = createThesaurusChildOfRoot(rootThesaurusId, thesaurusIdToAdd); + selectNode(newNode); + + return newNode; + } + + public VradiTreeTableNode createThesaurusChildOfRoot(String rootThesaurusId, String thesaurusIdToAdd) { + VradiTreeTableNode rootNode = getChild(getRootNode(), rootThesaurusId); + VradiTreeTableNode newNode = getChildLoador(ThesaurusTreeTableNodeLoadors.class).createNode(thesaurusIdToAdd, getDataProvider()); + insertNode(rootNode, newNode); + + return newNode; + } + + @Override + public void entitiesAdded(Set<Thesaurus> added) { + for (Thesaurus thesaurusConcerned : added) { + + String wikittyId = thesaurusConcerned.getWikittyId(); + + // Search on parent to creation case + if (idsLoaded.contains(thesaurusConcerned.getParent()) || idsLoaded.contains(wikittyId)) { + + // Find existing + VradiTreeTableNode existingNode = findThesaurusNode(wikittyId); + + // cas modification + if (existingNode != null) { + + // Parent id + VradiTreeTableNode parent = existingNode.getParent(); + + // Move case + String newParentId = thesaurusConcerned.getParent(); + if (parent != null && !parent.getId().equals(newParentId)) { + + if (log.isDebugEnabled()) { + log.debug("Move case : " + thesaurusConcerned.getName()); + } + + VradiTreeTableNode newParentNode = findThesaurusNode(newParentId); + + // Delete old + removeNode(existingNode); + + // Verify that node is not already created + if (getChild(newParentNode, wikittyId) == null) { + + createThesaurus(newParentNode.getId(), wikittyId); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("Modification case : " + thesaurusConcerned.getName()); + } + + // Modification case + refresh(existingNode); + } + } + + // Creation case + else { + + if (log.isDebugEnabled()) { + log.debug("Creation case : " + thesaurusConcerned.getName()); + } + + // Verify that node is not already created + if (findThesaurusNode(wikittyId) == null) { + + createThesaurus(thesaurusConcerned.getParent(), wikittyId); + } + } + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + for (String wikittyId : removed) { + + // if null : not in tree + if (idsLoaded.contains(wikittyId)) { + + if (log.isDebugEnabled()) { + log.debug("Removing node " + wikittyId + " from parent"); + } + VradiTreeTableNode node = findThesaurusNode(wikittyId); + + // Remove from cache + idsLoaded.remove(wikittyId); + + // If is already deleted + if (node != null) { + + removeNode(node); + } + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/helpers/ThesaurusTreeTableHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,91 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.loadors; + +import com.sun.star.uno.RuntimeException; +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.ArrayList; +import java.util.List; + +/** @author letellier */ +public class RootThesaurusNodeLoadors extends NavTreeNodeChildLoador<String, RootThesaurus, VradiTreeNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = + LogFactory.getLog(RootThesaurusNodeLoadors.class); + + public RootThesaurusNodeLoadors() { + super(RootThesaurus.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) { + + // ne recupere pas seulement les id pour les mettre en cache + List<RootThesaurus> rootThesaurusList; + try { + rootThesaurusList = VradiService.getVradiDataService().getRootThesaurus(); + } catch (VradiException ex) { + throw new RuntimeException("Can't get root thesaurus list", ex); + } + + // Return children + return extractIds(rootThesaurusList); + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + + if (log.isDebugEnabled()) { + log.debug("[Root loador] creating thesaurus " + id); + } + + return new VradiTreeNode( + getBeanType(), + id, + null, + NavHelper.getChildLoador(ThesaurusNodeLoadors.class)); + } + + protected List<String> extractIds(List<RootThesaurus> entities) { + List<String> ids = new ArrayList<String>(); + for (RootThesaurus e : entities) { + ids.add(e.getWikittyId()); + } + return ids; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusTreeTableNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusTreeTableNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusTreeTableNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,96 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.loadors; + +import com.sun.star.uno.RuntimeException; +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import jaxx.runtime.swing.nav.treetable.NavTreeTableNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; + +import java.util.ArrayList; +import java.util.List; + +/** @author letellier */ +public class RootThesaurusTreeTableNodeLoadors extends NavTreeTableNodeChildLoador<String, RootThesaurus, VradiTreeTableNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = + LogFactory.getLog(RootThesaurusTreeTableNodeLoadors.class); + + public RootThesaurusTreeTableNodeLoadors() { + super(RootThesaurus.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) { + + List<RootThesaurus> rootThesaurusList; + + try { + // ne recupere pas seulement les id pour les mettre en cache + rootThesaurusList = VradiService.getVradiDataService().getRootThesaurus(); + + if (log.isDebugEnabled()) { + for (RootThesaurus root : rootThesaurusList) { + log.debug("Root thesaurus find : " + root.getName()); + } + } + + } catch (VradiException ex) { + throw new RuntimeException("Can't get root thesaurus list", ex); + } + + // Return children + return extractIds(rootThesaurusList); + } + + @Override + public VradiTreeTableNode createNode(String id, NavDataProvider dataProvider) { + + return new VradiTreeTableNode( + getBeanType(), + id, + null, + NavHelper.getChildLoador(ThesaurusTreeTableNodeLoadors.class) + ); + } + + protected List<String> extractIds(List<RootThesaurus> entities) { + List<String> ids = new ArrayList<String>(); + for (RootThesaurus e : entities) { + ids.add(e.getWikittyId()); + } + return ids; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/RootThesaurusTreeTableNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.services.VradiService; +import org.chorem.vradi.ui.tree.VradiTreeNode; + +import java.util.ArrayList; +import java.util.List; + +/** @author letellier */ +public class ThesaurusNodeLoadors extends NavTreeNodeChildLoador<String, Thesaurus, VradiTreeNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = + LogFactory.getLog(ThesaurusNodeLoadors.class); + + public ThesaurusNodeLoadors() { + super(Thesaurus.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + List<Thesaurus> thesauruses = VradiService.getVradiDataService().getChildrenThesaurus(parentId); + return extractIds(thesauruses); + + } + + @Override + public VradiTreeNode createNode(String id, NavDataProvider dataProvider) { + + if (log.isDebugEnabled()) { + log.debug("[Thesaurus loador] creating thesaurus " + id); + } + + return new VradiTreeNode( + getBeanType(), + id, + null, + NavHelper.getChildLoador(ThesaurusNodeLoadors.class) + ); + } + + protected List<String> extractIds(List<Thesaurus> entities) { + List<String> ids = new ArrayList<String>(); + for (Thesaurus e : entities) { + ids.add(e.getWikittyId()); + } + return ids; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusTreeTableNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusTreeTableNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusTreeTableNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,98 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.NavHelper; +import jaxx.runtime.swing.nav.treetable.NavTreeTableNodeChildLoador; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.thesaurus.ThesaurusDataProvider; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** @author letellier */ +public class ThesaurusTreeTableNodeLoadors extends NavTreeTableNodeChildLoador<String, Thesaurus, VradiTreeTableNode> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** Logger */ + static private final Log log = + LogFactory.getLog(ThesaurusTreeTableNodeLoadors.class); + + public ThesaurusTreeTableNodeLoadors() { + super(Thesaurus.class); + } + + @Override + public List<String> getData(Class<?> parentClass, String parentId, NavDataProvider dataProvider) throws Exception { + + // ne recupere pas seulement les id pour les mettre en cache + Collection<Thesaurus> thesauruses = ((ThesaurusDataProvider) dataProvider).getChildrenThesaurus(parentId); + + if (log.isDebugEnabled()) { + if (RootThesaurus.class.equals(parentClass)) { + RootThesaurus root = ThesaurusDataHelper.restoreRootThesaurus(parentId); + for (Thesaurus thesaurus : thesauruses) { + log.debug("Children of root thesaurus " + root.getName() + " find : " + thesaurus.getName()); + } + } else { + Thesaurus root = ThesaurusDataHelper.restoreThesaurus(parentId); + for (Thesaurus thesaurus : thesauruses) { + log.debug("Children of root thesaurus " + root.getName() + " find : " + thesaurus.getName()); + } + } + } + + return extractIds(thesauruses); + } + + @Override + public VradiTreeTableNode createNode(String id, NavDataProvider dataProvider) { + + return new VradiTreeTableNode( + getBeanType(), + id, + null, + NavHelper.getChildLoador(ThesaurusTreeTableNodeLoadors.class) + ); + } + + protected List<String> extractIds(Collection<? extends BusinessEntity> entities) { + List<String> ids = new ArrayList<String>(); + for (BusinessEntity e : entities) { + ids.add(e.getWikittyId()); + } + return ids; + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/loadors/ThesaurusTreeTableNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ThesaurusTreeTableModel.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ThesaurusTreeTableModel.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ThesaurusTreeTableModel.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,109 @@ +/* + * #%L + * Vradi :: Swing + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.thesaurus.models; + +import jaxx.runtime.swing.nav.treetable.NavTreeTableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.entities.RootThesaurus; +import org.chorem.vradi.entities.Thesaurus; +import org.chorem.vradi.ui.thesaurus.ThesaurusDataProvider; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusDataHelper; +import org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper; +import org.chorem.vradi.ui.tree.VradiTreeTableNode; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier */ +public class ThesaurusTreeTableModel extends NavTreeTableModel.MyDefaultTreeTableModel { + + private static final Log log = LogFactory.getLog(ThesaurusTreeTableModel.class); + + protected ThesaurusDataProvider dataProvider; + + public ThesaurusTreeTableModel(ThesaurusDataProvider dataProvider) { + this.dataProvider = dataProvider; + } + + @Override + public Object getValueAt(Object value, int column) { + Object result; + VradiTreeTableNode node = (VradiTreeTableNode) value; + + RootThesaurus rootThesaurus = ThesaurusTreeTableHelper.getRootThesaurus(node); + if (rootThesaurus != null) { + result = getValueForRootThesaurus(rootThesaurus, column); + } else { + Thesaurus thesaurus = ThesaurusTreeTableHelper.getThesaurus(node); + result = getValueForThesaurus(thesaurus, column); + } + + return result; + } + + + @Override + public String[] getColumnsNames() { + return new String[]{_("vradi.thesaurus.colomns.name"), + _("vradi.thesaurus.colomns.nbForm"), + _("vradi.thesaurus.colomns.tags")}; + } + + @Override + public boolean isCellEditable(Object node, int column) { + return false; + } + + protected Object getValueForRootThesaurus(RootThesaurus rootThesaurus, int column) { + if (rootThesaurus == null) { + return "not found"; + } + + if (column == 0) { + return rootThesaurus; + } + return ""; + } + + protected Object getValueForThesaurus(Thesaurus thesaurus, int column) { + if (thesaurus == null) { + return "not found"; + } + + Object result = null; + switch (column) { + case 0: + result = thesaurus; + break; + case 1: + result = String.valueOf(dataProvider.getNbFormsForThesaurus(thesaurus)); + break; + case 2: + result = ThesaurusDataHelper.getTagsAsString(thesaurus); + break; + } + return result; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/thesaurus/models/ThesaurusTreeTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiDataProvider.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiDataProvider.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiDataProvider.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,78 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.tree; + +import jaxx.runtime.swing.nav.NavDataProvider; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.services.VradiService; +import org.nuiton.wikitty.WikittyProxy; + +/** + * Provider de données pour les noeuds des arbres. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class VradiDataProvider implements NavDataProvider { + + /** Logger */ + static private final Log log = LogFactory.getLog(VradiDataProvider.class); + + /** Wikitty proxy. */ + protected WikittyProxy proxy; + + /** Vradi data service. */ + protected VradiDataService dataService; + + public VradiDataProvider() { + proxy = VradiService.getWikittyProxy(); + dataService = VradiService.getVradiDataService(); + } + + /** + * Get wikitty proxy. + * + * @return + */ + public WikittyProxy getWikittyProxy() { + return proxy; + } + + /** + * Get vradi data service. + * + * @return + */ + public VradiDataService getVradiDataService() { + return dataService; + } + + @Override + public boolean isEnabled() { + return true; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiDataProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeNode.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeNode.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeNode.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,62 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.tree; + +import jaxx.runtime.swing.nav.tree.NavTreeNode; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; + +/** + * Vradi node use to fill vradi tree. + * <p/> + * User: sletellier + */ +public class VradiTreeNode extends NavTreeNode<VradiTreeNode> { + + private static final long serialVersionUID = 1L; + + public VradiTreeNode(String id) { + super(id); + } + + public VradiTreeNode(Class<?> internalClass, + String id, + String context, + NavTreeNodeChildLoador<?, ?, VradiTreeNode> loador) { + super(internalClass, id, context, loador); + } + + @Override + @SuppressWarnings({"unchecked"}) + public VradiTreeNode getContainerNode() { + if (isRoot()) { + // si on arrive sur le root, quelque chose ne va pas, + // on bloque par null, a defaut de declancher une exception + return this; + } + + // cas final : sur un noeud de donnee + classe interne de donnee + return super.getContainerNode(); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeNode.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeTableNode.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeTableNode.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeTableNode.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,61 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.tree; + +import jaxx.runtime.swing.nav.treetable.NavTreeTableNode; +import jaxx.runtime.swing.nav.treetable.NavTreeTableNodeChildLoador; + +/** + * Vradi node use to fill vradi tree table. + * <p/> + * User: sletellier + */ +public class VradiTreeTableNode extends NavTreeTableNode<VradiTreeTableNode> { + + private static final long serialVersionUID = 1L; + + public VradiTreeTableNode(String id) { + super(id); + } + + public VradiTreeTableNode(Class<?> internalClass, + String id, + String context, + NavTreeTableNodeChildLoador<?, ?, VradiTreeTableNode> loador) { + super(internalClass, id, context, loador); + } + + @Override + public VradiTreeTableNode getContainerNode() { + if (isRoot()) { + // si on arrive sur le root, quelque chose ne va pas, + // on bloque par null, a defaut de declancher une exception + return this; + } + + // cas final : sur un noeud de donnee + classe interne de donnee + return super.getContainerNode(); + } +} \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/VradiTreeTableNode.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/VradiTreeHelper.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/VradiTreeHelper.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/VradiTreeHelper.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,208 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.tree.helpers; + +import jaxx.runtime.swing.nav.tree.NavTreeHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiEntitiesListener; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.JTree; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeSelectionListener; +import javax.swing.event.TreeWillExpandListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.List; +import java.util.Set; + +/** + * Navigation tree helpers. + * + * @author sletellier + * @see NavTreeHelper + */ +public abstract class VradiTreeHelper<C extends BusinessEntity> extends NavTreeHelper<VradiTreeNode> implements VradiEntitiesListener<C> { + + /** Logger */ + static private final Log log = LogFactory.getLog(VradiTreeHelper.class); + + protected List<String> idsLoaded = new ArrayList<String>(); + + @Override + public void setUI(JTree tree, + boolean addExpandTreeListener, + boolean addOneClickSelectionListener, + TreeSelectionListener listener, + TreeWillExpandListener willExpandListener) { + + super.setUI(tree, + addExpandTreeListener, + addOneClickSelectionListener, + listener, + willExpandListener); + + // Add tree expend listener to keep loaded nodes ids + tree.addTreeExpansionListener(new TreeExpansionListener() { + @Override + public void treeExpanded(TreeExpansionEvent event) { + VradiTreeNode node = (VradiTreeNode) event.getPath().getLastPathComponent(); + registerLoadedIds(node); + } + + @Override + public void treeCollapsed(TreeExpansionEvent event) { + VradiTreeNode node = (VradiTreeNode) event.getPath().getLastPathComponent(); + Enumeration<VradiTreeNode> enumeration = node.children(); + while (enumeration.hasMoreElements()) { + VradiTreeNode child = enumeration.nextElement(); + idsLoaded.remove(child.getId()); + } + } + }); + } + + @Override + public void selectNode(VradiTreeNode node) { + super.selectNode(node); + registerLoadedIds(node); + } + + @Override + public VradiDataProvider getDataProvider() { + return (VradiDataProvider) dataProvider; + } + + /* + * Hack for use generic + */ + @Override + public VradiTreeNode getSelectedNode() { + return super.getSelectedNode(); + } + + @Override + public VradiTreeNode findNode(VradiTreeNode node, String... ids) { + return super.findNode(node, ids); + } + + @Override + public VradiTreeNode getRootNode() { + return super.getRootNode(); + } + + public List<String> getLoadedIds() { + return idsLoaded; + } + + public boolean isLoadedId(String id) { + return idsLoaded.contains(id); + } + + public void registerLoadedIds(VradiTreeNode node) { + idsLoaded.add(node.getId()); + Enumeration<VradiTreeNode> enumeration = node.children(); + while (enumeration.hasMoreElements()) { + VradiTreeNode child = enumeration.nextElement(); + idsLoaded.add(child.getId()); + } + } + + public void refresh(VradiTreeNode node) { + if (node == null) { + return; + } + getBridge().nodeChanged(node); + } + + public abstract void createEntityNode(String wikittyId); + + @Override + public void entitiesAdded(Set<C> added) { + + log.info("entityAdded : " + added.size()); + + for (C entity : added) { + + String wikittyId = entity.getWikittyId(); + + // Refresh + VradiTreeNode existingNode = findNode(getRootNode(), wikittyId); + // cas modification + if (existingNode != null) { + if (log.isDebugEnabled()) { + log.debug("Client modification occured"); + } + // Reconstruction des fils + refresh(existingNode); + } + + // cas creation + else { + if (log.isDebugEnabled()) { + log.debug("Client creation occured"); + } + createEntityNode(wikittyId); + } + } + } + + @Override + public void entitiesRemoved(Set<String> removed) { + + log.info("entityRemoved : " + removed.size()); + removeEntities(removed); + } + + public void removeEntities(Collection<String> entities) { + + for (String wikittyId : entities) { + + // If wikitty id it's not loaded, the event dont concerne this tree + if (isLoadedId(wikittyId)) { + + VradiTreeNode node = findNode(getRootNode(), wikittyId); + + idsLoaded.remove(wikittyId); + if (node != null) { + + if (log.isDebugEnabled()) { + log.debug("Removing node " + wikittyId + " from parent"); + } + + VradiTreeNode parent = node.getParent(); + int index = parent.getIndex(node); + node.removeFromParent(); + getBridge().nodesWereRemoved(parent, new int[]{index}, new VradiTreeNode[]{node}); + } + } + } + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/helpers/VradiTreeHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/AbstractVradiNodeLoadors.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/AbstractVradiNodeLoadors.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/AbstractVradiNodeLoadors.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,84 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.tree.loadors; + +import jaxx.runtime.swing.nav.NavDataProvider; +import jaxx.runtime.swing.nav.tree.NavTreeNodeChildLoador; +import org.chorem.vradi.services.VradiDataService; +import org.chorem.vradi.ui.tree.VradiDataProvider; +import org.chorem.vradi.ui.tree.VradiTreeNode; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.entities.BusinessEntity; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** @author sletellier <letellier@codelutin.com> */ +public abstract class AbstractVradiNodeLoadors<B extends BusinessEntity> extends NavTreeNodeChildLoador<String, B, VradiTreeNode> { + + protected AbstractVradiNodeLoadors(Class<B> beanType) { + super(beanType); + } + + public WikittyProxy getProxy(NavDataProvider dataProvider) { + return ((VradiDataProvider) dataProvider).getWikittyProxy(); + } + + public VradiDataService getDataService(NavDataProvider dataProvider) { + return ((VradiDataProvider) dataProvider).getVradiDataService(); + } + + public VradiTreeNode createVradiNode(String id) { + + return new VradiTreeNode( + getBeanType(), + id, + null, + null); + } + + public VradiTreeNode createVradiNode(String id, NavTreeNodeChildLoador<?, ?, VradiTreeNode> childLoador) { + + return new VradiTreeNode( + getBeanType(), + id, + null, + childLoador); + } + + protected List<String> extractIds(Collection<B> entities) { + List<String> ids = new ArrayList<String>(); + if (entities == null) { + return ids; + } + for (BusinessEntity e : entities) { + if (e != null) { + ids.add(e.getWikittyId()); + } + } + return ids; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/tree/loadors/AbstractVradiNodeLoadors.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionFileHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionFileHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionFileHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,98 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.widgets; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiContext; +import org.chorem.vradi.services.VradiException; +import org.chorem.vradi.ui.VradiMainUI; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.JOptionPane; +import java.awt.Desktop; +import java.io.File; +import java.util.List; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** @author sletellier */ +public abstract class MultipleSelectionFileHandler<B extends BusinessEntity, H> extends MultipleSelectionHandler<File, B, H> { + + + /** log. */ + private static final Log log = LogFactory.getLog(MultipleSelectionFileHandler.class); + + public MultipleSelectionFileHandler(MultipleSelectionPane ui, Class<H> handler, String lblKey) { + super(ui, handler); + ui.setLbl(_(lblKey)); + } + + @Override + public void init() { + Set<String> files = getFiles(); + fillList(files); + } + + @Override + public void add() { + File file = addFiles(ui, getBean()); + if (file != null) { + addToList(file, file.getName()); + } + } + + @Override + public void remove() { + List<String> filesNames = removeFiles(getBean(), getSelectedInList()); + removeFromList(filesNames); + } + + @Override + public void openSelected(String selected) { + try { + File file = downloadFile(selected, getBean().getWikittyId()); + Desktop.getDesktop().open(file); + } catch (Exception eee) { + log.error("Error on download file : " + selected, eee); + fileNotFound(selected); + } + } + + public void fileNotFound(String selected) { + VradiMainUI ui = VradiContext.MAIN_UI_ENTRY_DEF.getContextValue(VradiContext.get()); + JOptionPane.showConfirmDialog(ui, _("vradi.error.fileNotFound", selected), + _("vradi.error.fileNotFound.title"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); + } + + public abstract File downloadFile(String selected, String wikittyId) throws VradiException; + + public abstract List<String> removeFiles(B bean, List<String> selectedInList); + + public abstract Set<String> getFiles(); + + public abstract File addFiles(MultipleSelectionPane ui, B bean); +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionFileHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionHandler.java =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionHandler.java (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionHandler.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,125 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.widgets; + +import jaxx.runtime.SwingUtil; +import org.chorem.vradi.ui.helpers.UIHelper; +import org.nuiton.wikitty.entities.BusinessEntity; + +import javax.swing.DefaultListModel; +import javax.swing.JList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** @author sletellier */ +public abstract class MultipleSelectionHandler<D, B extends BusinessEntity, H> { + + protected MultipleSelectionPane<D, B> ui; + + protected Map<String, D> addedDatas; + + protected Class<H> handlerClass; + + public MultipleSelectionHandler(MultipleSelectionPane<D, B> ui, Class<H> handlerClass) { + this.ui = ui; + this.handlerClass = handlerClass; + addedDatas = new HashMap<String, D>(); + } + + public H getHandler() { + return UIHelper.getHandler(ui, handlerClass); + } + + protected JList getList() { + return ui.getList(); + } + + protected DefaultListModel getListModel() { + return ui.getListModel(); + } + + protected B getBean() { + return ui.getBean(); + } + + protected void setBean(B bean) { + ui.setBean(bean); + } + + public Collection<D> getAddedDatas() { + return addedDatas.values(); + } + + public D getAddedData(String id) { + return addedDatas.get(id); + } + + public abstract void init(); + + public abstract void add(); + + public abstract void remove(); + + public abstract void openSelected(String selected); + + protected void addToList(D addedData, String data) { + if (data != null) { + getListModel().addElement(data); + } + if (addedData != null) { + addedDatas.put(data, addedData); + } + } + + protected void removeFromList(List<String> datas) { + for (String data : datas) { + getListModel().removeElement(data); + } + } + + protected void removeFromList(String data) { + getListModel().removeElement(data); + } + + protected void fillList(Collection<String> datas) { + getList().removeAll(); + SwingUtil.fillList(getList(), datas, null); + } + + protected List<String> getSelectedInList() { + Object[] objects = getList().getSelectedValues(); + String[] selected = new String[objects.length]; + int cnt = 0; + for (Object o : objects) { + selected[cnt] = (String) o; + cnt++; + } + List<String> selectedList = Arrays.asList(selected); + return selectedList; + } +} Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionPane.jaxx =================================================================== --- trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionPane.jaxx (rev 0) +++ trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionPane.jaxx 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,129 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='multipleSelectionPane' + genericType='D, B extends BusinessEntity' + layout='{new BorderLayout()}'> + + <import> + java.awt.event.MouseAdapter + java.awt.event.MouseEvent + java.util.Collection + javax.swing.DefaultListModel + javax.swing.DefaultListCellRenderer + org.apache.commons.lang.StringUtils + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + org.nuiton.wikitty.entities.BusinessEntity + </import> + + <script><![CDATA[ + +void $afterCompleteSetup() { + addPropertyChangeListener("handler", new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (getHandler() != null && getBean() != null) { + init(); + } + } + }); + + list.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + ListSelectionModel selectionModel = list.getSelectionModel(); + int selectionIndex = selectionModel.getLeadSelectionIndex(); + String selected = (String)listModel.get(selectionIndex); + + getHandler().openSelected(selected); + } + } + }); +} + +public void init() { + if (handler != null) { + handler.init(); + } +} + +public B getBean() { + return getContextValue(getBeanType()); +} + +public void setBean(B bean) { + if (bean != null) { + setContextValue(bean); + } +} + +public Collection<D> getAddedDatas() { + return handler.getAddedDatas(); +} + ]]></script> + + <DefaultListModel id='listModel'/> + + <DefaultListCellRenderer id='listCellRenderer'/> + + <String id='lbl' javaBean='StringUtils.EMPTY'/> + + <MultipleSelectionHandler id='handler' javaBean='null' + genericType='D, B, ?'/> + + <Class id='beanType' javaBean='null' genericType='B'/> + + <Table constraints='BorderLayout.NORTH'> + <row> + <cell> + <JLabel text='{getLbl()}'/> + </cell> + <cell fill='horizontal' weightx='1'> + <JPanel/> + </cell> + <cell> + <JButton id='addFile' + enabled='{isEnabled()}' + actionIcon='add' + onActionPerformed='handler.add()'/> + </cell> + <cell> + <JButton id='removeFile' + enabled='{isEnabled() && (list.getSelectedIndex() != -1)}' + actionIcon='remove' + onActionPerformed='handler.remove()'/> + </cell> + </row> + </Table> + + <JScrollPane constraints='BorderLayout.CENTER'> + <JList id='list' + enabled='{isEnabled()}' + model='{listModel}' + cellRenderer='{listCellRenderer}'/> + </JScrollPane> +</JPanel> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/java/org/chorem/vradi/ui/widgets/MultipleSelectionPane.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/jnlp/vradi-server-jnlp.vm =================================================================== --- trunk/vradi-swing/src/main/jnlp/vradi-server-jnlp.vm (rev 0) +++ trunk/vradi-swing/src/main/jnlp/vradi-server-jnlp.vm 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<jnlp + spec="$jnlpspec" + codebase="$jnlpCodebase" + href="$outputFile"> + <information> + <title>$project.Name</title> + <vendor>$project.Organization.Name</vendor> + <homepage href="$project.Url"/> + <description>$project.Description</description> +#if($offlineAllowed) + <offline-allowed/> +#end + </information> +#if($allPermissions) + <security> + <all-permissions/> + </security> +#end + <resources> + <j2se version="$j2seVersion"/> + <property name="vradi.remote.endpoint" value="${jnlpCodebase}vradi-services-web" /> + $dependencies + $extensions + </resources> + <application-desc main-class="$mainClass"/> +</jnlp> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/jnlp/vradi-server-jnlp.vm ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/changelog.txt =================================================================== --- trunk/vradi-swing/src/main/resources/changelog.txt (rev 0) +++ trunk/vradi-swing/src/main/resources/changelog.txt 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,361 @@ + +---- 0.5.0 + +Bugs corrigés +============= + +Général +------- + +- Problème de lenteur + +Gestion des formulaires +----------------------- + +- Thésaurus créé en double +- Pièce jointe encapsulée non ajoutée au PDF +- Erreur à la génération PDF + +Gestion des flux XML +-------------------- + +- Aperçu vide + +Nouvelles fonctionalités +======================== + +Gestion des formulaires +----------------------- + +- Permettre la suppression des types de formulaires +- Multiples indexations +- Liens entre formualires +- Multi-sélection de flux dans les listes déroulantes + +---- 0.4.0 + +Bugs corrigés +============= + +Envoi de mail +------------- + +- Arbre non rafraichît à la supression de session +- Liste de formulaires non mise à jour après une suppression de formulaires +- Accusé de réception automatique ne fonctionne pas +- Ajouter des formulaires à un mail supprimé par annulation d'envoi d'un formulaire +- Modification possible d'un mail déjà envoyé +- Impossible d'associer les formulaires pour une nouvelle session + +Administration +-------------- + +- Rafraichissement de l'UI des utilisateurs/groupes +- Bug de case à cocher +- Bug de la couleur des thésaurus +- Impossible de supprimer un thésaurus nouvellement créé +- Problème affichage tooltip sur thésaurus +- Non modification des requêtes impactées +- Mauvaise proposition après la suppression de descripteurs +- Erreur à la suppression de thésaurus +- Impossible de supprimer un flux XML +- Champs du flux XML non vidés +- Possible de créer un statut vide + +Résultats de requêtes +--------------------- + +- Export CSV vide +- Refonte de la cartographie + +Traitement formulaire +--------------------- + +- Supression des erreurs de gestion des fichiers joints (encapsulés ou liés) +- Thésaurus ajouté au niveau des descripteurs + +Nouvelles fonctionnalités +========================= + +- Coloration syntaxique à la rédaction des requêtes +- Enregistrement de la disposition des fenêtres +- Ajout d'un menu contextuel sur le tooltip de résultat de recherche pour la copie + +---- 0.3.0 + +Bugs corrigés +============= + +- Erreurs de rafraichissements +- Impossible de fermer une session +- Résultats de recherche non rafraichis +- Lenteurs à l'affichage +- Association +- Recherche d'un thésaurus et de ses fils +- Tri des formulaires +- Problème de recherche sur un champ +- Cartographie - affichage-tri des noeuds + +Nouvelles fonctionalités +======================== + +- Possibilité d'enlever des destinataires/formulaires à la main depuis l'UI de mail +- Ajouter une fenêtre de recherche annexe +- Enregistrer des requêtes sans client +- Pouvoir jouer les requêtes des groupes +- Possibilité de voir les messages d'erreur d'envoi de mail +- Ajouter un menu contextuel pour ajouter les champs d'une requête +- Enlever un descripteur par double-clic +- Améliorer la documentation (requêtes et génération PDF) +- Envoi de mail si erreur de récupération automatique de flux +- Afficher et rayer les formulaires supprimés manuellement +- Afficher d'une manière différentes les formulaires ajoutés manuellement + +---- 0.2.0 + +Bugs corrigés +============= + +- Tous les flux importés à la même heure +- Gestion des arbres +- Ordre des descripteurs +- Formulaire non modifié lorsqu'il est changé +- Copie de thésaurus +- Import/Export de thésaurus +- Création de descripteur, limiter la taille du chemin +- Cartographie - prise en compte des critères de recherche cachés +- Multiples confirmations d'annulations +- Pas de désindexation des formulaires + +Nouvelles fonctionnalités +========================= + +- Copier/coller depuis n'importe quelle source +- Lien vers les formulaires depuis la cartographie +- Simplifier la copie de thésaurus depuis la recherche +- Retrouver simplement la dernière session ouverte +- Une seule génération PDF + +---- 0.1.0 + +Traitement de formulaire +======================== + +- Masques de saisie pour les champs de formulaires +- Validation du champ SourceURL +- Tout le thésaurus est parcouru à l'enregistrement d'un formulaire + +Flux xml +- Gestion des flux xml sur une adresse en https + +Thesaurus +- Possibilité d'avoir plusieurs thésaurus +- Possibilité de ne pas déplier l'arbre quand on sélectionne un noeud +- La checkbox 'Déplier les noeuds lors de la sélection' ne fonctionne pas +- Probleme de thésaurus quand rentré en majuscules +- Recherche d'un thesaurus et de ses fils + +Requêtes +- Pouvoir afficher le thésaurus lorsqu'on édite une requête +- Tableau traitement AO, manque des colones +- Mélange de 2 flux lors de l'utilisation des listes déroulantes +- Modifications de requêtes non sauvegardées +- Impossible de supprimer une requête + +Envoi de mails +- Rendre configurable l'e-mail d'envoi +- Problème de session lors de la suppression des destinataires +- Impossibilité de se connecter à Internet alors que le PC est connecté +- Ne rien rajouter à une session fermée +- Périodicité des requête pour un client existant +- Non-association des formulaires +- Utiliser le composant de liste utilisateur partout +- Pas de pièces jointes aux mails +- L'accusé de réception ne fonctionne pas +- Session créée le lendemain +- Corps de mail vide +- Bug de l'association formulaire - utilisateur + +Client, utilisateur, groupe, statut +----------------------------------- + +- Prise en compte de la date d'inscription des utilisateurs +- La suppression des status ne fonctionnent plus +- La modification du nom du groupe ne dégrise pas le bouton de sauvegarde +- Cocher ou décocher la case actif sur un client ne dégrise pas le bouton sauvegarder +- Le bouton supprimer ne fonctionne pas +- Erreur de l'import de base client + +Divers +------ + +- Migration vers la nouvelle API d'arbre de JAXX +- Achitecture client/serveur +- Utilisation du cache réparti +- Suppression des DTO +- Nouveau service de transfert de fichiers +- Mise au propre de la configuration basé sur ApplicationConfig +- Reindexation automatique si changement de version +- Impossibilité de faire l'association modèle PDF (nom de dossier avec caractère accentués) +- Augmenter la taille des tooltips +- Desélection des propositions + +---- 0.0.5 + +Traitement de formulaires +------------------------- + +- Propositions : montrer le chemin du noeud +- Pagination des résultats d'une recherche +- Ajout d'un champ tag sur l'infogène +- Déclenchement de la recherche de formulaires en arrière plan +- Gagner de la place en bas de l'écran de modification de formulaire +- Multi-sélection sans appuyer sur controle +- Bug : La zone de recherche ne fonctionne pas +- Bug : Impossible de voir tout le formulaire - redimmensionnement étrange +- Bug : Affichage des requetes/client/... retournant un formulaire +- Bug : Quand on sélectionne une proposition, elle n'est pas réaffichée dans les différents arbres du thésaurus +- Bug : Erreur au traitement des appel d'offre : choix du thesaurus +- Bug : Pas de récapitulatif des noeuds sélectionnés dans la première colonne de thésaurus +- Bug : Ajout d'une colonne de thésaurus non pris en compte +- Bug : La suppression d'une colonne de thésaurus est très longue +- Bug : L'ajout d'une colonne de thésaurus fait buger le thésaurus +- Bug : Pas de récapitulatif des noeuds sélectionnés dans la première colonne de thésaurus +- Bug : Mauvaises propositions de noeuds de thésaurus +- Bug : Problème de barre de défilement sur les colonnes du thésaurus + +Thésaurus +--------- + +- Ajout d'un numéro d'ordre +- Modification des requêtes associées lors d'une modification d'un descripteur +- Afficher les noeuds de premier niveau dans les colonnes du thésaurus +- Bug : Bug lors du changement de couleur d'une profondeur +- Bug : Doublons dans le thésaurus +- Bug : Erreur à l'enregistrement du thesaurus +- Bug : Mauvais thésaurus lors du déplacement d'un noeud +- Bug : Renommage de noeud de thésaurus non enregistré +- Bug : Duplication des noeuds de thésaurus après déplacement +- Bug : Impossibilité de remonter un noeud de thésaurus en fils du noeud root +- Bug : Erreur lors du déplacement d'un noeud de thésaurus +- Bug : Manque une scrollbar sur la liste des modifications de noeud de thésaurus +- Bug : Déplacement de noeud de thésaurus - proposer aucun changement +- Bug : Tri au runtime de l'admin thesaurus + +Requêtes +-------- + +- Support des plages de valeurs (FROM TO) +- Support des requêtes sur le dernier modifieur +- Possibilité de copier un noeud de thésaurus depuis l'administration et le coller dans une requête +- Ajout des '30 derniers jours' dans les champs pré-remplis de requête +- Visionner les résultats de recherche dans la cartographie du thésaurus +- Demander à l'utilisateur de confirmer l'annulation de l'édition des requêtes + +Envoi de mails +-------------- + +- Affichage d'une liste ordonnée des descripteurs associés à chaque formulaire +- Affichage du nombre de formulaires à envoyer à chaque client/utilisateur/groupe +- Ajout de la possibilité d'interrompre la procédure d'envoi de mail +- Ajout de la possibilité de réexpédier un message +- Confirmation quand un email est renvoyé +- Générer les PDFs non présents avant l'envoi des mails +- Afficher un message d'erreur quand pas de modèle PDF attaché +- Bug : Envoie uniquement les formulaires dont le statut est 'sélectionné' +- Bug : Message d'erreur 'bourrin' à l'envoi de mail +- Bug : Ajout de formulaires à une session envoyée +- Bug : Session envoyée alors qu'il y a des erreurs +- Bug : Mail envoyé avec un pdf alors que pas de modèle associé +- Bug : Le paragraphe de session n'est pas envoyé +- Bug : Les accusés de reception ne sont pas visible dans l'UI d'envoie de mail +- Bug : Erreur lors de la génération PDF (pendant l'envoi de mail) +- Bug : L'utilisateur reçoit 2 mails au lieu d'1 +- Bug : Un nouveau client ne doit pas recevoir tous les anciens formulaires +- Bug : Le bouton 'Envoyer les formulaires de la session' ne se grise pas une fois qu'elle a été envoyée +- Bug : Un utilisateur fils de tous les clients +- Bug : Erreur lorsque je supprime un Client ou un utilisateur de la liste des destinataires d'un formulaire + +Flux XML +-------- + +- Ajout de valeurs par defaut pour le mapping d'un flux XML +- Affichage du bilan de l'import de flux XML +- Prise en charge de l'url du flux après un copier coller dans le champ +- Bug : Impossible d'éditer le mapping d'un flux XML si hors-ligne +- Bug : Tooltip de description du flux vide +- Bug : L'ajout d'un nouveau flux dans l'admin n'apparait pas dans la combo du formulaire de recherche + +Client, utilisateur, groupe +--------------------------- + +- Import de base client depuis CSV +- Ajout de libellé et description pour les requêtes client/utilsateur +- Bug : Création des utilisateurs dans le bon client +- Bug : Suppressions d'utilisateurs et de clients +- Bug : Double sauvegarde pour l'administration client/utilisateur/groupe +- Bug : Bug d'affichage des clients quand plusieurs clients ont le même nom +- Bug : Il y a une ligne d'historique alors qu'aucune requête n'a été modifiée +- Bug : Pas de libellé et description pour les requêtes +- Bug : Il y a une ligne d'historique alors qu'aucune requête n'a été modifiée +- Bug : L'historique des requetes ne marche plus +- Bug : Tri des clients et utilisateurs par ordre alphabétique +- Bug : Préfixage des utilisateurs par le nom de leur client + +Statuts +------- + +- Bug : Ordre des statuts non conservés +- Bug : Les flèches de déplacement des statuts ne fonctionnent pas + +Types de formulaires +-------------------- + +- Bug : Le creation de type de formulaire ne fonctionne pas du tout + +Divers +------ + +- Faire fonctionner la reindexation +- Augmentation de la durée d'affichage des infos-bulles +- Ajout de barres de défilement dans la fenêtre de changelog +- La fenêtre d'admin ne doit pas être modale +- Bug : L'application demande si on veut sauver les modifications alors qu'on vient de cliquer sur le bouton supprimer +- Bug : Lors d'un clic sur supprimer, il n'y a pas de demande de confirmation + +---- 0.0.4 + +- Amélioration de l'ui d'administration des thésaurus (affichage des modifications apportées) +- Migration des données enregistrées avec la version précédente +- Ajout des statuts des formulaires +- Ajout de champs à l'infogène +- Amélioration de l'ergonomie +- Ajout des propositions de noeuds de thesaurus aux formulaires + +---- 0.0.3 + +- Amélioration de l'ui d'administration des thésaurus +- Ajout des tags sous la forme "a, b, c..." et ajout d'une description pour les thésaurus +- Export/import de la base de données +- Champ "name" remplacé par "objet" +- Changelog ajouté au menu d'aide +- Chaîne remplacé par ligne et text par paragraphe +- Prévisualisation du flux XML lors de la configuration +- Ajout d'un type de champ monétaire +- Chaque champ d'un formulaire a un nom cours et une description/nom long affichée en tooltip +- Une ligne par session et par client dans l'interface d'envoi d'e-mail +- Ajout d'une barre de progression lors des opérations longues +- Ajout de l'heure dans les dates +- Ajout des tags, séparés par une virgule et d'une description pour chaque noeud du thésaurus +- Ajout des champs source, initiateur et description dans l'infogène +- Possibilité de ne modifier que la date dans l'identifiant d'un formulaire. Identifiant de la forme date-id +- Ajouter un editeur en popup pour l'edition du paragraphe des emails a envoyer + +---- 0.0.2 + +- Client, utilisateur et groupe : création et mise à jour +- Création des types de formulaire +- Création du thésaurus +- Création manuelle de formulaires +- Création automatique de formulaires à partir de flux XMLs ou RSS +- Recherche de formulaires Property changes on: trunk/vradi-swing/src/main/resources/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/i18n/vradi-swing_fr_FR.properties =================================================================== --- trunk/vradi-swing/src/main/resources/i18n/vradi-swing_fr_FR.properties (rev 0) +++ trunk/vradi-swing/src/main/resources/i18n/vradi-swing_fr_FR.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,533 @@ +Can't\ create\ new\ session=Impossible de cr\u00E9er une nouvelle session +Can't\ create\ new\ session\ for\ reason\ \:\ %s=Impossible de cr\u00E9er une nouvelle session \:\n%s +Can't\ download\ file= +Can't\ found\ any\ opened\ mail\ session,\ please\ create\ a\ new\ session\ in\ mail\ management=Aucune session de mail trouv\u00E9e. Merci de cr\u00E9er une nouvelle session dans la gestion des mails. +Can't\ upload\ file= +Confirm\ thesaurus\ deletion=Confirmation de suppression du thesaurus +Error=Erreur +Warning\ all\ your\ thesaurus\ will\ be\ deleted\ before\ new\ import.\ Do\ you\ want\ to\ continue\ ?=Attention, tous les thesaurus seront entierrement supprim\u00E9s avant le nouvel import.\n\u00CAtes-vous s\u00FBr de vouloir continuer ? +vradi.action.about=A propos +vradi.action.about.tip=A propos de l'application Vradi... +vradi.action.cancel=Annuler +vradi.action.close=Fermer +vradi.action.commandline.configure.ui=Configurer l'application +vradi.action.commandline.disable.main.ui=Ne pas lancer l'ui principale +vradi.action.commandline.help=Afficher l'aide +vradi.action.commandline.help.ui=Afficher l'aide en ligne +vradi.action.configuration=Configuration +vradi.action.configuration.tip=Modifier la configuration +vradi.action.exit=Quitter +vradi.action.exit.tip=Quitter vradi +vradi.action.fullscreen=Plein \u00E9cran +vradi.action.fullscreen.tip=Passer en mode plein \u00E9cran +vradi.action.help=Aide +vradi.action.help.tip=Afficher l'aide +vradi.action.locale.= +vradi.action.locale.fr=Fran\u00E7ais +vradi.action.locale.fr.tip=Changer la langue en fran\u00E7ais +vradi.action.locale.uk=Anglais +vradi.action.locale.uk.tip=Changer la langue en anglais +vradi.action.normalscreen=Ecran normal +vradi.action.normalscreen.tip=Revenir en mode normal +vradi.action.select=Selectionnez +vradi.action.site=Site +vradi.action.site.tip=Acc\u00E9der au site de Vradi +vradi.action.stat= +vradi.action.test= +vradi.action.valid=Valider +vradi.admin.cancel.message=\u00CAtes-vous s\u00FBr de vouloir annuler les changements ? +vradi.admin.cancel.title=Annuler les changements ? +vradi.admin.client=Gestion des clients +vradi.admin.confirmDelete=Voulez vous supprimer \: %1$s ? +vradi.admin.deleteTitle=Suppression ? +vradi.admin.exportButtonText=Exporter +vradi.admin.exportCSV=Export +vradi.admin.exportTitle=Export des clients, utilisateurs et groupes +vradi.admin.form=Gestion des formulaires +vradi.admin.formsCreated.message=R\u00E9sultat de la cr\u00E9ation \:\n +vradi.admin.formsCreated.message.allWarning=- %1$s formulaires cr\u00E9\u00E9s\n- %2$d formulaires existants\n- %3$s erreurs de date\n- %4$s erreurs de nombre +vradi.admin.formsCreated.missingFormType=Aucun Type de formulaire associ\u00E9. +vradi.admin.formsCreated.title=R\u00E9sultat de la cr\u00E9ation +vradi.admin.group=Gestion des groupes +vradi.admin.importButtonText=Importer +vradi.admin.importCSV=Import +vradi.admin.importTitle=Import des clients, utilisateurs et groupes +vradi.admin.isInUse=Le status %1$s est encore utilis\u00E9, la suppression est impossible. +vradi.admin.isInUse.title=Impossible de supprimer le status +vradi.admin.noSelection=Veuillez s\u00E9lectionner un noeud de l'arbre. +vradi.admin.saveAnswer=Modification en cours, voulez vous sauvegarder \: +vradi.admin.saveTitle=Sauvegarder ? +vradi.admin.status=Gestion des statuts +vradi.admin.thesaurus=Gestion des th\u00E9saurus +vradi.admin.title=Administration +vradi.admin.userEnable=Actif +vradi.admin.warnTitle= +vradi.admin.xmlStream=Gestion des flux XML +vradi.adminClient.adresse=Adresse +vradi.adminClient.contact=Contact +vradi.adminClient.createClient=Cr\u00E9er un client +vradi.adminClient.createUser=Cr\u00E9er un utilisateur +vradi.adminClient.deleteClient=Supprimer +vradi.adminClient.deleteGroup=Supprimer le groupe +vradi.adminClient.listGroup=Groupes +vradi.adminClient.name=Nom +vradi.adminClient.newClientName=Nouveau client +vradi.adminClient.tel=T\u00E9l\u00E9phone +vradi.adminClient.title=Client \: %1$s +vradi.adminField.desc=Description +vradi.adminField.lbl=Label +vradi.adminField.name=Nom du champ +vradi.adminField.new=Ajouter +vradi.adminField.title=Champs du formulaire +vradi.adminField.type=Type +vradi.adminForm.createForm=Cr\u00E9er un type de formulaire +vradi.adminForm.deleteFormType=Supprimer un type de formulaire +vradi.adminForm.title=Type de formulaire \: %1$s +vradi.adminFormType.askName=Nom du type de formulaire \: +vradi.adminFormType.askNameInvalid=Le nom du type de formulaire contient des caracteres non alphanum\u00E9rique \! +vradi.adminFormType.askNameTitle=Nouveau type de formulaire +vradi.adminFormType.deleteFormType=Supprimer le type de formulaire +vradi.adminFormType.hideInfogene=Cacher l'infogene +vradi.adminFormType.showInfogene=Afficher l'infogene +vradi.adminFormType.template.download=T\u00E9l\u00E9charger +vradi.adminFormType.template.fieldBinding=Associez les champs +vradi.adminFormType.template.fieldBinding.label=Associez les champs du document OpenOffice aux champs du formulaire \: +vradi.adminFormType.template.fieldBinding.title=Associez les champs du document OpenOffice aux champs du formulaire +vradi.adminFormType.template.label=Mod\u00E8le de g\u00E9n\u00E9ration PDF \: +vradi.adminFormType.template.new=Ajouter +vradi.adminFormType.template.showExample=Voir un exemple +vradi.adminFormType.template.showExample.error.message=Aucun formulaire de ce type n'a \u00E9t\u00E9 enregistr\u00E9.\nAucun aper\u00E7u n'est donc disponible. +vradi.adminFormType.template.showExample.error.title=Aucun formulaire de ce type +vradi.adminGroup.addUser=Ajout l'utilisateur s\u00E9lectionn\u00E9 dans le groupe +vradi.adminGroup.createGroup=Cr\u00E9er un groupe +vradi.adminGroup.listUsers=Utilisateurs +vradi.adminGroup.name=Groupes +vradi.adminGroup.newGroupName=Nouveau groupe +vradi.adminGroup.removeUser= +vradi.adminGroup.title=Groupe \: %1$s +vradi.adminRequest.cancel=Annuler +vradi.adminRequest.edit=Editer +vradi.adminRequest.history.show=Voir l'historique des requ\u00EAtes +vradi.adminRequest.new=Nouvelle requ\u00EAte +vradi.adminRequest.remove=Supprimer +vradi.adminRequest.title=Requ\u00EAtes \: +vradi.adminRequest.valid=Valider +vradi.adminStatus.createStatus=Cr\u00E9er un nouveau statut +vradi.adminStatus.desc=Description +vradi.adminStatus.name=Nom +vradi.adminStatus.newStatusName=Nouveau statut +vradi.adminStatus.title=Gestion des statuts +vradi.adminThesaurus.askCreateRootThesaurus=\u00CAtes-vous s\u00FBr de vouloir cr\u00E9ez le nouveau th\u00E9saurus %1$s ? +vradi.adminThesaurus.askDeleteRootThesaurus=\u00CAtes-vous s\u00FBr de vouloir supprimer le th\u00E9saurus %1$s ainsi que tout ses descripteurs ? +vradi.adminThesaurus.askDeleteThesaurus=\u00CAtes-vous s\u00FBr de vouloir supprimer le descripteur %1$s ainsi que tout ses fils (%2$s formulaires seront impact\u00E9) ? +vradi.adminThesaurus.askEditRootThesaurus=\u00CAtes-vous s\u00FBr de vouloir renommer le th\u00E9saurus %1$s en %2$s ? +vradi.adminThesaurus.askEditThesaurus=Voulez-vous sauvegarder les modifications pour le descripteur %1$s (%2$s formulaires seront impact\u00E9) ? +vradi.adminThesaurus.askMoveThesaurus=\u00CAtes-vous s\u00FBr de vouloir d\u00E9placer le descripteur %1$s ? +vradi.adminThesaurus.askRootThesaurusEditName=Choisisez un nouveau nom pour le th\u00E9saurus %1$s +vradi.adminThesaurus.askRootThesaurusName=Choisisez un nom pour le th\u00E9saurus +vradi.adminThesaurus.askRootThesaurusTitle=Nouveau th\u00E9saurus +vradi.adminThesaurus.comment=Commentaire +vradi.adminThesaurus.creationTitle=Cr\u00E9ation d'un descripteur +vradi.adminThesaurus.editTitle=Edition du descripteur \: %1$s +vradi.adminThesaurus.exportButtonText=Exporter +vradi.adminThesaurus.exportThesaurusCSV=Export +vradi.adminThesaurus.exportThesaurusTitle=Exporter le th\u00E9saurus +vradi.adminThesaurus.importButtonText=Importer +vradi.adminThesaurus.importThesaurusCSV=Import +vradi.adminThesaurus.importTitle=Importer le th\u00E9saurus +vradi.adminThesaurus.move=D\u00E9placer +vradi.adminThesaurus.moveTitle=Sauvegarder ? +vradi.adminThesaurus.orderName=Ordre - Nom +vradi.adminThesaurus.path=Chemin \: +vradi.adminThesaurus.rootThesaurusInvalidName=Le nom du th\u00E9saurus est utilis\u00E9 pour cr\u00E9er des requ\u00EAtes,\nil ne doit contenir que des carat\u00E8res alphanum\u00E9rique. +vradi.adminThesaurus.select=S\u00E9lectionnez le descripteur de destination +vradi.adminThesaurus.selectAsk=D\u00E9placer le descripteur vers... +vradi.adminThesaurus.tags=Tags +vradi.adminThesaurus.warnNameIsExisting=Le descripteur "%s" existe d\u00E9j\u00E0 dans ce thesaurus +vradi.adminThesaurus.warnTitle=Descripteur existant +vradi.adminUi.invalid.email=Adresse email non valide +vradi.adminUi.invalid.url=URL non valide +vradi.adminUi.regex.fieldselect.nameValue=Les caract\u00E8res sp\u00E9ciaux ne sont pas autoris\u00E9s +vradi.adminUi.required.client.name=Ce champ est obligatoire +vradi.adminUi.required.fieldselect.nameValue=Ce champ est obligatoire +vradi.adminUi.required.fieldselect.type=Ce champ est obligatoire +vradi.adminUi.required.group.name=Ce champ est obligatoire +vradi.adminUi.required.user.name=Ce champ est obligatoire +vradi.adminUi.required.xmlStream.formTypeName=Ce champ est obligatoire +vradi.adminUi.required.xmlStream.name=Ce champ est obligatoire +vradi.adminUi.required.xmlStream.url=Ce champ est obligatoire +vradi.adminUser.addGroup=Ajouter l'utilisateur au groupe s\u00E9lectionn\u00E9 +vradi.adminUser.adresse=Adresse +vradi.adminUser.beginSearchDate=Date de d\u00E9but de recherche +vradi.adminUser.createUser=Cr\u00E9er un utilisateur +vradi.adminUser.deleteUser=Supprimer +vradi.adminUser.mail=Email +vradi.adminUser.name=Nom +vradi.adminUser.newUserName=Nouvel utilisateur +vradi.adminUser.phone=T\u00E9l\u00E9phone +vradi.adminUser.removeGroup=Retirer l'utilisateur du groupe s\u00E9lectionn\u00E9 +vradi.adminUser.service=Service +vradi.adminUser.title=Utilisateur \: %1$s +vradi.adminXmlStream.config=Configurer les flux XML +vradi.adminXmlStream.config.label.hours=\u00E0 la minute +vradi.adminXmlStream.config.load=Charger les nouveaux formulaires \u00E0 +vradi.adminXmlStream.config.title=Configuration des flux XML +vradi.adminXmlStream.createForms=Forcer l'import du flux +vradi.adminXmlStream.createNewWebHarvest.toolTip=Ouvrir l'editeur de script web harvest +vradi.adminXmlStream.createWebHarvestStream=Cr\u00E9er un flux Web Harvest +vradi.adminXmlStream.createXmlStream=Cr\u00E9er un flux +vradi.adminXmlStream.deleteXmlStream=Supprimer le flux XML +vradi.adminXmlStream.formType=Type de formulaire associ\u00E9 +vradi.adminXmlStream.hideForm=Cacher les d\u00E9tails du flux XML +vradi.adminXmlStream.name=Nom +vradi.adminXmlStream.newFormTypeName=Nouveau type de formulaire +vradi.adminXmlStream.newStreamName=Nouveau flux +vradi.adminXmlStream.newWebHarvestStreamName=Nouveau flux web harvest +vradi.adminXmlStream.showForm=Voir les d\u00E9tails du flux XML +vradi.adminXmlStream.startUrl=URL d'entr\u00E9 du script +vradi.adminXmlStream.table.field.defaultValue=Valeur par d\u00E9faut +vradi.adminXmlStream.table.field.defaultValue.tip=Valeur par d\u00E9faut +vradi.adminXmlStream.table.field.name=Champs du type de formulaire +vradi.adminXmlStream.table.field.name.tip=Champs du type de formulaire \u00E0 associer +vradi.adminXmlStream.table.field.values=Valeur du flux +vradi.adminXmlStream.table.field.values.tip=Valeur du flux xml \u00E0 associer au type de formulaire +vradi.adminXmlStream.title=Flux XML \: %1$s +vradi.adminXmlStream.url=URL du flux XML +vradi.adminXmlStream.validateUrl=Valider +vradi.adminXmlStream.webHarvestScript=Script \u00E0 executer +vradi.binding.forms.concurrence.message=Une erreur de concurrence est apparue.\nV\u00E9rifiez que personne n'effectue la m\u00EAme op\u00E9ration et recommencez. +vradi.changelog.title=Changelog +vradi.client.category=Clients +vradi.common.alls=Tous +vradi.common.cancel=Annuler +vradi.common.close=Fermer +vradi.common.copy=Copier +vradi.common.create=Nouveau +vradi.common.delete=Supprimer +vradi.common.edit=Editer +vradi.common.ok=Valider +vradi.common.paste=Coller +vradi.common.save=Sauvegarder +vradi.common.select=S\u00E9lectionner +vradi.common.timeseparator=\: +vradi.common.validate=Valider +vradi.config.category.directories=R\u00E9pertoires +vradi.config.category.directories.description=R\u00E9pertoires de l'application +vradi.config.category.other=Autre +vradi.config.category.other.description=Autres options +vradi.config.category.remote=Serveur +vradi.config.category.remote.description=Configuration du serveur +vradi.config.columns.description= +vradi.config.configFileName.description=Le nom du fichier de configuration +vradi.config.criteria.description= +vradi.config.database.version.description= +vradi.config.last.version.description= +vradi.config.login= +vradi.config.password= +vradi.config.queries.description= +vradi.config.remote.endpoint.description=Adresse du serveur distant +vradi.config.root.criteria.description= +vradi.config.rootThesaurus.description= +vradi.config.status.color.description= +vradi.config.swing.debug= +vradi.config.swingConfigFileName.description= +vradi.config.thesaurus.color.description= +vradi.config.thesaurus.description= +vradi.config.thesaurus.expanded.description= +vradi.config.ui.fullscreen=Pour afficher l'aplication en mode plein \u00E9cran +vradi.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB) +vradi.config.version.description= +vradi.config.wikitty.notifier.transporter.class.description=Class utilis\u00E9 pour transporter les \u00E9venements +vradi.config.wikitty.propagate.propagateEvent.description=Definie si l'instance est en mode serveur ou non +vradi.config.wikitty.xmpp.room.description=Adresse du salon XMPP auquel ce connecter pour recevoir les \u00E9venements +vradi.config.wikitty.xmpp.server.description=Adresse du serveur XMPP +vradi.config.xmlStreams.description= +vradi.createForm.askName=Nom du nouveau formulaire +vradi.createForm.askType=Type du nouveau formulaire +vradi.criteria.cartography=Cartographie / Thesaurus +vradi.criteria.clear=Effacer +vradi.criteria.collapse=Avanc\u00E9e - +vradi.criteria.empty=Aucun +vradi.criteria.formType=Type de formulaire +vradi.criteria.from=De +vradi.criteria.notCollapse=Avanc\u00E9e + +vradi.criteria.search=Rechercher +vradi.criteria.searchLast30days=30 derniers jours +vradi.criteria.searchLastDay=Hier +vradi.criteria.searchThisMonth=Mois courant +vradi.criteria.searchToDay=Aujourd'hui +vradi.criteria.status=Statut \: +vradi.criteria.to=\u00E0 +vradi.criteria.typeDate=Date concern\u00E9e +vradi.criteria.typeDate.Form.datePeremption=Date de p\u00E9remption +vradi.criteria.typeDate.Form.datePub=Date de publication +vradi.criteria.typeDate.Infogene.creationDate=Date de cr\u00E9ation +vradi.criteria.xmlStream=Flux XML \: +vradi.date.required.value=Ce champ est obligatoire +vradi.edit.proposition=Propositions +vradi.editor.convertToIso=ISO +vradi.editor.convertToIsoToolTip=Convertion en ISO +vradi.editor.convertToUtf=UTF +vradi.editor.convertToUtfToolTip=Convertion en UTF8 +vradi.editor.removeEndLine=\\n +vradi.editor.removeEndLineToolTip=Suppression des fins de lignes +vradi.editor.removeXML=<...> +vradi.editor.removeXMLToolTip=Supprimer les balises XML +vradi.editor.unescapeXML=XML +vradi.editor.unescapeXMLToolTip=Suppression des caract\u00E8res sp\u00E9ciaux XML +vradi.email.addGroup=Envoyer \u00E0 un groupe +vradi.email.addUser=Envoyer \u00E0 un utilisateur +vradi.email.askAbordSendingTitle=Continuer l'envoi ? +vradi.email.askModelEmpty=Le type de formulaire %1$s n'a pas de template associ\u00E9.\n\u00EAtes-vous s\u00FBr de vouloir continuer l'envoi ? +vradi.email.askUserEmailEmpty=L'utilisateur %1$s (du client %2$s) n'a pas d'email.\n\u00EAtes-vous s\u00FBr de vouloir continuer l'envoi ? +vradi.email.bindSession=Associer les formulaires aux utilisateurs +vradi.email.clientFilter=par clients +vradi.email.confimCloseSession=\u00CAtes-vous s\u00FBr de vouloir supprimer la session active ?\n\nATTENTION \: La session ne pourra pas \u00EAtre r\u00E9ouverte \! +vradi.email.confimCloseSession.titles=Supprimer la session active ? +vradi.email.confirmAddGroup=\u00CAtes-vous s\u00FBr de vouloir ajouter l'envoi des formulaires \: \n%1$s \n\naux groupes suivants \: \n%2$s +vradi.email.confirmAddTitle=Ajout des formulaires \u00E0 la session d'envoie +vradi.email.confirmAddUser=\u00CAtes-vous s\u00FBr de vouloir ajouter l'envoi des formulaires \: \n%1$s \n\naux utilisateurs suivants \: \n%2$s +vradi.email.confirmDelete=\u00CAtes-vous s\u00FBr de vouloir supprimer l'envoi de ce formulaire \: %1$s +vradi.email.confirmDeleteTitle=Suppression d'un formulaire ? +vradi.email.confirmRemoveForms=\u00CAtes-vous s\u00FBr de vouloir supprimer les formulaires suivantes de la session pour tout les utilisateurs \:\n%1$s +vradi.email.confirmRemoveFormsTitle=Suppression de formulaires +vradi.email.confirmRemoveUserForms=\u00CAtes-vous s\u00FBr de vouloir supprimer les formulaires suivantes de la session pour l'utilisateurs %1$s \:\n%1$s +vradi.email.confirmRemoveUserFormsTitle=Suppression de formulaires +vradi.email.confirmRevertFormDeletion=Etes-vous sur le vouloir annuler la suppression des formulaires suivants \: \n%1$s +vradi.email.confirmRevertFormDeletionTitle=Annuler la suppression des formulaires ? +vradi.email.confirmRevertGroupFormDeletion=Etes-vous sur le vouloir annuler pour les groupes \n\n'%2$s'\n\nla suppression des formulaires suivants \: \n%1$s +vradi.email.confirmRevertGroupFormDeletionTitle=Annuler la suppression des formulaires ? +vradi.email.confirmRevertUserFormDeletion=Etes-vous sur le vouloir annuler pour les utilisateurs \n\n'%2$s'\n\nla suppression des formulaires suivants \: \n%1$s +vradi.email.confirmRevertUserFormDeletionTitle=Annuler la suppression des formulaires ? +vradi.email.confirmSelectionForm=Le formulaire '%1$s' doit \u00EAtre s\u00E9lectionn\u00E9 pour l'envoi,\n\u00EAtes-vous sur de vouloir s\u00E9lectionner ce formulaire ? +vradi.email.confirmSelectionForm.title=Changer le status du formulaire +vradi.email.confirmSendSending=\u00CAtes-vous s\u00FBr de vouloir r\u00E9envoyer les emails \u00E0 %1$s ? +vradi.email.confirmSendSending.askMail=Veuillez saisir l'adresse mail \: +vradi.email.confirmSendSending.askMailTitle=Destinataire personnalis\u00E9 +vradi.email.confirmSendSending.optionNo=Non +vradi.email.confirmSendSending.optionOtherMail=Saisir l'email du destinataire +vradi.email.confirmSendSending.optionYes=Oui +vradi.email.confirmSendSendingTitle=R\u00E9envoy\u00E9 ? +vradi.email.confirmSendSession=\u00CAtes-vous s\u00FBr de vouloir traiter la session en cours ? +vradi.email.confirmSendSessionTitle=Confirmation d'envoi +vradi.email.deleteSession=D\u00E9truire la session +vradi.email.filter=Filtrer +vradi.email.formFilter=par formulaires +vradi.email.formGroupTitle=Groupes +vradi.email.formUserTitle=Utilisateurs +vradi.email.forms.revertDeletion=Annuler les suppressions +vradi.email.generation=G\u00E9n\u00E9ration des pdf +vradi.email.generation.msg=G\u00E9n\u00E9ration des pdf +vradi.email.generation.title=Les PDF sont en cours de g\u00E9n\u00E9ration +vradi.email.groupFilter=par groupes +vradi.email.hideForm= +vradi.email.hideSessionParagraph=Cacher le paragraphe de la session +vradi.email.invalid.value= +vradi.email.newSession=Cr\u00E9er une nouvelle session +vradi.email.noSelection=Veuillez s\u00E9lectionner un utilisateur ou une s\u00E9ssion dans l'arbre. +vradi.email.paragraph=Paragraphe +vradi.email.receptionProof=Accus\u00E9 de r\u00E9ception +vradi.email.removeFormFromSession=Supprimer les formulaires selectionn\u00E9 de la session +vradi.email.removeFormFromSessionForUser=Supprimer les formulaires selectionn\u00E9 de la session pour l'utilisateur +vradi.email.required.value=Email requis +vradi.email.sendSending=R\u00E9envoyer les formulaires +vradi.email.sendSending.sendError=L'envoi de l'email a \u00E9chou\u00E9 \: %1$s +vradi.email.sendSession=Envoyer les formulaires de la session +vradi.email.sendSession.error=L'envoi des emails a \u00E9chou\u00E9 +vradi.email.sendSession.msg=Envoi des messages +vradi.email.sendSession.title=Les messages sont en cours d'envoi +vradi.email.session=Date d'envoi +vradi.email.sessionAttachedfile=Fichiers attach\u00E9s +vradi.email.sessionParagraph=Paragraphe pour cette session +vradi.email.showForm= +vradi.email.showSessionParagraph=Afficher le paragraphe de la session +vradi.email.status=Statuts \: +vradi.email.thesaurusToolTipTitle=Descripteurs associ\u00E9s \: +vradi.email.title=Envoi des emails +vradi.email.titleGroup=Session d'envoi pour le groupe %1$s +vradi.email.titleUser=Session d'envoi pour l'utilisateur %1$s +vradi.email.userFilter=par utilisateurs +vradi.entity.creation.date=cr\u00E9\u00E9 le %1$td/%1$tm/%1$ty \u00E0 %1$tk\:%1$tM\:%1$tS +vradi.entity.lastModified.date.user=derni\u00E8re modification le %1$td/%1$tm/%1$ty \u00E0 %1$tk\:%1$tM\:%1$tS par %2$s +vradi.error.cantOpenHistory=Impossible d'ouvrir l'historique des requettes. +vradi.error.cantOpenHistory.title=Impossible d'ouvrir l'historique des requettes +vradi.error.executeTask=La t\u00E2che est en erreur \: +vradi.error.fieldsBinding.errors=[Erreur] Voici la liste des champs du mod\u00E8le qui ne sont pas associ\u00E9 \:\n%1$s\n\n +vradi.error.fieldsBinding.msg=Tous les champs ne sont pas associ\u00E9, \u00EAtes vous s\u00FBr de vouloir sauvegarder ?\n\n +vradi.error.fieldsBinding.title=Etes vous s\u00FBr de vouloir sauvegarder ? +vradi.error.fieldsBinding.warns=[Attention] Voici la liste des champs du type de formulaire qui ne sont pas associ\u00E9 \:\n%1$s\n\n +vradi.error.fileNotFound=Le fichier '%1$s' n'a pas \u00E9t\u00E9 trouv\u00E9 sur le serveur, \nassurez-vous de bien avoir sauvegard\u00E9 le formulaire avant de t\u00E9lecharger un fichier joint. +vradi.error.fileNotFound.title=Fichier non pr\u00E9sent sur le serveur +vradi.error.formTypeDeletionUsed=Le type de formulaire '%1$s' est encore utilis\u00E9, la suppression est impossible. +vradi.error.formTypeDeletionUsed.title=Suppression impossible +vradi.error.formWikittyObselete=Le formulaire '%1$s' \u00E0 \u00E9t\u00E9 modifi\u00E9 pendant que vous l'\u00E9ditiez, \nles modifications serons perdus. +vradi.error.formWikittyObselete.title=Sauvegarde impossible +vradi.error.sending.sendDialogError=Voici l'erreur survenus pendant l'envoie de l'email \:\n%1$s +vradi.error.sending.sendDialogError.title=Erreur lors de l'envoie de l'email +vradi.error.session.bindNonActiveSession=Impossible d'associer les formulaires d'une session non active +vradi.error.session.bindNonActiveSession.title=La session n'est pas active +vradi.error.session.sendDialogError=Voici les erreurs survenus pendant l'envoie des emails \:\n%1$s +vradi.error.session.sendDialogError.title=Erreurs lors de l'envoie des emails +vradi.export.cvs=Exporter en CSV +vradi.export.filter.csv=Fichier csv +vradi.export.validate.label=Exporter +vradi.file.template.description=Fichier OpenOffice (*.odt, *.ott) +vradi.file.template.wrongFileNamePattern=Le nom de fichier %s n'est pas valide \!\nIl ne doit \u00EAtre compos\u00E9 que \u00DE caract\u00E8res alphanum\u00E9riques. +vradi.form.datePeremption=Date de peremption +vradi.form.datePub=Date de publication +vradi.formType.category=Type de formulaires +vradi.forms.returned=formulaires trouv\u00E9s +vradi.forms.shown=Nombre de formulaires \u00E0 afficher +vradi.group.category=Groupes +vradi.help.top.title= +vradi.infogene.country=Pays +vradi.infogene.creationDate=Date de cr\u00E9ation +vradi.infogene.department=D\u00E9partement +vradi.infogene.description=Description +vradi.infogene.entity=Entit\u00E9 +vradi.infogene.id=Identifiant +vradi.infogene.objet=Objet +vradi.infogene.sourceText=Source +vradi.infogene.sourceURL=URL source +vradi.init.closed=Vradi a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s +vradi.init.context.done=Initialisation du contexte termin\u00E9e en %1$s. +vradi.init.ui.done=Initialisation de l'interface graphique termin\u00E9e en %1$s. +vradi.list.requests=Requ\u00EAtes +vradi.login.cancel=Annuler +vradi.login.email=Email +vradi.login.error=Erreur d'authentification +vradi.login.error.message=Vous avez entr\u00E9 un mauvais mot de passe ou le nom d'utilisateur n'existe pas. +vradi.login.login=Login +vradi.login.password=Mot de passe +vradi.login.register=Enregistrement +vradi.login.repeatPassword=V\u00E9rification du mot de passe +vradi.login.title=Authentification +vradi.login.validate=Valider +vradi.menu.addChildThesaurus=Ajouter un descripteur +vradi.menu.addColumns=Ajouter une colonne +vradi.menu.addCriteria=Ajouter ce noeud comme crit\u00E8re de recherche +vradi.menu.addRootChildThesaurus=Ajouter un th\u00E9saurus +vradi.menu.addThesaurus=Afficher le descripteur en colonne +vradi.menu.admin=Administration +vradi.menu.client=Gestion des clients +vradi.menu.debug= +vradi.menu.deleteThesaurusSelected=Supprimer le descripteur +vradi.menu.editThesaurusSelected=Editer le descripteur +vradi.menu.email=Emails +vradi.menu.email.admin=Administration des Emails +vradi.menu.file=Fichier +vradi.menu.file.locale=Langues +vradi.menu.file.offerList=Nouvelle fen\u00EAtre de recherche +vradi.menu.form=Formulaires +vradi.menu.form.new=Cr\u00E9er un nouveau %1$s +vradi.menu.formType=Gestion des types de formulaires +vradi.menu.group=Gestion des groupes +vradi.menu.help=Aide +vradi.menu.menuChangeColorSeleted=Changer la couleur pour cette profondeur +vradi.menu.moveThesaurusSelected=D\u00E9placer le descripteur +vradi.menu.removeCriteria=Supprimer ce crit\u00E8re de recherche +vradi.menu.status=Gestion des statuts +vradi.menu.thesaurus=Gestion des th\u00E9saurus +vradi.menu.xmlStream=Gestion des flux XML +vradi.message.cannot.display.address=Une erreur est apparue en essayant d'afficher l'adresse. +vradi.message.cannot.display.history=Aucun historique disponible pour ce groupe. +vradi.message.cannot.display.stream=Une erreur est apparue en essayant d'afficher le flux. +vradi.message.cannot.display.url=Une erreur est apparue en essayant d'afficher l'URL. +vradi.message.config.loaded=Configuration de Vradi v. %1$s charg\u00E9e. +vradi.message.goto.site=Acc\u00E9der au site de Vradi (%1$s) +vradi.message.help.usage=Aide de Vradi v %1$s +vradi.modificationTag.lastModifier=Auteur de la derni\u00E8re modification +vradi.num.required.value=Ce champ est obligatoire +vradi.offer.Form.datePeremption=Date p\u00E9remption +vradi.offer.Form.datePub=Date publication +vradi.offer.Form.xmlStream=Flux XML +vradi.offer.Infogene.country=Pays +vradi.offer.Infogene.creationDate=Date cr\u00E9ation +vradi.offer.Infogene.department=D\u00E9partement +vradi.offer.Infogene.description=Description +vradi.offer.Infogene.entity=Entit\u00E9 +vradi.offer.Infogene.id=Id +vradi.offer.Infogene.objet=Objet +vradi.offer.Infogene.sourceText=Source +vradi.offer.Infogene.sourceURL=Source URL +vradi.offer.Infogene.status=Statut +vradi.offer.Infogene.tag=Tag +vradi.offer.email.add=Ajouter pour l'envoie +vradi.offer.email.removeForm=Supprimer les formulaires de la session courante +vradi.offer.email.removeForm.msg=Voulez-vous supprimer %1$s formulaires de la session courante ? +vradi.offer.email.removeForm.title=Suppression des formulaires de la session courante +vradi.offer.status.change=Changer le status \u00E0 +vradi.offerEdit.affectedQueries=Requ\u00EAte ? +vradi.offerEdit.askRelatedFormName=Quel nom voulez-vous donner au formulaire li\u00E9 ? +vradi.offerEdit.askReplaceFormName=Quel nom voulez-vous donner au formulaire de remplacement ? +vradi.offerEdit.attachedfile=Fichiers attach\u00E9s \: +vradi.offerEdit.attachmentfile=Pi\u00E8ces jointes \: +vradi.offerEdit.cantGeneratePDF=Le type de formulaire n'a pas de model de g\u00E9n\u00E9ration PDF associ\u00E9. +vradi.offerEdit.cantGeneratePDFTitle=Impossible de g\u00E9n\u00E9rer le PDF +vradi.offerEdit.embeddedfile=Fichiers encapsul\u00E9s \: +vradi.offerEdit.otherIndexationTitle=Autre indexation du formulaire \: '%1$s' +vradi.offerEdit.relatedForm=Formulaires li\u00E9es +vradi.offerEdit.replaceForm=Autres indexations +vradi.offerEdit.view.pdf=Voir en PDF +vradi.offerList.status.change.confirmation.message=\u00CAtes-vous s\u00FBr de vouloir changer le statut des formulaires \u00E0 '%1$s' ? +vradi.offerList.status.change.confirmation.title=Modification des statuts +vradi.progressBar.title=Patientez SVP +vradi.register.ok=Enregistrement r\u00E9ussi +vradi.register.ok.message=Votre compte utilisateur a bien \u00E9t\u00E9 cr\u00E9\u00E9. +vradi.register.password.error=Erreur de mot de passe +vradi.register.password.error.message=Vous n'avez pas entr\u00E9 deux mots de passe identiques. +vradi.register.title=Enregistrement +vradi.register.user.error=Nom incorrect +vradi.register.user.error.message=Le nom d'utilisateur est d\u00E9j\u00E0 utilis\u00E9. +vradi.reindex.message=\u00CAtes-vous s\u00FBr de vouloir r\u00E9indexer les donn\u00E9es ? +vradi.reindex.title=Reindexation +vradi.request.form=Champs du formulaires +vradi.request.infogene=Champs de l'infog\u00E8ne +vradi.request.keywords=Champs +vradi.requestFormView.resultTable.description=Description +vradi.requestFormView.resultTable.name=Nom +vradi.requestFormView.resultTable.newQuery=Nouvelle requ\u00EAte +vradi.requestFormView.resultTable.oldQuery=Ancienne requ\u00EAte +vradi.requestFormView.resultTable.query=Requ\u00EAte +vradi.requestFormView.tab.table=Liste des requ\u00EAtes +vradi.requestFormView.tab.treetable=R\u00E9partition des requ\u00EAtes +vradi.requestFormView.title=Liste des requ\u00EAtes +vradi.requestSelectUI.description=Description +vradi.requestSelectUI.name=Nom +vradi.selectForm.title=Selection d'un formulaire li\u00E9 +vradi.status.category=Status +vradi.status.required.name=Ce champ est obligatoire +vradi.status.validate=Choisir le statut pour valider \: +vradi.stream.category=Flux xml +vradi.string.required.value=Ce champ est obligatoire +vradi.table.field.name=Champ +vradi.table.field.name.tip=Champ du mod\u00E8le OpenOffice \u00E0 remplacer +vradi.table.field.values=Valeur +vradi.table.field.values.tip=Valeur par laquelle le champ va \u00EAtre remplac\u00E9 +vradi.text.required.value=Ce champ est obligatoire +vradi.thesaurus.colomns.name=Nom +vradi.thesaurus.colomns.nbForm=Nombres de formulaires associ\u00E9s au descripteur +vradi.thesaurus.colomns.tags=Tags +vradi.thesaurus.colorTitle=Choisir une couleur pour la profondeur s\u00E9lectionn\u00E9e +vradi.thesaurus.commentToolTip=Commentaire \: +vradi.thesaurus.confirm.save=Sauvegarder +vradi.thesaurus.createNewRoot=Cr\u00E9er un th\u00E9saurus +vradi.thesaurus.expendByDefault=D\u00E9plier les descripteurs lors de la s\u00E9lection +vradi.thesaurus.name=Nom +vradi.thesaurus.nameToolTip=Chemin \: +vradi.thesaurus.nbforms=Nombre de formulaires attach\u00E9s +vradi.thesaurus.showApply=Montrer les implications +vradi.thesaurus.tags=Tags +vradi.thesaurus.tagsToolTip=Tags \: +vradi.thesaurus.toolTipTitle=Thesaurus \: %1$s +vradi.thesaurusCartographyUI.title=Cartographie des r\u00E9sultats de recherche +vradi.thesaurusQueryChangesUI.confirm.cancel=Vous allez annuler la modification des requ\u00EAtes.\nLes modifications des th\u00E9saurus sont d\u00E9j\u00E0 enregistr\u00E9es.\n\u00CAtes-vous s\u00FBr de vouloir continuer ? +vradi.title.about=A propos de Vradi... +vradi.title.welcome=Vradi +vradi.url.invalid.value= +vradi.url.required.value=Ce champ est obligatoire +vradi.user.category=Utilisateurs +vradi.vradiUser.regex.login=Ce champ n'est pas valide +vradi.vradiUser.required.login=Ce champ est obligatoire +vradi.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java. +vradi.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9 Property changes on: trunk/vradi-swing/src/main/resources/i18n/vradi-swing_fr_FR.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/icons/action-about.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-about.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-accept.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-accept.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-add.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-add.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-arrowDown.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-arrowDown.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-arrowLeft.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-arrowLeft.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-arrowRight.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-arrowRight.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-arrowUp.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-arrowUp.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-cancel.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-cancel.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-client_add.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-client_add.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-client_delete.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-client_delete.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-close.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-close.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-closeTab.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-closeTab.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-collapse.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-collapse.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-config.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-config.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-delete.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-delete.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-detach.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-detach.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-edit.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-edit.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-exit.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-exit.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-expand.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-expand.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-export.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-export.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-feed_add.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-feed_add.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-feed_delete.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-feed_delete.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-feed_magnify.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-feed_magnify.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-fileChooser.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-fileChooser.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-fullscreen.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-fullscreen.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-group_add.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-group_add.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-group_delete.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-group_delete.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-help.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-help.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-i18n-fr.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-i18n-fr.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-i18n-uk.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-i18n-uk.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-import.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-import.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-information.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-information.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-magnify.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-magnify.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-open.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-open.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-refresh.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-refresh.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-rename.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-rename.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-revert.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-revert.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-save.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-save.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-send.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-send.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-show-help.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-show-help.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-site.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-site.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-translate.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-translate.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/action-zoom.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/action-zoom.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/application_get.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/application_get.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/icons/time.png =================================================================== (Binary files differ) Property changes on: trunk/vradi-swing/src/main/resources/icons/time.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/vradi-swing/src/main/resources/log4j.properties =================================================================== --- trunk/vradi-swing/src/main/resources/log4j.properties (rev 0) +++ trunk/vradi-swing/src/main/resources/log4j.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,72 @@ +### +# #%L +# Vradi :: Swing +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +# Global logging configuration +log4j.rootLogger=ERROR, stdout, file + +# Console output +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.file=vradi.log +log4j.appender.file.MaxFileSize=10MB +log4j.appender.file.MaxBackupIndex=4 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p [%t] %c - %m%n + +# Vradi +log4j.logger.org.chorem.vradi=INFO +#log4j.logger.org.chorem.vradi.ui.admin.helpers.GroupNavigationTreeHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.admin.AdminHandler=DEBUG +#log4j.logger.org.chorem.vradi.VradiNotifier=DEBUG +#log4j.logger.org.chorem.vradi.services=DEBUG +#log4j.logger.org.chorem.vradi.ui.helpers.UIHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.admin.helpers.ClientNavigationTreeHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.email.helpers.EmailDataHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.thesaurus.helpers.ThesaurusTreeTableHelper=DEBUG +#log4j.logger.org.chorem.vradi.ui.email.helpers.SendingViewManager=DEBUG +#log4j.logger.org.chorem.vradi.ui.email.EmailHandler=DEBUG +#log4j.logger.org.chorem.vradi.ui.email.models.EmailEntityModel=DEBUG +#log4j.logger.org.chorem.vradi.services.managers.FormTypeManager=DEBUG + +# nuiton +log4j.logger.org.nuiton.i18n.Language=OFF + +# jaxx +#log4j.logger.jaxx.runtime.swing.navigation.handler.NavigationOneClicSelectionHandler=DEBUG +#log4j.logger.jaxx.runtime.swing.nav.treetable=DEBUG +#log4j.logger.jaxx.runtime.validator.swing.SwingValidator=ERROR +#log4j.logger.jaxx.runtime.swing.navigation.tree.NavigationTreeNode=ERROR +#log4j.logger.jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder=DEBUG + +# wikitty +log4j.logger.org.nuiton.wikitty=INFO +#log4j.logger.org.nuiton.wikitty.services.WikittyServiceCached=DEBUG + +# solr +log4j.logger.org.apache.solr=ERROR Property changes on: trunk/vradi-swing/src/main/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Client-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Client-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Client-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,42 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.client.name</message> + </field-validator> + </field> + + <field name="email"> + <field-validator type="email"> + <message>vradi.adminUi.invalid.email</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Client-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Group-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Group-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Group-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.group.name</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Group-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Status-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Status-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Status-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <!-- Name not null --> + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.status.required.name</message> + </field-validator> + </field> +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/Status-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/User-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/User-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/User-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,42 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.user.name</message> + </field-validator> + </field> + + <field name="email"> + <field-validator type="email"> + <message>vradi.adminUi.invalid.email</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/User-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/VradiUser-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/VradiUser-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/VradiUser-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,46 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <!-- pas d'URL selectionnee --> + <field name="login"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.vradiUser.required.login</message> + </field-validator> + <field-validator type="regex"> + <param name="expression">[a-zA-Z0-9_ ]+</param> + <message>vradi.vradiUser.regex.login</message> + </field-validator> + </field> + <field name="email"> + <field-validator type="email" short-circuit="true"> + <message>vradi.email.invalid.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/VradiUser-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/WebHarvestStream-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/WebHarvestStream-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/WebHarvestStream-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,55 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.name</message> + </field-validator> + </field> + <field name="url"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.url</message> + </field-validator> + <field-validator type="url"> + <message>vradi.adminUi.invalid.url</message> + </field-validator> + </field> + <field name="scriptUrl"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.url</message> + </field-validator> + <field-validator type="url"> + <message>vradi.adminUi.invalid.url</message> + </field-validator> + </field> + <field name="urlCommonSource"> + <field-validator type="url"> + <message>vradi.adminUi.invalid.url</message> + </field-validator> + </field> +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/WebHarvestStream-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/XmlStream-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/XmlStream-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/XmlStream-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,44 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + <field name="name"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.name</message> + </field-validator> + </field> + <field name="url"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.url</message> + </field-validator> + </field> + <field name="formTypeName"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.xmlStream.formTypeName</message> + </field-validator> + </field> +</validators> Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/entities/XmlStream-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/FieldSelectModel-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/FieldSelectModel-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/FieldSelectModel-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,48 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <!-- pas d'URL selectionnee --> + <field name="nameValue"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.adminUi.required.fieldselect.nameValue</message> + </field-validator> + <field-validator type="regex"> + <param name="expression"><![CDATA[[a-zA-Z0-9_]+]]></param> + <message>vradi.adminUi.regex.fieldselect.nameValue</message> + </field-validator> + </field> + + <field name="type"> + <field-validator type="required"> + <message>vradi.adminUi.required.fieldselect.type</message> + </field-validator> + </field> + + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/admin/models/FieldSelectModel-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/DateEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/DateEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/DateEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="required" short-circuit="true"> + <message>vradi.date.required.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/DateEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="email" short-circuit="true"> + <message>vradi.email.invalid.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,39 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.email.required.value</message> + </field-validator> + <field-validator type="email" short-circuit="true"> + <message>vradi.email.invalid.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/EmailEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/IdEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/IdEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/IdEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.string.required.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/IdEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/NumEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/NumEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/NumEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="required" short-circuit="true"> + <message>vradi.num.required.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/NumEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/StringEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/StringEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/StringEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.string.required.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/StringEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/TextEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/TextEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/TextEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.text.required.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/TextEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,36 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="simpleurl" short-circuit="true"> + <message>vradi.url.invalid.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-required-error-validation.xml =================================================================== --- trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-required-error-validation.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-required-error-validation.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,39 @@ +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="value"> + <field-validator type="requiredstring" short-circuit="true"> + <message>vradi.url.required.value</message> + </field-validator> + <field-validator type="simpleurl" short-circuit="true"> + <message>vradi.url.invalid.value</message> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/org/chorem/vradi/ui/offer/editors/UrlEditorModel-required-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/validators.xml =================================================================== --- trunk/vradi-swing/src/main/resources/validators.xml (rev 0) +++ trunk/vradi-swing/src/main/resources/validators.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + $Id$ + $HeadURL$ + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator Config 1.0//EN" + "http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd"> +<validators> + <!-- les validateurs fournis par XWork --> + <validator name="required" + class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/> + <validator name="requiredstring" + class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/> + <validator name="regex" + class="com.opensymphony.xwork2.validator.validators.RegexFieldValidator"/> + <validator name="stringlength" + class="com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator"/> + <validator name="int" + class="com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator"/> + <validator name="long" + class="com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator"/> + <validator name="short" + class="com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator"/> + <validator name="double" + class="com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator"/> + <validator name="date" + class="com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator"/> + <validator name="fieldexpression" + class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/> + <validator name="email" + class="com.opensymphony.xwork2.validator.validators.EmailValidator"/> + <validator name="url" + class="com.opensymphony.xwork2.validator.validators.URLValidator"/> + + <validator name="visitor" + class="com.opensymphony.xwork2.validator.validators.VisitorFieldValidator"/> + <validator name="conditionalvisitor" + class="com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator"/> + + <!-- les validateurs fournis par Jaxx --> + <validator name="collectionFieldExpression" + class="org.nuiton.validator.xwork2.field.CollectionFieldExpressionValidator"/> + <validator name="collectionUniqueKey" + class="org.nuiton.validator.xwork2.field.CollectionUniqueKeyValidator"/> + <validator name="requiredFile" + class="org.nuiton.validator.xwork2.field.RequiredFileFieldValidator"/> + <validator name="existingFile" + class="org.nuiton.validator.xwork2.field.ExistingFileFieldValidator"/> + <validator name="notExistingFile" + class="org.nuiton.validator.xwork2.field.NotExistingFileFieldValidator"/> + <validator name="existingDirectory" + class="org.nuiton.validator.xwork2.field.ExistingDirectoryFieldValidator"/> + <validator name="notExistingDirectory" + class="org.nuiton.validator.xwork2.field.NotExistingDirectoryFieldValidator"/> + <validator name="fieldexpressionwithparams" + class="org.nuiton.validator.xwork2.field.FieldExpressionWithParamsValidator"/> + + <!-- les validateurs spécifiques à ObServe --> + <validator name="simpleurl" + class="org.chorem.vradi.ui.offer.validators.SimpleUrlValidator"/> + + +</validators> Property changes on: trunk/vradi-swing/src/main/resources/validators.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/main/resources/vradi.properties =================================================================== --- trunk/vradi-swing/src/main/resources/vradi.properties (rev 0) +++ trunk/vradi-swing/src/main/resources/vradi.properties 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,105 @@ +### +# #%L +# Vradi :: Swing +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2010 Codelutin +# %% +# 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 3 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, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +application.name=${project.name} +application.version=${project.version} +application.site.url=http://vradi.labs.libre-entreprise.org/vradi/index.html +#licence.name=${project.licenses[0].license.name} +#licence.url=${project.licenses.0.url} +application.organisation.name=${project.organization.name} +application.organisation.url=${project.organization.url} + +# Wikitty +wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceHessianClient,\ +org.nuiton.wikitty.services.WikittyServiceNotifier,\ +org.nuiton.wikitty.services.WikittyServiceCached,\ +org.nuiton.wikitty.services.WikittyServiceSecurity +wikitty.service.cache.allwaysRestoreCopies=false +wikitty.service.event.propagate=false +wikitty.service.event.listen=true +wikitty.service.event.propagate.transporter=org.nuiton.wikitty.services.XMPPNotifierTransporter +wikitty.WikittyServiceCached.components=org.nuiton.wikitty.services.WikittyCacheJCS +wikitty.service.server.url=${vradi.remote.endpoint}/wikittyservice +wikitty.service.cache.priority.extensions=Thesaurus, User, Status, XmlStream +jcs.default= +jcs.default.cacheattributes.MaxObjects=1000 +jcs.priority.cacheattributes.MaxObjects=10000 + +# icones d'action (icon.action.nomAction=*.???) +icon.action.about=action-about.png +icon.action.accept=action-accept.png +icon.action.add=action-add.png +icon.action.arrowDown=action-arrowDown.png +icon.action.arrowLeft=action-arrowLeft.png +icon.action.arrowRight=action-arrowRight.png +icon.action.arrowUp=action-arrowUp.png +icon.action.remove=action-remove.png +icon.action.rename=action-rename.png +icon.action.cancel=action-cancel.png +icon.action.client.add=action-client_add.png +icon.action.client.delete=action-client_delete.png +icon.action.closeTab=action-closeTab.png +icon.action.close=action-close.png +icon.action.config=action-config.png +icon.action.delete=action-delete.png +icon.action.exit=action-exit.png +icon.action.export=action-export.png +icon.action.error=error.png +icon.action.feed.add=action-feed_add.png +icon.action.feed.delete=action-feed_delete.png +icon.action.feed.magnify=action-feed_magnify.png +icon.action.fullscreen=action-fullscreen.png +icon.action.fileChooser=action-fileChooser.png +icon.action.group.add=action-group_add.png +icon.action.group.delete=action-group_delete.png +icon.action.help=action-help.png +icon.action.history=time.png +icon.action.information=action-information.png +icon.action.import=action-import.png +icon.action.i18n-es=action-i18n-es.png +icon.action.i18n-fr=action-i18n-fr.png +icon.action.i18n-uk=action-i18n-uk.png +icon.action.leave-fullscreen=action-leave-fullscreen.png +icon.action.revert=action-revert.png +icon.action.save=action-save.png +icon.action.show-help=action-show-help.png +icon.action.send=action-send.png +icon.action.site=action-site.png +icon.action.sort=action-refresh.png +icon.action.unconnected=action-unconnected.png +icon.action.validate=action-validate.png +icon.action.warning=warning.png +icon.action.translate=action-translate.png +icon.action.expand=action-expand.png +icon.action.collapse=action-collapse.png +icon.action.detach=action-detach.png +icon.action.edit=action-edit.png +icon.action.move=action-arrowRight.png +icon.action.select=action-accept.png +icon.action.view=action-magnify.png +icon.action.search=action-magnify.png +icon.action.open=action-open.png + +color.BlockingLayerUI.blockingColor=50,50,50 \ No newline at end of file Property changes on: trunk/vradi-swing/src/main/resources/vradi.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/site/rst/index.rst =================================================================== --- trunk/vradi-swing/src/site/rst/index.rst (rev 0) +++ trunk/vradi-swing/src/site/rst/index.rst 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,33 @@ +.. - +.. * #%L +.. * Vradi +.. * +.. * $Id$ +.. * $HeadURL$ +.. * %% +.. * Copyright (C) 2009 - 2010 Codelutin +.. * %% +.. * 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 3 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, see +.. * <http://www.gnu.org/licenses/gpl-3.0.html>. +.. * #L% +.. - +VRADI :: Module Swing +===================== + +Le module Swing de VRADI contient les interfaces utilisateurs réalisées en JAXX. + +Vous pouvez lancer VRADI depuis la page suivante_ + +.. _suivante::jnlp-report.html + Property changes on: trunk/vradi-swing/src/site/rst/index.rst ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/site/site_fr.xml =================================================================== --- trunk/vradi-swing/src/site/site_fr.xml (rev 0) +++ trunk/vradi-swing/src/site/site_fr.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Vradi + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <menu ref="parent"/> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> \ No newline at end of file Property changes on: trunk/vradi-swing/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/test/java/org/chorem/vradi/VradiHelperTest.java =================================================================== --- trunk/vradi-swing/src/test/java/org/chorem/vradi/VradiHelperTest.java (rev 0) +++ trunk/vradi-swing/src/test/java/org/chorem/vradi/VradiHelperTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,74 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi; + +import org.junit.Assert; +import org.junit.Test; + +import java.awt.Color; +import java.util.Arrays; +import java.util.List; + +/** + * Test vradi helper methods. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class VradiHelperTest { + + /** + * Test string spliting. + * Test inner separator in string. + */ + @Test + public void stringToListTest() { + // no trap + String test = "111,222,333,444,555"; + List<String> tests = VradiHelper.stringToList(test); + Assert.assertEquals(5, tests.size()); + + // with trap + test = "111,\"222,333\",444,555"; + tests = VradiHelper.stringToList(test); + Assert.assertEquals(4, tests.size()); + } + + @Test + public void testGetColor() { + Color e = new Color(255, 34, 0); + System.out.println(e); + } + + @Test + public void testJoin() { + Assert.assertEquals("toto, \ntiti, \ntutu", VradiHelper.join(Arrays.asList(new String[]{"toto", "titi", "tutu"}), ", ", '\n', 6)); + Assert.assertEquals("toto, titi, \ntutu", VradiHelper.join(Arrays.asList(new String[]{"toto", "titi", "tutu"}), ", ", '\n', 12)); + Assert.assertEquals("tototototototototo, \ntiti, \ntutu", VradiHelper.join(Arrays.asList(new String[]{"tototototototototo", "titi", "tutu"}), ", ", '\n', 6)); + } +} Property changes on: trunk/vradi-swing/src/test/java/org/chorem/vradi/VradiHelperTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/test/java/org/chorem/vradi/services/FileServiceProxyTest.java =================================================================== --- trunk/vradi-swing/src/test/java/org/chorem/vradi/services/FileServiceProxyTest.java (rev 0) +++ trunk/vradi-swing/src/test/java/org/chorem/vradi/services/FileServiceProxyTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,59 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.services; + +import org.chorem.vradi.VradiConstants; +import org.junit.Assert; +import org.junit.Test; + +/** + * File service proxy tests. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class FileServiceProxyTest { + + /* + * Test that buildUrl method return url without double //. + */ + @Test + public void testBuildUrls() throws Exception { + FileServiceProxy proxy = new FileServiceProxy(null); + Assert.assertEquals("http://vradi/post", proxy.buildUrl("http://vradi/post", true)); + Assert.assertEquals("http://vradi/post", proxy.buildUrl("http://vradi/post/", true)); + Assert.assertEquals("http://vradi/post/template", proxy.buildUrl("http://vradi/post", true, "template")); + Assert.assertEquals("http://vradi/post/template/toto", proxy.buildUrl("http://vradi/post", true, "template", "toto")); + String url = proxy.buildUrl("http://dbdev/vradi", true, + VradiConstants.FileType.EMBEDDED_FORM_FILES.toString(), "2010-11-171f6c420d-94b4-472a-8a1b-797fa59c2111", + "ààà ééé.pdf"); + + Assert.assertEquals("http://dbdev/vradi/EMBEDDED_FORM_FILES/2010-11-171f6c420d-94b4-472a-8a1b-797...", + url); + } +} Property changes on: trunk/vradi-swing/src/test/java/org/chorem/vradi/services/FileServiceProxyTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ChangeLogUITest.java =================================================================== --- trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ChangeLogUITest.java (rev 0) +++ trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ChangeLogUITest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,58 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui; + +import org.apache.commons.lang.RandomStringUtils; +import org.junit.Test; + +/** + * ChangeLogUI. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class ChangeLogUITest { + + /** Test d'affichage d'un contenu énorme. */ + @Test + public void testDisplayHugeContent() { + + StringBuffer buffer = new StringBuffer(); + + for (int i = 0; i < 1000; ++i) { + String str = RandomStringUtils.randomAlphanumeric(100); + buffer.append(str + "\n"); + } + + ChangeLogUI clUI = new ChangeLogUI(); + clUI.getContent().setText(buffer.toString()); + clUI.setLocationRelativeTo(null); + clUI.setModal(false); + clUI.setVisible(true); + } +} Property changes on: trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/ChangeLogUITest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/XmlStreamHelperTest.java =================================================================== --- trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/XmlStreamHelperTest.java (rev 0) +++ trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/XmlStreamHelperTest.java 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,62 @@ +/* + * #%L + * Vradi :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Codelutin, Chatellier Eric + * %% + * 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package org.chorem.vradi.ui.helpers; + +import junit.framework.Assert; +import org.chorem.vradi.services.VradiException; +import org.jdom.Element; +import org.junit.Test; + +import java.net.URL; + +/** + * Test for XmlStreamHelper class. + * + * @author chatellier + * @version $Revision$ + * <p/> + * Last update : $Date$ + * By : $Author$ + */ +public class XmlStreamHelperTest { + + /** + * Test first rss stream element parsing. + * + * @throws VradiException + */ + @Test + public void testFirstElementParsing() throws VradiException { + + URL equipeRss = getClass().getResource("/rss/equipe_rss.xml"); + String rssUrl = equipeRss.toString(); + + Element element = XmlStreamHelper.getFirstElementJDom(rssUrl); + Assert.assertNotNull(element); + + element = XmlStreamHelper.getFirstElementXpp(rssUrl); + Assert.assertNotNull(element); + } +} Property changes on: trunk/vradi-swing/src/test/java/org/chorem/vradi/ui/helpers/XmlStreamHelperTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/vradi-swing/src/test/resources/rss/equipe_rss.xml =================================================================== --- trunk/vradi-swing/src/test/resources/rss/equipe_rss.xml (rev 0) +++ trunk/vradi-swing/src/test/resources/rss/equipe_rss.xml 2011-04-11 21:54:18 UTC (rev 1) @@ -0,0 +1,298 @@ +<?xml version="1.0" encoding="iso-8859-1" ?> +<!-- + #%L + Vradi :: Swing + + $Id$ + $HeadURL$ + %% + Copyright (C) 2009 - 2010 Codelutin + %% + 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 3 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, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <channel> + <title>L'Equipe.fr Actu Sport</title> + <link>http://www.lequipe.fr</link> + <description>Suivez l'actualit� des sports, les analyses, les r�sultats + sportifs, les calendriers des �v�nements sportifs + </description> + <language>fr</language> + <copyright>Copyright L'Equipe.fr</copyright> + <pubDate>Thu, 10 Jun 2010 18:51:01 +0200</pubDate> + <image> + <title>L'Equipe.fr</title> + <url>http://www.lequipe.fr/home/logo_RSS.gif</url> + <link>http://www.lequipe.fr</link> + <width>119</width> + <height>28</height> + </image> + <item> + <title>Cyclisme - Tour - Sastre dans le pr�s�lection</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Cyclisme/20100610_183853_sastre-dans-le-preselection.html</link> + <description>Touch� par une hernie discale, Carlos Sastre figure bien dans + la pr�s�lection du Tour de France publi�e par Cerv�lo... + </description> + <pubDate>Thu, 10 Jun 2010 18:38:00 +0200</pubDate> + </item> + <item> + <title>F1 - GP du Canada - Le Grand Prix d'apr�s</title> + <enclosure + url="http://www.lequipe.fr/Medias/Formule1/201006/270x197/le-circuit-gilles-ville..." + type="image/jpeg" length="8640"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Formule1/20100610_183311_le-grand-prix-d-apres.html</link> + <description> + <![CDATA[<img src='/Medias/Formule1/201006/270x197/le-circuit-gilles-villeneuve-hote-du-grand-prix-du-canada.jpg' width='154' align='left' border='0'> Apr�s un an d'absence, le Grand Prix du Canada est de nouveau au calendrier. Les deux pilotes Red Bull, Webber et... ]]></description> + <pubDate>Thu, 10 Jun 2010 18:33:00 +0200</pubDate> + </item> + <item> + <title>Tennis - WTA - Birmingham - Li en huiti�mes</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_182901_li-en-huitiemes.html</link> + <description>Na Li, t�te de s�rie num�ro 1, s'est qualifi�e jeudi pour les + huiti�mes de finale aux d�pens de la locale Anne... + </description> + <pubDate>Thu, 10 Jun 2010 18:29:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - Mandela a re�u Cristiano Ronaldo</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_182245_nelson-mandela-a-recu-cristiano-ronaldo.html</link> + <description>L'ancien pr�sident sud-africain Nelson Mandela, a re�u + mercredi � son domicile, Cristiano Ronaldo, a annonc� jeudi la... + </description> + <pubDate>Thu, 10 Jun 2010 18:22:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - AFS - Le m�me onze face au Mexique</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_180850_le-meme-onze-face-au-mexique.html</link> + <description>Alberto Parreira, le s�lectionneur sud-africain, a d�clar� ce + jeudi en conf�rence de presse qu'il ne comptait pas... + </description> + <pubDate>Thu, 10 Jun 2010 18:08:00 +0200</pubDate> + </item> + <item> + <title>Foot - Transferts - Brest enregistre deux renforts</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_180734_brest-enregistre-deux-renforts.html</link> + <description>Brest, fra�chement promu en Ligue 1, enregistre ses deux + premi�res recrues du mercato. Tomas Micola (21 ans, 1,78 m, 75... + </description> + <pubDate>Thu, 10 Jun 2010 18:07:00 +0200</pubDate> + </item> + <item> + <title>Foot - Amical - Le Japon d��oit encore</title> + <enclosure + url="http://www.lequipe.fr/Medias/Football/201006/270x197/le-japon-n-a-pas-su-se-..." + type="image/jpeg" length="8374"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_175840_le-japon-decoit-encore.html</link> + <description> + <![CDATA[<img src='/Medias/Football/201006/270x197/le-japon-n-a-pas-su-se-montrer-decisif-contre-le-zimbabwe-0-.jpg' width='154' align='left' border='0'> Le Japon affrontait jeudi le Zimbabwe, 110e �quipe mondiale, pour son dernier match de pr�paration en vue de la Coupe... ]]></description> + <pubDate>Thu, 10 Jun 2010 17:58:00 +0200</pubDate> + </item> + <item> + <title>Foot - Transferts - Un Espoir tch�que � Anderlecht</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_175504_un-espoir-tcheque-a-anderlecht.html</link> + <description>Anderlecht vient de recruter un international Espoirs tch�que + pour sa d�fense. Jan Lecjaks, lat�ral gauche de 20 ans,... + </description> + <pubDate>Thu, 10 Jun 2010 17:55:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - ARG - D�bat sur la forme de Messi</title> + <enclosure + url="http://www.lequipe.fr/Medias/Football/201006/270x197/messi-reve-de-la-coupe-..." + type="image/jpeg" length="6588"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_175307_debat-sur-la-forme-de-messi.html</link> + <description> + <![CDATA[<img src='/Medias/Football/201006/270x197/messi-reve-de-la-coupe-du-monde.jpg' width='154' align='left' border='0'> En Argentine, l'�tat de forme de Lionel Messi inqui�te la presse apr�s la saison harassante que vient de vivre le... ]]></description> + <pubDate>Thu, 10 Jun 2010 17:53:00 +0200</pubDate> + </item> + <item> + <title>Foot - Amical - Japon - Zimbabwe : 0-0</title> + <link/> + <description/> + <pubDate>Thu, 10 Jun 2010 17:35:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - ALL - Beckenbauer fan de L�w</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_172939_beckenbauer-fan-de-low.html</link> + <description>L'ancien capitaine, puis s�lectionneur de l'Allemagne, Franz + Beckenbauer a estim� lors du 60e Congr�s de la FIFA qu'il... + </description> + <pubDate>Thu, 10 Jun 2010 17:29:00 +0200</pubDate> + </item> + <item> + <title>Foot - Transferts - Sochaux pense � Aubemeyang</title> + <enclosure + url="http://www.lequipe.fr/Medias/Football/201006/270x197/pierre-emerick-aubameya..." + type="image/jpeg" length="7823"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_172636_sochaux-pense-a-aubemeyang.html</link> + <description> + <![CDATA[<img src='/Medias/Football/201006/270x197/pierre-emerick-aubameyang-etait-prete-cette-saison-par-l-ac-.jpg' width='154' align='left' border='0'> Le FC Sochaux pourrait conclure la semaine prochaine une ou plusieurs arriv�es. A l'heure actuelle, trois noms -Sauget,... ]]></description> + <pubDate>Thu, 10 Jun 2010 17:26:00 +0200</pubDate> + </item> + <item> + <title>Tennis - ATP - Halle - Federer en d�monstration</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_172259_federer-en-demonstration.html</link> + <description>Roger Federer (n�1), quintuple laur�at � Halle (2003, 2004, + 2005, 2006 et 2008), n'a eu besoin que de 51 petites... + </description> + <pubDate>Thu, 10 Jun 2010 17:22:00 +0200</pubDate> + </item> + <item> + <title>Foot - Transferts - Stoch (Chelsea) � Fenerbah�e</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_172153_stoch-chelsea-a-fenerbahce.html</link> + <description>Pr�t� l'an pass� � Twente par Chelsea, Miroslav Stoch ne + portera plus le maillot des Blues . Le milieu offensif... + </description> + <pubDate>Thu, 10 Jun 2010 17:21:00 +0200</pubDate> + </item> + <item> + <title>Tennis - WTA - Birmingham - Sharapova facile</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_171049_sharapova-facile.html</link> + <description>Maria Sharapova (n�2), qui avait vu son match du 2e tour face + � Bethanie Mattek-Sands interrompu par la pluie, la... + </description> + <pubDate>Thu, 10 Jun 2010 17:10:00 +0200</pubDate> + </item> + <item> + <title>Auto - 24h du Mans - L'ACO pr�pare 2011</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Formule1/20100610_170909_l-aco-prepare-2011.html</link> + <description>Comme chaque ann�e, l'Automobile Club de l'Ouest, + organisateur des 24 heures du Mans, a tenu sa traditionnelle... + </description> + <pubDate>Thu, 10 Jun 2010 17:09:00 +0200</pubDate> + </item> + <item> + <title>Rugby - Pro D2 - Montauban encore r�trograd�</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Rugby/20100610_165209_montauban-encore-retrograde.html</link> + <description>Clap de fin pour Montauban ? D�j� r�trograd� du Top 14 en + raison de difficult�s financi�res, Montauban s'est vu refuser... + </description> + <pubDate>Thu, 10 Jun 2010 16:52:00 +0200</pubDate> + </item> + <item> + <title>Cyclisme - Dauphin� - Vogondy devant Sicard !</title> + <enclosure + url="http://www.lequipe.fr/Medias/Cyclisme/201006/270x197/la-joie-de-vogondy-a-l-..." + type="image/jpeg" length="11459"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Cyclisme/20100610_165045_vogondy-devant-sicard.html</link> + <description> + <![CDATA[<img src='/Medias/Cyclisme/201006/270x197/la-joie-de-vogondy-a-l-arrivee-a-risoul.jpg' width='154' align='left' border='0'> Les coureurs fran�ais ont anim� avec bonheur la premi�re arriv�e en c�te, jeudi � Risoul : Nicolas Vogondy (BBox) s'est... ]]></description> + <pubDate>Thu, 10 Jun 2010 16:50:00 +0200</pubDate> + </item> + <item> + <title>Tennis - WTA - Brimingham - Reza�, enfin !</title> + <enclosure + url="http://www.lequipe.fr/Medias/Tennis/201005/270x197/aravane-rezai-a-concede-u..." + type="image/jpeg" length="10655"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_164338_rezai-solide.html</link> + <description> + <![CDATA[<img src='/Medias/Tennis/201005/270x197/aravane-rezai-a-concede-un-set-face-a-kerber-sans-consequenc.jpg' width='154' align='left' border='0'> Programm�e mardi, finalement d�but�e mercredi mais interrompue apr�s seulement deux jeux � cause de la pluie, la... ]]></description> + <pubDate>Thu, 10 Jun 2010 16:43:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - FRA - Reclus, mais sensibles � tout</title> + <enclosure + url="http://www.lequipe.fr/Medias/Football/201004/270x197/les-bleus-chercheront-a..." + type="image/jpeg" length="7200"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100414_224444_reclus-mais-sensibles-a-tout.html</link> + <description> + <![CDATA[<img src='/Medias/Football/201004/270x197/les-bleus-chercheront-a-s-isoler.jpg' width='154' align='left' border='0'> Plus que jamais, l'�quipe de France tente de se couper du monde � l'h�tel Pezula de Knysna en Afrique du Sud, comme... ]]></description> + <pubDate>Wed, 14 Apr 2010 22:44:00 +0200</pubDate> + </item> + <item> + <title>Tennis - ATP - Halle - Zverev surprend Melzer</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_162924_zverev-surprend-melzer.html</link> + <description>J�rgen Melzer (n�6), r�cent demi-finaliste � Roland-Garros, + s'est inclin� en huiti�mes de finale � Halle, jeudi, face... + </description> + <pubDate>Thu, 10 Jun 2010 16:29:00 +0200</pubDate> + </item> + <item> + <title>Rugby - Transferts - S-B. Williams rentre au pays</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Rugby/20100610_162551_s-b-williams-rentre-au-pays.html</link> + <description>La f�d�ration n�o-z�landaise est arriv�e � ses fins : Sonny + Bill Williams rentre au pays apr�s deux ann�es pass�es �... + </description> + <pubDate>Thu, 10 Jun 2010 16:25:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - La finale r�v�e de Pel�</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_162110_la-finale-revee-de-pele.html</link> + <description>La l�gende du football br�silien Pel� esp�re que son pays + atteindra la finale du Mondial 2010 face � une formation... + </description> + <pubDate>Thu, 10 Jun 2010 16:21:00 +0200</pubDate> + </item> + <item> + <title>Tennis - WTA - Birmingham - Lucic continue</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_160901_lucic-continue.html</link> + <description>Issue des qualifications et tombeuse de Mariana Duque Marino + au 1er tour, Mirjana Lucic, l'ex-enfant prodige du tennis... + </description> + <pubDate>Thu, 10 Jun 2010 16:09:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - ITA - Zambrotta : �On sera � la hauteur�</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_160944_zambrotta-on-sera-a-la-hauteur.html</link> + <description>Le d�fenseur lat�ral de l'Italie, Gianluca Zambrotta a + assur�, jeudi, qu'il faudrait compter sur l'Italie lors du... + </description> + <pubDate>Thu, 10 Jun 2010 16:09:00 +0200</pubDate> + </item> + <item> + <title>Rugby - Transferts - Lea'aetoa, un an � Bayonne</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Rugby/20100610_160547_lea-aetoa-un-an-a-bayonne.html</link> + <description>Apr�s une petite saison pass�e � Toulon, Tonga Lea'aetoa (33 + ans, 1,83 m, 123 kg) quitte la Rade pour Bayonne. Le... + </description> + <pubDate>Thu, 10 Jun 2010 16:05:00 +0200</pubDate> + </item> + <item> + <title>Tennis - ATP - Queen's - Sela s'offre Roddick</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Tennis/20100610_155227_sela-s-offre-roddick.html</link> + <description>Belle performance pour Dudi Sela. L'Isra�lien, t�te de s�rie + num�ro 14, a domin� Andy Roddick (n�4), quadruple laur�at... + </description> + <pubDate>Thu, 10 Jun 2010 15:52:00 +0200</pubDate> + </item> + <item> + <title>Cyclisme - Tour - Soler incertain</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Cyclisme/20100610_155259_soler-incertain.html</link> + <description>Bless� au genou lors de la premi�re �tape du Crit�rium du + Dauphin�, �limin� � l'issue du contre-la-montre de mercredi... + </description> + <pubDate>Thu, 10 Jun 2010 15:52:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - ALG - Mansouri sur le banc</title> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_154716_mansouri-sur-le-banc.html</link> + <description>Le s�lectionneur alg�rien Rabah Saadane a confi� jeudi que + son capitaine Yazid Mansouri d�buterait le match face � la... + </description> + <pubDate>Thu, 10 Jun 2010 15:47:00 +0200</pubDate> + </item> + <item> + <title>Foot - CM - BRE - Alves pas surpris pour Henry</title> + <enclosure + url="http://www.lequipe.fr/Medias/Football/201006/270x197/le-bresilien-daniel-alv..." + type="image/jpeg" length="6776"/> + <link>http://www.lequipe.fr/redir.php?ORIG=RSS&RUB=homeG&URL=http://www.lequipe.fr/Football/20100610_153704_alves-pas-surpris-pour-henry.html</link> + <description> + <![CDATA[<img src='/Medias/Football/201006/270x197/le-bresilien-daniel-alves.jpg' width='154' align='left' border='0'> Partenaire de Thierry Henry depuis deux ans au FC Barcelone, Daniel Alves a confi� jeudi en conf�rence de presse ne pas... ]]></description> + <pubDate>Thu, 10 Jun 2010 15:37:00 +0200</pubDate> + </item> + </channel> +</rss> \ No newline at end of file Property changes on: trunk/vradi-swing/src/test/resources/rss/equipe_rss.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native