details: /erp/devel/pi/rev/d61bca59af84
changeset: 8448:d61bca59af84
user: Martin Taal <martin.taal <at> openbravo.com>
date: Sat Sep 25 11:26:10 2010 +0200
summary: Fixes issue 14636: Support database views defined in the AD in the
Data Access Layer, Fixes issue 9640: Table Validation on View
details: /erp/devel/pi/rev/508c1e4e6b7a
changeset: 8449:508c1e4e6b7a
user: Martin Taal <martin.taal <at> openbravo.com>
date: Sat Sep 25 11:27:17 2010 +0200
summary: Fixes source warning
diffstat:
src-test/org/openbravo/test/AllAntTaskTests.java | 2 +
src-test/org/openbravo/test/dal/ViewTest.java | 52 ++++++++++++++++++++++++
src/org/openbravo/base/model/Column.java | 5 +-
src/org/openbravo/base/model/ModelProvider.java | 19 ++++----
4 files changed, 65 insertions(+), 13 deletions(-)
diffs (149 lines):
diff -r d6f404defcf2 -r 508c1e4e6b7a
src-test/org/openbravo/test/AllAntTaskTests.java
--- a/src-test/org/openbravo/test/AllAntTaskTests.java Fri Sep 24 15:33:32
2010 +0200
+++ b/src-test/org/openbravo/test/AllAntTaskTests.java Sat Sep 25 11:27:17
2010 +0200
@@ -40,6 +40,7 @@
import org.openbravo.test.dal.OBContextTest;
import org.openbravo.test.dal.ReadByNameTest;
import org.openbravo.test.dal.ValidationTest;
+import org.openbravo.test.dal.ViewTest;
import org.openbravo.test.expression.EvaluationTest;
import org.openbravo.test.model.ClassLoaderTest;
import org.openbravo.test.model.OneToManyTest;
@@ -98,6 +99,7 @@
suite.addTestSuite(DalStoredProcedureTest.class);
suite.addTestSuite(ReadByNameTest.class);
suite.addTestSuite(AdminContextTest.class);
+ suite.addTestSuite(ViewTest.class);
// expression
suite.addTestSuite(EvaluationTest.class);
diff -r d6f404defcf2 -r 508c1e4e6b7a
src-test/org/openbravo/test/dal/ViewTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/dal/ViewTest.java Sat Sep 25 11:27:17
2010 +0200
@@ -0,0 +1,52 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.dal;
+
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.test.base.BaseTest;
+
+/**
+ * Test if views work properly
+ *
+ * @author mtaal
+ */
+public class ViewTest extends BaseTest {
+
+ /**
+ * Iterates over all views
+ */
+ public void testViews() {
+ setBigBazaarAdminContext();
+ int cnt = 0;
+ for (Entity entity : ModelProvider.getInstance().getModel()) {
+ if (entity.isView()) {
+ for (BaseOBObject bob :
OBDal.getInstance().createQuery(entity.getName(), "").list()) {
+ assertTrue(bob.getEntity() == entity);
+ cnt++;
+ }
+ }
+ }
+ assertTrue(cnt > 0);
+ System.err.println(cnt);
+ }
+}
\ No newline at end of file
diff -r d6f404defcf2 -r 508c1e4e6b7a src/org/openbravo/base/model/Column.java
--- a/src/org/openbravo/base/model/Column.java Fri Sep 24 15:33:32 2010 +0200
+++ b/src/org/openbravo/base/model/Column.java Sat Sep 25 11:27:17 2010 +0200
@@ -217,7 +217,6 @@
return getDomainType() instanceof PrimitiveDomainType;
}
- @SuppressWarnings("unchecked")
public Class<?> getPrimitiveType() {
if (isPrimitiveType()) {
return ((PrimitiveDomainType) getDomainType()).getPrimitiveType();
@@ -249,9 +248,7 @@
// note calls isSuperActive(), if it would call isActive there is a
danger
// for infinite looping, see issue:
// https://issues.openbravo.com/view.php?id=8632
- if (thatColumn != null
- && (!thatColumn.isSuperActive() || !thatColumn.getTable().isActive()
|| thatColumn
- .getTable().isView())) {
+ if (thatColumn != null && (!thatColumn.isSuperActive() ||
!thatColumn.getTable().isActive())) {
log.error("Column " + this + " refers to a non active table or column
or to a view"
+ thatColumn);
}
diff -r d6f404defcf2 -r 508c1e4e6b7a
src/org/openbravo/base/model/ModelProvider.java
--- a/src/org/openbravo/base/model/ModelProvider.java Fri Sep 24 15:33:32
2010 +0200
+++ b/src/org/openbravo/base/model/ModelProvider.java Sat Sep 25 11:27:17
2010 +0200
@@ -181,9 +181,6 @@
// this map stores the mapped tables
tablesByTableName = new HashMap<String, Table>();
for (final Table t : tables) {
- if (t.isView()) {
- continue;
- }
// tables are stored case insensitive!
tablesByTableName.put(t.getTableName().toLowerCase(), t);
}
@@ -242,7 +239,8 @@
for (final Entity e : model) {
for (final Property p : e.getProperties()) {
p.initializeName();
- if (p.getColumnName() != null) {
+ // don't do mandatory value setting for views
+ if (!e.isView() && p.getColumnName() != null) {
final Boolean mandatory =
colMandatories.get(createColumnMandatoryKey(e.getTableName(),
p.getColumnName()));
if (mandatory != null) {
@@ -385,9 +383,10 @@
log.debug("Setting targetEntity and reference Property for " +
thisProp);
final Column thatColumn = c.getReferenceType();
if (thatColumn == null) {
- log.error("Property "
- + thisProp
- + " is mapped incorrectly, there is no reference column for
it, removing from the mapping");
+ log
+ .error("Property "
+ + thisProp
+ + " is mapped incorrectly, there is no reference column
for it, removing from the mapping");
thisProp.getEntity().getProperties().remove(thisProp);
if (thisProp.getEntity().getIdProperties().remove(thisProp)) {
Check.fail("Incorrect mapping for property " + thisProp
@@ -429,9 +428,11 @@
// }
if (t.getPrimaryKeyColumns().size() == 0) {
+ // note, after this issue is solved:
+ // https://issues.openbravo.com/view.php?id=14696
+ // then also log.warn for views
if (!t.isView()) {
- // don't log the views, these are ignored anyway
- log.warn("Ignoring table " + t.getName() + " because it has no
primary key columns");
+ log.warn("Ignoring table/view " + t.getName() + " because it has no
primary key columns");
}
toRemove.add(t);
continue;
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits