From 76aa74990e660c981fca824db176a56b281281fa Mon Sep 17 00:00:00 2001 From: Willem Date: Sat, 10 Jun 2017 02:22:01 +0200 Subject: [PATCH] WIP: left over open files for long... --- pom.xml | 4 - todo.txt | 1 + vasc-backend/pom.xml | 1 + .../vasc/backend/AbstractVascBackend.java | 142 -------- .../AbstractVascBackendControllerLocal.java | 61 ++-- .../backend/AbstractVascBackendLocal.java | 87 +++++ .../backend/AbstractVascBackendRecord.java | 8 + .../forwardfire/vasc/backend/VascBackend.java | 90 +----- ...ult.java => VascBackendAccessDataKey.java} | 27 +- ....java => VascBackendAccessDataRecord.java} | 8 +- .../vasc/backend/VascBackendController.java | 7 +- .../backend/VascBackendControllerLocal.java | 11 +- .../vasc/backend/VascBackendLifeCycle.java | 10 + .../vasc/backend/VascBackendLocal.java | 8 + .../vasc/backend/crud/VascBackendCrud.java} | 28 +- .../VascBackendCrudRevision.java} | 22 +- .../vasc/backend/crud/package-info.java | 8 + .../AbstractVascBackendAccessDataKey.java} | 39 ++- .../data/BeanVascBackendAccessDataKey.java | 75 +++++ ...a => BeanVascBackendAccessDataRecord.java} | 62 ++-- .../data/HashMapVascBackendAccessDataKey.java | 104 ++++++ ...> HashMapVascBackendAccessDataRecord.java} | 46 +-- .../DefaultVascBackendListRequest.java} | 82 ++--- .../DefaultVascBackendListResult.java} | 59 ++-- .../vasc/backend/list/VascBackendList.java | 71 ++++ .../VascBackendListFeature.java} | 28 +- .../VascBackendListRequest.java} | 18 +- .../VascBackendListResult.java} | 11 +- .../vasc/backend/list/package-info.java | 8 + .../select/DefaultVascBackendSelectItem.java | 62 ++++ .../backend/select/VascBackendSelect.java | 12 + .../VascBackendSelectItem.java} | 19 +- .../vasc/backend/select/package-info.java | 8 + .../backend/jdbc/AbstractJdbcVascBackend.java | 87 +++++ .../vasc/backend/jdbc/JdbcVascBackend.java | 169 ---------- .../backend/jdbc/JdbcVascBackendList.java | 147 +++++++++ .../backend/jdbc/JdbcVascBackendSelect.java | 111 +++++++ .../JdbcVascBackendXpqlList.java} | 142 ++++---- .../vasc/backend/jdbc/xpql/package-info.java | 8 + vasc-backend/vasc-backend-jpa/pom.xml | 57 ++-- .../jpa/AbstractPersistenceVascBackend.java | 89 ++--- .../jpa/PersistanceVascBackendCrud.java | 161 ++++++++++ ...va => PersistanceVascBackendXpqlList.java} | 248 +++++++------- .../backend/ldap/AbstractLdapVascBackend.java | 119 +++++++ ...cBackend.java => LdapVascBackendCrud.java} | 161 ++-------- .../backend/ldap/LdapVascBackendList.java | 220 +++++++++++++ .../AbstractMetaModelVascBackend.java | 142 ++++++++ ...MetaModelVascBackendAccessDataRecord.java} | 42 +-- .../metamodel/MetaModelVascBackendCrud.java | 143 +++++++++ ...end.java => MetaModelVascBackendList.java} | 213 +++--------- .../metamodel/RowVascEntryRecordCreator.java | 25 -- .../mongodb/AbstractMongodbVascBackend.java | 104 ++++++ .../backend/mongodb/MongodbVascBackend.java | 191 ----------- .../MongodbVascBackendAccessDataKey.java | 78 +++++ .../MongodbVascBackendAccessDataRecord.java} | 56 ++-- .../mongodb/MongodbVascBackendCrud.java | 91 ++++++ .../mongodb/MongodbVascBackendList.java | 127 ++++++++ .../mongodb/MongodbVascBackendSelect.java | 70 ++++ vasc-backend/vasc-backend-object/.project | 23 ++ vasc-backend/vasc-backend-object/pom.xml | 18 ++ .../object/ObjectEnumVascBackendSelect.java | 141 ++++++++ .../ObjectEnumVascBackendSelectType.java | 9 + .../object}/VascSelectItemModelEntry.java | 303 +++++++++--------- .../vasc/backend/object/package-info.java | 8 + .../vasc/backend/test/CrudTest.java | 40 +-- vasc-core-ejb3-client/pom.xml | 47 +-- .../vasc/ejb3/VascServiceRemoteBackend.java | 26 +- vasc-core-ejb3-server/pom.xml | 61 ++-- .../vasc/ejb3/VascServiceManagerImpl.java | 4 +- vasc-core/pom.xml | 91 +++--- .../VascChoicesSelectItemModel.java | 10 +- .../proxy/AbstractVascBackendProxy.java | 198 ++++-------- .../AbstractVascBackendProxyFeature.java} | 91 ++---- .../vasc/backend/proxy/VascBackendProxy.java | 9 +- .../backend/proxy/VascBackendProxyCache.java | 167 ---------- .../proxy/VascBackendProxyEventExecutor.java | 28 +- .../backend/proxy/VascBackendProxyFilter.java | 31 +- .../backend/proxy/VascBackendProxyPaged.java | 51 ++- .../backend/proxy/VascBackendProxySearch.java | 100 ++---- .../backend/proxy/VascBackendProxySort.java | 49 ++- .../proxy/VascBackendProxyTimerLogger.java | 68 +--- .../core/AbstractVascEntryFieldLocal.java | 8 +- .../vasc/core/AbstractVascEntryState.java | 16 +- .../vasc/core/VascEntryConfigController.java | 6 +- .../core/VascEntryConfigControllerLocal.java | 4 +- .../forwardfire/vasc/core/VascEntryField.java | 4 +- .../vasc/core/VascEntryFieldLocal.java | 4 +- .../forwardfire/vasc/core/VascEntryState.java | 12 +- .../vasc/core/VascInterfaceLoader.java | 4 +- .../vasc/core/ui/VascSelectItemModel.java | 3 +- .../DefaultVascEntryConfigController.java | 32 +- .../vasc/impl/DefaultVascFactory.java | 4 +- .../vasc/impl/DefaultVascInterfaceLoader.java | 6 +- .../entry/SetParameterBackendListener.java | 6 +- .../entry/config/VascDefaultsFinalizer.java | 4 +- .../entry/config/VascIdCheckFinalizer.java | 4 +- .../frontend/DefaultVascFrontendActions.java | 14 +- .../frontend/DefaultVascFrontendHelper.java | 10 +- .../frontend/DefaultVascFrontendPager.java | 4 +- .../impl/jndi/JndiVascControllerFactory.java | 4 +- .../ui/VascSelectItemModelStringEnum.java | 181 ----------- .../x4o/VascBackendElementConfigurator.java | 4 +- .../x4o/VascEntryLinkParameterElement.java | 2 +- .../vasc/demo/client/swing/JMainPanel.java | 4 +- .../server/ui/load/LoadVascXmlWriter.java | 8 +- vasc-demo/vasc-demo-tech-domain/.project | 11 + .../model/AbstractPetStoreEntity.java | 25 -- .../model/AbstractPetStoreVascBackend.java | 87 ++++- .../tech/domain/petstore/model/Category.java | 21 +- .../petstore/model/CategoryProduct.java | 24 +- .../demo/tech/domain/petstore/model/Item.java | 31 +- .../domain/petstore/model/ItemInventory.java | 23 +- .../domain/petstore/model/ItemSupplier.java | 17 +- .../tech/domain/petstore/model/Order.java | 18 +- .../tech/domain/petstore/model/OrderLine.java | 19 +- .../domain/petstore/model/OrderStatus.java | 17 +- .../domain/petstore/model/UserAccount.java | 19 +- .../domain/petstore/model/UserCredential.java | 19 +- .../domain/petstore/model/UserProfile.java | 20 +- vasc-demo/vasc-demo-tech-web/pom.xml | 196 +++++------ .../generic/VascEntryExportWriterCsv.java | 2 +- .../generic/VascEntryExportWriterXml.java | 4 +- vasc-frontend/pom.xml | 1 + vasc-frontend/vasc-frontend-api/.project | 23 ++ vasc-frontend/vasc-frontend-api/pom.xml | 11 + .../vasc/frontend/api/event/package-info.java | 8 + .../vasc/frontend/api/package-info.java | 8 + .../vasc/frontend/api/view/VascView.java | 5 + .../frontend/api/view/VascViewComponent.java | 5 + .../frontend/api/view/VascViewContainer.java | 7 + .../vasc/frontend/api/view/VascViewField.java | 12 + .../frontend/api/view/VascViewFieldPanel.java | 5 + .../vasc/frontend/api/view/package-info.java | 8 + .../api/view/table/VascViewTable.java | 7 + .../api/view/table/VascViewTableColumn.java | 7 + .../frontend/api/view/table/package-info.java | 8 + .../vasc/frontend/api/TestViewApi.java | 14 + .../vasc-frontend-cxf-server/pom.xml | 100 +++--- vasc-frontend/vasc-frontend-swing/pom.xml | 74 +++-- .../vasc/frontend/swing/ui/SwingList.java | 8 +- vasc-frontend/vasc-frontend-swt/pom.xml | 5 + .../vasc/frontend/swt/SwtActionPanel.java | 2 +- .../vasc/frontend/swt/SwtVascEditDialog.java | 2 +- .../vasc/frontend/swt/SwtVascFrontend.java | 2 +- .../vasc/frontend/swt/ui/SwtList.java | 14 +- .../vasc-frontend-web-export/pom.xml | 67 ++-- vasc-frontend/vasc-frontend-web-jsf/pom.xml | 89 +++-- .../AbstractJSFVascFacesControllerBase.java | 4 +- .../AbstractJSFVascFacesControllerEJB.java | 4 +- .../web/jsf/JSFVascEntrySupportBean.java | 4 +- .../frontend/web/jsf/VascDataBackendBean.java | 6 +- .../vasc/frontend/web/jsf/ui/JSFList.java | 6 +- .../frontend/web/jsf/ui/JSFListModel.java | 12 +- vasc-lib/vasc-lib-xpql/pom.xml | 75 ++--- .../execute/jpa/XpqlQueryManagerImpl.java | 6 +- .../vasc/xpql/impl/DefaultQuery.java | 58 +--- .../vasc/xpql/impl/QueryInclude.java | 25 +- .../vasc/xpql/impl/QueryParameter.java | 13 +- .../forwardfire/vasc/xpql/impl/QueryText.java | 15 +- .../vasc/xpql/query/AbstractQuery.java | 2 +- .../vasc/xpql/query/AbstractQueryPart.java | 92 ------ .../vasc/xpql/query/QueryPart.java | 11 +- .../vasc/opt/editor/VirtualVascBackend.java | 62 ++-- .../metamodel/MetaModelSchemaAutoEntry.java | 26 +- .../data/TestModelVascDataSource.java | 57 ++-- 165 files changed, 4299 insertions(+), 3373 deletions(-) delete mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{DefaultVascBackendResult.java => VascBackendAccessDataKey.java} (69%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{VascEntryFieldValue.java => VascBackendAccessDataRecord.java} (82%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java rename vasc-backend/{vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java => vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java} (67%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{data/HashMapVascEntryRecordCreator.java => crud/VascBackendCrudRevision.java} (73%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java rename vasc-backend/{vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java => vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java} (64%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/{BeanVascEntryFieldValue.java => BeanVascBackendAccessDataRecord.java} (65%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/{HashMapVascEntryFieldValue.java => HashMapVascBackendAccessDataRecord.java} (65%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{AbstractVascBackendState.java => list/DefaultVascBackendListRequest.java} (66%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{AbstractVascBackendResult.java => list/DefaultVascBackendListResult.java} (55%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{DefaultVascBackendState.java => list/VascBackendListFeature.java} (76%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{VascBackendState.java => list/VascBackendListRequest.java} (80%) rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{VascBackendResult.java => list/VascBackendListResult.java} (85%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java rename vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/{VascEntryRecordCreator.java => select/VascBackendSelectItem.java} (81%) create mode 100644 vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java create mode 100644 vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java delete mode 100644 vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java create mode 100644 vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java create mode 100644 vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java rename vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/{JdbcVascBackendXpql.java => xpql/JdbcVascBackendXpqlList.java} (55%) create mode 100644 vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java create mode 100644 vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java rename vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/{XpqlPersistanceVascBackend.java => PersistanceVascBackendXpqlList.java} (65%) create mode 100644 vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/AbstractLdapVascBackend.java rename vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/{LdapVascBackend.java => LdapVascBackendCrud.java} (63%) create mode 100644 vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendList.java create mode 100644 vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/AbstractMetaModelVascBackend.java rename vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/{RowVascEntryFieldValue.java => MetaModelVascBackendAccessDataRecord.java} (61%) create mode 100644 vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendCrud.java rename vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/{MetaModelVascBackend.java => MetaModelVascBackendList.java} (55%) delete mode 100644 vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java create mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/AbstractMongodbVascBackend.java delete mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java create mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataKey.java rename vasc-backend/{vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryRecordCreator.java => vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataRecord.java} (54%) create mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendCrud.java create mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendList.java create mode 100644 vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendSelect.java create mode 100644 vasc-backend/vasc-backend-object/.project create mode 100644 vasc-backend/vasc-backend-object/pom.xml create mode 100644 vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelect.java create mode 100644 vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelectType.java rename {vasc-core/src/main/java/net/forwardfire/vasc/impl/ui => vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object}/VascSelectItemModelEntry.java (56%) create mode 100644 vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/package-info.java rename vasc-core/src/main/java/net/forwardfire/vasc/{core/ui/VascSelectItem.java => backend/proxy/AbstractVascBackendProxyFeature.java} (53%) delete mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java delete mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java delete mode 100644 vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreEntity.java create mode 100644 vasc-frontend/vasc-frontend-api/.project create mode 100644 vasc-frontend/vasc-frontend-api/pom.xml create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/event/package-info.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/package-info.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascView.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewComponent.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewContainer.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewField.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewFieldPanel.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/package-info.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTable.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTableColumn.java create mode 100644 vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/package-info.java create mode 100644 vasc-frontend/vasc-frontend-api/src/test/java/net/forwardfire/vasc/frontend/api/TestViewApi.java delete mode 100644 vasc-lib/vasc-lib-xpql/src/main/java/net/forwardfire/vasc/xpql/query/AbstractQueryPart.java diff --git a/pom.xml b/pom.xml index a35d8cc..463f9d6 100644 --- a/pom.xml +++ b/pom.xml @@ -124,10 +124,6 @@ 6.0 - 3.0 - 1.1 - 1.0.2 - 3.0-alpha-1 1.0-MR1 1.2 2.2.1-b03 diff --git a/todo.txt b/todo.txt index c51961a..cc19459 100644 --- a/todo.txt +++ b/todo.txt @@ -35,3 +35,4 @@ - create XML-RPC frontend - export interface + exports - graphs of numeric value columns +- Add JETT export templates support diff --git a/vasc-backend/pom.xml b/vasc-backend/pom.xml index e9168cc..658c2f4 100644 --- a/vasc-backend/pom.xml +++ b/vasc-backend/pom.xml @@ -18,5 +18,6 @@ vasc-backend-metamodel vasc-backend-api vasc-backend-test + vasc-backend-object diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java deleted file mode 100644 index 40b4c1d..0000000 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackend.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.vasc.backend; - -import java.io.Serializable; - -/** - * AbstractVascBackend. - * - * - * @author Willem Cazander - * @version 1.0 Aug 2, 2007 - */ -abstract public class AbstractVascBackend implements VascBackend { - - private String id = null; - - /** - * @see net.forwardfire.vasc.backend.VascBackend#getId() - */ - @Override - public String getId() { - return id; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String) - */ - @Override - public void setId(String id) { - if (id==null) { - throw new IllegalArgumentException("id may not be null"); - } - this.id=id; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#startBackend() - */ - @Override - public void startBackend() { - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#stopBackend() - */ - @Override - public void stopBackend() { - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isReadOnly() - */ - @Override - public boolean isReadOnly() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isPageable() - */ - @Override - public boolean isPageable() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSearchable() - */ - @Override - public boolean isSearchable() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSortable() - */ - @Override - public boolean isSortable() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable() - */ - @Override - public boolean isRecordMoveable() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveDownById(java.lang.Object) - */ - @Override - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { - return 0l; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#doRecordMoveUpById(java.lang.Object) - */ - @Override - public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException { - return 0l; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() - */ - @Override - public boolean hasPageSummary() { - return false; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary() - */ - @Override - public boolean hasTotalSummary() { - return false; - } -} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java index 2ebba7f..defe0b5 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendControllerLocal.java @@ -22,14 +22,12 @@ package net.forwardfire.vasc.backend; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; - /** * AbstractVascBackendControllerLocal * @@ -38,18 +36,16 @@ import java.util.Map; */ abstract public class AbstractVascBackendControllerLocal implements VascBackendControllerLocal { - private Map> backends = null; + private Map backends = null; public AbstractVascBackendControllerLocal() { - backends = new HashMap>(1000); + backends = new HashMap(1000); } - /** - * @see net.forwardfire.vasc.backend.VascBackendController#getVascBackendById(java.lang.String) - */ @Override - public VascBackend getVascBackendById(String id) { - return backends.get(id); + @SuppressWarnings("unchecked") + public BACKEND_TYPE getVascBackendById(Class clazz,String id) { + return (BACKEND_TYPE) backends.get(id); } /** @@ -64,44 +60,49 @@ abstract public class AbstractVascBackendControllerLocal implements VascBackendC Collections.sort(result); // lets do abc for consistance behauvior. return result; } - + /** - * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.VascBackend) + * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#addVascBackend(net.forwardfire.vasc.backend.crud.VascBackendCrud) */ - @SuppressWarnings("unchecked") @Override - public void addVascBackend(VascBackend backend) { + public void addVascBackend(VascBackend backend) { if (backend==null) { throw new NullPointerException("backend must not be null."); } if (backend.getId()==null) { throw new IllegalArgumentException("The backend must have an id."); } - backend.startBackend(); - VascBackend castedBackend = (VascBackend) backend; - backends.put(backend.getId(), castedBackend); + backends.put(backend.getId(), backend); } - /** - * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#removeVascBackendById(java.lang.String) - */ @Override - public void removeVascBackendById(String backendId) { - VascBackend backend = getVascBackendById(backendId); - if (backend==null) { - throw new NullPointerException("Could not find backend to remove with id: "+backendId); + public VascBackend removeVascBackend(VascBackend backend) { + VascBackend result = getVascBackendById(VascBackend.class,backend.getId()); + if (result==null) { + throw new NullPointerException("Could not find backend to remove with id: "+backend.getId()); } - backend.stopBackend(); - backends.remove(backendId); + return backends.remove(backend.getId()); } - /** - * @see net.forwardfire.vasc.backend.VascBackendControllerLocal#clearAndStopBackends() - */ @Override - public void clearAndStopBackends() { + public void stopBackends() { for (String backendId:getVascBackendIds()) { - removeVascBackendById(backendId); + VascBackend vb = getVascBackendById(VascBackend.class,backendId); + if (vb instanceof VascBackendLocal) { + VascBackendLocal vbl = (VascBackendLocal)vb; + vbl.stopBackend(); + } + } + } + + @Override + public void startBackends() { + for (String backendId:getVascBackendIds()) { + VascBackend vb = getVascBackendById(VascBackend.class,backendId); + if (vb instanceof VascBackendLocal) { + VascBackendLocal vbl = (VascBackendLocal)vb; + vbl.startBackend(); + } } } } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java new file mode 100644 index 0000000..e7f0dd3 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendLocal.java @@ -0,0 +1,87 @@ +package net.forwardfire.vasc.backend; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Objects; + +abstract public class AbstractVascBackendLocal implements VascBackendLocal { + + private static final String CHECK_MSG_ID = " in "; + private String id = null; + private volatile boolean running = false; + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackend#getId() + */ + @Override + final public String getId() { + return id; + } + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendLocal#setId(java.lang.String) + */ + @Override + final public void setId(String id) { + if (id==null) { + throw new IllegalArgumentException("id may not be null"); + } + if (this.id!=null) { + throw new IllegalStateException("Can't change id after setting."); + } + this.id=id; + } + + abstract protected void startBackendLocal(); + protected void stopBackendLocal() { + } + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendLocal#startBackend() + */ + @Override + final public void startBackend() { + requireNonEmpty(getId(),"id is empty."); + startBackendLocal(); + running = true; + } + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendLocal#stopBackend() + */ + @Override + final public void stopBackend() { + stopBackendLocal(); + running = false; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendLifeCycle#isRunning() + */ + @Override + final public boolean isRunning() { + return running; + } + + final private String createCheckMessage(String message) { + return message + CHECK_MSG_ID + getId(); + } + + final protected void requireNonNull(Object value, String message) { + Objects.requireNonNull(value, createCheckMessage(message)); + } + + final protected void requireNonEmpty(String value, String message) { + requireNonNull(value, message); + if (value.isEmpty()) { + throw new IllegalArgumentException(createCheckMessage(message)); + } + } + + final protected void requireNonEmpty(Collection value, String message) { + requireNonNull(value, message); + if (value.isEmpty()) { + throw new IllegalArgumentException(createCheckMessage(message)); + } + } +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java new file mode 100644 index 0000000..0e0da4e --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendRecord.java @@ -0,0 +1,8 @@ +package net.forwardfire.vasc.backend; + +import java.io.Serializable; + +public abstract interface AbstractVascBackendRecord extends VascBackend { + + VascBackendAccessDataRecord createVascBackendAccessDataRecord(); +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java index c39f231..7c52f8a 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackend.java @@ -1,96 +1,10 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - package net.forwardfire.vasc.backend; import java.io.Serializable; -/** - * VascBackend provides stateless data access to a data source. - * - * @author Willem Cazander - * @version 1.0 Mar 21, 2007 - */ -public interface VascBackend { +public interface VascBackend { String getId(); - void setId(String id); - void startBackend(); - void stopBackend(); - - VascBackendResult execute(VascBackendState state) throws VascBackendException; - - boolean isReadOnly(); - - //public DATA_OBJECT fetch(Map pks) throws VascBackendException; - - void persist(DATA_OBJECT record) throws VascBackendException; - - DATA_OBJECT merge(DATA_OBJECT record) throws VascBackendException; - - void delete(DATA_OBJECT record) throws VascBackendException; - - /** - * Creates a new Field acces obj the the given field entry. - * note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle. - * @return - */ - VascEntryFieldValue provideVascEntryFieldValue(); - - /** - * Creates a new RecordCreater obj the the given entry. - * note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle. - * @return - */ - VascEntryRecordCreator provideVascEntryRecordCreator(); - - /** - * Defines if the backend supports sorting - * @return - */ - boolean isSortable(); - - /** - * Defines if the backend supports pageing - * @return - */ - boolean isPageable(); - - /** - * Defines if the backend supports pageing - * @return - */ - boolean isSearchable(); - - /** - * Defines if the backend supports moveing an record up or down. - * @return - */ - boolean isRecordMoveable(); - long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException; - long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException; - - boolean hasPageSummary(); - - boolean hasTotalSummary(); + VascBackendAccessDataKey createVascBackendAccessDataKey(); } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java similarity index 69% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java index 68d113c..981ece1 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendResult.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataKey.java @@ -23,28 +23,21 @@ package net.forwardfire.vasc.backend; import java.io.Serializable; -import java.util.List; import java.util.Map; + /** - * DefaultVascBackendResult. + * VascEntryFieldValue * * @author Willem Cazander - * @version 1.0 Aug 23, 2014 + * @version 1.0 Oct 24, 2014 */ -public final class DefaultVascBackendResult extends AbstractVascBackendResult { +public interface VascBackendAccessDataKey extends Serializable { - public DefaultVascBackendResult(List pageData) { - this(pageData,-1); - } + Map> getKeyMapType(); + Map getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException; + DATA_PK getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException; - public DefaultVascBackendResult(List pageData,long totalSize) { - this(pageData,totalSize,null,null); - } - - public DefaultVascBackendResult(List pageData, long totalSize, - Map pageSummary, - Map totalSummary) { - super(pageData, totalSize, pageSummary, totalSummary); - } -} + Map getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException; + DATA_PK getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException; +} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java similarity index 82% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java index 8ce072f..2d4118a 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryFieldValue.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendAccessDataRecord.java @@ -31,11 +31,11 @@ import java.io.Serializable; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascEntryFieldValue extends Serializable { +public interface VascBackendAccessDataRecord extends Serializable { - Serializable getValue(String backendName,DATA_OBJECT record) throws VascBackendException; + DATA_PK getPrimaryKey(DATA_RECORD record) throws VascBackendException; - String getDisplayValue(String backendName,DATA_OBJECT record) throws VascBackendException; + Serializable getValue(String backendName,DATA_RECORD record) throws VascBackendException; - void setValue(String backendName,DATA_OBJECT record,Serializable value) throws VascBackendException; + void setValue(String backendName,DATA_RECORD record,Serializable value) throws VascBackendException; } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java index 92ac6de..6aab34b 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendController.java @@ -22,18 +22,17 @@ package net.forwardfire.vasc.backend; -import java.io.Serializable; import java.util.List; - /** + * VascBackendController. * * @author Willem Cazander * @version 1.0 Sep 4, 2008 */ public interface VascBackendController { - VascBackend getVascBackendById(String id); + BACKEND_TYPE getVascBackendById(Class clazz,String id); List getVascBackendIds(); -} \ No newline at end of file +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java index 60b732b..cb21bfe 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendControllerLocal.java @@ -22,9 +22,6 @@ package net.forwardfire.vasc.backend; -import java.io.Serializable; - - /** * * @author Willem Cazander @@ -32,9 +29,11 @@ import java.io.Serializable; */ public interface VascBackendControllerLocal extends VascBackendController { - void addVascBackend(VascBackend backend); + void addVascBackend(VascBackend backend); - void removeVascBackendById(String backendId); + VascBackend removeVascBackend(VascBackend backend); - void clearAndStopBackends(); + void startBackends(); + + void stopBackends(); } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java new file mode 100644 index 0000000..f2b5d4a --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLifeCycle.java @@ -0,0 +1,10 @@ +package net.forwardfire.vasc.backend; + +import java.io.Serializable; + +public interface VascBackendLifeCycle extends VascBackend { + + void startBackend(); + void stopBackend(); + boolean isRunning(); +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java new file mode 100644 index 0000000..fbd76d3 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendLocal.java @@ -0,0 +1,8 @@ +package net.forwardfire.vasc.backend; + +import java.io.Serializable; + +public interface VascBackendLocal extends VascBackendLifeCycle { + + void setId(String id); +} diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java similarity index 67% rename from vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java index 7f32411..dc57218 100644 --- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryRecordCreator.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrud.java @@ -20,26 +20,28 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +package net.forwardfire.vasc.backend.crud; -package net.forwardfire.vasc.backend.mongodb; +import java.io.Serializable; +import net.forwardfire.vasc.backend.AbstractVascBackendRecord; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; - -import com.mongodb.BasicDBObject; /** - * Provides a mongodb object to create a new row. + * VascBackendCrud provides stateless data access to a data source. * * @author Willem Cazander - * @version 1.0 Dec 30, 2011 + * @version 1.0 Mar 21, 2007 */ -public class MongodbVascEntryRecordCreator implements VascEntryRecordCreator { - - private static final long serialVersionUID = -9213830731796787384L; +public interface VascBackendCrud extends AbstractVascBackendRecord { - @Override - public BasicDBObject newRecord() throws VascBackendException { - return new BasicDBObject(); - } + public DATA_RECORD fetch(DATA_PK recordPK) throws VascBackendException; + + DATA_RECORD persist(DATA_RECORD record) throws VascBackendException; + + DATA_RECORD merge(DATA_RECORD record) throws VascBackendException; + + void delete(DATA_PK recordPK) throws VascBackendException; + + DATA_RECORD newRecord() throws VascBackendException; } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java similarity index 73% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java index b2fb32a..3321c30 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryRecordCreator.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/VascBackendCrudRevision.java @@ -20,26 +20,24 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend.data; +package net.forwardfire.vasc.backend.crud; import java.io.Serializable; -import java.util.HashMap; +import java.util.List; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; /** - * MapVascEntryRecordCreator creates a new HashMap for Map based record backends. + * VascBackendCrudRevision idea test. * * @author Willem Cazander - * @version 1.0 Dec 05, 2009 + * @version 1.0 Mar 25, 2014 */ -public class HashMapVascEntryRecordCreator implements VascEntryRecordCreator> { +public interface VascBackendCrudRevision extends VascBackendCrud { - private static final long serialVersionUID = 1L; - - @Override - public HashMap newRecord() throws VascBackendException { - return new HashMap(10); - } + List revisionList(DATA_PK recordPK) throws VascBackendException; + + void revisionDelete(String version) throws VascBackendException; + + DATA_RECORD revisionFetch(DATA_PK recordPK,String version) throws VascBackendException; } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java new file mode 100644 index 0000000..973576d --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/crud/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.backend.crud; \ No newline at end of file diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java similarity index 64% rename from vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java index 2cdde42..45e7a4a 100644 --- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascEntryFieldValue.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/AbstractVascBackendAccessDataKey.java @@ -20,38 +20,35 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend.mongodb; +package net.forwardfire.vasc.backend.data; import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryFieldValue; - -import com.mongodb.BasicDBObject; /** - * Provides a mongodb field entry knowlege. + * AbstractVascBackendAccessDataKey. + * note: all types need to have a String constructor ot * * @author Willem Cazander - * @version 1.0 Dec 30, 2011 + * @version 1.0 Oct 27, 2014 */ -public class MongodbVascEntryFieldValue implements VascEntryFieldValue { +@SuppressWarnings("serial") +abstract public class AbstractVascBackendAccessDataKey implements VascBackendAccessDataKey { - private static final long serialVersionUID = -7371273796529818557L; - - @Override - public Serializable getValue(String backendName, BasicDBObject row) throws VascBackendException { - Serializable data = (Serializable) row.get(backendName); - return data; + private final Map> keyMapType; + + public AbstractVascBackendAccessDataKey(Map> keyMapType) { + this.keyMapType = keyMapType; } - + @Override - public String getDisplayValue(String field, BasicDBObject row) throws VascBackendException { - return ""+getValue(field,row); - } - - @Override - public void setValue(String backendName, BasicDBObject row, Serializable value) throws VascBackendException { - row.put(backendName, value); + public final Map> getKeyMapType() { + return keyMapType; } } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java new file mode 100644 index 0000000..bb03b95 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataKey.java @@ -0,0 +1,75 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.data; + + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; + +import org.x4o.xml.element.DefaultElementObjectPropertyValue; + +/** + * BeanVascBackendAccessDataKey provides primary key support on beans. + * + * @author Willem Cazander + * @version 1.0 Oct 27, 2014 + */ +@SuppressWarnings("serial") +public class BeanVascBackendAccessDataKey extends AbstractVascBackendAccessDataKey { + + private final Class primaryKeyType; + private final DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue(); + + public BeanVascBackendAccessDataKey(Class primaryKeyType,Map> keyMapType) { + super(keyMapType); + this.primaryKeyType=primaryKeyType; + } + + @Override + public Map getKeyMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException { + Map result = new HashMap(); + + return result; + } + + @Override + public DATA_PK getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException { + //DATA_PK result = primaryKeyType.newInstance(); + return null; + } + + @Override + public Map getStringMapFromPrimaryKey(DATA_PK primaryKey) throws VascBackendException { + return null; + } + + @Override + public DATA_PK getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException { + return null; + } +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java similarity index 65% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java index f6a6461..59ae248 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryFieldValue.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascBackendAccessDataRecord.java @@ -26,26 +26,40 @@ package net.forwardfire.vasc.backend.data; import java.io.Serializable; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import org.x4o.xml.element.DefaultElementObjectPropertyValue; /** - * BeanVascEntryFieldValue provides get/set support for bean based backends. + * BeanVascBackendAccessDataRecord provides get/set support for bean based backends. * * @author Willem Cazander * @version 1.0 Dec 05, 2009 */ -public class BeanVascEntryFieldValue implements VascEntryFieldValue { +@SuppressWarnings("serial") +public class BeanVascBackendAccessDataRecord implements VascBackendAccessDataRecord { - private static final long serialVersionUID = 1L; + private final String primaryKeyProperty; private DefaultElementObjectPropertyValue bean = new DefaultElementObjectPropertyValue(); + public BeanVascBackendAccessDataRecord(String primaryKeyProperty) { + this.primaryKeyProperty = primaryKeyProperty; + } + /** - * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable) */ @Override - public Serializable getValue(String backendName, DATA_OBJECT record) throws VascBackendException { + @SuppressWarnings("unchecked") + public DATA_PK getPrimaryKey(DATA_RECORD record) throws VascBackendException { + return (DATA_PK) getValue(primaryKeyProperty, record); + } + + /** + * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object) + */ + @Override + public Serializable getValue(String backendName, DATA_RECORD record) throws VascBackendException { if (backendName==null) { throw new NullPointerException("Can't get value of null backendName."); } @@ -59,42 +73,12 @@ public class BeanVascEntryFieldValue implement throw new VascBackendException(e); } } - + /** - * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object) + * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object) */ @Override - public String getDisplayValue(String backendName, DATA_OBJECT record) throws VascBackendException { - Serializable value = getValue(backendName,record); - if (value==null) { - return ""; - } - return value.toString(); - - /* TODO: move - if (field.getDisplayName()==null) { - if (value instanceof String) { - return (String)value; - } - return ""+value; - } - try { - Object result = bean.getProperty(value, field.getDisplayName()); - if (result instanceof String) { - return (String)result; - } - return ""+result; - } catch (Exception e) { - throw new VascBackendException(e); - } - */ - } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object) - */ - @Override - public void setValue(String backendName, DATA_OBJECT record,Serializable value) throws VascBackendException { + public void setValue(String backendName, DATA_RECORD record,Serializable value) throws VascBackendException { if (backendName==null) { throw new NullPointerException("Can't set value of null backendName."); } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java new file mode 100644 index 0000000..eb8e459 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataKey.java @@ -0,0 +1,104 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.data; + +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import net.forwardfire.vasc.backend.VascBackendException; + +/** + * HashMapVascBackendAccessDataKey provides get/set support on Map key object. + * note: all types need to have a String constructor. + * + * @author Willem Cazander + * @version 1.0 Oct 26, 2014 + */ +@SuppressWarnings("serial") +public class HashMapVascBackendAccessDataKey extends AbstractVascBackendAccessDataKey> { + + public HashMapVascBackendAccessDataKey(Map> keyMapType) { + super(keyMapType); + } + + @Override + public Map getKeyMapFromPrimaryKey(HashMap primaryKey) throws VascBackendException { + return new HashMap(primaryKey); // wrap only as key is already object map + } + + @Override + public HashMap getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException { + return new HashMap(keyMap); // wrap only as key is already object map + } + + @Override + public Map getStringMapFromPrimaryKey(HashMap primaryKey) throws VascBackendException { + HashMap result = new HashMap(primaryKey.size()); + for (String key:primaryKey.keySet()) { + Serializable value = primaryKey.get(key); + if (value == null) { + result.put(key, null); + } else { + result.put(key, value.toString()); + } + } + return result; + } + + @Override + public HashMap getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException { + try { + HashMap result = new HashMap(keyMap.size()); + for (String key:keyMap.keySet()) { + String valueStr = keyMap.get(key); + Class valueType = getKeyMapType().get(key); + if (valueType == null) { + throw new IllegalArgumentException("unknown key: "+key); + } + if (valueStr == null) { + result.put(key, null); + continue; + } + Constructor valueObj = valueType.getConstructor(new Class[]{String.class}); + Object value = valueObj.newInstance(new Object[]{valueStr}); + result.put(key, (Serializable)value); + } + return result; + } catch (NoSuchMethodException e) { + throw new VascBackendException(e); + } catch (SecurityException e) { + throw new VascBackendException(e); + } catch (InstantiationException e) { + throw new VascBackendException(e); + } catch (IllegalAccessException e) { + throw new VascBackendException(e); + } catch (IllegalArgumentException e) { + throw new VascBackendException(e); + } catch (InvocationTargetException e) { + throw new VascBackendException(e); + } + } +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java similarity index 65% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java index bfee46f..957e61a 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascEntryFieldValue.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/HashMapVascBackendAccessDataRecord.java @@ -24,22 +24,40 @@ package net.forwardfire.vasc.backend.data; import java.io.Serializable; import java.util.HashMap; +import java.util.Map; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; /** - * MapVascEntryFieldValue provides get/set support on Map record object. + * HashMapVascBackendAccessDataRecord provides get/set support on Map record object. * * @author Willem Cazander * @version 1.0 Dec 05, 2009 */ -public class HashMapVascEntryFieldValue implements VascEntryFieldValue> { - - private static final long serialVersionUID = 1L; +@SuppressWarnings("serial") +public class HashMapVascBackendAccessDataRecord implements VascBackendAccessDataRecord,HashMap> { + private final Map> keyMapType; + + public HashMapVascBackendAccessDataRecord(Map> keyMapType) { + this.keyMapType = keyMapType; + } + /** - * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable) + */ + @Override + public HashMap getPrimaryKey(HashMap record) throws VascBackendException { + HashMap result = new HashMap(keyMapType.size()); + for (String key:keyMapType.keySet()) { + result.put(key, record.get(key)); + } + return result; + } + + /** + * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object) */ @Override public Serializable getValue(String backendName,HashMap map) throws VascBackendException { @@ -52,21 +70,9 @@ public class HashMapVascEntryFieldValue implements VascEntryFieldValue record) throws VascBackendException { - Serializable fieldValue = getValue(field,record); - if (fieldValue==null) { - fieldValue = ""; - } - return fieldValue.toString(); - } - - /** - * @see net.forwardfire.vasc.core.entry.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object) + * @see net.forwardfire.vasc.core.entry.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object) */ @Override public void setValue(String backendName, HashMap map,Serializable value) throws VascBackendException { diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java similarity index 66% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java index d26ee06..11e44fa 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendState.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListRequest.java @@ -20,20 +20,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; +package net.forwardfire.vasc.backend.list; import java.util.HashMap; import java.util.Map; import java.util.Set; + + /** + * Holds the state for the backend * * @author Willem Cazander * @version 1.0 May 26, 2009 */ -abstract public class AbstractVascBackendState implements VascBackendState { - - private static final long serialVersionUID = 1L; +@SuppressWarnings("serial") +public class DefaultVascBackendListRequest implements VascBackendListRequest { + protected Map parameters = null; private int pageIndex = 0; private int pageSize = 0; @@ -41,38 +44,25 @@ abstract public class AbstractVascBackendState implements VascBackendState { private String sortField = null; private String searchString = null; private boolean ascending = true; - //private long pagesTotalRecords = 0; - public AbstractVascBackendState() { + public DefaultVascBackendListRequest() { parameters = new HashMap(10); } - /** - * @see net.forwardfire.vasc.backend.VascBackendState#setDataParameter(java.lang.String, java.lang.Object) - */ - @Override public void setDataParameter(String key, Object data) { parameters.put(key,data); } - - /** - * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameter(java.lang.String) - */ - @Override + public void removeDataParameter(String key) { parameters.remove(key); } - - /** - * @see net.forwardfire.vasc.backend.VascBackendState#removeDataParameterAll() - */ - @Override + public void removeDataParameterAll() { parameters.clear(); } /** - * @see net.forwardfire.vasc.backend.VascBackendState#getDataParameter(java.lang.String) + * @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameter(java.lang.String) */ @Override public Object getDataParameter(String key) { @@ -80,7 +70,7 @@ abstract public class AbstractVascBackendState implements VascBackendState { } /** - * @see net.forwardfire.vasc.backend.VascBackendState#getDataParameterKeys() + * @see net.forwardfire.vasc.backend.list.VascBackendListRequest#getDataParameterKeys() */ @Override public Set getDataParameterKeys() { @@ -88,85 +78,65 @@ abstract public class AbstractVascBackendState implements VascBackendState { } /** - * @see net.forwardfire.vasc.backend.VascBackend#getPageIndex() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageIndex() */ @Override public int getPageIndex() { return pageIndex; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#setPageIndex(int) - */ - @Override + public void setPageIndex(int pageIndex) { this.pageIndex=pageIndex; } - + /** - * @see net.forwardfire.vasc.backend.VascBackend#getPageSize() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getPageSize() */ @Override public int getPageSize() { return pageSize; } - /** - * @see net.forwardfire.vasc.backend.VascBackend#setPageSize(int) - */ - @Override public void setPageSize(int pageSize) { this.pageSize=pageSize; } /** - * @see net.forwardfire.vasc.backend.VascBackend#getSearchString() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSearchString() */ @Override public String getSearchString() { return searchString; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#setSearchString(java.lang.String) - */ - @Override + public void setSearchString(String searchString) { this.searchString=searchString; } - + /** - * @see net.forwardfire.vasc.backend.VascBackend#isSortAscending() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#isSortAscending() */ @Override public boolean isSortAscending() { return ascending; } - /** - * @see net.forwardfire.vasc.backend.VascBackend#setSortAscending(boolean) - */ - @Override public void setSortAscending(boolean ascending) { this.ascending=ascending; } - + /** - * @see net.forwardfire.vasc.backend.VascBackend#getSortField() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getSortField() */ @Override public String getSortField() { return sortField; } - /** - * @see net.forwardfire.vasc.backend.VascBackend#setSortField(java.lang.String) - */ - @Override public void setSortField(String sortField) { this.sortField=sortField; } - + /** * @return the pageSizeMax */ @@ -174,11 +144,7 @@ abstract public class AbstractVascBackendState implements VascBackendState { public int getPageSizeMax() { return pageSizeMax; } - - /** - * @param pageSizeMax the pageSizeMax to set - */ - @Override + public void setPageSizeMax(int pageSizeMax) { this.pageSizeMax = pageSizeMax; } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java similarity index 55% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java index 36a6e20..c9be9a1 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/AbstractVascBackendResult.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/DefaultVascBackendListResult.java @@ -20,61 +20,60 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; +package net.forwardfire.vasc.backend.list; import java.io.Serializable; import java.util.List; import java.util.Map; /** - * AbstractVascBackendResult. + * DefaultVascBackendResult. * * @author Willem Cazander * @version 1.0 Aug 23, 2014 */ -abstract public class AbstractVascBackendResult implements VascBackendResult { - - private final List pageData; - private final long totalSize; - private final Map pageSummary; - private final Map totalSummary; +@SuppressWarnings("serial") +public final class DefaultVascBackendListResult implements VascBackendListResult { - public AbstractVascBackendResult(List pageData,long totalSize,Map pageSummary,Map totalSummary) { - this.pageData = pageData; - this.totalSize = totalSize; - this.pageSummary = pageSummary; - this.totalSummary = totalSummary; + private final List data; + private final long totalRecordCount; + private final Map> dataExtra; + + public DefaultVascBackendListResult(List data) { + this(data,data.size()); + } + + public DefaultVascBackendListResult(List data,long totalRecordCount) { + this(data,totalRecordCount,null); + } + + public DefaultVascBackendListResult(List data,long totalRecordCount,Map> dataExtra) { + this.data = data; + this.totalRecordCount = totalRecordCount; + this.dataExtra = dataExtra; } /** - * @see net.forwardfire.vasc.backend.VascBackendResult#getPageData() + * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getData() */ @Override - public List getPageData() { - return pageData; + public List getData() { + return data; } /** - * @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSize() + * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getTotalRecordCount() */ @Override - public long getTotalSize() { - return totalSize; + public long getTotalRecordCount() { + return totalRecordCount; } /** - * @see net.forwardfire.vasc.backend.VascBackendResult#getPageSummary() + * @see net.forwardfire.vasc.backend.list.VascBackendListResult#getDataExtra() */ @Override - public Map getPageSummary() { - return pageSummary; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackendResult#getTotalSummary() - */ - @Override - public Map getTotalSummary() { - return totalSummary; + public Map> getDataExtra() { + return dataExtra; } } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java new file mode 100644 index 0000000..6a6097f --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendList.java @@ -0,0 +1,71 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.list; + +import java.io.Serializable; +import java.util.EnumSet; +import java.util.List; + +import net.forwardfire.vasc.backend.AbstractVascBackendRecord; +import net.forwardfire.vasc.backend.VascBackendException; + +/** + * VascBackendList provides stateless data access to a data source which result one or multiple results. + * + * @author Willem Cazander + * @version 1.0 Aug 25, 2014 + */ +public interface VascBackendList extends AbstractVascBackendRecord { + + final static String ROW_ACTION_MOVE_UP = "rowActionMoveUp"; + final static String ROW_ACTION_MOVE_DOWN = "rowActionMoveDown"; + final static String ROW_ACTION_DELETE = "rowActionDelete"; + + /** + * Defines the features this list backend supports. + * @return An enum set of feature flags. + */ + EnumSet getSupportedFeatures(); + + /** + * Executes the list request with parameters to return a list result. + * @param request + * @return + * @throws VascBackendException + */ + VascBackendListResult execute(VascBackendListRequest request) throws VascBackendException; + + /** + * @return Returns the action names of the row actions we support. + */ + List getSupportedRowActions(); + + /** + * Executes a single row action on one or more rows of fresh data. + * @param request + * @param recordPKs + * @param actionName + * @throws VascBackendException + */ + void executeRowAction(VascBackendListRequest request,List recordPKs,String actionName) throws VascBackendException; +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java similarity index 76% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java index 654ea8d..f39f02a 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/DefaultVascBackendState.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListFeature.java @@ -20,16 +20,28 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; - +package net.forwardfire.vasc.backend.list; /** - * Holds the state for the backend + * VascBackendListFeatures. * * @author Willem Cazander - * @version 1.0 May 26, 2009 + * @version 1.0 Aug 26, 2014 */ -public class DefaultVascBackendState extends AbstractVascBackendState { - - private static final long serialVersionUID = 8828343641448595993L; -} \ No newline at end of file +public enum VascBackendListFeature { + + /** Defines if the backend supports sorting. */ + SORT_DATA, + SORT_DATA_PROXY, + + /** Defines if the backend supports paging. */ + PAGE_DATA, + PAGE_DATA_PROXY, + + /** Defines if the backend support full text search. */ + TEXT_SEARCH, + TEXT_SEARCH_PROXY, + + DATA_EXTRA, + DATA_EXTRA_PROXY; +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java similarity index 80% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java index 4f9cc52..ecb56be 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendState.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListRequest.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; +package net.forwardfire.vasc.backend.list; import java.io.Serializable; import java.util.Set; @@ -31,28 +31,20 @@ import java.util.Set; * @author Willem Cazander * @version 1.0 May 26, 2009 */ -public interface VascBackendState extends Serializable { +public interface VascBackendListRequest extends Serializable { - void setDataParameter(String key,Object data); - void removeDataParameter(String key); - void removeDataParameterAll(); Object getDataParameter(String key); Set getDataParameterKeys(); - + String getSortField(); - void setSortField(String name); + boolean isSortAscending(); - void setSortAscending(boolean ascending); - - void setPageSize(int size); + int getPageSize(); - void setPageSizeMax(int size); int getPageSizeMax(); - void setPageIndex(int index); int getPageIndex(); - void setSearchString(String searchString); String getSearchString(); } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java similarity index 85% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java index 205fadc..5f65c6c 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascBackendResult.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/VascBackendListResult.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; +package net.forwardfire.vasc.backend.list; import java.io.Serializable; import java.util.List; @@ -32,10 +32,9 @@ import java.util.Map; * @author Willem Cazander * @version 1.0 Aug 23, 2014 */ -public interface VascBackendResult { +public interface VascBackendListResult extends Serializable { - List getPageData(); - long getTotalSize(); - Map getPageSummary(); - Map getTotalSummary(); + List getData(); + long getTotalRecordCount(); + Map> getDataExtra(); } diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java new file mode 100644 index 0000000..a40f6c2 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/list/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.backend.list; \ No newline at end of file diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java new file mode 100644 index 0000000..c957ab2 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/DefaultVascBackendSelectItem.java @@ -0,0 +1,62 @@ +package net.forwardfire.vasc.backend.select; + +import java.io.Serializable; + +public class DefaultVascBackendSelectItem implements VascBackendSelectItem { + + private final boolean header; + private final boolean enabled; + private final String name; + private final boolean nameI18nKey; + private final String description; + private final boolean descriptionI18nKey; + private final DATA_PK primaryKey; + + public DefaultVascBackendSelectItem(boolean header, boolean enabled, + String name, boolean nameI18nKey, String description, + boolean descriptionI18nKey, DATA_PK primaryKey) { + super(); + this.header = header; + this.enabled = enabled; + this.name = name; + this.nameI18nKey = nameI18nKey; + this.description = description; + this.descriptionI18nKey = descriptionI18nKey; + this.primaryKey = primaryKey; + } + + @Override + public boolean isHeader() { + return header; + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isNameI18nKey() { + return nameI18nKey; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public boolean isDescriptionI18nKey() { + return descriptionI18nKey; + } + + @Override + public DATA_PK getPrimaryKey() { + return primaryKey; + } +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java new file mode 100644 index 0000000..4b9c753 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelect.java @@ -0,0 +1,12 @@ +package net.forwardfire.vasc.backend.select; + +import java.io.Serializable; +import java.util.List; + +import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.VascBackendException; + +public interface VascBackendSelect extends VascBackend { + + List> execute() throws VascBackendException; +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java similarity index 81% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java rename to vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java index e5d197e..5480223 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/VascEntryRecordCreator.java +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/VascBackendSelectItem.java @@ -20,17 +20,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend; +package net.forwardfire.vasc.backend.select; import java.io.Serializable; - /** * * @author Willem Cazander - * @version 1.0 Mar 21, 2007 + * @version 1.0 Aug 12, 2007 */ -public interface VascEntryRecordCreator extends Serializable { - - DATA_OBJECT newRecord() throws VascBackendException; -} \ No newline at end of file +public interface VascBackendSelectItem { + + boolean isHeader(); + boolean isEnabled(); + String getName(); + boolean isNameI18nKey(); + String getDescription(); + boolean isDescriptionI18nKey(); + DATA_PK getPrimaryKey(); +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java new file mode 100644 index 0000000..d385214 --- /dev/null +++ b/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/select/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.backend.select; \ No newline at end of file diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java new file mode 100644 index 0000000..c1fd70e --- /dev/null +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/AbstractJdbcVascBackend.java @@ -0,0 +1,87 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.jdbc; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey; + +/** + * AbstractJdbcVascBackend. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +abstract public class AbstractJdbcVascBackend extends AbstractVascBackendLocal> { + + private JdbcConnectionProvider jdbcConnectionProvider = null; + private final Map> keyMapType = new HashMap>(5); + + abstract protected void startBackendJdbc(); + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal() + */ + @Override + protected final void startBackendLocal() { + requireNonNull(getJdbcConnectionProvider(), "jdbcConnectionProvider is null."); + requireNonEmpty(keyMapType.keySet(), "No primary keys defined."); + startBackendJdbc(); + } + + protected final void addKeyMapType(String field,Class fieldType) { + requireNonEmpty(field,"field has to have value"); + requireNonNull(fieldType,"field has to have value"); + keyMapType.put(field, fieldType); + } + + protected final Map> getKeyMapType() { + return keyMapType; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey() + */ + @Override + public final VascBackendAccessDataKey> createVascBackendAccessDataKey() { + return new HashMapVascBackendAccessDataKey(keyMapType); + } + + /** + * @return the JdbcConnectionProvider + */ + public final JdbcConnectionProvider getJdbcConnectionProvider() { + return jdbcConnectionProvider; + } + + /** + * @param JdbcConnectionProvider the JdbcConnectionProvider to set + */ + public final void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) { + this.jdbcConnectionProvider = jdbcConnectionProvider; + } +} diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java deleted file mode 100644 index b805ee0..0000000 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackend.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.vasc.backend.jdbc; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; -import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; -import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue; -import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator; - -/** - * JdbcVascBackend Simple jdbc vasc backend. - * - * @author Willem Cazander - * @version 1.0 Sep 5, 2008 - */ -public class JdbcVascBackend extends AbstractVascBackend> { - - private JdbcConnectionProvider jdbcConnectionProvider = null; - private String sqlList = null; - //private String idColumn = null; - //private String sqlDelete = null; - //private String sqlUpdate = null; - //private String sqlInsert = null; - - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() - */ - @Override - public boolean isReadOnly() { - return true; - } - - /** - * @return the JdbcConnectionProvider - */ - public JdbcConnectionProvider getJdbcConnectionProvider() { - return jdbcConnectionProvider; - } - - /** - * @param JdbcConnectionProvider the JdbcConnectionProvider to set - */ - public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) { - this.jdbcConnectionProvider = jdbcConnectionProvider; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult> execute(VascBackendState state) throws VascBackendException { - JdbcConnectionProvider prov = getJdbcConnectionProvider(); - List> result = new ArrayList>(50); - Connection connection = null; - try { - connection = prov.getJdbcConnection(); - Statement s = connection.createStatement(); - s.execute(getSqlList()); - ResultSet rs = s.getResultSet(); - int cols = rs.getMetaData().getColumnCount(); - while (rs.next()) { - HashMap map = new HashMap(cols); - for (int i=1;i<=cols;i++) { - String columnName = rs.getMetaData().getColumnName(i); - Object columnObject = rs.getObject(i); - map.put(columnName, columnObject); - } - result.add(map); - } - } catch (SQLException e) { - throw new VascBackendException(e); - } finally { - if (connection!=null) { - try { - connection.close(); - } catch (Exception e) { - } - } - } - - return new DefaultVascBackendResult>(result); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) - */ - @Override - public HashMap merge(HashMap object) throws VascBackendException { - return object; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) - */ - @Override - public void persist(HashMap object) throws VascBackendException { - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object) - */ - @Override - public void delete(HashMap object) throws VascBackendException { - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue(net.forwardfire.vasc.core.VascEntryField) - */ - @Override - public VascEntryFieldValue provideVascEntryFieldValue() { - return new HashMapVascEntryFieldValue(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator(net.forwardfire.vasc.core.VascEntry) - */ - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return new HashMapVascEntryRecordCreator(); - } - - /** - * @return the sqlList - */ - public String getSqlList() { - return sqlList; - } - - /** - * @param sqlList the sqlList to set - */ - public void setSqlList(String sqlList) { - this.sqlList = sqlList; - } -} diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java new file mode 100644 index 0000000..fd53174 --- /dev/null +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendList.java @@ -0,0 +1,147 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.jdbc; + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; + +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; + +/** + * JdbcVascBackend Simple jdbc vasc backend. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class JdbcVascBackendList extends AbstractJdbcVascBackend implements VascBackendList,HashMap> { + + private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class); + private final List rowActions = new ArrayList(); + private String query = null; + private String queryExtra = null; + + @Override + protected void startBackendJdbc() { + requireNonEmpty(getQuery(), "query is empty."); + if (queryExtra!=null && !queryExtra.isEmpty()) { + features.add(VascBackendListFeature.DATA_EXTRA); + } + } + + @Override + public VascBackendAccessDataRecord, HashMap> createVascBackendAccessDataRecord() { + return new HashMapVascBackendAccessDataRecord(getKeyMapType()); + } + + @Override + public EnumSet getSupportedFeatures() { + return features; + } + + @Override + public List getSupportedRowActions() { + return rowActions; + } + + @Override + public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException { + } + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendList#execute(VascBackendListRequest state) + */ + @Override + public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException { + JdbcConnectionProvider prov = getJdbcConnectionProvider(); + List> result = new ArrayList>(50); + Connection connection = null; + try { + connection = prov.getJdbcConnection(); + Statement s = connection.createStatement(); + s.execute(getQuery()); + ResultSet rs = s.getResultSet(); + int cols = rs.getMetaData().getColumnCount(); + while (rs.next()) { + HashMap map = new HashMap(cols); + for (int i=1;i<=cols;i++) { + String columnName = rs.getMetaData().getColumnName(i); + Serializable columnObject = (Serializable) rs.getObject(i); + map.put(columnName, columnObject); + } + result.add(map); + } + } catch (SQLException e) { + throw new VascBackendException(e); + } finally { + if (connection!=null) { + try { + connection.close(); + } catch (Exception e) { + } + } + } + return new DefaultVascBackendListResult>(result); + } + + /** + * @return the query + */ + public String getQuery() { + return query; + } + + /** + * @param query the query to set + */ + public void setQuery(String query) { + this.query = query; + } + + /** + * @return the queryExtra + */ + public String getQueryExtra() { + return queryExtra; + } + + /** + * @param queryExtra the queryExtra to set + */ + public void setQueryExtra(String queryExtra) { + this.queryExtra = queryExtra; + } +} diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java new file mode 100644 index 0000000..963026d --- /dev/null +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendSelect.java @@ -0,0 +1,111 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.jdbc; + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; + +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; +import net.forwardfire.vasc.backend.select.VascBackendSelect; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; + +/** + * JdbcVascBackend Simple jdbc vasc backend. + * + * @author Willem Cazander + * @version 1.0 Sep 5, 2008 + */ +public class JdbcVascBackendSelect extends AbstractJdbcVascBackend implements VascBackendSelect> { + + private String query = null; + + @Override + protected void startBackendJdbc() { + requireNonEmpty(getQuery(), "query is empty."); + } + + @Override + public List>> execute() throws VascBackendException { + return null; + } + + public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException { + JdbcConnectionProvider prov = getJdbcConnectionProvider(); + List> result = new ArrayList>(50); + Connection connection = null; + try { + connection = prov.getJdbcConnection(); + Statement s = connection.createStatement(); + s.execute(getQuery()); + ResultSet rs = s.getResultSet(); + int cols = rs.getMetaData().getColumnCount(); + while (rs.next()) { + HashMap map = new HashMap(cols); + for (int i=1;i<=cols;i++) { + String columnName = rs.getMetaData().getColumnName(i); + Serializable columnObject = (Serializable) rs.getObject(i); + map.put(columnName, columnObject); + } + result.add(map); + } + } catch (SQLException e) { + throw new VascBackendException(e); + } finally { + if (connection!=null) { + try { + connection.close(); + } catch (Exception e) { + } + } + } + return new DefaultVascBackendListResult>(result); + } + + /** + * @return the query + */ + public String getQuery() { + return query; + } + + /** + * @param query the query to set + */ + public void setQuery(String query) { + this.query = query; + } +} diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java similarity index 55% rename from vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java rename to vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java index 78164df..3647216 100644 --- a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/JdbcVascBackendXpql.java +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/JdbcVascBackendXpqlList.java @@ -20,25 +20,26 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend.jdbc; +package net.forwardfire.vasc.backend.jdbc.xpql; +import java.io.Serializable; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; -import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue; -import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.jdbc.AbstractJdbcVascBackend; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.xpql.query.QueryParameterValue; /** @@ -47,53 +48,46 @@ import net.forwardfire.vasc.xpql.query.QueryParameterValue; * @author Willem Cazander * @version 1.0 Sep 5, 2008 */ -public class JdbcVascBackendXpql extends AbstractVascBackend> { +public class JdbcVascBackendXpqlList extends AbstractJdbcVascBackend implements VascBackendList,HashMap> { - private JdbcConnectionProvider jdbcConnectionProvider = null; - + private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class); + private final List rowActions = new ArrayList(); private net.forwardfire.vasc.xpql.query.Query query = null; + private net.forwardfire.vasc.xpql.query.Query queryExtra = null; + + @Override + protected void startBackendJdbc() { + requireNonNull(getQuery(), "query is null."); + if (queryExtra!=null) { + features.add(VascBackendListFeature.DATA_EXTRA); + } + } + + @Override + public VascBackendAccessDataRecord, HashMap> createVascBackendAccessDataRecord() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EnumSet getSupportedFeatures() { + return features; + } + + @Override + public List getSupportedRowActions() { + return rowActions; + } + + @Override + public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException { + } /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @Override - public boolean isReadOnly() { - return true; - } - - /** - * @return the JdbcConnectionProvider - */ - public JdbcConnectionProvider getJdbcConnectionProvider() { - return jdbcConnectionProvider; - } - - /** - * @param JdbcConnectionProvider the JdbcConnectionProvider to set - */ - public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) { - this.jdbcConnectionProvider = jdbcConnectionProvider; - } - - /** - * @return the query - */ - public net.forwardfire.vasc.xpql.query.Query getQuery() { - return query; - } - - /** - * @param query the query to set - */ - public void setQuery(net.forwardfire.vasc.xpql.query.Query query) { - this.query = query; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult> execute(VascBackendState state) throws VascBackendException { + public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException { // Copy parameters for (String key:state.getDataParameterKeys()) { Object value = state.getDataParameter(key); @@ -113,17 +107,17 @@ public class JdbcVascBackendXpql extends AbstractVascBackend> result = new ArrayList>(50); + List> result = new ArrayList>(50); while (rs.next()) { - HashMap map = new HashMap(cols); + HashMap map = new HashMap(cols); for (int i=1;i<=cols;i++) { String columnName = rs.getMetaData().getColumnName(i); - Object columnObject = rs.getObject(i); + Serializable columnObject = (Serializable) rs.getObject(i); map.put(columnName, columnObject); } result.add(map); } - return new DefaultVascBackendResult>(result); + return new DefaultVascBackendListResult>(result); } catch (SQLException e) { throw new VascBackendException(e); } finally { @@ -135,42 +129,18 @@ public class JdbcVascBackendXpql extends AbstractVascBackend merge(HashMap object) throws VascBackendException { - return object; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) - */ - @Override - public void persist(HashMap object) throws VascBackendException { + public net.forwardfire.vasc.xpql.query.Query getQuery() { + return query; } /** - * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object) + * @param query the query to set */ - @Override - public void delete(HashMap object) throws VascBackendException { + public void setQuery(net.forwardfire.vasc.xpql.query.Query query) { + this.query = query; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue() - */ - @Override - public VascEntryFieldValue provideVascEntryFieldValue() { - return new HashMapVascEntryFieldValue(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator() - */ - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return new HashMapVascEntryRecordCreator(); - } -} \ No newline at end of file +} diff --git a/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java new file mode 100644 index 0000000..6581635 --- /dev/null +++ b/vasc-backend/vasc-backend-jdbc/src/main/java/net/forwardfire/vasc/backend/jdbc/xpql/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.backend.jdbc.xpql; \ No newline at end of file diff --git a/vasc-backend/vasc-backend-jpa/pom.xml b/vasc-backend/vasc-backend-jpa/pom.xml index ec46ef9..9ab1890 100644 --- a/vasc-backend/vasc-backend-jpa/pom.xml +++ b/vasc-backend/vasc-backend-jpa/pom.xml @@ -1,29 +1,30 @@ - - 4.0.0 - - vasc-backend - net.forwardfire.vasc.backend - 0.4.2-SNAPSHOT - - vasc-backend-jpa - vasc-backend-jpa - vasc-backend-jpa - - - net.forwardfire.vasc.backend - vasc-backend-api - ${project.version} - - - net.forwardfire.vasc.lib - vasc-lib-xpql - ${project.version} - - - javax.persistence - persistence-api - ${persistence-api.version} - provided - - + + 4.0.0 + + vasc-backend + net.forwardfire.vasc.backend + 0.4.2-SNAPSHOT + + vasc-backend-jpa + vasc-backend-jpa + vasc-backend-jpa + + + net.forwardfire.vasc.backend + vasc-backend-api + ${project.version} + + + net.forwardfire.vasc.lib + vasc-lib-xpql + ${project.version} + + + javax + javaee-api + ${javaee-api.version} + provided + + diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java index 5c8e055..d1e4512 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/AbstractPersistenceVascBackend.java @@ -26,73 +26,54 @@ import java.io.Serializable; import javax.persistence.EntityManager; -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; /** + * AbstractPersistenceVascBackend. * * @author Willem Cazander - * @version 1.0 Mar 21, 2007 + * @version 1.0 Aug 25, 2014 */ -abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend { +abstract public class AbstractPersistenceVascBackend extends AbstractVascBackendLocal { - protected boolean emTransaction = true; + private Boolean emTransaction; - abstract EntityManager getEntityManager(); + private EntityManagerProvider entityManagerProvider = null; + abstract protected void startBackendPersistence(); + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal() + */ @Override - public void persist(DATA_OBJECT object) throws VascBackendException { - EntityManager s = getEntityManager(); - try { - if (emTransaction) { - s.getTransaction().begin(); - } - s.persist(object); - if (emTransaction) { - s.getTransaction().commit(); - } - } finally { - if (s!=null) { - //s.close(); - } - } + protected final void startBackendLocal() { + requireNonNull(getEntityManagerProvider(), "entityManagerProvider is null."); + //requireNonEmpty(keyMapType.keySet(), "No primary keys defined."); + startBackendPersistence(); } - @Override - public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException { - EntityManager s = getEntityManager(); - try { - if (emTransaction) { - s.getTransaction().begin(); - } - DATA_OBJECT result = (DATA_OBJECT)s.merge(object); - if (emTransaction) { - s.getTransaction().commit(); - } - return result; - } finally { - if (s!=null) { - //s.close(); - } + protected final EntityManager getEntityManager() { + if (emTransaction == null) { + emTransaction=entityManagerProvider.hasEntityManagerTransaction(); } + return entityManagerProvider.getEntityManager(); } - @Override - public void delete(DATA_OBJECT object) throws VascBackendException { - EntityManager s = getEntityManager(); - try { - if (emTransaction) { - s.getTransaction().begin(); - } - Object newObject = s.merge(object); - s.remove(newObject); - if (emTransaction) { - s.getTransaction().commit(); - } - } finally { - if (s!=null) { - //s.close(); - } - } + protected final boolean hasTransaction() { + return emTransaction; + } + + /** + * @return the entityManagerProvider + */ + public final EntityManagerProvider getEntityManagerProvider() { + return entityManagerProvider; + } + + /** + * @param entityManagerProvider the entityManagerProvider to set + */ + public final void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) { + this.entityManagerProvider = entityManagerProvider; } } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java new file mode 100644 index 0000000..5cbe905 --- /dev/null +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendCrud.java @@ -0,0 +1,161 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backends.jpa; + +import java.io.Serializable; + +import javax.persistence.EntityManager; + +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; + +/** + * Manages persistance with xpql queries + * + * @author Willem Cazander + * @version 1.0 Mar 17, 2009 + */ +public class PersistanceVascBackendCrud extends AbstractPersistenceVascBackend implements VascBackendCrud { + + private Class recordClass = null; + + public PersistanceVascBackendCrud() { + } + + public PersistanceVascBackendCrud(Class recordClass) { + setRecordClass(recordClass); + } + + @Override + protected void startBackendPersistence() { + requireNonNull(getRecordClass(), "recordClass is null"); + } + + @Override + public VascBackendAccessDataRecord createVascBackendAccessDataRecord() { + // TODO Auto-generated method stub + return null; + } + + @Override + public VascBackendAccessDataKey createVascBackendAccessDataKey() { + // TODO Auto-generated method stub + return null; + } + + + @Override + public DATA_RECORD newRecord() throws VascBackendException { + try { + return getRecordClass().newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new VascBackendException(e); + } + } + + @Override + public DATA_RECORD fetch(DATA_PK recordPK) throws VascBackendException { + EntityManager s = getEntityManager(); + try { + if (hasTransaction()) { + s.getTransaction().begin(); + } + DATA_RECORD record = s.find(getRecordClass(), recordPK); + if (hasTransaction()) { + s.getTransaction().commit(); + } + return record; + } finally { + if (s!=null) { + //s.close(); + } + } + } + + @Override + public DATA_RECORD persist(DATA_RECORD record) throws VascBackendException { + EntityManager s = getEntityManager(); + try { + if (hasTransaction()) { + s.getTransaction().begin(); + } + s.persist(record); + if (hasTransaction()) { + s.getTransaction().commit(); + } + return record; + } finally { + if (s!=null) { + //s.close(); + } + } + } + + @Override + public DATA_RECORD merge(DATA_RECORD record) throws VascBackendException { + EntityManager s = getEntityManager(); + try { + if (hasTransaction()) { + s.getTransaction().begin(); + } + DATA_RECORD result = (DATA_RECORD)s.merge(record); + if (hasTransaction()) { + s.getTransaction().commit(); + } + return result; + } finally { + if (s!=null) { + //s.close(); + } + } + } + + @Override + public void delete(DATA_PK recordPK) throws VascBackendException { + EntityManager s = getEntityManager(); + try { + if (hasTransaction()) { + s.getTransaction().begin(); + } + Object newObject = s.find(Object.class,recordPK); + s.remove(newObject); + if (hasTransaction()) { + s.getTransaction().commit(); + } + } finally { + if (s!=null) { + //s.close(); + } + } + } + + public Class getRecordClass() { + return recordClass; + } + + public void setRecordClass(Class recordClass) { + this.recordClass = recordClass; + } +} diff --git a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java similarity index 65% rename from vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java rename to vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java index 1114fe8..fa0cbeb 100644 --- a/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/XpqlPersistanceVascBackend.java +++ b/vasc-backend/vasc-backend-jpa/src/main/java/net/forwardfire/vasc/backends/jpa/PersistanceVascBackendXpqlList.java @@ -23,32 +23,30 @@ package net.forwardfire.vasc.backends.jpa; import java.io.Serializable; +import java.util.EnumSet; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; -import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue; -import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.data.BeanVascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.xpql.query.QueryParameterValue; - - /** * Manages persistance with xpql queries * * @author Willem Cazander * @version 1.0 Mar 17, 2009 */ -public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend { - - private EntityManagerProvider entityManagerProvider = null; +public class PersistanceVascBackendXpqlList extends AbstractPersistenceVascBackend implements VascBackendList { private net.forwardfire.vasc.xpql.query.Query query = null; @@ -62,38 +60,62 @@ public class XpqlPersistanceVascBackend extend private net.forwardfire.vasc.xpql.query.Query queryMoveDownUp = null; - private Class resultClass = null; - - public XpqlPersistanceVascBackend() { - } - - /** - * @see net.forwardfire.vasc.backends.jpa.AbstractPersistenceVascBackend#getEntityManager() - */ - @Override - EntityManager getEntityManager() { - emTransaction=entityManagerProvider.hasEntityManagerTransaction(); - return entityManagerProvider.getEntityManager(); + public PersistanceVascBackendXpqlList() { } @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + protected void startBackendPersistence() { + // TODO Auto-generated method stub + + } + + @Override + public VascBackendAccessDataRecord createVascBackendAccessDataRecord() { + // TODO Auto-generated method stub + return null; + } + + @Override + public VascBackendAccessDataKey createVascBackendAccessDataKey() { + // TODO Auto-generated method stub + return null; + } + + @Override + public EnumSet getSupportedFeatures() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getSupportedRowActions() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void executeRowAction(VascBackendListRequest request,List recordPKs, String actionName) throws VascBackendException { + // TODO Auto-generated method stub + + } + + @Override + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + return new DefaultVascBackendListResult(executeList(state),fetchTotalExecuteSize(state)); } @SuppressWarnings("unchecked") - private List executeList(VascBackendState state) throws VascBackendException { + private List executeList(VascBackendListRequest state) throws VascBackendException { + + // Copy parameters + for (String key:state.getDataParameterKeys()) { + Object value = state.getDataParameter(key); + query.setQueryParameter(key, value); + if (queryTotal!=null) { + queryTotal.setQueryParameter(key, value); + } + } - // Copy parameters - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - //System.out.println("Set para pame: "+key+" value: "+value); - query.setQueryParameter(key, value); - if (queryTotal!=null) { - queryTotal.setQueryParameter(key, value); - } - } - EntityManager em = getEntityManager(); try { Query q = em.createQuery(query.toPreparedSQL(query)); @@ -109,11 +131,11 @@ public class XpqlPersistanceVascBackend extend q.setFirstResult(state.getPageIndex()*state.getPageSize()); q.setMaxResults(state.getPageSize()); } - if (emTransaction) { + if (hasTransaction()) { em.getTransaction().begin(); } - List data = q.getResultList(); - if (emTransaction) { + List data = q.getResultList(); + if (hasTransaction()) { em.getTransaction().commit(); } return data; @@ -123,24 +145,6 @@ public class XpqlPersistanceVascBackend extend } } } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue() - */ - @Override - public VascEntryFieldValue provideVascEntryFieldValue() { - VascEntryFieldValue result = new BeanVascEntryFieldValue(); - return result; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator() - */ - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - VascEntryRecordCreator result = new BeanVascEntryRecordCreator(resultClass); - return result; - } /** * @return the query @@ -155,53 +159,24 @@ public class XpqlPersistanceVascBackend extend public void setQuery(net.forwardfire.vasc.xpql.query.Query query) { this.query = query; } - + /** * @return the queryTotal */ public net.forwardfire.vasc.xpql.query.Query getQueryTotal() { return queryTotal; } - + /** * @param queryTotal the queryTotal to set */ public void setQueryTotal(net.forwardfire.vasc.xpql.query.Query queryTotal) { this.queryTotal = queryTotal; } - + /** - * @return the resultClass + * @see net.forwardfire.vasc.backend.crud.VascBackendList#isPageable() */ - public Class getResultClass() { - return resultClass; - } - - /** - * @param resultClass the resultClass to set - */ - public void setResultClass(Class resultClass) { - this.resultClass = resultClass; - } - - /** - * @return the entityManagerProvider - */ - public EntityManagerProvider getEntityManagerProvider() { - return entityManagerProvider; - } - - /** - * @param entityManagerProvider the entityManagerProvider to set - */ - public void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) { - this.entityManagerProvider = entityManagerProvider; - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable() - */ - @Override public boolean isPageable() { if (queryTotal==null) { return false; @@ -209,21 +184,21 @@ public class XpqlPersistanceVascBackend extend return true; } - private long fetchTotalExecuteSize(VascBackendState state) { + private long fetchTotalExecuteSize(VascBackendListRequest state) { EntityManager em = getEntityManager(); try { Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal)); List values = queryTotal.getOrderQueryParameterValues(); int i = 1; for (QueryParameterValue value:values) { - q.setParameter(i,value.getValue()); + q.setParameter(i,value.getValue()); i++; } - if (emTransaction) { + if (hasTransaction()) { em.getTransaction().begin(); } Long resultTotal = (Long)q.getSingleResult(); - if (emTransaction) { + if (hasTransaction()) { em.getTransaction().commit(); } return resultTotal; @@ -234,25 +209,23 @@ public class XpqlPersistanceVascBackend extend } } - /** * @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object) */ - @Override - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { + public long doRecordMoveDownById(Object primaryId) throws VascBackendException { long result = 0l; if (queryMoveDown!=null) { EntityManager em = getEntityManager(); try { - if (emTransaction) { + if (hasTransaction()) { em.getTransaction().begin(); } // Copy parameters - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - queryMoveDown.setQueryParameter(key, value); - } +// for (String key:state.getDataParameterKeys()) { +// Object value = state.getDataParameter(key); +// queryMoveDown.setQueryParameter(key, value); +// } // set id queryMoveDown.setQueryParameter("id", primaryId); @@ -268,10 +241,10 @@ public class XpqlPersistanceVascBackend extend result+=q.executeUpdate(); // Copy parameters - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - queryMoveDownUp.setQueryParameter(key, value); - } +// for (String key:state.getDataParameterKeys()) { +// Object value = state.getDataParameter(key); +// queryMoveDownUp.setQueryParameter(key, value); +// } // set id queryMoveDownUp.setQueryParameter("id", primaryId); @@ -286,7 +259,7 @@ public class XpqlPersistanceVascBackend extend } result+=q.executeUpdate(); - if (emTransaction) { + if (hasTransaction()) { em.getTransaction().commit(); } } finally { @@ -301,21 +274,20 @@ public class XpqlPersistanceVascBackend extend /** * @see net.forwardfire.vasc.core.AbstractVascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object) */ - @Override - public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException { + public long doRecordMoveUpById(Object primaryId) throws VascBackendException { long result = 0l; if (queryMoveUp!=null) { EntityManager em = getEntityManager(); try { - if (emTransaction) { - em.getTransaction().begin(); - } +// if (emTransaction) { +// em.getTransaction().begin(); +// } // Copy parameters - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - queryMoveUp.setQueryParameter(key, value); - } +// for (String key:state.getDataParameterKeys()) { +// Object value = state.getDataParameter(key); +// queryMoveUp.setQueryParameter(key, value); +// } // set id queryMoveUp.setQueryParameter("id", primaryId); @@ -331,10 +303,10 @@ public class XpqlPersistanceVascBackend extend result+=q.executeUpdate(); // Copy parameters - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - queryMoveUpDown.setQueryParameter(key, value); - } +// for (String key:state.getDataParameterKeys()) { +// Object value = state.getDataParameter(key); +// queryMoveUpDown.setQueryParameter(key, value); +// } // set id queryMoveUpDown.setQueryParameter("id", primaryId); @@ -349,9 +321,9 @@ public class XpqlPersistanceVascBackend extend } result+=q.executeUpdate(); - if (emTransaction) { - em.getTransaction().commit(); - } +// if (emTransaction) { +// em.getTransaction().commit(); +// } } finally { if (em!=null) { //em.close(); @@ -360,11 +332,21 @@ public class XpqlPersistanceVascBackend extend } return result; } + + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendList#isSearchable() + */ + public boolean isSearchable() { + if (query.getQueryParameterValue("text_search")!=null) { + return true; + } + return false; + } /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isRecordMoveable() + * @see net.forwardfire.vasc.backend.crud.AbstractVascBackendCrud#isRecordMoveable() */ - @Override public boolean isRecordMoveable() { return queryMoveUp!=null & queryMoveDown!=null; } @@ -424,16 +406,4 @@ public class XpqlPersistanceVascBackend extend public void setQueryMoveDownUp(net.forwardfire.vasc.xpql.query.Query queryMoveDownUp) { this.queryMoveDownUp = queryMoveDownUp; } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSearchable() - */ - @Override - public boolean isSearchable() { - if (query.getQueryParameterValue("text_search")==null) { - return false; - } - //return true; - return false; - } -} \ No newline at end of file +} diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/AbstractLdapVascBackend.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/AbstractLdapVascBackend.java new file mode 100644 index 0000000..4785679 --- /dev/null +++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/AbstractLdapVascBackend.java @@ -0,0 +1,119 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.ldap; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import com.novell.ldap.LDAPConnection; +import com.novell.ldap.LDAPException; + +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey; + +/** + * LdapVascBackend provides abstract data access for ldap. + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +abstract public class AbstractLdapVascBackend extends AbstractVascBackendLocal> { + + private Logger logger = Logger.getLogger(AbstractLdapVascBackend.class.getName()); + private LdapConnectionProvider ldapConnectionProvider = null; + private String baseDN = null; + + private final Map> keyMapType = new HashMap>(5); + + abstract protected void startBackendLdap(); + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal() + */ + @Override + protected final void startBackendLocal() { + requireNonEmpty(getBaseDN(), "baseDN requires value."); + requireNonEmpty(keyMapType.keySet(), "No primary keys defined."); + startBackendLdap(); + } + + protected void safeDisconnect(LDAPConnection connection) { + if (connection==null) { + return; + } + try { + connection.disconnect(); + } catch (LDAPException e) { + logger.warning("Error while disconnecting: "+e.getMessage()); + } + } + + protected final void addKeyMapType(String field,Class fieldType) { + requireNonEmpty(field,"field has to have value"); + requireNonNull(fieldType,"field has to have value"); + keyMapType.put(field, fieldType); + } + + protected final Map> getKeyMapType() { + return keyMapType; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey() + */ + @Override + public final VascBackendAccessDataKey> createVascBackendAccessDataKey() { + return new HashMapVascBackendAccessDataKey(keyMapType); + } + + /** + * @return the ldapConnectionProvider. + */ + public final LdapConnectionProvider getLdapConnectionProvider() { + return ldapConnectionProvider; + } + + /** + * @param ldapConnectionProvider the ldapConnectionProvider to set. + */ + public final void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) { + this.ldapConnectionProvider = ldapConnectionProvider; + } + + /** + * @return the baseDN. + */ + public final String getBaseDN() { + return baseDN; + } + + /** + * @param baseDN the baseDN to set. + */ + public final void setBaseDN(String baseDN) { + this.baseDN = baseDN; + } +} diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendCrud.java similarity index 63% rename from vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java rename to vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendCrud.java index e6d1129..6c44f84 100644 --- a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackend.java +++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendCrud.java @@ -22,25 +22,18 @@ package net.forwardfire.vasc.backend.ldap; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.logging.Logger; -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; -import net.forwardfire.vasc.backend.data.HashMapVascEntryFieldValue; -import net.forwardfire.vasc.backend.data.HashMapVascEntryRecordCreator; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord; import com.novell.ldap.LDAPAttribute; -import com.novell.ldap.LDAPAttributeSet; import com.novell.ldap.LDAPConnection; import com.novell.ldap.LDAPEntry; import com.novell.ldap.LDAPException; @@ -54,91 +47,39 @@ import com.novell.ldap.LDAPSearchResults; * @author Willem Cazander * @version 1.0 Sep 4, 2008 */ -public class LdapVascBackend extends AbstractVascBackend> { +public class LdapVascBackendCrud extends AbstractLdapVascBackend implements VascBackendCrud,HashMap> { - private Logger logger = Logger.getLogger(LdapVascBackend.class.getName()); - private LdapConnectionProvider ldapConnectionProvider = null; - private String baseDN = null; + private Logger logger = Logger.getLogger(LdapVascBackendCrud.class.getName()); private String keyAttribute = null; private String ldapFilter = null; private String createObjectClass = null; private int timeLimit = 10000; private boolean referralFollowing = true; - /** - * @return the ldapConnectionProvider. - */ - public LdapConnectionProvider getLdapConnectionProvider() { - return ldapConnectionProvider; - } - - /** - * @param ldapConnectionProvider the ldapConnectionProvider to set. - */ - public void setLdapConnectionProvider(LdapConnectionProvider ldapConnectionProvider) { - this.ldapConnectionProvider = ldapConnectionProvider; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute() - */ @Override - public VascBackendResult> execute(VascBackendState state) throws VascBackendException { - LdapConnectionProvider prov = getLdapConnectionProvider(); - LDAPConnection connection = prov.getLdapConnection(); - List> result = new ArrayList>(50); - try { - - LDAPSearchConstraints cons = new LDAPSearchConstraints(); - cons.setBatchSize( 0 ); - cons.setTimeLimit(getTimeLimit() ) ; - cons.setReferralFollowing(isReferralFollowing()); - connection.setConstraints(cons); + protected void startBackendLdap() { + } + + @Override + public VascBackendAccessDataRecord, HashMap> createVascBackendAccessDataRecord() { + return new HashMapVascBackendAccessDataRecord(getKeyMapType()); + } - int searchScope = LDAPConnection.SCOPE_ONE; - String searchBase = baseDN; - - LDAPSearchResults searchResults = connection.search( - searchBase, // object to read - searchScope, // scope - read single object - getLdapFilter(), // search filter - null, // return all attributes - false); // return attrs and values - - while (searchResults.hasMore()) { - LDAPEntry entry = searchResults.next(); - HashMap map = new HashMap(10); - - LDAPAttributeSet attributeSet = entry.getAttributeSet(); - Iterator i = attributeSet.iterator(); - while (i.hasNext()) { - LDAPAttribute attr = i.next(); - String[] s = attr.getStringValueArray(); - if (s.length==1) { - map.put(attr.getName(), attr.getStringValue()); - } else { - List multiValue = new ArrayList(s.length); - for (String ss:s) { - multiValue.add(ss); - } - map.put(attr.getName(), multiValue ); - } - } - result.add(map); - } - } catch (LDAPException e) { - throw new VascBackendException(e); - } finally { - safeDisconnect(connection); - } - return new DefaultVascBackendResult>(result); + @Override + public HashMap fetch(HashMap recordPK) throws VascBackendException { + return null; + } + + @Override + public HashMap newRecord() throws VascBackendException { + return new HashMap(); } /** - * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#merge(java.lang.Object) */ @Override - public HashMap merge(HashMap map) throws VascBackendException { + public HashMap merge(HashMap map) throws VascBackendException { LdapConnectionProvider prov = getLdapConnectionProvider(); LDAPConnection connection = prov.getLdapConnection(); try { @@ -149,7 +90,7 @@ public class LdapVascBackend extends AbstractVascBackend> cons.setReferralFollowing(isReferralFollowing()); connection.setConstraints(cons); int searchScope = LDAPConnection.SCOPE_ONE; - String searchBase = baseDN; + String searchBase = getBaseDN(); String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; LDAPSearchResults searchResults = connection.search( searchBase, // object to read @@ -216,15 +157,15 @@ public class LdapVascBackend extends AbstractVascBackend> } /** - * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#persist(java.lang.Object) */ @Override - public void persist(HashMap map) throws VascBackendException { + public HashMap persist(HashMap map) throws VascBackendException { LdapConnectionProvider prov = getLdapConnectionProvider(); LDAPConnection connection = prov.getLdapConnection(); try { String keyValue = (String)map.get(keyAttribute); - LDAPEntry entry = new LDAPEntry(keyAttribute+"="+keyValue+","+baseDN); + LDAPEntry entry = new LDAPEntry(keyAttribute+"="+keyValue+","+getBaseDN()); LDAPAttribute ob = new LDAPAttribute("objectClass"); String[] obs = createObjectClass.split(","); @@ -248,19 +189,20 @@ public class LdapVascBackend extends AbstractVascBackend> } finally { safeDisconnect(connection); } + return fetch(map); } /** - * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#delete(java.lang.Object) */ @Override - public void delete(HashMap map) throws VascBackendException { + public void delete(HashMap map) throws VascBackendException { LdapConnectionProvider prov = getLdapConnectionProvider(); LDAPConnection connection = prov.getLdapConnection(); try { String keyValue = (String)map.get(keyAttribute); int searchScope = LDAPConnection.SCOPE_ONE; - String searchBase = baseDN; + String searchBase = getBaseDN(); String filter = "(&"+ldapFilter+"("+keyAttribute+"="+keyValue+"))"; LDAPSearchResults searchResults = connection.search( searchBase, // object to read @@ -282,47 +224,6 @@ public class LdapVascBackend extends AbstractVascBackend> } } - private void safeDisconnect(LDAPConnection connection) { - if (connection==null) { - return; - } - try { - connection.disconnect(); - } catch (LDAPException e) { - logger.warning("Error while disconnecting: "+e.getMessage()); - } - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator() - */ - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return new HashMapVascEntryRecordCreator(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue() - */ - @Override - public VascEntryFieldValue provideVascEntryFieldValue() { - return new HashMapVascEntryFieldValue(); - } - - /** - * @return the baseDN. - */ - public String getBaseDN() { - return baseDN; - } - - /** - * @param baseDN the baseDN to set. - */ - public void setBaseDN(String baseDN) { - this.baseDN = baseDN; - } - /** * @return the keyAttribute. */ diff --git a/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendList.java b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendList.java new file mode 100644 index 0000000..b980623 --- /dev/null +++ b/vasc-backend/vasc-backend-ldap/src/main/java/net/forwardfire/vasc/backend/ldap/LdapVascBackendList.java @@ -0,0 +1,220 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.ldap; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; + +import com.novell.ldap.LDAPAttribute; +import com.novell.ldap.LDAPAttributeSet; +import com.novell.ldap.LDAPConnection; +import com.novell.ldap.LDAPEntry; +import com.novell.ldap.LDAPException; +import com.novell.ldap.LDAPModification; +import com.novell.ldap.LDAPSearchConstraints; +import com.novell.ldap.LDAPSearchResults; + +/** + * LdapVascBackend provides abstract data access for ldap. + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public class LdapVascBackendList extends AbstractLdapVascBackend implements VascBackendList,HashMap> { + + private Logger logger = Logger.getLogger(LdapVascBackendList.class.getName()); + private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class); + private final List rowActions = new ArrayList(); + private String keyAttribute = null; + private String ldapFilter = null; + private String createObjectClass = null; + private int timeLimit = 10000; + private boolean referralFollowing = true; + + @Override + protected void startBackendLdap() { + // TODO Auto-generated method stub + + } + + @Override + public VascBackendAccessDataRecord, HashMap> createVascBackendAccessDataRecord() { + return new HashMapVascBackendAccessDataRecord(getKeyMapType()); + } + + @Override + public EnumSet getSupportedFeatures() { + return features; + } + + @Override + public List getSupportedRowActions() { + return rowActions; + } + + @Override + public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException { + + } + + /** + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute() + */ + @Override + public VascBackendListResult> execute(VascBackendListRequest state) throws VascBackendException { + LdapConnectionProvider prov = getLdapConnectionProvider(); + LDAPConnection connection = prov.getLdapConnection(); + List> result = new ArrayList>(50); + try { + + LDAPSearchConstraints cons = new LDAPSearchConstraints(); + cons.setBatchSize( 0 ); + cons.setTimeLimit(getTimeLimit() ) ; + cons.setReferralFollowing(isReferralFollowing()); + connection.setConstraints(cons); + + int searchScope = LDAPConnection.SCOPE_ONE; + String searchBase = getBaseDN(); + + LDAPSearchResults searchResults = connection.search( + searchBase, // object to read + searchScope, // scope - read single object + getLdapFilter(), // search filter + null, // return all attributes + false); // return attrs and values + + while (searchResults.hasMore()) { + LDAPEntry entry = searchResults.next(); + HashMap map = new HashMap(10); + + LDAPAttributeSet attributeSet = entry.getAttributeSet(); + Iterator i = attributeSet.iterator(); + while (i.hasNext()) { + LDAPAttribute attr = i.next(); + String[] s = attr.getStringValueArray(); + if (s.length==1) { + map.put(attr.getName(), attr.getStringValue()); + } else { + List multiValue = new ArrayList(s.length); + for (String ss:s) { + multiValue.add(ss); + } + map.put(attr.getName(), (Serializable)multiValue ); + } + } + result.add(map); + } + } catch (LDAPException e) { + throw new VascBackendException(e); + } finally { + safeDisconnect(connection); + } + return new DefaultVascBackendListResult>(result); + } + + /** + * @return the keyAttribute. + */ + public String getKeyAttribute() { + return keyAttribute; + } + + /** + * @param keyAttribute the keyAttribute to set. + */ + public void setKeyAttribute(String keyAttribute) { + this.keyAttribute = keyAttribute; + } + + /** + * @return the ldapFilter. + */ + public String getLdapFilter() { + return ldapFilter; + } + + /** + * @param ldapFilter the ldapFilter to set. + */ + public void setLdapFilter(String ldapFilter) { + this.ldapFilter = ldapFilter; + } + + /** + * @return the createObjectClass. + */ + public String getCreateObjectClass() { + return createObjectClass; + } + + /** + * @param createObjectClass the createObjectClass to set. + */ + public void setCreateObjectClass(String createObjectClass) { + this.createObjectClass = createObjectClass; + } + + /** + * @return the timeLimit. + */ + public int getTimeLimit() { + return timeLimit; + } + + /** + * @param timeLimit the timeLimit to set. + */ + public void setTimeLimit(int timeLimit) { + this.timeLimit = timeLimit; + } + + /** + * @return the referralFollowing. + */ + public boolean isReferralFollowing() { + return referralFollowing; + } + + /** + * @param referralFollowing the referralFollowing to set. + */ + public void setReferralFollowing(boolean referralFollowing) { + this.referralFollowing = referralFollowing; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/AbstractMetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/AbstractMetaModelVascBackend.java new file mode 100644 index 0000000..6f04802 --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/AbstractMetaModelVascBackend.java @@ -0,0 +1,142 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.metamodel; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import org.eobjects.metamodel.DataContext; + +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataKey; + +/** + * AbstractMetaModelVascBackend provides shared metamodel options. + * + * @author Willem Cazander + * @version 1.0 Oct 27, 2014 + */ +abstract public class AbstractMetaModelVascBackend extends AbstractVascBackendLocal> { + + private Logger logger = Logger.getLogger(MetaModelVascBackendCrud.class.getName()); + private MetaModelDataContextProvider dataContextProvider = null; + private DataContext dataContext = null; + + private String table = null; + private String tableId = null; + private final Map> keyMapType = new HashMap>(5); + + abstract protected void startBackendMetaModel(); + + @Override + protected void stopBackendLocal() { + dataContext = null; + } + + /** + * @see net.forwardfire.vasc.backend.AbstractVascBackendLocal#startBackendLocal() + */ + @Override + protected final void startBackendLocal() { + requireNonNull(getDataContextProvider(), "dataContextProvider is null."); + requireNonEmpty(keyMapType.keySet(), "No primary keys defined."); + requireNonNull(table,"table needs value"); + //requireNonNull(tableId,"table needs value"); + + long startTime = System.currentTimeMillis(); + dataContext = dataContextProvider.getDataContext(); + requireNonNull(dataContext,"dataContextProvider created null dataContext."); + + long stopTime = System.currentTimeMillis(); + logger.fine(dataContext.getClass().getSimpleName()+" created for: "+table+" in: "+(stopTime-startTime)+" ms."); + + startBackendMetaModel(); + } + + protected final void addKeyMapType(String field,Class fieldType) { + requireNonEmpty(field,"field has to have value"); + requireNonNull(fieldType,"field has to have value"); + keyMapType.put(field, fieldType); + } + + protected final Map> getKeyMapType() { + return keyMapType; + } + + protected DataContext getDataContext() { + return dataContext; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey() + */ + @Override + public final VascBackendAccessDataKey> createVascBackendAccessDataKey() { + return new HashMapVascBackendAccessDataKey(keyMapType); + } + + /** + * @return the dataContextProvider + */ + public final MetaModelDataContextProvider getDataContextProvider() { + return dataContextProvider; + } + + /** + * @param dataContextProvider the dataContextProvider to set + */ + public final void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) { + this.dataContextProvider = dataContextProvider; + } + + /** + * @return the table + */ + public final String getTable() { + return table; + } + + /** + * @param table the table to set + */ + public final void setTable(String table) { + this.table = table; + } + + /** + * @return the tableId + */ + public final String getTableId() { + return tableId; + } + + /** + * @param tableId the tableId to set + */ + public final void setTableId(String tableId) { + this.tableId = tableId; + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendAccessDataRecord.java similarity index 61% rename from vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java rename to vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendAccessDataRecord.java index 613a363..5fe530e 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryFieldValue.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendAccessDataRecord.java @@ -1,20 +1,36 @@ package net.forwardfire.vasc.backend.metamodel; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import org.eobjects.metamodel.data.Row; import org.eobjects.metamodel.query.SelectItem; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; -public class RowVascEntryFieldValue implements VascEntryFieldValue { - - private static final long serialVersionUID = -806674640688182132L; +@SuppressWarnings("serial") +public class MetaModelVascBackendAccessDataRecord implements VascBackendAccessDataRecord,Row> { + + private final Map> keyMapType; + + public MetaModelVascBackendAccessDataRecord(Map> keyMapType) { + this.keyMapType = keyMapType; + } + + @Override + public HashMap getPrimaryKey(Row record) throws VascBackendException { + HashMap result = new HashMap(); + for (String key:keyMapType.keySet()) { + result.put(key, getValue(key,record)); + } + return result; + } /** - * @see net.forwardfire.vasc.backend.VascEntryFieldValue#getValue(java.lang.String, java.lang.Object) + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getValue(java.lang.String, java.lang.Object) */ @Override public Serializable getValue(String backendName, Row record) throws VascBackendException { @@ -31,7 +47,7 @@ public class RowVascEntryFieldValue implements VascEntryFieldValue { Serializable fieldValue = (Serializable) record.getValue(indexOf(backendName,record)); return fieldValue; } - + private int indexOf(String columnName,Row row) { // RM after MM Row update if (columnName==null) { return UpdateableRow.INDEX_NOT_FOUND; @@ -47,19 +63,7 @@ public class RowVascEntryFieldValue implements VascEntryFieldValue { } /** - * @see net.forwardfire.vasc.backend.VascEntryFieldValue#getDisplayValue(java.lang.String, java.lang.Object) - */ - @Override - public String getDisplayValue(String backendName, Row record) throws VascBackendException { - Object fieldValue = getValue(backendName,record); - if (fieldValue==null) { - fieldValue = ""; - } - return fieldValue.toString(); - } - - /** - * @see net.forwardfire.vasc.backend.VascEntryFieldValue#setValue(java.lang.String, java.lang.Object, java.lang.Object) + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#setValue(java.lang.String, java.lang.Object, java.lang.Object) */ @Override public void setValue(String backendName, Row record,Serializable value) throws VascBackendException { diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendCrud.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendCrud.java new file mode 100644 index 0000000..986986a --- /dev/null +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendCrud.java @@ -0,0 +1,143 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.metamodel; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import org.eobjects.metamodel.DataContext; +import org.eobjects.metamodel.UpdateableDataContext; +import org.eobjects.metamodel.data.DataSet; +import org.eobjects.metamodel.data.Row; +import org.eobjects.metamodel.jdbc.JdbcDataContext; +import org.eobjects.metamodel.query.OrderByItem.Direction; +import org.eobjects.metamodel.query.Query; +import org.eobjects.metamodel.query.SelectItem; +import org.eobjects.metamodel.query.builder.SatisfiedQueryBuilder; +import org.eobjects.metamodel.query.builder.SatisfiedWhereBuilder; +import org.eobjects.metamodel.schema.Column; +import org.eobjects.metamodel.schema.Schema; +import org.eobjects.metamodel.schema.Table; + +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; +import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; +import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl; +import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl; + +/** + * MetaModelVascBackend provides vasc backend for metamodel. + * + * @author Willem Cazander + * @version 1.0 Dec 31, 2011 + */ +public class MetaModelVascBackendCrud extends AbstractMetaModelVascBackend implements VascBackendCrud,Row> { + + private Logger logger = Logger.getLogger(MetaModelVascBackendCrud.class.getName()); + private CrudDataContext crudDataContext = null; + + + @Override + protected void startBackendMetaModel() { +// if (isUpdateableDataContext()) { +// CrudDataContextImpl crudDataContextImpl = new CrudDataContextImpl(getUpdateableDataContext()); +// if (tableId!=null && tableId.isEmpty()==false) { +// List ids = new ArrayList(1); +// ids.add(tableId); +// crudDataContextImpl.overridePrimaryKeysForTable(table,ids); +// } +// crudDataContext = crudDataContextImpl; +// } + } + + @Override + public VascBackendAccessDataRecord, Row> createVascBackendAccessDataRecord() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Row newRecord() throws VascBackendException { + return crudDataContext.createRow(crudDataContext.getTableByQualifiedLabel(getTable())); + } + + @Override + public Row fetch(HashMap recordPK) throws VascBackendException { + // TODO Auto-generated method stub + return null; + } + + + /** + * Returns casted version of data context. + */ + private UpdateableDataContext getUpdateableDataContext() { + return (UpdateableDataContext)getDataContext(); + } + + /** + * Returns true when data context in updateable. + */ + private boolean isUpdateableDataContext() { + return getDataContext() instanceof UpdateableDataContext; + } + + public boolean isReadOnly() { + return isUpdateableDataContext()==false; + } + + @Override + public Row persist(Row object) throws VascBackendException { + if (crudDataContext==null) { + return object; + } + crudDataContext.persist((UpdateableRow) object); + return object; + } + + @Override + public Row merge(Row object) throws VascBackendException { + if (crudDataContext==null) { + return object; + } + return crudDataContext.merge((UpdateableRow) object); + } + + @Override + public void delete(HashMap recordPK) throws VascBackendException { + if (crudDataContext==null) { + return; + } + //crudDataContext.delete((UpdateableRow) object); + } +} diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendList.java similarity index 55% rename from vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java rename to vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendList.java index 07fa7be..1425ffc 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackend.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/MetaModelVascBackendList.java @@ -22,8 +22,11 @@ package net.forwardfire.vasc.backend.metamodel; +import java.io.Serializable; import java.util.ArrayList; import java.util.Date; +import java.util.EnumSet; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.logging.Logger; @@ -42,12 +45,15 @@ import org.eobjects.metamodel.schema.Column; import org.eobjects.metamodel.schema.Schema; import org.eobjects.metamodel.schema.Table; -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.data.HashMapVascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRow; import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContextImpl; @@ -59,91 +65,39 @@ import net.forwardfire.vasc.backend.metamodel.crud.UpdateableRowMapImpl; * @author Willem Cazander * @version 1.0 Dec 31, 2011 */ -public class MetaModelVascBackend extends AbstractVascBackend { +public class MetaModelVascBackendList extends AbstractMetaModelVascBackend implements VascBackendList,Row> { - private Logger logger = Logger.getLogger(MetaModelVascBackend.class.getName()); - private MetaModelDataContextProvider dataContextProvider = null; - private DataContext dataContext = null; - private CrudDataContext crudDataContext = null; - private String table = null; - private String tableId = null; - - /** - * Returns casted version of data context. - */ - private UpdateableDataContext getUpdateableDataContext() { - return (UpdateableDataContext)dataContext; + private Logger logger = Logger.getLogger(MetaModelVascBackendList.class.getName()); + private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class); + private final List rowActions = new ArrayList(); + + @Override + protected void startBackendMetaModel() { } - /** - * Returns true when data context in updateable. - */ - private boolean isUpdateableDataContext() { - return dataContext instanceof UpdateableDataContext; + @Override + public VascBackendAccessDataRecord,Row> createVascBackendAccessDataRecord() { + return new MetaModelVascBackendAccessDataRecord(getKeyMapType()); } - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isReadOnly() - */ @Override - public boolean isReadOnly() { - return isUpdateableDataContext()==false; - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend() - */ - @Override - public void startBackend() { - if (table==null) { - throw new NullPointerException("Can't start with null table."); - } - if (table.isEmpty()) { - throw new NullPointerException("Can't start with empty table."); - } - long startTime = System.currentTimeMillis(); - dataContext = dataContextProvider.getDataContext(); - if (isUpdateableDataContext()) { - CrudDataContextImpl crudDataContextImpl = new CrudDataContextImpl(getUpdateableDataContext()); - if (tableId!=null && tableId.isEmpty()==false) { - List ids = new ArrayList(1); - ids.add(tableId); - crudDataContextImpl.overridePrimaryKeysForTable(table,ids); - } - crudDataContext = crudDataContextImpl; - - } - long stopTime = System.currentTimeMillis(); - logger.fine(dataContext.getClass().getSimpleName()+" created for: "+table+" in: "+(stopTime-startTime)+" ms."); + public EnumSet getSupportedFeatures() { + return features; } - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend() - */ @Override - public void stopBackend() { - dataContext = null; - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable() - */ - @Override - public boolean isPageable() { - return true; + public List getSupportedRowActions() { + return rowActions; } - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isSortable() - */ @Override - public boolean isSortable() { - return true; + public void executeRowAction(VascBackendListRequest request,List> recordPKs, String actionName) throws VascBackendException { } - private long fetchTotalExecuteSize(VascBackendState state) { + private long fetchTotalExecuteSize(VascBackendListRequest state) { + DataContext dataContext = getDataContext(); Schema schema = dataContext.getDefaultSchema(); - Table t = schema.getTableByName(table); + Table t = schema.getTableByName(getTable()); Query q = createFilterQuery(state,t,true); DataSet ds = dataContext.executeQuery(q); if (ds.next()==false) { @@ -156,7 +110,9 @@ public class MetaModelVascBackend extends AbstractVascBackend { return result.longValue(); } - private Query createFilterQuery(VascBackendState state,Table t,boolean count) { + private Query createFilterQuery(VascBackendListRequest state,Table t,boolean count) { + DataContext dataContext = getDataContext(); + Object qWhere = null; if (count==false) { qWhere = dataContext.query().from(t).select(t.getColumns()); @@ -208,18 +164,19 @@ public class MetaModelVascBackend extends AbstractVascBackend { } @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + return new DefaultVascBackendListResult(executeList(state),fetchTotalExecuteSize(state)); } - private List executeList(VascBackendState state) throws VascBackendException { + private List executeList(VascBackendListRequest state) throws VascBackendException { + DataContext dataContext = getDataContext(); Schema schema = dataContext.getDefaultSchema(); - Table t = schema.getTableByName(table); + Table t = schema.getTableByName(getTable()); if (t==null) { - throw new VascBackendException("Could not get meta table for: '"+table+"'."); + throw new VascBackendException("Could not get meta table for: '"+getTable()+"'."); } Query q = createFilterQuery(state,t,false); - if (isSortable() && state.getSortField() != null) { + if (state.getSortField() != null) { Column orderColumn = t.getColumnByName(state.getSortField()); if (state.isSortAscending()) { q.orderBy(orderColumn,Direction.ASC); @@ -227,7 +184,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { q.orderBy(orderColumn,Direction.DESC); } } - if (isPageable() && state.getPageSize()>0) { + if (state.getPageSize()>0) { if (state.getPageIndex()>0) { q.setFirstRow((state.getPageIndex()*state.getPageSize())+1); // MM is 1 based ?? @@ -239,12 +196,12 @@ public class MetaModelVascBackend extends AbstractVascBackend { q.setMaxRows(state.getPageSize()); } List result = new ArrayList(50); - if (crudDataContext!=null) { - DataSet ds = crudDataContext.executeQuery(q); - result.addAll(ds.toRows()); - ds.close(); - return result; - } +// if (crudDataContext!=null) { +// DataSet ds = crudDataContext.executeQuery(q); +// result.addAll(ds.toRows()); +// ds.close(); +// return result; +// } DataSet ds = dataContext.executeQuery(q); while (ds.next()) { @@ -252,7 +209,7 @@ public class MetaModelVascBackend extends AbstractVascBackend { SelectItem[] cols = row.getSelectItems(); List keys = new ArrayList(1); keys.add(cols[0].getColumn().getName()); - UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(table),keys,cols); + UpdateableRowMapImpl rowMM = new UpdateableRowMapImpl(dataContext.getDefaultSchema().getTableByName(getTable()),keys,cols); for (SelectItem col:cols) { Object value = row.getValue(col); rowMM.setValue(col, value); @@ -263,80 +220,4 @@ public class MetaModelVascBackend extends AbstractVascBackend { return result; } - - @Override - public void persist(Row object) throws VascBackendException { - if (crudDataContext==null) { - return; - } - crudDataContext.persist((UpdateableRow) object); - } - - @Override - public Row merge(Row object) throws VascBackendException { - if (crudDataContext==null) { - return object; - } - return crudDataContext.merge((UpdateableRow) object); - } - - @Override - public void delete(Row object) throws VascBackendException { - if (crudDataContext==null) { - return; - } - crudDataContext.delete((UpdateableRow) object); - } - - @Override - public RowVascEntryFieldValue provideVascEntryFieldValue() { - return new RowVascEntryFieldValue(); - } - - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return new RowVascEntryRecordCreator(crudDataContext,crudDataContext.getDefaultSchema().getTableByName(table)); - } - - /** - * @return the dataContextProvider - */ - public MetaModelDataContextProvider getDataContextProvider() { - return dataContextProvider; - } - - /** - * @param dataContextProvider the dataContextProvider to set - */ - public void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) { - this.dataContextProvider = dataContextProvider; - } - - /** - * @return the table - */ - public String getTable() { - return table; - } - - /** - * @param table the table to set - */ - public void setTable(String table) { - this.table = table; - } - - /** - * @return the tableId - */ - public String getTableId() { - return tableId; - } - - /** - * @param tableId the tableId to set - */ - public void setTableId(String tableId) { - this.tableId = tableId; - } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java deleted file mode 100644 index 9a54644..0000000 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/RowVascEntryRecordCreator.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.forwardfire.vasc.backend.metamodel; - -import org.eobjects.metamodel.data.Row; -import org.eobjects.metamodel.schema.Table; - -import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; -import net.forwardfire.vasc.backend.metamodel.crud.CrudDataContext; - -public class RowVascEntryRecordCreator implements VascEntryRecordCreator { - - private static final long serialVersionUID = -1182678362367989090L; - private CrudDataContext dataContext = null; - private Table table = null; - - public RowVascEntryRecordCreator(CrudDataContext dataContext,Table table) { - this.dataContext=dataContext; - this.table=table; - } - - @Override - public Row newRecord() throws VascBackendException { - return dataContext.createRow(table); - } -} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/AbstractMongodbVascBackend.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/AbstractMongodbVascBackend.java new file mode 100644 index 0000000..12b92c9 --- /dev/null +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/AbstractMongodbVascBackend.java @@ -0,0 +1,104 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.mongodb; + +import org.bson.types.ObjectId; + +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.VascBackendException; + +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; + +/** + * AbstractMongodbVascBackend + * + * @author Willem Cazander + * @version 1.0 Oct 26, 2014 + */ +abstract public class AbstractMongodbVascBackend extends AbstractVascBackendLocal { + + public static final String PK_FIELD_NAME = "_id"; + private MongodbConnectionProvider connectionProvider = null; + private String collection = null; + private DB database = null; + + @Override + public final void startBackendLocal() { + requireNonNull(connectionProvider, "Can't start with null connectionProvider."); + requireNonEmpty(collection, "Can't start without collection."); + database = connectionProvider.getMongodbConnection(); + requireNonNull(database, "connectionProvider provided us a null database."); + } + + @Override + public final void stopBackendLocal() { + database = null; + } + + protected final DBCollection getDBCollection() { + return database.getCollection(collection); + } + + protected final void deleteById(ObjectId objectId) throws VascBackendException { + getDBCollection().remove(new BasicDBObject(PK_FIELD_NAME,objectId)); // remove by _id + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataKey() + */ + @Override + public final VascBackendAccessDataKey createVascBackendAccessDataKey() { + return new MongodbVascBackendAccessDataKey(); + } + + /** + * @return the connectionProvider + */ + public final MongodbConnectionProvider getConnectionProvider() { + return connectionProvider; + } + + /** + * @param connectionProvider the connectionProvider to set + */ + public final void setConnectionProvider(MongodbConnectionProvider connectionProvider) { + this.connectionProvider = connectionProvider; + } + + /** + * @return the collection + */ + public final String getCollection() { + return collection; + } + + /** + * @param collection the collection to set + */ + public final void setCollection(String collection) { + this.collection = collection; + } +} diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java deleted file mode 100644 index 3dbe656..0000000 --- a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackend.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.vasc.backend.mongodb; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import net.forwardfire.vasc.backend.AbstractVascBackend; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; -import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; - -import com.mongodb.DB; -import com.mongodb.DBCollection; -import com.mongodb.DBCursor; -import com.mongodb.DBObject; -import com.mongodb.BasicDBObject; -import com.mongodb.WriteConcern; -import com.mongodb.WriteResult; - -/** - * MongodbVascBackend Provides backend for mongodb. - * - * @author Willem Cazander - * @version 1.0 Dec 30, 2011 - */ -public class MongodbVascBackend extends AbstractVascBackend { - - private Logger logger = null; - private MongodbConnectionProvider connectionProvider = null; - private String collection = null; - private DB database = null; - - public MongodbVascBackend() { - logger = Logger.getLogger(MongodbVascBackend.class.getName()); - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#startBackend() - */ - @Override - public void startBackend() { - if (connectionProvider==null) { - throw new NullPointerException("Can't start backend with null connectionProvider."); - } - database = connectionProvider.getMongodbConnection(); - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#stopBackend() - */ - @Override - public void stopBackend() { - database = null; - } - - /** - * @see net.forwardfire.vasc.backend.AbstractVascBackend#isPageable() - */ - @Override - public boolean isPageable() { - return true; - } - - private long fetchTotalExecuteSize(VascBackendState state) { - DBCollection coll = getDBCollection(); - DBObject query = createFilterQuery(state); - long result = coll.count(query); - return result; - } - - private DBObject createFilterQuery(VascBackendState state) { - DBObject query = new BasicDBObject(); - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - query.put(key, value); - logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'"); - } - return query; - } - - @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - return new DefaultVascBackendResult(executeList(state),fetchTotalExecuteSize(state)); - } - - private List executeList(VascBackendState state) throws VascBackendException { - DBCollection coll = getDBCollection(); - DBObject query = createFilterQuery(state); - DBCursor cur = coll.find(query); - if (isPageable() && state.getPageSize()>0) { - cur.limit(state.getPageSize()); - cur.skip(state.getPageIndex()); - } - List result = new ArrayList(cur.count()); - while (cur.hasNext()) { - DBObject row = cur.next(); - result.add((BasicDBObject)row); - } - return result; - } - - @Override - public void persist(BasicDBObject object) throws VascBackendException { - DBCollection coll = getDBCollection(); - coll.insert(object); - } - - @Override - public BasicDBObject merge(BasicDBObject row) throws VascBackendException { - DBCollection coll = getDBCollection(); - DBObject query = new BasicDBObject(); - query.put("_id",row.get("_id")); - WriteResult wr = coll.update(query,row,false,false,WriteConcern.SAFE); - logger.info("WriteResult: "+wr); - return row; - } - - @Override - public void delete(BasicDBObject object) throws VascBackendException { - DBCollection coll = getDBCollection(); - DBObject query = new BasicDBObject(); - query.put("_id",object.get("_id")); - coll.remove(query); // remove by _id - } - - @Override - public MongodbVascEntryFieldValue provideVascEntryFieldValue() { - return new MongodbVascEntryFieldValue(); - } - - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return new MongodbVascEntryRecordCreator(); - } - - private DBCollection getDBCollection() { - return database.getCollection(collection); - } - - /** - * @return the connectionProvider - */ - public MongodbConnectionProvider getConnectionProvider() { - return connectionProvider; - } - - /** - * @param connectionProvider the connectionProvider to set - */ - public void setConnectionProvider(MongodbConnectionProvider connectionProvider) { - this.connectionProvider = connectionProvider; - } - - /** - * @return the collection - */ - public String getCollection() { - return collection; - } - - /** - * @param collection the collection to set - */ - public void setCollection(String collection) { - this.collection = collection; - } -} diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataKey.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataKey.java new file mode 100644 index 0000000..6d77938 --- /dev/null +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataKey.java @@ -0,0 +1,78 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.mongodb; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.bson.types.ObjectId; + +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.VascBackendException; + +/** + * MongodbVascBackendAccessDataKey convert key type to string and back. + * + * @author Willem Cazander + * @version 1.0 Oct 26, 2014 + */ +@SuppressWarnings("serial") +public class MongodbVascBackendAccessDataKey implements VascBackendAccessDataKey { + + private final Map> keyMapType; + + public MongodbVascBackendAccessDataKey() { + keyMapType = new HashMap>(1); + keyMapType.put(AbstractMongodbVascBackend.PK_FIELD_NAME, ObjectId.class); + } + + @Override + public Map> getKeyMapType() { + return keyMapType; + } + + @Override + public Map getKeyMapFromPrimaryKey(ObjectId primaryKey) throws VascBackendException { + Map result = new HashMap(1); + result.put(MongodbVascBackendCrud.PK_FIELD_NAME, primaryKey); + return result; + } + + @Override + public ObjectId getPrimaryKeyFromKeyMap(Map keyMap) throws VascBackendException { + return (ObjectId)keyMap.get(MongodbVascBackendCrud.PK_FIELD_NAME); + } + + @Override + public Map getStringMapFromPrimaryKey(ObjectId primaryKey) throws VascBackendException { + Map result = new HashMap(1); + result.put(MongodbVascBackendCrud.PK_FIELD_NAME, primaryKey.toString()); + return result; + } + + @Override + public ObjectId getPrimaryKeyFromStringMap(Map keyMap) throws VascBackendException { + return new ObjectId(keyMap.get(MongodbVascBackendCrud.PK_FIELD_NAME)); + } +} diff --git a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryRecordCreator.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataRecord.java similarity index 54% rename from vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryRecordCreator.java rename to vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataRecord.java index b060f2a..4e5c407 100644 --- a/vasc-backend/vasc-backend-api/src/main/java/net/forwardfire/vasc/backend/data/BeanVascEntryRecordCreator.java +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendAccessDataRecord.java @@ -20,41 +20,47 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.backend.data; +package net.forwardfire.vasc.backend.mongodb; import java.io.Serializable; -import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; +import org.bson.types.ObjectId; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; + +import com.mongodb.BasicDBObject; /** - * BeanVascEntryRecordCreator creates a new backend record based on class object. + * Provides a mongodb field entry knowlege. * * @author Willem Cazander - * @version 1.0 Dec 05, 2009 + * @version 1.0 Dec 30, 2011 */ -public class BeanVascEntryRecordCreator implements VascEntryRecordCreator { - - private static final long serialVersionUID = 1L; - private Class resultClass = null; - - public BeanVascEntryRecordCreator(Class resultClass) { - if (resultClass==null) { - throw new NullPointerException("Can't provide creator service with null class object."); - } - this.resultClass=resultClass; - } +@SuppressWarnings("serial") +public class MongodbVascBackendAccessDataRecord implements VascBackendAccessDataRecord { - @SuppressWarnings("unchecked") + /** + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getPrimaryKey(java.io.Serializable) + */ @Override - public DATA_OBJECT newRecord() throws VascBackendException { - try { - return (DATA_OBJECT)resultClass.newInstance(); - } catch (InstantiationException e) { - throw new VascBackendException(e); - } catch (IllegalAccessException e) { - throw new VascBackendException(e); - } + public ObjectId getPrimaryKey(BasicDBObject record) throws VascBackendException { + return record.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#getValue(java.lang.String, java.io.Serializable) + */ + @Override + public Serializable getValue(String backendName, BasicDBObject record) throws VascBackendException { + return (Serializable) record.get(backendName); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendAccessDataRecord#setValue(java.lang.String, java.io.Serializable, java.io.Serializable) + */ + @Override + public void setValue(String backendName, BasicDBObject record,Serializable value) throws VascBackendException { + record.put(backendName, value); } } diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendCrud.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendCrud.java new file mode 100644 index 0000000..1afa85b --- /dev/null +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendCrud.java @@ -0,0 +1,91 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.mongodb; + +import java.util.logging.Logger; + +import org.bson.types.ObjectId; + +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; + +import com.mongodb.DBCollection; +import com.mongodb.DBObject; +import com.mongodb.BasicDBObject; +import com.mongodb.WriteConcern; +import com.mongodb.WriteResult; + +/** + * MongodbVascBackend Provides backend for mongodb. + * + * @author Willem Cazander + * @version 1.0 Dec 30, 2011 + */ +public class MongodbVascBackendCrud extends AbstractMongodbVascBackend implements VascBackendCrud { + + private Logger logger = null; + + public MongodbVascBackendCrud() { + logger = Logger.getLogger(MongodbVascBackendCrud.class.getName()); + } + + @Override + public BasicDBObject newRecord() throws VascBackendException { + return new BasicDBObject(); + } + + @Override + public BasicDBObject fetch(ObjectId recordPK) throws VascBackendException { + return (BasicDBObject)getDBCollection().findOne(new BasicDBObject(PK_FIELD_NAME,recordPK)); + } + + @Override + public BasicDBObject persist(BasicDBObject object) throws VascBackendException { + getDBCollection().insert(object); + return fetch(object.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME)); + } + + @Override + public BasicDBObject merge(BasicDBObject row) throws VascBackendException { + DBCollection coll = getDBCollection(); + DBObject query = new BasicDBObject(); + query.put(AbstractMongodbVascBackend.PK_FIELD_NAME,row.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME)); + WriteResult wr = coll.update(query,row,false,false,WriteConcern.SAFE); + logger.finer("WriteResult: "+wr); + return fetch(row.getObjectId(AbstractMongodbVascBackend.PK_FIELD_NAME)); + } + + @Override + public void delete(ObjectId objectId) throws VascBackendException { + deleteById(objectId); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataRecord() + */ + @Override + public VascBackendAccessDataRecord createVascBackendAccessDataRecord() { + return new MongodbVascBackendAccessDataRecord(); + } +} diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendList.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendList.java new file mode 100644 index 0000000..5d3dcf0 --- /dev/null +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendList.java @@ -0,0 +1,127 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.mongodb; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.logging.Logger; + +import org.bson.types.ObjectId; + +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; + +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; +import com.mongodb.BasicDBObject; + +/** + * MongodbVascBackendList Provides backend for mongodb. + * + * @author Willem Cazander + * @version 1.0 Dec 30, 2011 + */ +public class MongodbVascBackendList extends AbstractMongodbVascBackend implements VascBackendList { + + private Logger logger = null; + private final EnumSet features = EnumSet.noneOf(VascBackendListFeature.class); + private final List rowActions = new ArrayList(); + + public MongodbVascBackendList() { + logger = Logger.getLogger(MongodbVascBackendList.class.getName()); + features.add(VascBackendListFeature.PAGE_DATA); + rowActions.add(ROW_ACTION_DELETE); + } + + @Override + public EnumSet getSupportedFeatures() { + return features; + } + + private long fetchTotalExecuteSize(VascBackendListRequest state) { + DBCollection coll = getDBCollection(); + DBObject query = createFilterQuery(state); + long result = coll.count(query); + return result; + } + + private DBObject createFilterQuery(VascBackendListRequest state) { + DBObject query = new BasicDBObject(); + for (String key:state.getDataParameterKeys()) { + Object value = state.getDataParameter(key); + query.put(key, value); + logger.finer("Setting query parameter key: '"+key+"' value: '"+value+"'"); + } + return query; + } + + @Override + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + return new DefaultVascBackendListResult(executeList(state),fetchTotalExecuteSize(state)); + } + + private List executeList(VascBackendListRequest state) throws VascBackendException { + DBCollection coll = getDBCollection(); + DBObject query = createFilterQuery(state); + DBCursor cur = coll.find(query); + if (state.getPageSize()>0) { + cur.limit(state.getPageSize()); + cur.skip(state.getPageIndex()); + } + List result = new ArrayList(cur.count()); + while (cur.hasNext()) { + DBObject row = cur.next(); + result.add((BasicDBObject)row); + } + return result; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackend#createVascBackendAccessDataRecord() + */ + @Override + public VascBackendAccessDataRecord createVascBackendAccessDataRecord() { + return new MongodbVascBackendAccessDataRecord(); + } + + @Override + public List getSupportedRowActions() { + return rowActions; + } + + @Override + public void executeRowAction(VascBackendListRequest request,List recordPKs, String actionName) throws VascBackendException { + if (ROW_ACTION_DELETE.equals(actionName)) { + for (ObjectId objectId:recordPKs) { + deleteById(objectId); + } + } + } +} diff --git a/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendSelect.java b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendSelect.java new file mode 100644 index 0000000..50106c3 --- /dev/null +++ b/vasc-backend/vasc-backend-mongodb/src/main/java/net/forwardfire/vasc/backend/mongodb/MongodbVascBackendSelect.java @@ -0,0 +1,70 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.mongodb; + +import java.util.ArrayList; +import java.util.List; + +import org.bson.types.ObjectId; + +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.select.DefaultVascBackendSelectItem; +import net.forwardfire.vasc.backend.select.VascBackendSelect; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; + +import com.mongodb.DBCollection; +import com.mongodb.DBCursor; +import com.mongodb.DBObject; +import com.mongodb.BasicDBObject; + +/** + * MongodbVascBackendSelect Provides backend for mongodb. + * + * @author Willem Cazander + * @version 1.0 Dec 30, 2011 + */ +public class MongodbVascBackendSelect extends AbstractMongodbVascBackend implements VascBackendSelect { + + @Override + public List> execute() throws VascBackendException { + DBCollection coll = getDBCollection(); + DBObject query = new BasicDBObject(); + DBCursor cur = coll.find(query); + List> result = new ArrayList>(cur.count()); + while (cur.hasNext()) { + BasicDBObject row = (BasicDBObject)cur.next(); + + boolean header = false; + boolean enabled = true; + String name = row.getString("toto"); + boolean nameI18nKey = false; + String description = row.getString("sdf"); + boolean descriptionI18nKey = false; + ObjectId primaryKey = row.getObjectId(PK_FIELD_NAME); + + result.add(new DefaultVascBackendSelectItem(header,enabled,name,nameI18nKey,description,descriptionI18nKey,primaryKey)); + } + return result; + } + +} diff --git a/vasc-backend/vasc-backend-object/.project b/vasc-backend/vasc-backend-object/.project new file mode 100644 index 0000000..841aecd --- /dev/null +++ b/vasc-backend/vasc-backend-object/.project @@ -0,0 +1,23 @@ + + + vasc-backend-object + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-backend/vasc-backend-object/pom.xml b/vasc-backend/vasc-backend-object/pom.xml new file mode 100644 index 0000000..fd56940 --- /dev/null +++ b/vasc-backend/vasc-backend-object/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + net.forwardfire.vasc.backend + vasc-backend + 0.4.2-SNAPSHOT + + vasc-backend-object + vasc-backend-object + vasc-backend-object + + + net.forwardfire.vasc.backend + vasc-backend-api + ${project.version} + + + \ No newline at end of file diff --git a/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelect.java b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelect.java new file mode 100644 index 0000000..1b2f5ab --- /dev/null +++ b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelect.java @@ -0,0 +1,141 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.backend.object; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import net.forwardfire.vasc.backend.AbstractVascBackendLocal; +import net.forwardfire.vasc.backend.VascBackendAccessDataKey; +import net.forwardfire.vasc.backend.VascBackendException; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.select.DefaultVascBackendSelectItem; +import net.forwardfire.vasc.backend.select.VascBackendSelect; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; + +/** +* ObjectEnumVascBackendSelect uses an Enum as select backend. +* +* @author Willem Cazander +* @version 1.0 Oct 27, 2007 +*/ +public class ObjectEnumVascBackendSelect extends AbstractVascBackendLocal implements VascBackendSelect { + + private Class> enumClass = null; + private ObjectEnumVascBackendSelectType enumReturnType = null; + private String enumReturnMethod = null; + + @Override + protected void startBackendLocal() { + requireNonNull(enumClass, "enumClass is null"); + requireNonNull(enumReturnType, "enumClass is null"); + } + + @Override + public VascBackendAccessDataKey createVascBackendAccessDataKey() { + return null; + } + + @Override + public List> execute() throws VascBackendException { + + List> result = new ArrayList>(); + + for (Enum enumObject:enumClass.getEnumConstants()) { + + + boolean header = false; + boolean enabled = true; + String name = enumObject.name(); + boolean nameI18nKey = false; + String description = enumObject.name(); + boolean descriptionI18nKey = false; + ENUM_RETURN_TYPE primaryKey = (ENUM_RETURN_TYPE)getEnumValue(enumObject); + + result.add(new DefaultVascBackendSelectItem(header,enabled,name,nameI18nKey,description,descriptionI18nKey,primaryKey)); + } + + return result; + } + + private Object getEnumValue(Enum enumObject) { + switch (enumReturnType) { + case VALUE: + return enumObject; + case METHOD: + try { + return enumObject.getClass().getMethod(enumReturnMethod, new Class[]{}).invoke(null, new Object[]{}); + } catch (Exception e) { + throw new IllegalStateException("Could not get static return method value: "+e.getMessage(),e); + } + case NAME: + return enumObject.name(); + case ORDINAL: + return enumObject.ordinal(); + default: + throw new IllegalStateException("Unknown enum return type: "+enumReturnType.name()); + } + } + +/* + public List getVascSelectItems(VascEntry currentEntry) throws VascException { + List result = new ArrayList(100); + + if (nullLabel!=null) { + if (nullKeyValue==null) { + nullKeyValue = "null"; + } + nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); + VascBackendSelectItem item = new VascBackendSelectItem(nullLabel,null,nullKeyValue); + result.add(item); + } + + if (enumClass!=null) { + for (Object o:enumClass.getEnumConstants()) { + String value = o.toString(); + result.add(new VascBackendSelectItem(value,value,value)); + } + } + if (data==null) { + return result; + } + if (data instanceof String) { + String[] values = ((String)data).split(","); + for (String value:values) { + result.add(new VascBackendSelectItem(value,value,value)); + } + } else if (data instanceof List) { + List values = (List)data; + for (Object o:values) { + String value = ""+o; + result.add(new VascBackendSelectItem(value,value,value)); + } + } + + return result; + } +*/ + +} \ No newline at end of file diff --git a/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelectType.java b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelectType.java new file mode 100644 index 0000000..fc9d1a1 --- /dev/null +++ b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/ObjectEnumVascBackendSelectType.java @@ -0,0 +1,9 @@ +package net.forwardfire.vasc.backend.object; + +public enum ObjectEnumVascBackendSelectType { + + VALUE, + NAME, + ORDINAL, + METHOD, +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/VascSelectItemModelEntry.java similarity index 56% rename from vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java rename to vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/VascSelectItemModelEntry.java index 2d9b2f3..b55b0e5 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelEntry.java +++ b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/VascSelectItemModelEntry.java @@ -20,7 +20,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.impl.ui; +package net.forwardfire.vasc.backend.object; import java.io.Serializable; import java.util.ArrayList; @@ -28,17 +28,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.forwardfire.vasc.backend.DefaultVascBackendState; -import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldLocal; -import net.forwardfire.vasc.core.VascEntryLocal; -import net.forwardfire.vasc.core.ui.VascSelectItem; -import net.forwardfire.vasc.core.ui.VascSelectItemModel; -import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; /** * The DefaultVascSelectItemModel @@ -46,8 +40,9 @@ import net.forwardfire.vasc.core.VascException; * @author Willem Cazander * @version 1.0 Oct 27, 2007 */ -public class VascSelectItemModelEntry implements VascSelectItemModel { +public class VascSelectItemModelEntry /*implements VascSelectItemModel*/ { + /* private static final long serialVersionUID = 1L; private String entryId = null; private String keyFieldId = null; @@ -59,12 +54,9 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { private Map entryParameterFieldIds = new HashMap(3); private Boolean useParentFields = null; - /** - * @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry) - */ @Override - public List getVascSelectItems(VascEntry currentEntry) throws VascException { - List result = new ArrayList(100); + public List getVascSelectItems(VascEntry currentEntry) throws VascException { + List result = new ArrayList(100); VascEntryLocal entry = (VascEntryLocal)currentEntry.getVascFrontendController().getVascController().getVascEntryController().getVascEntryById(entryId); if (keyFieldId==null) { @@ -85,7 +77,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { // set frontend data for new clone, we need te get better lifecycle management for stats/entry/etc entry.setVascFrontendController(currentEntry.getVascFrontendController()); - VascBackend back = currentEntry.getVascFrontendController().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendController().getVascController(), entry); + VascBackendCrud back = currentEntry.getVascFrontendController().getVascController().getVascEntryConfigController().configVascBackendProxied(currentEntry.getVascFrontendController().getVascController(), entry); try { if (nullLabel!=null) { if (nullKeyValue==null) { @@ -93,14 +85,14 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { } nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); if (nullObjectValue==null) { - result.add(new VascSelectItem(nullLabel,null,nullKeyValue)); + result.add(new VascBackendSelectItem(nullLabel,null,nullKeyValue)); } else { - result.add(new VascSelectItem(nullLabel,nullObjectValue,nullKeyValue)); + result.add(new VascBackendSelectItem(nullLabel,nullObjectValue,nullKeyValue)); } } // set def para - VascBackendState state = new DefaultVascBackendState(); + DefaultVascBackendListRequest state = new DefaultVascBackendListRequest(); for (String key2:entry.getEntryParameterKeys()) { Object value = entry.getEntryParameter(key2); @@ -137,7 +129,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { } VascEntryField field = fieldOrg.clone(); field.getVascValidators().clear(); - VascEntryFieldValue v = fieldEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); + VascBackendAccessDataRecord v = fieldEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); Serializable record = fieldEntry.getVascFrontendController().getVascEntryState().getEntryDataObject(); if (record==null) { @@ -157,7 +149,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { VascEntryField fieldClone = key.clone(); fieldClone.getVascValidators().clear(); - VascEntryFieldValue v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); + VascBackendAccessDataRecord v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); key.setVascEntryFieldValue(v); } if (dis.getVascEntryFieldValue()==null) { @@ -165,7 +157,7 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { VascEntryField fieldClone = dis.clone(); fieldClone.getVascValidators().clear(); - VascEntryFieldValue v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); + VascBackendAccessDataRecord v = currentEntry.getVascFrontendController().getVascEntryState().getVascBackend().provideVascEntryFieldValue(); dis.setVascEntryFieldValue(v); } @@ -173,12 +165,12 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { // execute for (Serializable o:back.execute(state).getPageData()) { Serializable keyId = key.getVascEntryFieldValue().getValue(key.getBackendName(), o); - String nameId = dis.getVascEntryFieldValue().getDisplayValue(dis.getBackendName(), o); + String nameId = ""+dis.getVascEntryFieldValue().getValue(dis.getBackendName(), o); if (returnKeyValue!=null && false==returnKeyValue) { - VascSelectItem item = new VascSelectItem(nameId,o,""+keyId); + VascBackendSelectItem item = new VascBackendSelectItem(nameId,o,""+keyId); result.add(item); } else { - VascSelectItem item = new VascSelectItem(nameId,keyId,""+keyId); // per default return keyID object. + VascBackendSelectItem item = new VascBackendSelectItem(nameId,keyId,""+keyId); // per default return keyID object. result.add(item); } } @@ -187,132 +179,133 @@ public class VascSelectItemModelEntry implements VascSelectItemModel { } return result; } - - /** - * @return the entryId - */ - public String getEntryId() { - return entryId; - } - - /** - * @param entryId the entryId to set - */ - public void setEntryId(String entryId) { - this.entryId = entryId; - } - - /** - * @return the keyFieldId - */ - public String getKeyFieldId() { - return keyFieldId; - } - - /** - * @param keyFieldId the keyFieldId to set - */ - public void setKeyFieldId(String keyFieldId) { - this.keyFieldId = keyFieldId; - } - - /** - * @return the displayFieldId - */ - public String getDisplayFieldId() { - return displayFieldId; - } - - /** - * @param displayFieldId the displayFieldId to set - */ - public void setDisplayFieldId(String displayFieldId) { - this.displayFieldId = displayFieldId; - } - - /** - * @return the nullLabel - */ - @Override - public String getNullLabel() { - return nullLabel; - } - - /** - * @param nullLabel the nullLabel to set - */ - @Override - public void setNullLabel(String nullLabel) { - this.nullLabel = nullLabel; - } - - /** - * @return the nullKeyValue - */ - @Override - public String getNullKeyValue() { - return nullKeyValue; - } - - /** - * @param nullKeyValue the nullKeyValue to set - */ - @Override - public void setNullKeyValue(String nullKeyValue) { - this.nullKeyValue = nullKeyValue; - } - - /** - * @return the returnKeyValue - */ - public Boolean getReturnKeyValue() { - return returnKeyValue; - } - - /** - * @param returnKeyValue the returnKeyValue to set - */ - public void setReturnKeyValue(Boolean returnKeyValue) { - this.returnKeyValue = returnKeyValue; - } - - public String getEntryParameterFieldId(String parameterName) { - return entryParameterFieldIds.get(parameterName); - } - public void addEntryParameterFieldId(String parameterName,String valueFieldId) { - entryParameterFieldIds.put(parameterName, valueFieldId); - } - public List getEntryParameterFieldIdKeys() { - return new ArrayList(entryParameterFieldIds.keySet()); - } - - /** - * @return the useParentFields - */ - public Boolean getUseParentFields() { - return useParentFields; - } - - /** - * @param useParentFields the useParentFields to set - */ - public void setUseParentFields(Boolean useParentFields) { - this.useParentFields = useParentFields; - } - - /** - * @return the nullObjectValue - */ - public String getNullObjectValue() { - return nullObjectValue; - } - - /** - * @param nullObjectValue the nullObjectValue to set - */ - public void setNullObjectValue(String nullObjectValue) { - this.nullObjectValue = nullObjectValue; - } - + /* +// +// /** +// * @return the entryId +// */ +// public String getEntryId() { +// return entryId; +// } +// +// /** +// * @param entryId the entryId to set +// */ +// public void setEntryId(String entryId) { +// this.entryId = entryId; +// } +// +// /** +// * @return the keyFieldId +// */ +// public String getKeyFieldId() { +// return keyFieldId; +// } +// +// /** +// * @param keyFieldId the keyFieldId to set +// */ +// public void setKeyFieldId(String keyFieldId) { +// this.keyFieldId = keyFieldId; +// } +// +// /** +// * @return the displayFieldId +// */ +// public String getDisplayFieldId() { +// return displayFieldId; +// } +// +// /** +// * @param displayFieldId the displayFieldId to set +// */ +// public void setDisplayFieldId(String displayFieldId) { +// this.displayFieldId = displayFieldId; +// } +// +// /** +// * @return the nullLabel +// */ +// @Override +// public String getNullLabel() { +// return nullLabel; +// } +// +// /** +// * @param nullLabel the nullLabel to set +// */ +// @Override +// public void setNullLabel(String nullLabel) { +// this.nullLabel = nullLabel; +// } +// +// /** +// * @return the nullKeyValue +// */ +// @Override +// public String getNullKeyValue() { +// return nullKeyValue; +// } +// +// /** +// * @param nullKeyValue the nullKeyValue to set +// */ +// @Override +// public void setNullKeyValue(String nullKeyValue) { +// this.nullKeyValue = nullKeyValue; +// } +// +// /** +// * @return the returnKeyValue +// */ +// public Boolean getReturnKeyValue() { +// return returnKeyValue; +// } +// +// /** +// * @param returnKeyValue the returnKeyValue to set +// */ +// public void setReturnKeyValue(Boolean returnKeyValue) { +// this.returnKeyValue = returnKeyValue; +// } +// +// public String getEntryParameterFieldId(String parameterName) { +// return entryParameterFieldIds.get(parameterName); +// } +// public void addEntryParameterFieldId(String parameterName,String valueFieldId) { +// entryParameterFieldIds.put(parameterName, valueFieldId); +// } +// public List getEntryParameterFieldIdKeys() { +// return new ArrayList(entryParameterFieldIds.keySet()); +// } +// +// /** +// * @return the useParentFields +// */ +// public Boolean getUseParentFields() { +// return useParentFields; +// } +// +// /** +// * @param useParentFields the useParentFields to set +// */ +// public void setUseParentFields(Boolean useParentFields) { +// this.useParentFields = useParentFields; +// } +// +// /** +// * @return the nullObjectValue +// */ +// public String getNullObjectValue() { +// return nullObjectValue; +// } +// +// /** +// * @param nullObjectValue the nullObjectValue to set +// */ +// public void setNullObjectValue(String nullObjectValue) { +// this.nullObjectValue = nullObjectValue; +// } +// } \ No newline at end of file diff --git a/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/package-info.java b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/package-info.java new file mode 100644 index 0000000..5371e9b --- /dev/null +++ b/vasc-backend/vasc-backend-object/src/main/java/net/forwardfire/vasc/backend/object/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.backend.object; \ No newline at end of file diff --git a/vasc-backend/vasc-backend-test/src/main/java/net/forwardfire/vasc/backend/test/CrudTest.java b/vasc-backend/vasc-backend-test/src/main/java/net/forwardfire/vasc/backend/test/CrudTest.java index 2e67a8c..edc9190 100644 --- a/vasc-backend/vasc-backend-test/src/main/java/net/forwardfire/vasc/backend/test/CrudTest.java +++ b/vasc-backend/vasc-backend-test/src/main/java/net/forwardfire/vasc/backend/test/CrudTest.java @@ -4,12 +4,12 @@ import java.io.Serializable; import junit.framework.TestCase; import net.forwardfire.vasc.backend.DefaultVascBackendController; -import net.forwardfire.vasc.backend.DefaultVascBackendState; -import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest; +import net.forwardfire.vasc.backend.list.VascBackendListResult; import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; -import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend; +import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackendCrud; import org.testng.annotations.Test; @@ -27,7 +27,7 @@ public class CrudTest extends TestCase { mmDB.setUsername("postgres"); mmDB.setPassword("postgresql"); - MetaModelVascBackend mm = new MetaModelVascBackend(); + MetaModelVascBackendCrud mm = new MetaModelVascBackendCrud(); mm.setId("mm"); mm.setTable("country"); mm.setTableId("country_id"); @@ -42,21 +42,23 @@ public class CrudTest extends TestCase { setup(); - VascBackend backend = (VascBackend) backends.getVascBackendById("mm"); + VascBackendCrud backend = (VascBackendCrud) backends.getVascBackendById(VascBackendCrud.class,"mm"); assertNotNull(backend); - DefaultVascBackendState state = new DefaultVascBackendState(); - VascBackendResult result = backend.execute(state); - assertNotNull(result); - assertFalse(result.getPageData().isEmpty()); - VascEntryFieldValue values = backend.provideVascEntryFieldValue(); - - for (Serializable record:result.getPageData()) { - Object id = values.getValue("country_id", record); - Object name = values.getValue("name", record); - Object code = values.getValue("code", record); - System.out.println("line: "+id+" name: "+name+" code: "+code); - } +// +// DefaultVascBackendListRequest state = new DefaultVascBackendListRequest(); +// VascBackendListResult result = backend.execute(state); +// assertNotNull(result); +// assertFalse(result.getData().isEmpty()); +// +// VascBackendAccessDataRecord values = backend.provideVascEntryFieldValue(); +// +// for (Serializable record:result.getData()) { +// Object id = values.getValue("country_id", record); +// Object name = values.getValue("name", record); +// Object code = values.getValue("code", record); +// System.out.println("line: "+id+" name: "+name+" code: "+code); +// } } } diff --git a/vasc-core-ejb3-client/pom.xml b/vasc-core-ejb3-client/pom.xml index b128e38..d459523 100644 --- a/vasc-core-ejb3-client/pom.xml +++ b/vasc-core-ejb3-client/pom.xml @@ -1,24 +1,25 @@ - - 4.0.0 - - net.forwardfire.vasc - vasc - 0.4.2-SNAPSHOT - - vasc-core-ejb3-client - vasc-core-ejb3-client - vasc-core-ejb3-client - - - net.forwardfire.vasc - vasc-core - ${project.version} - - - javax.ejb - ejb-api - ${ejb-api.version} - provided - - + + 4.0.0 + + net.forwardfire.vasc + vasc + 0.4.2-SNAPSHOT + + vasc-core-ejb3-client + vasc-core-ejb3-client + vasc-core-ejb3-client + + + net.forwardfire.vasc + vasc-core + ${project.version} + + + javax + javaee-api + ${javaee-api.version} + provided + + diff --git a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java index 60af2c2..cb0673f 100644 --- a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java +++ b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java @@ -26,12 +26,12 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.backend.VascEntryRecordCreator; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * VascServiceRemoteBackend wraps VascBasckend to the ejb3 context. @@ -39,7 +39,7 @@ import net.forwardfire.vasc.backend.VascEntryRecordCreator; * @author Willem Cazander * @version 1.0 18 Nov 2012 */ -public class VascServiceRemoteBackend implements VascBackend { +public class VascServiceRemoteBackend implements VascBackendCrud { private String backendId = null; private VascServiceManager vascManager = null; @@ -68,13 +68,13 @@ public class VascServiceRemoteBackend implemen // we cant change id } - public void delete(DATA_OBJECT object) throws VascBackendException { + public void delete(DATA_PK object) throws VascBackendException { Object[] args = new Object[1]; args[0]=object; vascManager.invokeBackendMethod(backendId, "delete", args); } - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { + public long doRecordMoveDownById(VascBackendListRequest state,Object primaryId) throws VascBackendException { Object[] args = new Object[2]; args[0]=state; args[1]=primaryId; @@ -82,7 +82,7 @@ public class VascServiceRemoteBackend implemen return (Long)result; } - public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { + public long doRecordMoveUpById(VascBackendListRequest state, Object primaryId) throws VascBackendException { Object[] args = new Object[2]; args[0]=state; args[1]=primaryId; @@ -91,14 +91,14 @@ public class VascServiceRemoteBackend implemen } @SuppressWarnings("unchecked") - public VascBackendResult execute(VascBackendState state) throws VascBackendException { + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { Object[] args = new Object[1]; args[0]=state; Object result = vascManager.invokeBackendMethod(backendId, "execute", args); - return (VascBackendResult)result; + return (VascBackendListResult)result; } - public long fetchTotalExecuteSize(VascBackendState state) { + public long fetchTotalExecuteSize(VascBackendListRequest state) { Object[] args = new Object[1]; args[0]=state; Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); @@ -144,10 +144,10 @@ public class VascServiceRemoteBackend implemen } @Override - public VascEntryFieldValue provideVascEntryFieldValue() { + public VascBackendAccessDataRecord provideVascEntryFieldValue() { Object[] args = new Object[0]; Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); - return (VascEntryFieldValue)result; + return (VascBackendAccessDataRecord)result; } @Override diff --git a/vasc-core-ejb3-server/pom.xml b/vasc-core-ejb3-server/pom.xml index 7a679ff..6424a60 100644 --- a/vasc-core-ejb3-server/pom.xml +++ b/vasc-core-ejb3-server/pom.xml @@ -1,35 +1,30 @@ - - 4.0.0 - - net.forwardfire.vasc - vasc - 0.4.2-SNAPSHOT - - vasc-core-ejb3-server - vasc-core-ejb3-server - vasc-core-ejb3-server - - + + 4.0.0 + net.forwardfire.vasc - vasc-core-ejb3-client - ${project.version} - - - net.forwardfire.vasc.backend - vasc-backend-jpa - ${project.version} - - - javax.ejb - ejb-api - ${ejb-api.version} - provided - - - javax.persistence - persistence-api - ${persistence-api.version} - provided - - + vasc + 0.4.2-SNAPSHOT + + vasc-core-ejb3-server + vasc-core-ejb3-server + vasc-core-ejb3-server + + + net.forwardfire.vasc + vasc-core-ejb3-client + ${project.version} + + + net.forwardfire.vasc.backend + vasc-backend-jpa + ${project.version} + + + javax + javaee-api + ${javaee-api.version} + provided + + \ No newline at end of file diff --git a/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java b/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java index fe3f0ef..52dfb85 100644 --- a/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java +++ b/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java @@ -45,7 +45,7 @@ import javax.persistence.EntityManager; import org.x4o.xml.io.X4OReader; -import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.backends.jpa.EntityManagerProvider; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; @@ -224,7 +224,7 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ public Object invokeBackendMethod(String backendId,String method,Object[] args) { VascController v = getVascController(); - VascBackend vb = v.getVascBackendController().getVascBackendById(backendId); + VascBackendCrud vb = v.getVascBackendController().getVascBackendById(backendId); Method vbm = null; for (Method m:vb.getClass().getMethods()) { if (m.getName().equals(method)) { diff --git a/vasc-core/pom.xml b/vasc-core/pom.xml index 736adc0..b14c515 100644 --- a/vasc-core/pom.xml +++ b/vasc-core/pom.xml @@ -1,46 +1,47 @@ - - 4.0.0 - - vasc - net.forwardfire.vasc - 0.4.2-SNAPSHOT - - vasc-core - vasc-core - vasc-core - - - org.x4o - x4o-driver - ${x4o.version} - - - org.x4o - x4o-meta - ${x4o.version} - - - net.forwardfire.vasc.backend - vasc-backend-api - ${project.version} - - - javax.persistence - persistence-api - ${persistence-api.version} - provided - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - provided - - - de.odysseus.juel - juel - 2.1.0 - test - - + + 4.0.0 + + vasc + net.forwardfire.vasc + 0.4.2-SNAPSHOT + + vasc-core + vasc-core + vasc-core + + + org.x4o + x4o-driver + ${x4o.version} + + + org.x4o + x4o-meta + ${x4o.version} + + + net.forwardfire.vasc.backend + vasc-backend-api + ${project.version} + + + javax + javaee-api + ${javaee-api.version} + provided + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + provided + + + de.odysseus.juel + juel + 2.1.0 + test + + diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java index 83a2a87..38241ee 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/annotations/VascChoicesSelectItemModel.java @@ -26,7 +26,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.core.ui.VascSelectItem; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; import net.forwardfire.vasc.core.ui.VascSelectItemModel; import net.forwardfire.vasc.core.VascException; @@ -54,8 +54,8 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa * @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry) */ @Override - public List getVascSelectItems(net.forwardfire.vasc.core.VascEntry entry) throws VascException { - List result = new ArrayList(10); + public List getVascSelectItems(net.forwardfire.vasc.core.VascEntry entry) throws VascException { + List result = new ArrayList(10); if ("null".equals(vascChoices.nullLabel())==false) { nullLabel = vascChoices.nullLabel(); nullKeyValue = vascChoices.nullKeyValue(); @@ -65,7 +65,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa nullKeyValue = "null"; } String nullLabelText = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); - VascSelectItem item = new VascSelectItem(nullLabelText,null,nullKeyValue); + VascBackendSelectItem item = new VascBackendSelectItem(nullLabelText,null,nullKeyValue); result.add(item); } int index = 0; @@ -78,7 +78,7 @@ public class VascChoicesSelectItemModel implements VascSelectItemModel,Serializa throw new IllegalStateException("Can't have unequal sizes of array of keys and values of vascChoices annotation."); } for (String key:a) { - VascSelectItem item = new VascSelectItem(); + VascBackendSelectItem item = new VascBackendSelectItem(); String name = null; if (val) { name = key; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java index 3091798..394940d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxy.java @@ -23,13 +23,14 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; +import java.util.EnumSet; +import java.util.List; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; -import net.forwardfire.vasc.backend.VascEntryRecordCreator; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntry; /** @@ -38,19 +39,25 @@ import net.forwardfire.vasc.core.VascEntry; * @author Willem Cazander * @version 1.0 Apr 1, 2009 */ -abstract public class AbstractVascBackendProxy implements VascBackendProxy { +abstract public class AbstractVascBackendProxy implements VascBackendProxy { - protected VascBackend backend = null; + protected VascBackendList backend = null; protected VascEntry entry = null; + private volatile boolean running = false; @Override - abstract public VascBackendProxy clone() throws CloneNotSupportedException; + abstract public VascBackendProxy clone() throws CloneNotSupportedException; + + protected void startBackendProxy() { + } + protected void stopBackendProxy() { + } /** - * @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry) + * @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.crud.VascBackendList, net.forwardfire.vasc.core.VascEntry) */ @Override - public void initProxy(VascBackend backend, VascEntry entry) { + final public void initProxy(VascBackendList backend, VascEntry entry) { if (backend==null) { throw new NullPointerException("backend object may not be null."); } @@ -59,8 +66,35 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { } this.backend=backend; this.entry=entry; + startBackend(); } + /** + * @see net.forwardfire.vasc.backend.VascBackendLifeCycle#startBackend() + */ + @Override + final public void startBackend() { + startBackendProxy(); + running = true; + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendLifeCycle#stopBackend() + */ + @Override + final public void stopBackend() { + running = false; + stopBackendProxy(); + } + + /** + * @see net.forwardfire.vasc.backend.VascBackendLifeCycle#isRunning() + */ + @Override + public boolean isRunning() { + return running; + } + /** * @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#isProxyNeeded() */ @@ -70,104 +104,7 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.VascBackend#startBackend() - */ - @Override - public void startBackend() { - backend.startBackend(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#stopBackend() - */ - @Override - public void stopBackend() { - backend.stopBackend(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isReadOnly() - */ - @Override - public boolean isReadOnly() { - return backend.isReadOnly(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSortable() - */ - @Override - public boolean isSortable() { - return backend.isSortable(); - } - - /** - * @throws Exception - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - return backend.execute(state); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#delete(java.lang.Object) - */ - @Override - public void delete(Serializable object) throws VascBackendException { - backend.delete(object); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isPageable() - */ - @Override - public boolean isPageable() { - return backend.isPageable(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSearchable() - */ - @Override - public boolean isSearchable() { - return backend.isSearchable(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#merge(java.lang.Object) - */ - @Override - public Serializable merge(Serializable object) throws VascBackendException { - return backend.merge(object); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#persist(java.lang.Object) - */ - @Override - public void persist(Serializable object) throws VascBackendException { - backend.persist(object); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryFieldValue() - */ - @Override - public VascEntryFieldValue provideVascEntryFieldValue() { - return backend.provideVascEntryFieldValue(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#provideVascEntryRecordCreator() - */ - @Override - public VascEntryRecordCreator provideVascEntryRecordCreator() { - return backend.provideVascEntryRecordCreator(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#getId() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#getId() */ @Override public String getId() { @@ -175,50 +112,25 @@ abstract public class AbstractVascBackendProxy implements VascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.VascBackend#setId(java.lang.String) + * @see net.forwardfire.vasc.backend.list.VascBackendList#getSupportedFeatures() */ @Override - public void setId(String id) { - backend.setId(id); + public EnumSet getSupportedFeatures() { + return backend.getSupportedFeatures(); // backend will always provide cloned copy } - /** - * @see net.forwardfire.vasc.core.VascBackend#doRecordMoveDownById(VascBackendState state,java.lang.Object) - */ @Override - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascBackendException { - return backend.doRecordMoveDownById(state,primaryId); + public VascBackendListResult execute(VascBackendListRequest request) throws VascBackendException { + return backend.execute(request); } - /** - * @see net.forwardfire.vasc.core.VascBackend#doRecordMoveUpById(VascBackendState state,java.lang.Object) - */ @Override - public long doRecordMoveUpById(VascBackendState state,Object primaryId) throws VascBackendException { - return backend.doRecordMoveUpById(state,primaryId); + public List getSupportedRowActions() { + return backend.getSupportedRowActions(); } - /** - * @see net.forwardfire.vasc.backend.VascBackend#isRecordMoveable() - */ @Override - public boolean isRecordMoveable() { - return backend.isRecordMoveable(); + public void executeRowAction(VascBackendListRequest request,List recordPKs,String actionName) throws VascBackendException { + executeRowAction(request, recordPKs, actionName); } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#hasPageSummary() - */ - @Override - public boolean hasPageSummary() { - return backend.hasPageSummary(); - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#hasTotalSummary() - */ - @Override - public boolean hasTotalSummary() { - return backend.hasTotalSummary(); - } -} \ No newline at end of file +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItem.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxyFeature.java similarity index 53% rename from vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItem.java rename to vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxyFeature.java index aaf4a45..de282e7 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItem.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/AbstractVascBackendProxyFeature.java @@ -20,88 +20,45 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.core.ui; +package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; +import java.util.EnumSet; + +import net.forwardfire.vasc.backend.list.VascBackendListFeature; /** + * AbstractVascBackendProxyFeature to implement single features of the backend. * * @author Willem Cazander - * @version 1.0 Aug 12, 2007 + * @version 1.0 Aug 27, 2014 */ -public class VascSelectItem { - - private String label = null; - private Serializable value = null; - private String keyValue = null; - private boolean disabled = false; +abstract public class AbstractVascBackendProxyFeature extends AbstractVascBackendProxy { - public VascSelectItem() { - - } - public VascSelectItem(String label,Serializable value) { - setLabel(label); - setValue(value); - } - public VascSelectItem(String label,Serializable value,String keyValue) { - setLabel(label); - setValue(value); - setKeyValue(keyValue); + private final VascBackendListFeature proxyFeature; + private final VascBackendListFeature proxyFeatureExtraFlag; + + protected AbstractVascBackendProxyFeature(VascBackendListFeature proxyFeature,VascBackendListFeature proxyFeatureExtraFlag) { + this.proxyFeature=proxyFeature; + this.proxyFeatureExtraFlag=proxyFeatureExtraFlag; } /** - * @return the label + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() */ - public String getLabel() { - return label; + @Override + final public boolean isProxyNeeded() { + return !backend.getSupportedFeatures().contains(proxyFeature); } /** - * @param label the label to set + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#getSupportedFeatures() */ - public void setLabel(String label) { - this.label = label; - } - - /** - * @return the value - */ - public Serializable getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(Serializable value) { - this.value = value; - } - - /** - * @return the keyValue - */ - public String getKeyValue() { - return keyValue; - } - - /** - * @param keyValue the keyValue to set - */ - public void setKeyValue(String keyValue) { - this.keyValue = keyValue; - } - - /** - * @return the disabled - */ - public boolean isDisabled() { - return disabled; - } - - /** - * @param disabled the disabled to set - */ - public void setDisabled(boolean disabled) { - this.disabled = disabled; + @Override + final public EnumSet getSupportedFeatures() { + EnumSet result = super.getSupportedFeatures(); + result.add(proxyFeature); + result.add(proxyFeatureExtraFlag); + return result; } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxy.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxy.java index 62ddab9..c9beeeb 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxy.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxy.java @@ -24,7 +24,8 @@ package net.forwardfire.vasc.backend.proxy; import java.io.Serializable; -import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.VascBackendLifeCycle; +import net.forwardfire.vasc.backend.list.VascBackendList; import net.forwardfire.vasc.core.VascEntry; /** @@ -33,11 +34,11 @@ import net.forwardfire.vasc.core.VascEntry; * @author Willem Cazander * @version 1.0 May 9, 2012 */ -public interface VascBackendProxy extends VascBackend,Cloneable { +public interface VascBackendProxy extends VascBackendList,VascBackendLifeCycle,Cloneable { - void initProxy(VascBackend backend,VascEntry entry); + void initProxy(VascBackendList backend,VascEntry entry); boolean isProxyNeeded(); - VascBackendProxy clone() throws CloneNotSupportedException; + VascBackendProxy clone() throws CloneNotSupportedException; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java deleted file mode 100644 index 66f8b61..0000000 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyCache.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.vasc.backend.proxy; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; - -/** -* Does simple caching for the data. -* -* @author Willem Cazander -* @version 1.0 Nov 19, 2009 -*/ -public class VascBackendProxyCache extends AbstractVascBackendProxy { - - private VascBackendResult data = null; - private String searchString = null; - private Map dataState = null; - private int pageIndex = 0; - private int pageSize = 0; - private int pageSizeMax = 0; - private String sortField = null; - private boolean sortDir = true; - private boolean requestFlush = false; - - public VascBackendProxyCache() { - dataState = new HashMap(10); - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxyCache result = new VascBackendProxyCache(); - return result; - } - - private boolean isStateChanged(VascBackendState state) { - boolean changed = false; - for (String key:state.getDataParameterKeys()) { - Object value = state.getDataParameter(key); - Object valueLast = dataState.get(key); - dataState.put(key, value); - if (value==null & valueLast==null) { - continue; - } - if (value==null & valueLast!=null) { - changed = true; - break; - } - if (value.equals(valueLast)==false) { - changed = true; - break; - } - } - - if (state.getSortField()!=null && state.getSortField().equals(sortField)==false) { - changed = true; - } - sortField = state.getSortField(); - if (state.isSortAscending()==sortDir) { - changed = true; - } - sortDir = state.isSortAscending(); - - if (state.getPageSizeMax()==pageSizeMax) { - changed = true; - } - pageSizeMax = state.getPageSizeMax(); - if (state.getPageSize()==pageSize) { - changed = true; - } - pageSize = state.getPageSize(); - if (state.getPageIndex()==pageIndex) { - changed = true; - } - pageIndex = state.getPageIndex(); - - if (state.getSearchString()!=null && state.getSearchString().equals(searchString)==false) { - changed = true; - } - searchString = state.getSearchString(); - - if (requestFlush) { - requestFlush = false; - changed = true; - } - - return changed; - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#stopBackend() - */ - @Override - public void stopBackend() { - super.stopBackend(); - data = null; - dataState.clear(); - requestFlush = true; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - boolean changed = isStateChanged(state); - if (data==null | changed) { - data = backend.execute(state); - } - return data; - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object) - */ - @Override - public void delete(Serializable object) throws VascBackendException { - requestFlush = true; - super.delete(object); - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object) - */ - @Override - public Serializable merge(Serializable object) throws VascBackendException { - requestFlush = true; - return super.merge(object); - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object) - */ - @Override - public void persist(Serializable object) throws VascBackendException { - requestFlush = true; - super.persist(object); - } -} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java index c394335..4855506 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyEventExecutor.java @@ -26,10 +26,10 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackendEventType; @@ -40,7 +40,7 @@ import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener.VascBackend * @author Willem Cazander * @version 1.0 Sep 21, 2010 */ -public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { +public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { private List listeners = null; @@ -48,13 +48,13 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxyEventExecutor result = new VascBackendProxyEventExecutor(); + public VascBackendProxy clone() throws CloneNotSupportedException { + VascBackendProxyEventExecutor result = new VascBackendProxyEventExecutor<>(); return result; } @Override - public void initProxy(VascBackend backend,VascEntry entry) { + public void initProxy(VascBackendCrud backend,VascEntry entry) { super.initProxy(backend, entry); this.entry=entry; this.listeners=new ArrayList(10); @@ -115,10 +115,10 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object) */ @Override - public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascBackendException { + public long doRecordMoveDownById(VascBackendListRequest state, Object primaryId) throws VascBackendException { fireVascEvent(VascBackendEventType.PRE_MOVE_DOWN,primaryId); Long result = super.doRecordMoveDownById(state, primaryId); fireVascEvent(VascBackendEventType.POST_MOVE_DOWN,result); @@ -126,10 +126,10 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object) */ @Override - public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { + public long doRecordMoveUpById(VascBackendListRequest state, Object primaryId) throws VascBackendException { fireVascEvent(VascBackendEventType.PRE_MOVE_UP,primaryId); Long result = super.doRecordMoveUpById(state, primaryId); fireVascEvent(VascBackendEventType.POST_MOVE_UP,result); @@ -137,12 +137,12 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.VascBackendState) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#execute(net.forwardfire.vasc.backend.list.VascBackendListRequest) */ @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { fireVascEvent(VascBackendEventType.PRE_EXECUTE,state); - VascBackendResult result = super.execute(state); + VascBackendListResult result = super.execute(state); fireVascEvent(VascBackendEventType.POST_EXECUTE,result); return result; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java index aeb46b0..6c2c74c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyFilter.java @@ -26,12 +26,10 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * Simple filter support @@ -39,7 +37,7 @@ import net.forwardfire.vasc.core.VascEntry; * @author Willem Cazander * @version 1.0 Oct 27, 2007 */ -public class VascBackendProxyFilter extends AbstractVascBackendProxy { +public class VascBackendProxyFilter extends AbstractVascBackendProxy { private List filters = null; @@ -47,17 +45,16 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxyFilter result = new VascBackendProxyFilter(); + public VascBackendProxy clone() throws CloneNotSupportedException { + VascBackendProxyFilter result = new VascBackendProxyFilter<>(); return result; } /** - * @see net.forwardfire.vasc.backend.proxy.VascBackendProxy#initProxy(net.forwardfire.vasc.backend.VascBackend, net.forwardfire.vasc.core.VascEntry) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#startBackendProxy() */ @Override - public void initProxy(VascBackend backend, VascEntry entry) { - super.initProxy(backend,entry); + protected void startBackendProxy() { filters = entry.getVascBackendFilters(); for (VascProxyFilter filter:filters) { filter.initFilter(entry); @@ -76,19 +73,19 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - VascBackendResult result = backend.execute(state); + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + VascBackendListResult result = backend.execute(state); if (filters==null) { return result; } if (filters.isEmpty()) { return result; } - List search = new ArrayList(result.getPageData().size()/2); - for (Serializable o:result.getPageData()) { + List search = new ArrayList(result.getData().size()/2); + for (Serializable o:result.getData()) { for (VascProxyFilter filter:filters) { Serializable r = filter.filterObject(o); if (r!=null) { @@ -96,6 +93,6 @@ public class VascBackendProxyFilter extends AbstractVascBackendProxy { } } } - return new DefaultVascBackendResult(search,search.size()); + return new DefaultVascBackendListResult(search,search.size()); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java index 1cb5875..ab97183 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyPaged.java @@ -26,10 +26,11 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * Simulates a real pages backend. @@ -37,42 +38,26 @@ import net.forwardfire.vasc.backend.VascBackendState; * @author Willem Cazander * @version 1.0 Oct 27, 2007 */ -public class VascBackendProxyPaged extends AbstractVascBackendProxy { +public class VascBackendProxyPaged extends AbstractVascBackendProxyFeature { + + public VascBackendProxyPaged() { + super(VascBackendListFeature.PAGE_DATA,VascBackendListFeature.PAGE_DATA_PROXY); + } /** * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxyPaged result = new VascBackendProxyPaged(); - return result; + public VascBackendProxy clone() throws CloneNotSupportedException { + return new VascBackendProxyPaged(); } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @Override - public boolean isProxyNeeded() { - if (backend.isPageable()) { - return false; - } - return true; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isPageable() - */ - @Override - public boolean isPageable() { - return true; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - VascBackendResult allData = backend.execute(state); + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + VascBackendListResult allData = backend.execute(state); int pageSize = state.getPageSize(); if (pageSize==0) { return allData; @@ -81,12 +66,12 @@ public class VascBackendProxyPaged extends AbstractVascBackendProxy { int off = state.getPageIndex()*pageSize; int offMax = off+state.getPageSize(); for (int i=off;i=allData.getPageData().size()) { + if (i>=allData.getData().size()) { break; } - Serializable o = allData.getPageData().get(i); + Serializable o = allData.getData().get(i); paged.add(o); } - return new DefaultVascBackendResult(paged,allData.getPageData().size()); + return new DefaultVascBackendListResult(paged,allData.getData().size()); } -} \ No newline at end of file +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java index 9e1f173..6c9e67a 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySearch.java @@ -26,11 +26,12 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.DefaultVascBackendResult; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntryField; /** @@ -39,42 +40,27 @@ import net.forwardfire.vasc.core.VascEntryField; * @author Willem Cazander * @version 1.0 Oct 27, 2007 */ -public class VascBackendProxySearch extends AbstractVascBackendProxy { - +public class VascBackendProxySearch extends AbstractVascBackendProxyFeature { + + public VascBackendProxySearch() { + super(VascBackendListFeature.TEXT_SEARCH,VascBackendListFeature.TEXT_SEARCH_PROXY); + } + /** * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxySearch result = new VascBackendProxySearch(); + public VascBackendProxy clone() throws CloneNotSupportedException { + VascBackendProxySearch result = new VascBackendProxySearch<>(); return result; } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @Override - public boolean isProxyNeeded() { - if (backend.isSearchable()) { - return false; - } - return true; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#isSearchable() - */ - @Override - public boolean isSearchable() { - return true; - } - - /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) - */ - @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { - VascBackendResult result = backend.execute(state); + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { + VascBackendListResult result = backend.execute(state); if (state.getSearchString()==null) { return result; } @@ -82,59 +68,21 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy { return result; } String searchString = state.getSearchString().toLowerCase(); - List search = new ArrayList(result.getPageData().size()/4); - for (Serializable record:result.getPageData()) { + List search = new ArrayList(result.getData().size()/4); + for (Serializable record:result.getData()) { for (VascEntryField field:entry.getVascEntryFields()) { - VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(); + VascBackendAccessDataRecord fieldValue = backend.provideVascEntryFieldValue(); Serializable value = fieldValue.getValue(field.getBackendName(), record); if (value==null) { continue; // can't search null values. } String r = value.toString().toLowerCase(); - if (r.contains(searchString)) { - search.add(record); - break; - } - } - - /* - for (Method method:o.getClass().getMethods()) { - if (method.getName().startsWith("get")==false) { //a bit durty - continue; - } - if (method.getName().equals("getClass")) { - continue; - } - if (method.getReturnType().isAssignableFrom(Collection.class)) { - continue; - } - if (method.getReturnType().isAssignableFrom(List.class)) { - continue; - } - if (method.getReturnType().isAssignableFrom(Set.class)) { - continue; - } - if (method.getReturnType().isAssignableFrom(Map.class)) { - continue; - } - Object res; - try { - res = method.invoke(o,new Object[]{}); - } catch (Exception e) { - throw new VascException(e); + if (r.contains(searchString)) { + search.add(record); + break; } - if (res==null) { - continue; - } - String r = res.toString().toLowerCase(); - if (r.contains(searchString)) { - search.add(o); - break; - } - } - */ + } } - //records = search.size(); - return new DefaultVascBackendResult(search); + return new DefaultVascBackendListResult(search); } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java index faa3ef1..0b7b7af 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxySort.java @@ -27,9 +27,10 @@ import java.util.Collections; import java.util.Comparator; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntryField; /** @@ -38,28 +39,21 @@ import net.forwardfire.vasc.core.VascEntryField; * @author Willem Cazander * @version 1.0 Oct 27, 2007 */ -public class VascBackendProxySort extends AbstractVascBackendProxy { +public class VascBackendProxySort extends AbstractVascBackendProxyFeature { + + public VascBackendProxySort() { + super(VascBackendListFeature.SORT_DATA,VascBackendListFeature.SORT_DATA_PROXY); + } /** * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxySort result = new VascBackendProxySort(); + public VascBackendProxy clone() throws CloneNotSupportedException { + VascBackendProxySort result = new VascBackendProxySort<>(); return result; } - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#isProxyNeeded() - */ - @Override - public boolean isProxyNeeded() { - if (backend.isSortable()) { - return false; - } - return true; - } - public VascEntryField getVascEntryFieldByBackendName(String linkId) { for (VascEntryField a:entry.getVascEntryFields()) { if (a.getBackendName().equals(linkId)) { @@ -70,31 +64,32 @@ public class VascBackendProxySort extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @SuppressWarnings("unchecked") @Override - public VascBackendResult execute(final VascBackendState state) throws VascBackendException { - VascBackendResult result = backend.execute(state); + public VascBackendListResult execute(final VascBackendListRequest state) throws VascBackendException { + VascBackendListResult result = backend.execute(state); if (state.getSortField()==null) { return result; } final VascEntryField field = getVascEntryFieldByBackendName(state.getSortField()); - final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(); - Collections.sort(result.getPageData(), new Comparator() { + final VascBackendAccessDataRecord fieldValue = backend.provideVascEntryFieldValue(); + Collections.sort(result.getData(), new Comparator() { @SuppressWarnings("rawtypes") @Override public int compare(Serializable o1, Serializable o2) { try { Comparable c1 = null; Comparable c2 = null; - if (field.getDisplayName()!=null) { - c1 = fieldValue.getDisplayValue(field.getBackendName(), o1); - c2 = fieldValue.getDisplayValue(field.getBackendName(), o2); - } else { +// if (field.getDisplayName()!=null) { +// c1 = fieldValue.getValue(field.getBackendName(), o1); +// c2 = fieldValue.getValue(field.getBackendName(), o2); +// } else { + // TODO: fix none Comparable goes toString c1 = (Comparable)fieldValue.getValue(field.getBackendName(), o1); c2 = (Comparable)fieldValue.getValue(field.getBackendName(), o2); - } +// } if (c1==null & c2==null) { return 0; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java index 09ac070..abadd06 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/backend/proxy/VascBackendProxyTimerLogger.java @@ -27,8 +27,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * Does simple timer logging for the backend actions. @@ -36,7 +36,7 @@ import net.forwardfire.vasc.backend.VascBackendState; * @author Willem Cazander * @version 1.0 Nov 19, 2009 */ -public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { +public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { protected Logger logger = null; protected Level logLevel = Level.INFO; @@ -49,17 +49,17 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { * @see java.lang.Object#clone() */ @Override - public VascBackendProxy clone() throws CloneNotSupportedException { - VascBackendProxyTimerLogger result = new VascBackendProxyTimerLogger(); + public VascBackendProxy clone() throws CloneNotSupportedException { + VascBackendProxyTimerLogger result = new VascBackendProxyTimerLogger<>(); result.logLevel=logLevel; return result; } /** - * @see net.forwardfire.vasc.backend.VascBackend#execute(VascBackendState state) + * @see net.forwardfire.vasc.backend.crud.VascBackendCrud#execute(VascBackendListRequest state) */ @Override - public VascBackendResult execute(VascBackendState state) throws VascBackendException { + public VascBackendListResult execute(VascBackendListRequest state) throws VascBackendException { long t1 = System.currentTimeMillis(); try { return backend.execute(state); @@ -70,13 +70,13 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveDownById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object) */ @Override - public long doRecordMoveDownById(VascBackendState state, Object primaryId) throws VascBackendException { + public long doRecordMoveDownById(VascBackendListRequest request,Serializable recordPK) throws VascBackendException { long t1 = System.currentTimeMillis(); try { - return backend.doRecordMoveDownById(state, primaryId); + return backend.doRecordMoveDownById(request, recordPK); } finally { long t2 = System.currentTimeMillis(); logger.log(logLevel,"vasc-doRecordMoveDownById backend: "+getId()+" in "+(t2-t1)+" ms"); @@ -84,61 +84,19 @@ public class VascBackendProxyTimerLogger extends AbstractVascBackendProxy { } /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.VascBackendState, java.lang.Object) + * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#doRecordMoveUpById(net.forwardfire.vasc.backend.list.VascBackendListRequest, java.lang.Object) */ @Override - public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascBackendException { + public long doRecordMoveUpById(VascBackendListRequest request,Serializable recordPK) throws VascBackendException { long t1 = System.currentTimeMillis(); try { - return backend.doRecordMoveUpById(state, primaryId); + return backend.doRecordMoveUpById(request, recordPK); } finally { long t2 = System.currentTimeMillis(); logger.log(logLevel,"vasc-doRecordMoveUpById backend: "+getId()+" in "+(t2-t1)+" ms"); } } - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#delete(java.lang.Object) - */ - @Override - public void delete(Serializable object) throws VascBackendException { - long t1 = System.currentTimeMillis(); - try { - backend.delete(object); - } finally { - long t2 = System.currentTimeMillis(); - logger.log(logLevel,"vasc-delete backend: "+getId()+" in "+(t2-t1)+" ms"); - } - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#merge(java.lang.Object) - */ - @Override - public Serializable merge(Serializable object) throws VascBackendException { - long t1 = System.currentTimeMillis(); - try { - return backend.merge(object); - } finally { - long t2 = System.currentTimeMillis(); - logger.log(logLevel,"vasc-merge backend: "+getId()+" in "+(t2-t1)+" ms"); - } - } - - /** - * @see net.forwardfire.vasc.backend.proxy.AbstractVascBackendProxy#persist(java.lang.Object) - */ - @Override - public void persist(Serializable object) throws VascBackendException { - long t1 = System.currentTimeMillis(); - try { - backend.persist(object); - } finally { - long t2 = System.currentTimeMillis(); - logger.log(logLevel,"vasc-persist backend: "+getId()+" in "+(t2-t1)+" ms"); - } - } - /** * @return the logLevel */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java index b658687..eb8e24e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryFieldLocal.java @@ -26,7 +26,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleCrudOrderMetaLocal; import net.forwardfire.vasc.validators.VascValidator; @@ -43,7 +43,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole private String backendName = null; private String displayName = null; private VascEntryFieldType vascEntryFieldType = null; - private VascEntryFieldValue vascEntryFieldValue = null; + private VascBackendAccessDataRecord vascEntryFieldValue = null; private List vascValidators = null; private Serializable defaultValue = null; private Integer sizeList = null; @@ -147,7 +147,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole * @return the vascEntryFieldValue */ @Override - public VascEntryFieldValue getVascEntryFieldValue() { + public VascBackendAccessDataRecord getVascEntryFieldValue() { return vascEntryFieldValue; } @@ -155,7 +155,7 @@ abstract public class AbstractVascEntryFieldLocal extends AbstractVascBaseIdRole * @param vascEntryFieldValue the vascEntryFieldValue to set */ @Override - public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) { + public void setVascEntryFieldValue(VascBackendAccessDataRecord vascEntryFieldValue) { this.vascEntryFieldValue = vascEntryFieldValue; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java index 883200f..4b1ebd8 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryState.java @@ -28,8 +28,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * Holds all default state values @@ -43,11 +43,11 @@ abstract public class AbstractVascEntryState implements VascEntryState { private List entryDataList = null; private Serializable entryDataObject = null; private Long totalBackendRecords = null; - private VascBackendState vascBackendState = null; + private VascBackendListRequest vascBackendState = null; private VascEntryState state = null; private Map multiActionSelection = null; private boolean isEditCreate = false; - private VascBackend vascBackend = null; + private VascBackendCrud vascBackend = null; private VascEntry vascEntry = null; public AbstractVascEntryState() { @@ -91,7 +91,7 @@ abstract public class AbstractVascEntryState implements VascEntryState { * @return the vascBackendState */ @Override - public VascBackendState getVascBackendState() { + public VascBackendListRequest getVascBackendState() { return vascBackendState; } @@ -99,7 +99,7 @@ abstract public class AbstractVascEntryState implements VascEntryState { * @param vascBackendState the vascBackendState to set */ @Override - public void setVascBackendState(VascBackendState vascBackendState) { + public void setVascBackendState(VascBackendListRequest vascBackendState) { this.vascBackendState = vascBackendState; } @@ -143,7 +143,7 @@ abstract public class AbstractVascEntryState implements VascEntryState { * @return the vascBackend */ @Override - public VascBackend getVascBackend() { + public VascBackendCrud getVascBackend() { return vascBackend; } @@ -151,7 +151,7 @@ abstract public class AbstractVascEntryState implements VascEntryState { * @param vascBackend the vascBackend to set */ @Override - public void setVascBackend(VascBackend vascBackend) { + public void setVascBackend(VascBackendCrud vascBackend) { this.vascBackend = vascBackend; } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java index 035a799..38036c5 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigController.java @@ -25,7 +25,7 @@ package net.forwardfire.vasc.core; import java.io.Serializable; import java.util.List; -import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.VascException; @@ -46,9 +46,9 @@ public interface VascEntryConfigController { void configVascEntry(VascController vascController,VascEntryLocal vascEntry) throws VascException; - VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException; + VascBackendCrud configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException; - VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackend realBackend) throws VascException; + VascBackendCrud configVascBackendProxied(VascController vascController,VascEntry vascEntry,VascBackendCrud realBackend) throws VascException; List getVascEntryExporterIds(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java index 24f9ce5..0ba0f2d 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryConfigControllerLocal.java @@ -24,7 +24,7 @@ package net.forwardfire.vasc.core; import java.util.List; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.core.entry.VascEntryExport; import net.forwardfire.vasc.core.entry.VascEntryFieldValidatorService; @@ -60,7 +60,7 @@ public interface VascEntryConfigControllerLocal extends VascEntryConfigControlle void removeVascEntryExporter(VascEntryExport exporter); - VascBackendState getMasterVascBackendState(); + VascBackendListRequest getMasterVascBackendState(); void setResourceBundle(String resourceBundle); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java index 00b900b..bfe6083 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryField.java @@ -25,7 +25,7 @@ package net.forwardfire.vasc.core; import java.io.Serializable; import java.util.List; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMeta; import net.forwardfire.vasc.validators.VascValidator; @@ -56,7 +56,7 @@ public interface VascEntryField extends VascBaseIdRoleCrudOrderMeta { /** * @return the vascEntryFieldValue */ - VascEntryFieldValue getVascEntryFieldValue(); + VascBackendAccessDataRecord getVascEntryFieldValue(); /** * @return the vascValidators diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java index 4cbe3bd..b7d8188 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryFieldLocal.java @@ -24,7 +24,7 @@ package net.forwardfire.vasc.core; import java.io.Serializable; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.core.base.VascBaseIdRoleCrudOrderMetaLocal; import net.forwardfire.vasc.validators.VascValidator; @@ -55,7 +55,7 @@ public interface VascEntryFieldLocal extends VascEntryField,VascBaseIdRoleCrudOr /** * @param vascEntryFieldValue the vascEntryFieldValue to set */ - void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue); + void setVascEntryFieldValue(VascBackendAccessDataRecord vascEntryFieldValue); /** * @param vascValidator the vascValidator to add diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryState.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryState.java index 53aeaab..1378512 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryState.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryState.java @@ -26,8 +26,8 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; /** * Holds all the data for state. @@ -61,12 +61,12 @@ public interface VascEntryState extends Serializable { /** * @return the vascBackendState */ - VascBackendState getVascBackendState(); + VascBackendListRequest getVascBackendState(); /** * @param vascBackendState the vascBackendState to set */ - void setVascBackendState(VascBackendState vascBackendState); + void setVascBackendState(VascBackendListRequest vascBackendState); /** * @return the totalBackendRecords @@ -97,12 +97,12 @@ public interface VascEntryState extends Serializable { /** * @return the vascBackend */ - public VascBackend getVascBackend(); + public VascBackendCrud getVascBackend(); /** * @param vascBackend the vascBackend to set */ - void setVascBackend(VascBackend vascBackend); + void setVascBackend(VascBackendCrud vascBackend); /** * @return the isEditCreate diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java index 3cd6d4b..ac53509 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascInterfaceLoader.java @@ -1,6 +1,6 @@ package net.forwardfire.vasc.core; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.frontend.VascFrontendActions; import net.forwardfire.vasc.frontend.VascFrontendControllerLocal; import net.forwardfire.vasc.frontend.VascFrontendDataSelector; @@ -19,7 +19,7 @@ public interface VascInterfaceLoader { VascEntryState createVascEntryStateImpl(); - VascBackendState createVascBackendStateImpl(); + VascBackendListRequest createVascBackendStateImpl(); VascFrontendControllerLocal createVascFrontendControllerLocalImpl(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItemModel.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItemModel.java index 9ccaee5..4c3cf7c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItemModel.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/ui/VascSelectItemModel.java @@ -25,6 +25,7 @@ package net.forwardfire.vasc.core.ui; import java.io.Serializable; import java.util.List; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascException; @@ -42,7 +43,7 @@ public interface VascSelectItemModel extends Serializable { * @return * @throws VascException */ - List getVascSelectItems(VascEntry entry) throws VascException; + List getVascSelectItems(VascEntry entry) throws VascException; /** * @return the nullLabel diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java index 0cac763..8ed3f8c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryConfigController.java @@ -30,10 +30,10 @@ import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; -import net.forwardfire.vasc.backend.DefaultVascBackendState; -import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.backend.proxy.VascBackendProxy; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; @@ -69,7 +69,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll private Map> vascInterfaceImpls = null; private Map> vascInterfaceImplFrontends = null; private VascInterfaceLoader vascInterfaceLoader = null; - private VascBackendState masterVascBackendState = null; + private VascBackendListRequest masterVascBackendState = null; private String resourceBundle = null; public DefaultVascEntryConfigController() { @@ -80,7 +80,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll vascInterfaceImpls = new HashMap>(VascInterfaceKey.values().length); vascInterfaceImplFrontends = new HashMap>(VascInterfaceKeyFrontend.values().length); vascInterfaceLoader = new DefaultVascInterfaceLoader(this); - masterVascBackendState = new DefaultVascBackendState(); + masterVascBackendState = new DefaultVascBackendListRequest(); masterVascBackendState.setPageSize(100); masterVascBackendState.setPageSizeMax(1500); } @@ -177,8 +177,8 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry) */ @Override - public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException { - VascBackend realBackend = vascController.getVascBackendController().getVascBackendById(vascEntry.getBackendId()); + public VascBackendCrud configVascBackendProxied(VascController vascController,VascEntry vascEntry) throws VascException { + VascBackendCrud realBackend = vascController.getVascBackendController().getVascBackendById(VascBackendCrud.class,vascEntry.getBackendId()); if (realBackend==null) { throw new VascException("Could not find backend: "+vascEntry.getBackendId()); } @@ -186,11 +186,11 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll } /** - * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.backend.VascBackend) + * @see net.forwardfire.vasc.core.VascEntryConfigController#configVascBackendProxied(net.forwardfire.vasc.core.VascController, net.forwardfire.vasc.core.VascEntry, net.forwardfire.vasc.backend.crud.VascBackendCrud) */ @Override - public VascBackend configVascBackendProxied(VascController vascController,VascEntry vascEntry, VascBackend realBackend) throws VascException { - VascBackend backend = realBackend; + public VascBackendCrud configVascBackendProxied(VascController vascController,VascEntry vascEntry, VascBackendCrud realBackend) throws VascException { + VascBackendCrud backend = realBackend; for (VascBackendProxy proxy:backendProxies) { VascBackendProxy proxyClone; try { @@ -217,7 +217,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll // get the interface loader and create some impl objects VascInterfaceLoader loader = getVascInterfaceLoader(); VascFrontendControllerLocal controller = loader.createVascFrontendControllerLocalImpl(); - VascBackendState backendState = loader.createVascBackendStateImpl(); + VascBackendListRequest backendState = loader.createVascBackendStateImpl(); VascEntryState state = loader.createVascEntryStateImpl(); // Add impl to tree @@ -234,7 +234,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll controller.setVascFrontendUserSettingController( loader.createVascFrontendUserSettingControllerImpl(entry)); // Config backend state from master template - VascBackendState master = getMasterVascBackendState(); + VascBackendListRequest master = getMasterVascBackendState(); for (String key:master.getDataParameterKeys()) { backendState.setDataParameter(key, master.getDataParameter(key)); } @@ -257,14 +257,14 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll } // Add backend to entry - VascBackend backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry); + VascBackendCrud backend = vascController.getVascEntryConfigController().configVascBackendProxied(vascController, entry); controller.getVascEntryState().setVascBackend(backend); controller.getVascEntryState().setVascEntry(entry); // Fetch all data field value impl for this backend. for (VascEntryField field:entry.getVascEntryFields()) { if (field.getVascEntryFieldValue()==null) { - VascEntryFieldValue v = backend.provideVascEntryFieldValue(); + VascBackendAccessDataRecord v = backend.provideVascEntryFieldValue(); ((VascEntryFieldLocal)field).setVascEntryFieldValue(v); } } @@ -422,7 +422,7 @@ public class DefaultVascEntryConfigController implements VascEntryConfigControll * @see net.forwardfire.vasc.core.VascEntryConfigControllerLocal#getMasterVascBackendState() */ @Override - public VascBackendState getMasterVascBackendState() { + public VascBackendListRequest getMasterVascBackendState() { return masterVascBackendState; } } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java index 8b2d464..842ded1 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascFactory.java @@ -23,7 +23,7 @@ package net.forwardfire.vasc.impl; import net.forwardfire.vasc.backend.DefaultVascBackendController; -import net.forwardfire.vasc.backend.DefaultVascBackendState; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest; import net.forwardfire.vasc.backend.proxy.VascBackendProxyCache; import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor; import net.forwardfire.vasc.backend.proxy.VascBackendProxyFilter; @@ -73,7 +73,7 @@ public class DefaultVascFactory { vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LINK, DefaultVascEntryLink.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_ENTRY_LIST_OPTION, DefaultVascEntryListOption.class); - vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_BACKEND_STATE, DefaultVascBackendState.class); + vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_BACKEND_STATE, DefaultVascBackendListRequest.class); vascConfig.putVascInterfaceImplemention(VascInterfaceKey.VASC_FRONTEND_CONTROLLER_LOCAL, DefaultVascFrontendController.class); vascConfig.putVascInterfaceImplementionFrontend(VascInterfaceKeyFrontend.VASC_FRONTEND_ACTIONS, DefaultVascFrontendActions.class); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java index 118a5d3..1397bcd 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascInterfaceLoader.java @@ -22,7 +22,7 @@ package net.forwardfire.vasc.impl; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascEntryField; @@ -114,8 +114,8 @@ public class DefaultVascInterfaceLoader implements VascInterfaceLoader { * @see net.forwardfire.vasc.core.VascInterfaceLoader#createVascBackendStateImpl() */ @Override - public VascBackendState createVascBackendStateImpl() { - return (VascBackendState)createImpl(VascInterfaceKey.VASC_BACKEND_STATE); + public VascBackendListRequest createVascBackendStateImpl() { + return (VascBackendListRequest)createImpl(VascInterfaceKey.VASC_BACKEND_STATE); } /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java index a998ace..dd71288 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/SetParameterBackendListener.java @@ -22,7 +22,7 @@ package net.forwardfire.vasc.impl.entry; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener; @@ -74,8 +74,8 @@ public class SetParameterBackendListener implements VascEntryBackendEventListene */ @Override public void vascEvent(VascEntry entry, Object data) { - if (data instanceof VascBackendState) { - VascBackendState state = (VascBackendState)data; + if (data instanceof VascBackendListRequest) { + VascBackendListRequest state = (VascBackendListRequest)data; if (isUserValue) { if (value==null) { value="id"; diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java index 3312ae5..739cfb9 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java @@ -27,7 +27,7 @@ import java.util.Locale; import org.x4o.xml.conv.ObjectConverterException; -import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryConfigFinalizer; @@ -59,7 +59,7 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { } // Check if backendId is valid - VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() ); + VascBackendCrud back = vascController.getVascBackendController().getVascBackendById( VascBackendCrud.class, entry.getBackendId() ); if (back==null) { throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java index 00ba656..cb0717a 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascIdCheckFinalizer.java @@ -24,7 +24,7 @@ package net.forwardfire.vasc.impl.entry.config; import java.io.Serializable; -import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldSet; @@ -68,7 +68,7 @@ public class VascIdCheckFinalizer implements VascEntryConfigFinalizer { } // Check if backendId is valid - VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() ); + VascBackendCrud back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() ); if (back==null) { throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java index 6c09c6f..be91b26 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendActions.java @@ -27,8 +27,8 @@ import java.util.Date; import java.util.logging.Logger; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascBackendResult; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.backend.proxy.VascProxyFilter; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; @@ -210,7 +210,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions { // Fire pre read event entry.getVascFrontendController().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null); entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null); - VascBackendState backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); + VascBackendListRequest backendState = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); // check and correct max page size if (backendState.getPageSize() > backendState.getPageSizeMax()) { @@ -226,7 +226,7 @@ public class DefaultVascFrontendActions implements VascFrontendActions { } } - VascBackendResult result; + VascBackendListResult result; try { result = entry.getVascFrontendController().getVascEntryState().getVascBackend().execute(backendState); } catch (VascBackendException ve) { @@ -234,11 +234,11 @@ public class DefaultVascFrontendActions implements VascFrontendActions { } // Set data in frontend - entry.getVascFrontendController().getVascEntryState().setEntryDataList(result.getPageData()); - entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(result.getTotalSize()); + entry.getVascFrontendController().getVascEntryState().setEntryDataList(result.getData()); + entry.getVascFrontendController().getVascEntryState().setTotalBackendRecords(result.getTotalRecordCount()); // check if we need to change the current page if table size if changed in between - int pages = new Long(result.getTotalSize()/backendState.getPageSize()).intValue(); + int pages = new Long(result.getTotalRecordCount()/backendState.getPageSize()).intValue(); if (backendState.getPageIndex() > pages) { backendState.setPageIndex(pages); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java index 19e62d5..2adb758 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.logging.Logger; import net.forwardfire.vasc.backend.VascBackendException; -import net.forwardfire.vasc.backend.VascEntryFieldValue; +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryLink; @@ -202,10 +202,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { return "no-selection"; } VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); - VascEntryFieldValue ve = v.getVascEntryFieldValue(); + VascBackendAccessDataRecord ve = v.getVascEntryFieldValue(); String result = "no-data"; try { - result = ve.getDisplayValue(v.getBackendName(), row); + result = ""+ve.getValue(v.getBackendName(), row); } catch (VascBackendException e) { throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e); } @@ -224,10 +224,10 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { return "no-selection"; } VascEntryField v = parent.getVascEntryFieldById(parent.getDisplayNameFieldId()); - VascEntryFieldValue ve = v.getVascEntryFieldValue(); + VascBackendAccessDataRecord ve = v.getVascEntryFieldValue(); String result = "no-data"; try { - result = ve.getDisplayValue(v.getBackendName(), row); + result = ""+ve.getValue(v.getBackendName(), row); } catch (VascBackendException e) { throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java index 204ba0f..f42f33f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendPager.java @@ -26,7 +26,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; import net.forwardfire.vasc.frontend.VascFrontendPageInfoNumber; @@ -156,7 +156,7 @@ public class DefaultVascFrontendPager implements VascFrontendPageInfo { @Override public List getTablePagesFromBackend() { List result = new ArrayList(30); - VascBackendState state = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); + VascBackendListRequest state = entry.getVascFrontendController().getVascEntryState().getVascBackendState(); if (state.getPageSize()==0) { return result; // paging disabled } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java index a362515..f3a7d85 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java @@ -33,9 +33,9 @@ import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendController; import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascControllerLocal; import net.forwardfire.vasc.core.VascControllerProvider; @@ -130,7 +130,7 @@ public class JndiVascControllerFactory implements ObjectFactory { return backendController.getVascBackendIds(); } @Override - public VascBackend getVascBackendById(String id) { + public VascBackendCrud getVascBackendById(String id) { return backendController.getVascBackendById(id); } }); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java deleted file mode 100644 index c356dbd..0000000 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/ui/VascSelectItemModelStringEnum.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2007-2012 forwardfire.net All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.forwardfire.vasc.impl.ui; - -import java.util.ArrayList; -import java.util.List; - -import net.forwardfire.vasc.core.VascEntry; -import net.forwardfire.vasc.core.ui.VascSelectItem; -import net.forwardfire.vasc.core.ui.VascSelectItemModel; -import net.forwardfire.vasc.core.VascException; - - - - -/** -* The DefaultVascSelectItemModel -* -* @author Willem Cazander -* @version 1.0 Oct 27, 2007 -*/ -public class VascSelectItemModelStringEnum implements VascSelectItemModel { - - private static final long serialVersionUID = 1L; - private Object data = null; - private Class enumClass = null; - private String nullLabel = null; - private String nullKeyValue = null; - private Boolean returnKeyValue = null; - private Boolean useParentFields = null; - - /** - * @see net.forwardfire.vasc.core.ui.VascSelectItemModel#getVascSelectItems(net.forwardfire.vasc.core.VascEntry) - */ - @Override - public List getVascSelectItems(VascEntry currentEntry) throws VascException { - List result = new ArrayList(100); - - if (nullLabel!=null) { - if (nullKeyValue==null) { - nullKeyValue = "null"; - } - nullLabel = currentEntry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(nullLabel); - VascSelectItem item = new VascSelectItem(nullLabel,null,nullKeyValue); - result.add(item); - } - - if (enumClass!=null) { - for (Object o:enumClass.getEnumConstants()) { - String value = o.toString(); - result.add(new VascSelectItem(value,value,value)); - } - } - if (data==null) { - return result; - } - if (data instanceof String) { - String[] values = ((String)data).split(","); - for (String value:values) { - result.add(new VascSelectItem(value,value,value)); - } - } else if (data instanceof List) { - List values = (List)data; - for (Object o:values) { - String value = ""+o; - result.add(new VascSelectItem(value,value,value)); - } - } - - return result; - } - - - /** - * @return the data - */ - public Object getData() { - return data; - } - - /** - * @param data the data to set - */ - public void setData(Object data) { - this.data = data; - } - - /** - * @return the nullLabel - */ - @Override - public String getNullLabel() { - return nullLabel; - } - - /** - * @param nullLabel the nullLabel to set - */ - @Override - public void setNullLabel(String nullLabel) { - this.nullLabel = nullLabel; - } - - /** - * @return the nullKeyValue - */ - @Override - public String getNullKeyValue() { - return nullKeyValue; - } - - /** - * @param nullKeyValue the nullKeyValue to set - */ - @Override - public void setNullKeyValue(String nullKeyValue) { - this.nullKeyValue = nullKeyValue; - } - - /** - * @return the returnKeyValue - */ - public Boolean getReturnKeyValue() { - return returnKeyValue; - } - - /** - * @param returnKeyValue the returnKeyValue to set - */ - public void setReturnKeyValue(Boolean returnKeyValue) { - this.returnKeyValue = returnKeyValue; - } - - /** - * @return the useParentFields - */ - public Boolean getUseParentFields() { - return useParentFields; - } - - /** - * @param useParentFields the useParentFields to set - */ - public void setUseParentFields(Boolean useParentFields) { - this.useParentFields = useParentFields; - } - - /** - * @return the enumClass - */ - public Class getEnumClass() { - return enumClass; - } - - /** - * @param enumClass the enumClass to set - */ - public void setEnumClass(Class enumClass) { - this.enumClass = enumClass; - } -} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascBackendElementConfigurator.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascBackendElementConfigurator.java index ca2583d..68506de 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascBackendElementConfigurator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascBackendElementConfigurator.java @@ -25,9 +25,9 @@ package net.forwardfire.vasc.impl.x4o; import java.io.Serializable; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendController; import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.VascController; import org.x4o.xml.element.AbstractElementConfigurator; @@ -50,7 +50,7 @@ public class VascBackendElementConfigurator extends AbstractElementConfigurator public void doConfigElement(Element element) throws ElementConfiguratorException { @SuppressWarnings("unchecked") - VascBackend backend = (VascBackend)element.getElementObject(); + VascBackendCrud backend = (VascBackendCrud)element.getElementObject(); VascController vascController = VascDriver.getVascController(element.getLanguageSession()); VascBackendController backendController = vascController.getVascBackendController(); diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java index 3a050ac..350f13e 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryLinkParameterElement.java @@ -22,8 +22,8 @@ package net.forwardfire.vasc.impl.x4o; +import net.forwardfire.vasc.backend.object.VascSelectItemModelEntry; import net.forwardfire.vasc.core.VascEntryLinkLocal; -import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; diff --git a/vasc-demo/vasc-demo-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java b/vasc-demo/vasc-demo-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java index f768549..b8dd783 100644 --- a/vasc-demo/vasc-demo-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java +++ b/vasc-demo/vasc-demo-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java @@ -43,8 +43,8 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; -import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendControllerLocal; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascEntryControllerLocal; @@ -121,7 +121,7 @@ public class JMainPanel extends JPanel { for (String id:entryIds) { VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id); String backendId = ve.getBackendId(); - VascBackend vb = new VascServiceRemoteBackend(vascManager,backendId); + VascBackendCrud vb = new VascServiceRemoteBackend(vascManager,backendId); /* for (String key:ve.getEntryParameterKeys()) { diff --git a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java index dc0183b..38c1830 100644 --- a/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java +++ b/vasc-demo/vasc-demo-server/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java @@ -24,14 +24,14 @@ package net.forwardfire.vasc.demo.server.ui.load; import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb; -import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend; +import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackendCrud; +import net.forwardfire.vasc.backend.object.VascSelectItemModelEntry; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldType; import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.VascEntryLinkType; -import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry; import net.forwardfire.vasc.opt.metamodel.MetaModelSchemaAutoEntry; import org.x4o.xml.io.sax.ext.ContentWriterXml; @@ -90,7 +90,7 @@ public class LoadVascXmlWriter { writeGroup(model.groupId,model.rolesGroup); writeMetaProvider(model); - for (MetaModelVascBackend vb:autoEntry.getResultBackends()) { + for (MetaModelVascBackendCrud vb:autoEntry.getResultBackends()) { writeEntryBackend(vb,model); } for (VascEntry ve:autoEntry.getResultEntries()) { @@ -159,7 +159,7 @@ public class LoadVascXmlWriter { xmlWriter.endElement(URI_VASC_LANG, "entryGroup", ""); } - private void writeEntryBackend(MetaModelVascBackend vb,LoadStepData model) throws SAXException { + private void writeEntryBackend(MetaModelVascBackendCrud vb,LoadStepData model) throws SAXException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "id", "", "", vb.getId()); diff --git a/vasc-demo/vasc-demo-tech-domain/.project b/vasc-demo/vasc-demo-tech-domain/.project index 088691d..ddb4c1e 100644 --- a/vasc-demo/vasc-demo-tech-domain/.project +++ b/vasc-demo/vasc-demo-tech-domain/.project @@ -5,11 +5,21 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder + + org.eclipse.wst.validation.validationbuilder + + + org.eclipse.m2e.core.maven2Builder @@ -19,5 +29,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreEntity.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreEntity.java deleted file mode 100644 index d350e39..0000000 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreEntity.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.forwardfire.vasc.demo.tech.domain.petstore.model; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Id; - -import net.forwardfire.vasc.annotations.VascFieldTemplate; - -@SuppressWarnings("serial") -abstract public class AbstractPetStoreEntity implements Serializable { - - private Long id; - - @Id - @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) - @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } -} diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreVascBackend.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreVascBackend.java index 55ba65f..245ebe4 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreVascBackend.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/AbstractPetStoreVascBackend.java @@ -1,17 +1,80 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; -import net.forwardfire.vasc.backend.VascBackend; +import java.io.Serializable; + +import net.forwardfire.vasc.backend.VascBackendAccessDataRecord; +import net.forwardfire.vasc.backend.crud.VascBackendCrud; +import net.forwardfire.vasc.backend.list.DefaultVascBackendListRequest; +import net.forwardfire.vasc.backend.list.VascBackendList; +import net.forwardfire.vasc.backend.list.VascBackendListFeature; +import net.forwardfire.vasc.backend.list.VascBackendListRequest; +import net.forwardfire.vasc.backend.list.VascBackendListResult; +import net.forwardfire.vasc.backend.select.VascBackendSelect; public final class AbstractPetStoreVascBackend { - public interface CategoryBackend extends VascBackend {} - public interface CategoryProductBackend extends VascBackend {} - public interface ItemBackend extends VascBackend {} - public interface ItemInventoryBackend extends VascBackend {} - public interface ItemSupplierBackend extends VascBackend {} - public interface OrderBackend extends VascBackend {} - public interface OrderLineBackend extends VascBackend {} - public interface OrderStatusBackend extends VascBackend {} - public interface UserAccountBackend extends VascBackend {} - public interface UserCredentialBackend extends VascBackend {} - public interface UserProfileBackend extends VascBackend {} + public interface CategoryBackend extends VascBackendCrud {} + public interface CategoryProductBackend extends VascBackendCrud {} + public interface ItemBackend extends VascBackendCrud {} + public interface ItemInventoryBackend extends VascBackendCrud {} + public interface ItemSupplierBackend extends VascBackendCrud {} + public interface OrderBackend extends VascBackendCrud {} + public interface OrderLineBackend extends VascBackendCrud {} + public interface OrderStatusBackend extends VascBackendCrud {} + public interface UserAccountBackend extends VascBackendCrud {} + public interface UserCredentialBackend extends VascBackendCrud {} + + public interface UserProfileBackend extends VascBackendCrud {} + public interface UserProfileBackendList extends VascBackendList {} + public interface UserProfileBackendSelect extends VascBackendSelect {} + + + interface BackendCreator { + VascBackendList createList(); + VascBackendCrud createCrud(); + VascBackendSelect createSelect(); + } + + static { + try { + UserProfileBackend test = null; + VascBackendAccessDataRecord f = test.createVascBackendAccessDataRecord(); + Long tweevle = f.getPrimaryKey(test.fetch(12l)); + test.delete(tweevle); + UserProfile upNew = test.newRecord(); + upNew.setLocale("NL"); + upNew.setSignUpAgent("test"); + upNew = test.merge(upNew); + + test.newRecord(); // Create + test.fetch(null); // Read + test.merge(null); // Update + test.delete(null);// Delete + test.getId(); // backend id + //test.provideVascEntryFieldValue(); // field+pk <-> data + + + UserProfileBackendList upList = null; + + boolean pagingSupport = upList.getSupportedFeatures().contains(VascBackendListFeature.PAGE_DATA); + + DefaultVascBackendListRequest request = new DefaultVascBackendListRequest(); + request.setPageIndex(2); + request.setDataParameter("a", "b"); + VascBackendListResult re = upList.execute(request); + re.getData(); + re.getDataExtra(); + re.getTotalRecordCount(); + + upList.execute(null); // Read List + //upList.doRecordMoveUpById(null,null); // up + //upList.doRecordMoveDownById(null,null); // down + upList.getSupportedFeatures(); // features + //upList.provideVascEntryFieldValue(); // field+pk <-> data + + } catch (Exception e) { + + } + } + + } diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Category.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Category.java index bfe28d2..2f28ace 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Category.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Category.java @@ -1,20 +1,37 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.IdClass; import net.forwardfire.vasc.annotations.VascField; import net.forwardfire.vasc.annotations.VascFieldTemplate; -@Entity +@Entity() @Table(name=AbstractPetStoreDBTable.CATEGORY,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class Category extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class Category implements Serializable { + private Long id; private String name = null; private String description = null; private String iconUrl = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @Column(name="name",nullable=false) @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) public String getName() { diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/CategoryProduct.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/CategoryProduct.java index 285f73d..662c70f 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/CategoryProduct.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/CategoryProduct.java @@ -1,8 +1,11 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; @@ -13,16 +16,29 @@ import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.CATEGORY_PRODUCT,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class CategoryProduct extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class CategoryProduct implements Serializable { + private Long id; private Category category = null; private String name = null; private String description = null; private String iconUrl = null; - @OneToOne(fetch=FetchType.LAZY) - @JoinColumn(name="category_id",nullable=false) - @VascModelReference + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @OneToOne(fetch=FetchType.LAZY) + @JoinColumn(name="category_id",nullable=false) + @VascModelReference public Category getCategory() { return category; } diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Item.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Item.java index baebd15..9f44489 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Item.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Item.java @@ -1,5 +1,7 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,8 +15,10 @@ import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.ITEM,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class Item extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class Item implements Serializable { + private Long id; private CategoryProduct categoryProduct = null; private ItemSupplier itemSupplier = null; private Float price = null; @@ -22,9 +26,20 @@ public class Item extends AbstractPetStoreEntity { private String name = null; private String description = null; - @OneToOne(fetch=FetchType.LAZY) - @JoinColumn(name="category_product_id",nullable=false) - @VascModelReference + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @OneToOne(fetch=FetchType.LAZY) + @JoinColumn(name="category_product_id",nullable=false) + @VascModelReference public CategoryProduct getCategoryProduct() { return categoryProduct; } @@ -32,9 +47,9 @@ public class Item extends AbstractPetStoreEntity { this.categoryProduct = categoryProduct; } - @OneToOne(fetch=FetchType.LAZY) - @JoinColumn(name="item_supplier_id",nullable=false) - @VascModelReference + @OneToOne(fetch=FetchType.LAZY) + @JoinColumn(name="item_supplier_id",nullable=false) + @VascModelReference public ItemSupplier getItemSupplier() { return itemSupplier; } @@ -58,7 +73,6 @@ public class Item extends AbstractPetStoreEntity { this.status = status; } - @Column(name="name",nullable=false) @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) public String getName() { @@ -68,7 +82,6 @@ public class Item extends AbstractPetStoreEntity { this.name = name; } - @Column(name="description",nullable=false) @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) public String getDescription() { diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemInventory.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemInventory.java index 822e68d..45b5590 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemInventory.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemInventory.java @@ -1,5 +1,7 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,14 +15,27 @@ import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.ITEM_INVENTORY,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class ItemInventory extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class ItemInventory implements Serializable { + private Long id; private Item item = null; private Integer inventoryCount = null; - @OneToOne(fetch=FetchType.LAZY) - @JoinColumn(name="item_id",nullable=false) - @VascModelReference + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @OneToOne(fetch=FetchType.LAZY) + @JoinColumn(name="item_id",nullable=false) + @VascModelReference public Item getItem() { return item; } diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemSupplier.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemSupplier.java index a798cac..8547cc7 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemSupplier.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/ItemSupplier.java @@ -1,5 +1,7 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -10,8 +12,10 @@ import net.forwardfire.vasc.annotations.VascFieldTemplate; @Entity @Table(name=AbstractPetStoreDBTable.ITEM_SUPPLIER,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class ItemSupplier extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class ItemSupplier implements Serializable { + private Long id; private String name = null; private String description = null; private String website = null; @@ -25,6 +29,17 @@ public class ItemSupplier extends AbstractPetStoreEntity { this.name = name; } + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @Column(name="description",nullable=false) @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) public String getDescription() { diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Order.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Order.java index e75002d..9186f45 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Order.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/Order.java @@ -1,21 +1,26 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import net.forwardfire.vasc.annotations.VascField; +import net.forwardfire.vasc.annotations.VascFieldTemplate; import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.ORDER,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class Order extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class Order implements Serializable { + private Long id; private UserAccount userAccount = null; private Date orderDate = null; private Date shipDate = null; @@ -32,6 +37,17 @@ public class Order extends AbstractPetStoreEntity { private String billZipCode = null; private String billCountry = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="user_account_id",nullable=false) @VascModelReference diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderLine.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderLine.java index 8d79d54..c5f6969 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderLine.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderLine.java @@ -1,25 +1,42 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import net.forwardfire.vasc.annotations.VascField; +import net.forwardfire.vasc.annotations.VascFieldTemplate; import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.ORDER_LINE,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class OrderLine extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class OrderLine implements Serializable { + private Long id; private Order order = null; private Integer lineNumber = null; private Item item = null; private Integer quantity = null; private Float itemPrice = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="order_id",nullable=false) @VascModelReference diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderStatus.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderStatus.java index b811048..301a099 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderStatus.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/OrderStatus.java @@ -1,5 +1,7 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -10,13 +12,26 @@ import net.forwardfire.vasc.annotations.VascFieldTemplate; @Entity @Table(name=AbstractPetStoreDBTable.ORDER_STATUS,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class OrderStatus extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class OrderStatus implements Serializable { + private Long id; private String type = null; private Boolean active = null; private String name = null; private String description = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @Column(name="type",nullable=false) public String getType() { return type; diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserAccount.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserAccount.java index 899b846..184798c 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserAccount.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserAccount.java @@ -1,15 +1,21 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.Id; import javax.persistence.Table; import net.forwardfire.vasc.annotations.VascField; +import net.forwardfire.vasc.annotations.VascFieldTemplate; @Entity @Table(name=AbstractPetStoreDBTable.USER_ACCOUNT,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class UserAccount extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class UserAccount implements Serializable { + private Long id; private String email = null; private String firstName = null; private String lastName = null; @@ -19,6 +25,17 @@ public class UserAccount extends AbstractPetStoreEntity { private String country = null; private String countryState = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @Column(name="email",nullable=false) public String getEmail() { return email; diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserCredential.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserCredential.java index 2826980..ac8bee0 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserCredential.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserCredential.java @@ -1,19 +1,25 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import net.forwardfire.vasc.annotations.VascField; +import net.forwardfire.vasc.annotations.VascFieldTemplate; import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.USER_CREDENTIAL,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class UserCredential extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class UserCredential implements Serializable { + private Long id; private UserAccount userAccount = null; private String password = null; private String secretQuestion0 = null; @@ -21,6 +27,17 @@ public class UserCredential extends AbstractPetStoreEntity { private String secretQuestion1 = null; private String secretAnswer1 = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="user_account_id",nullable=false) @VascModelReference diff --git a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserProfile.java b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserProfile.java index c8908c9..ee8869a 100644 --- a/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserProfile.java +++ b/vasc-demo/vasc-demo-tech-domain/src/main/java/net/forwardfire/vasc/demo/tech/domain/petstore/model/UserProfile.java @@ -1,27 +1,43 @@ package net.forwardfire.vasc.demo.tech.domain.petstore.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; - +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import net.forwardfire.vasc.annotations.VascDefaultValue; import net.forwardfire.vasc.annotations.VascField; +import net.forwardfire.vasc.annotations.VascFieldTemplate; import net.forwardfire.vasc.annotations.VascModelReference; @Entity @Table(name=AbstractPetStoreDBTable.USER_PROFILE,schema=AbstractPetStoreDBCatalog.SCHEMA) -public class UserProfile extends AbstractPetStoreEntity { +@SuppressWarnings("serial") +public class UserProfile implements Serializable { + private Long id; private String signUpIp = null; private String signUpAgent = null; private String locale = null; private UserAccount userAccount = null; private Category userCategory = null; + @Id + @Column(name=AbstractPetStoreDBColumn.ID,nullable=false) + @VascFieldTemplate(templateClass=AbstractPetStoreVascFieldTemplate.class) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + @Column(name=AbstractPetStoreDBColumn.SIGNUP_IP,nullable=false) @VascField(list=false) @VascDefaultValue(value="0.0.0.0") diff --git a/vasc-demo/vasc-demo-tech-web/pom.xml b/vasc-demo/vasc-demo-tech-web/pom.xml index 1cb8443..29de764 100644 --- a/vasc-demo/vasc-demo-tech-web/pom.xml +++ b/vasc-demo/vasc-demo-tech-web/pom.xml @@ -1,98 +1,100 @@ - - 4.0.0 - - vasc-demo - net.forwardfire.vasc.demo - 0.4.2-SNAPSHOT - .. - - vasc-demo-tech-web - vasc-demo-tech-web - vasc-demo-tech-web - - - - src/main/resources - - - src/main/webapp - - - - - - - net.forwardfire.vasc - vasc-frontend-web-jsf - ${project.version} - provided - - - net.forwardfire.vasc.backend - vasc-backend-metamodel - ${project.version} - provided - - - net.forwardfire.vasc.demo - vasc-demo-tech-domain - ${project.version} - provided - - - javax - javaee-api - ${javaee-api.version} - provided - - - org.richfaces.ui - richfaces-components-ui - provided - - - net.jawr - jawr - ${jawr.version} - provided - - - de.tudarmstadt.ukp.wikipedia - de.tudarmstadt.ukp.wikipedia.api - 0.9.1 - provided - - - org.ocpsoft.rewrite - rewrite-servlet - ${rewrite-servlet.version} - provided - - - - - net.forwardfire.vasc - vasc-core - ${project.version} - provided - - - net.forwardfire.vasc - vasc-core-ejb3-client - ${project.version} - provided - - - javax - javaee-api - ${javaee-api.version} - provided - - - net.forwardfire.vasc.lib - vasc-lib-i18n - ${project.version} - provided - - + + 4.0.0 + + vasc-demo + net.forwardfire.vasc.demo + 0.4.2-SNAPSHOT + .. + + vasc-demo-tech-web + vasc-demo-tech-web + vasc-demo-tech-web + + + + src/main/resources + + + src/main/webapp + + + + + + + net.forwardfire.vasc + vasc-frontend-web-jsf + ${project.version} + provided + + + net.forwardfire.vasc.backend + vasc-backend-metamodel + ${project.version} + provided + + + net.forwardfire.vasc.demo + vasc-demo-tech-domain + ${project.version} + provided + + + javax + javaee-api + ${javaee-api.version} + provided + + + org.richfaces.ui + richfaces-components-ui + provided + + + net.jawr + jawr + ${jawr.version} + provided + + + de.tudarmstadt.ukp.wikipedia + de.tudarmstadt.ukp.wikipedia.api + 0.9.1 + provided + + + org.ocpsoft.rewrite + rewrite-servlet + ${rewrite-servlet.version} + provided + + + + + net.forwardfire.vasc + vasc-core + ${project.version} + provided + + + net.forwardfire.vasc + vasc-core-ejb3-client + ${project.version} + provided + + + javax + javaee-api + ${javaee-api.version} + provided + + + net.forwardfire.vasc.lib + vasc-lib-i18n + ${project.version} + provided + + \ No newline at end of file diff --git a/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterCsv.java b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterCsv.java index 701a2ae..669a07b 100644 --- a/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterCsv.java +++ b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterCsv.java @@ -135,7 +135,7 @@ public class VascEntryExportWriterCsv extends AbstractVascEntryExportWriter { @Override protected void doExportRowField(Serializable o, VascEntryField c,boolean isLast) throws VascBackendException { p.write(quoteChar.toCharType()); - p.write(c.getVascEntryFieldValue().getDisplayValue(c.getBackendName(), o)); + p.write(""+c.getVascEntryFieldValue().getValue(c.getBackendName(), o)); p.write(quoteChar.toCharType()); if (isLast==false) { p.write(separatorChar.toCharType()); diff --git a/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterXml.java b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterXml.java index ae35e2e..e0d464a 100644 --- a/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterXml.java +++ b/vasc-export/vasc-export-generic/src/main/java/net/forwardfire/vasc/export/generic/VascEntryExportWriterXml.java @@ -78,11 +78,11 @@ public class VascEntryExportWriterXml extends AbstractVascEntryExportWriter { protected void doExportRowField(Serializable o, VascEntryField c,boolean isLast) throws VascBackendException { if (xmlTree) { p.write("\t\t<"+c.getId()+">\n"); } else { p.write("\t\t\n"); } } diff --git a/vasc-frontend/pom.xml b/vasc-frontend/pom.xml index 98b27ff..cfc88bd 100644 --- a/vasc-frontend/pom.xml +++ b/vasc-frontend/pom.xml @@ -16,5 +16,6 @@ vasc-frontend-web-jsf vasc-frontend-web-export vasc-frontend-cxf + vasc-frontend-api \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/.project b/vasc-frontend/vasc-frontend-api/.project new file mode 100644 index 0000000..1b1d7d8 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/.project @@ -0,0 +1,23 @@ + + + vasc-frontend-api + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-frontend/vasc-frontend-api/pom.xml b/vasc-frontend/vasc-frontend-api/pom.xml new file mode 100644 index 0000000..131c5a1 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + net.forwardfire.vasc + vasc-frontend + 0.4.2-SNAPSHOT + + vasc-frontend-api + vasc-frontend-api + vasc-frontend-api + \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/event/package-info.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/event/package-info.java new file mode 100644 index 0000000..c996213 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/event/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.frontend.api.event; \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/package-info.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/package-info.java new file mode 100644 index 0000000..804711a --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.frontend.api; \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascView.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascView.java new file mode 100644 index 0000000..bd27e03 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascView.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.frontend.api.view; + +public class VascView { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewComponent.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewComponent.java new file mode 100644 index 0000000..4673fd8 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewComponent.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.frontend.api.view; + +public interface VascViewComponent { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewContainer.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewContainer.java new file mode 100644 index 0000000..cc8b8f2 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewContainer.java @@ -0,0 +1,7 @@ +package net.forwardfire.vasc.frontend.api.view; + +public interface VascViewContainer { + + int getChildCount(); + VascViewContainer getChild(int i); +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewField.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewField.java new file mode 100644 index 0000000..52066c7 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewField.java @@ -0,0 +1,12 @@ +/** + * + */ +package net.forwardfire.vasc.frontend.api.view; + +/** + * @author willemc + * + */ +public class VascViewField { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewFieldPanel.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewFieldPanel.java new file mode 100644 index 0000000..2e188ec --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/VascViewFieldPanel.java @@ -0,0 +1,5 @@ +package net.forwardfire.vasc.frontend.api.view; + +public class VascViewFieldPanel { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/package-info.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/package-info.java new file mode 100644 index 0000000..191e369 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.frontend.api.view; \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTable.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTable.java new file mode 100644 index 0000000..7300b23 --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTable.java @@ -0,0 +1,7 @@ +package net.forwardfire.vasc.frontend.api.view.table; + +import net.forwardfire.vasc.frontend.api.view.VascViewComponent; + +public class VascViewTable implements VascViewComponent { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTableColumn.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTableColumn.java new file mode 100644 index 0000000..5714aca --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/VascViewTableColumn.java @@ -0,0 +1,7 @@ +package net.forwardfire.vasc.frontend.api.view.table; + +import net.forwardfire.vasc.frontend.api.view.VascViewComponent; + +public class VascViewTableColumn { + +} diff --git a/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/package-info.java b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/package-info.java new file mode 100644 index 0000000..7e7248c --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/main/java/net/forwardfire/vasc/frontend/api/view/table/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author willemc + * + */ +package net.forwardfire.vasc.frontend.api.view.table; \ No newline at end of file diff --git a/vasc-frontend/vasc-frontend-api/src/test/java/net/forwardfire/vasc/frontend/api/TestViewApi.java b/vasc-frontend/vasc-frontend-api/src/test/java/net/forwardfire/vasc/frontend/api/TestViewApi.java new file mode 100644 index 0000000..2f7fd1f --- /dev/null +++ b/vasc-frontend/vasc-frontend-api/src/test/java/net/forwardfire/vasc/frontend/api/TestViewApi.java @@ -0,0 +1,14 @@ +package net.forwardfire.vasc.frontend.api; + +import net.forwardfire.vasc.frontend.api.view.VascView; + +public class TestViewApi { + + + public void testViewApi() { + + VascView view = new VascView(); + + + } +} diff --git a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml index 1ade78d..07f7458 100644 --- a/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml +++ b/vasc-frontend/vasc-frontend-cxf/vasc-frontend-cxf-server/pom.xml @@ -1,51 +1,51 @@ - - 4.0.0 - - vasc-frontend-cxf - net.forwardfire.vasc - 0.4.2-SNAPSHOT - .. - - vasc-frontend-cxf-server - vasc-frontend-cxf-server - vasc-frontend-cxf-server - - - net.forwardfire.vasc - vasc-core - ${project.version} - - - net.forwardfire.vasc - vasc-frontend-cxf-client - ${project.version} - - - org.apache.cxf - cxf-rt-transports-http - ${cxf-rt.version} - - - org.apache.cxf - cxf-rt-databinding-jaxb - ${cxf-rt.version} - - - org.apache.cxf - cxf-rt-frontend-jaxws - ${cxf-rt.version} - - - org.apache.cxf - cxf-rt-frontend-jaxrs - ${cxf-rt.version} - - - javax.servlet - servlet-api - ${servlet-api.version} - jar - provided - - + + 4.0.0 + + vasc-frontend-cxf + net.forwardfire.vasc + 0.4.2-SNAPSHOT + .. + + vasc-frontend-cxf-server + vasc-frontend-cxf-server + vasc-frontend-cxf-server + + + net.forwardfire.vasc + vasc-core + ${project.version} + + + net.forwardfire.vasc + vasc-frontend-cxf-client + ${project.version} + + + org.apache.cxf + cxf-rt-transports-http + ${cxf-rt.version} + + + org.apache.cxf + cxf-rt-databinding-jaxb + ${cxf-rt.version} + + + org.apache.cxf + cxf-rt-frontend-jaxws + ${cxf-rt.version} + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf-rt.version} + + + javax + javaee-api + ${javaee-api.version} + provided + + diff --git a/vasc-frontend/vasc-frontend-swing/pom.xml b/vasc-frontend/vasc-frontend-swing/pom.xml index 088ac7d..84eb298 100644 --- a/vasc-frontend/vasc-frontend-swing/pom.xml +++ b/vasc-frontend/vasc-frontend-swing/pom.xml @@ -1,35 +1,41 @@ - - 4.0.0 - - vasc-frontend - net.forwardfire.vasc - 0.4.2-SNAPSHOT - - vasc-frontend-swing - vasc-frontend-swing - vasc-frontend-swing - - - net.forwardfire.vasc - vasc-core - ${project.version} - - - com.michaelbaranov - microba - ${microba.version} - - - de.odysseus.juel - juel - ${juel.version} - test - - - net.forwardfire.vasc.test - vasc-test-frontend - ${project.version} - test - - + + 4.0.0 + + vasc-frontend + net.forwardfire.vasc + 0.4.2-SNAPSHOT + + vasc-frontend-swing + vasc-frontend-swing + vasc-frontend-swing + + + net.forwardfire.vasc + vasc-core + ${project.version} + + + net.forwardfire.vasc + vasc-frontend-api + ${project.version} + + + com.michaelbaranov + microba + ${microba.version} + + + de.odysseus.juel + juel + ${juel.version} + test + + + net.forwardfire.vasc.test + vasc-test-frontend + ${project.version} + test + + diff --git a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java index ea9deec..d3398a5 100644 --- a/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java +++ b/vasc-frontend/vasc-frontend-swing/src/main/java/net/forwardfire/vasc/frontend/swing/ui/SwingList.java @@ -33,9 +33,9 @@ import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; +import net.forwardfire.vasc.backend.select.VascBackendSelectItem; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.ui.VascSelectItem; import net.forwardfire.vasc.core.ui.VascSelectItemModel; import net.forwardfire.vasc.core.ui.VascUIComponent; import net.forwardfire.vasc.core.ui.VascValueModel; @@ -69,7 +69,7 @@ public class SwingList implements VascUIComponent { comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - VascSelectItem i = (VascSelectItem)((JComboBox)e.getSource()).getSelectedItem(); + VascBackendSelectItem i = (VascBackendSelectItem)((JComboBox)e.getSource()).getSelectedItem(); try { model.setValue(i.getValue()); } catch (VascException ee) { @@ -83,7 +83,7 @@ public class SwingList implements VascUIComponent { if (model.getValue()!=null) { for (int i=0;ivasc-core ${project.version} + + net.forwardfire.vasc + vasc-frontend-api + ${project.version} +