cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: Squashed commit of the following:
Date Fri, 14 Nov 2014 17:48:37 GMT
Repository: cayenne
Updated Branches:
  refs/heads/CAY-1946 16a8cec66 -> 66ea11873


Squashed commit of the following:

commit b7a352148071b8183c8eb960c88e9560387f78e0
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Fri Nov 14 16:22:42 2014 +0300

    fix cdb import

commit ff7f3df8da2fc20fbdc989adf4605f6553aaf8b9
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Fri Nov 14 13:51:02 2014 +0300

    fix cdb import

commit b1c24d820f10e01bb51bd603f76aba16eed0c5f1
Merge: b14e9d8 fde7761
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Fri Nov 14 13:39:38 2014 +0300

    Merge remote-tracking branch 'upstream/CAY-1946' into CAY-1946

commit b14e9d82a854d37f8fee03a662735e2e4c9365f3
Merge: 1a722e5 fca0df5
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Mon Oct 27 15:51:11 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit 1a722e5a5af61ac63b5cd7ed6b77d986a7a51a02
Merge: 31d59e0 76af157
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Tue Oct 21 11:05:18 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit 31d59e0c4aa8af61935413984a452f1788105187
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Thu Oct 9 20:04:47 2014 +0300

    add maven reporting plugins

    checkstyle, pmd, findbugs
    clirr - report about broken backward compatibility api

commit 5eff639ca7736dd8e861d33d43b7195637a8d560
Merge: f657579 3b1d6ef
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Wed Oct 8 11:16:57 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit f657579b4c7fb2065f9e6cc61ee681d6aa595b74
Merge: 5438bce 9bcf298
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Wed Sep 24 16:43:38 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit 5438bce8bee873a92c9c33be52db6e313c36c72b
Merge: a71e2ae 4b8b337
Author: Alex Kolonitsky <alexkolonitsky@Alexs-iMac.local>
Date:   Sun Sep 7 17:24:03 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit a71e2aeff164e9fcecc99668483fe33f04a2210b
Merge: 1454f65 f65d762
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Fri Aug 29 10:34:30 2014 +0300

    Merge remote-tracking branch 'upstream/master'

commit 1454f65c71bd011f93ac7db0d4cddd5e863556e9
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Mon Aug 18 16:45:06 2014 +0300

    1) add idea project files to git ignore
    2) fix build/documentation generation

commit 90de78de01b25c2d62bfe7e431e10aa12cb07d15
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Date:   Mon Aug 18 14:18:54 2014 +0300

    CAY-1942 Refactoring of NamedObjectFactory and NamingStrategy

    * Change enums first letter to lower case
    * Rename SmartNameGenerator to DefaultNameGenerator; BasicNameGenerator to LegacyNamegenerator,


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/66ea1187
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/66ea1187
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/66ea1187

Branch: refs/heads/CAY-1946
Commit: 66ea11873d27c4196613cb61d5853618e5abb0ee
Parents: 16a8cec
Author: aadamchik <aadamchik@apache.org>
Authored: Fri Nov 14 20:40:35 2014 +0300
Committer: aadamchik <aadamchik@apache.org>
Committed: Fri Nov 14 20:40:35 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/access/DbLoader.java     | 45 +++++++++-----------
 .../loader/ManyToManyCandidateEntity.java       | 19 ++++++++-
 .../access/loader/filters/EntityFilters.java    | 25 +++++++++++
 .../modeler/dialog/db/DbLoaderHelper.java       |  5 ++-
 .../dialog/db/DbLoaderOptionsDialog.java        |  4 +-
 pom.xml                                         | 28 +-----------
 6 files changed, 70 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
index e538e48..8e81483 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
@@ -72,6 +72,7 @@ public class DbLoader {
     private static final Log LOGGER = LogFactory.getLog(DbLoader.class);
 
     public static final String WILDCARD = "%";
+    public static final String WILDCARD_PATTERN = ".*";
 
     /**
      * CAY-479 - need to track which entities which are skipped during loading from db since
it it already present in
@@ -398,13 +399,16 @@ public class DbLoader {
 
                 DbAttribute attr = loadDbAttribute(rs);
                 attr.setEntity(dbEntity);
-                if (!filters.filter(new DbPath(dbEntity.getCatalog(), dbEntity.getSchema(),
tableName))
-                        .columnFilter().isInclude(attr)) {
-
+                DbPath path = new DbPath(dbEntity.getCatalog(), dbEntity.getSchema(), tableName);
+                Filter<DbAttribute> filter = filters.filter(path).columnFilter();
+                if (!filter.isInclude(attr)) {
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug("Importing: attribute '" + attr.getEntity().getName()
+ "." + attr.getName()
+                                + "' is skipped (Path: " + path + "; Filter: " + filter +
")");
+                    }
                     continue;
                 }
 
-
                 dbEntity.addAttribute(attr);
             }
         } finally {
@@ -499,8 +503,6 @@ public class DbLoader {
     }
 
     protected void loadDbRelationships(DataMap map, DbEntity entity, DbLoaderConfiguration
config) throws SQLException {
-        String pkEntName = entity.getName();
-
         // Get all the foreign keys referencing this table
         ResultSet rs;
 
@@ -508,23 +510,19 @@ public class DbLoader {
             rs = getMetaData().getExportedKeys(entity.getCatalog(), entity.getSchema(), entity.getName());
         } catch (SQLException cay182Ex) {
             // Sybase-specific - the line above blows on VIEWS, see CAY-182.
-            LOGGER.info("Error getting relationships for '" + pkEntName + "', ignoring.");
+            LOGGER.info("Error getting relationships for '" + entity.getName() + "', ignoring.");
             return;
         }
 
         try {
-            if (!rs.next()) {
-                return;
-            }
-
             // these will be initialized every time a new target entity is found
             // in the result set (which should be ordered by table name among other things)
             DbRelationship forwardRelationship = null;
             DbRelationshipDetected reverseRelationship = null;
             DbEntity fkEntity = null;
-            ExportedKey key;
+            ExportedKey key = null;
 
-            do {
+            while (rs.next()) {
                 key = ExportedKey.extractData(rs);
 
                 short keySeq = rs.getShort("KEY_SEQ");
@@ -537,7 +535,6 @@ public class DbLoader {
 
                     // start new entity
                     String fkEntityName = key.getFKTableName();
-                    String fkName = key.getFKName();
 
                     fkEntity = map.getDbEntity(fkEntityName);
                     DbPath path = new DbPath(entity.getCatalog(), entity.getSchema(), entity.getName());
@@ -552,19 +549,13 @@ public class DbLoader {
                         continue;
                     } else {
                         // init relationship
-                        String forwardPreferredName = nameGenerator.createDbRelationshipName(key,
true);
-                        forwardRelationship = new DbRelationship(DefaultUniqueNameGenerator
-                                .generate(NameCheckers.dbRelationship, entity, forwardPreferredName));
-
+                        forwardRelationship = new DbRelationship(generateName(entity, key,
true));
                         forwardRelationship.setSourceEntity(entity);
                         forwardRelationship.setTargetEntity(fkEntity);
                         entity.addRelationship(forwardRelationship);
 
-                        String reversePreferredName = nameGenerator.createDbRelationshipName(key,
false);
-                        reverseRelationship = new DbRelationshipDetected(DefaultUniqueNameGenerator
-                                .generate(NameCheckers.dbRelationship, fkEntity, reversePreferredName));
-
-                        reverseRelationship.setFkName(fkName);
+                        reverseRelationship = new DbRelationshipDetected(generateName(fkEntity,
key, false));
+                        reverseRelationship.setFkName(key.getFKName());
                         reverseRelationship.setToMany(false);
                         reverseRelationship.setSourceEntity(fkEntity);
                         reverseRelationship.setTargetEntity(entity);
@@ -598,7 +589,7 @@ public class DbLoader {
                     }
 
                 }
-            } while (rs.next());
+            }
 
             if (forwardRelationship != null) {
                 postProcessMasterDbRelationship(forwardRelationship, key);
@@ -610,6 +601,12 @@ public class DbLoader {
         }
     }
 
+    private String generateName(DbEntity entity, ExportedKey key, boolean toMany) {
+        String forwardPreferredName = nameGenerator.createDbRelationshipName(key, toMany);
+        return DefaultUniqueNameGenerator
+                .generate(NameCheckers.dbRelationship, entity, forwardPreferredName);
+    }
+
     /**
      * Detects correct relationship multiplicity and "to dep pk" flag. Only
      * called on relationships from PK to FK, not the reverse ones.

http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/cayenne-server/src/main/java/org/apache/cayenne/access/loader/ManyToManyCandidateEntity.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/ManyToManyCandidateEntity.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/ManyToManyCandidateEntity.java
index 8cf4ae1..6e392d8 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/ManyToManyCandidateEntity.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/ManyToManyCandidateEntity.java
@@ -28,12 +28,17 @@ import org.apache.cayenne.map.naming.DefaultUniqueNameGenerator;
 import org.apache.cayenne.map.naming.ExportedKey;
 import org.apache.cayenne.map.naming.NameCheckers;
 import org.apache.cayenne.map.naming.ObjectNameGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Class represent ObjEntity that may be optimized using flattened relationships
  * as many to many table
  */
 public class ManyToManyCandidateEntity {
+
+    private static final Log LOG = LogFactory.getLog(ManyToManyCandidateEntity.class);
+
     private final ObjEntity joinEntity;
 
     private final DbRelationship dbRel1;
@@ -82,14 +87,24 @@ public class ManyToManyCandidateEntity {
     private boolean isManyToMany() {
         boolean isNotHaveAttributes = joinEntity.getAttributes().size() == 0;
 
-        return isNotHaveAttributes && reverseRelationship1.isToDependentPK() &&
reverseRelationship2.isToDependentPK()
+        return isNotHaveAttributes
+                && reverseRelationship1.isToDependentPK()
+                && reverseRelationship2.isToDependentPK()
                 && !entity1.equals(entity2);
     }
 
     private void addFlattenedRelationship(ObjectNameGenerator nameGenerator, ObjEntity srcEntity,
ObjEntity dstEntity,
                                           DbRelationship rel1, DbRelationship rel2) {
 
-        ExportedKey key = new ExportedKey(rel1.getSourceEntity().getName(),
+        if (rel1.getSourceAttributes().isEmpty() && rel2.getTargetAttributes().isEmpty())
{
+            LOG.warn("Wrong call ManyToManyCandidateEntity.addFlattenedRelationship(... ,
" + srcEntity.getName()
+                    + ", " + dstEntity.getName() + ", ...)");
+
+            return;
+        }
+
+        ExportedKey key = new ExportedKey(
+                rel1.getSourceEntity().getName(),
                 rel1.getSourceAttributes().iterator().next().getName(),
                 null,
                 rel2.getTargetEntity().getName(),

http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
index 5fde570..83e9a48 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import static org.apache.cayenne.access.loader.filters.FilterFactory.*;
+import static org.apache.commons.lang.StringUtils.isBlank;
 
 /**
  * @since 3.2.
@@ -321,6 +322,10 @@ public class EntityFilters {
         }
 
         public Builder includeTables(String tableFilters) {
+            if (isBlank(tableFilters)) {
+                return this;
+            }
+
             for (String pattern : tableFilters.split(",")) {
                 this.tableFilters = this.tableFilters.join(include(pattern));
             }
@@ -329,6 +334,10 @@ public class EntityFilters {
         }
 
         public Builder includeColumns(String columnFilters) {
+            if (isBlank(columnFilters)) {
+                return this;
+            }
+
             for (String pattern : columnFilters.split(",")) {
                 this.columnFilters = this.columnFilters.join(include(pattern));
             }
@@ -337,6 +346,10 @@ public class EntityFilters {
         }
 
         public Builder includeProcedures(String proceduresFilters) {
+            if (isBlank(proceduresFilters)) {
+                return this;
+            }
+
             for (String pattern : proceduresFilters.split(",")) {
                 this.proceduresFilters = this.proceduresFilters.join(include(pattern));
             }
@@ -345,6 +358,10 @@ public class EntityFilters {
         }
 
         public Builder excludeTables(String tableFilters) {
+            if (isBlank(tableFilters)) {
+                return this;
+            }
+
             for (String pattern : tableFilters.split(",")) {
                 this.tableFilters = this.tableFilters.join(exclude(pattern));
             }
@@ -353,6 +370,10 @@ public class EntityFilters {
         }
 
         public Builder excludeColumns(String columnFilters) {
+            if (isBlank(columnFilters)) {
+                return this;
+            }
+
             for (String pattern : columnFilters.split(",")) {
                 this.columnFilters = this.columnFilters.join(exclude(pattern));
             }
@@ -361,6 +382,10 @@ public class EntityFilters {
         }
 
         public Builder excludeProcedures(String proceduresFilters) {
+            if (isBlank(proceduresFilters)) {
+                return this;
+            }
+
             for (String pattern : proceduresFilters.split(",")) {
                 this.proceduresFilters = this.proceduresFilters.join(exclude(pattern));
             }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
index c48c2b2..4776507 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
@@ -53,6 +53,8 @@ import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
 import org.apache.cayenne.modeler.util.LongRunningTask;
 import org.apache.cayenne.resource.Resource;
+import org.apache.cayenne.tools.dbimport.config.FiltersConfigBuilder;
+import org.apache.cayenne.tools.dbimport.config.ReverseEngineering;
 import org.apache.cayenne.util.DeleteRuleUpdater;
 import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
@@ -412,7 +414,8 @@ public class DbLoaderHelper {
                 }
 
                 DbLoaderConfiguration configuration = new DbLoaderConfiguration();
-                configuration.setFiltersConfig(new FiltersConfig(filterBuilder.build()));
+                configuration.setFiltersConfig(new FiltersConfigBuilder(new ReverseEngineering())
+                        .add(filterBuilder.build()).filtersConfig());
                 loader.load(dataMap, configuration, types);
 
                 /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderOptionsDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderOptionsDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderOptionsDialog.java
index 4190203..fe24b30 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderOptionsDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderOptionsDialog.java
@@ -163,9 +163,9 @@ public class DbLoaderOptionsDialog extends CayenneDialog {
             boolean shouldLoadProcedures) {
 
         this.choice = CANCEL;
-        this.tableNamePatternField.setText(DbLoader.WILDCARD);
+        this.tableNamePatternField.setText(DbLoader.WILDCARD_PATTERN);
         this.loadProcedures.setSelected(shouldLoadProcedures);
-        this.procNamePatternField.setText(DbLoader.WILDCARD);
+        this.procNamePatternField.setText(DbLoader.WILDCARD_PATTERN);
         this.procNamePatternField.setEnabled(shouldLoadProcedures);
         this.procedureLabel.setEnabled(shouldLoadProcedures);
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/66ea1187/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d5c1f76..56334a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -535,7 +535,7 @@
 				<enabled>true</enabled>
 			</releases>
 		</pluginRepository>
-    </pluginRepositories>
+	</pluginRepositories>
 	<build>
 		<defaultGoal>install</defaultGoal>
 
@@ -676,32 +676,6 @@
 										<ignore />
 									</action>
 								</pluginExecution>
-								<pluginExecution>
-									<pluginExecutionFilter>
-										<groupId>org.apache.maven.plugins</groupId>
-                    					<artifactId>maven-checkstyle-plugin</artifactId>
-                    					<versionRange>[1.0,)</versionRange>
-										<goals>
-											<goal>check</goal>
-										</goals>
-									</pluginExecutionFilter>
-									<action>
-										<ignore />
-									</action>
-								</pluginExecution>
-								<pluginExecution>
-									<pluginExecutionFilter>
-										<groupId>org.apache.maven.plugins</groupId>
-                    					<artifactId>maven-pmd-plugin</artifactId>
-                    					<versionRange>[1.0,)</versionRange>
-										<goals>
-											<goal>check</goal>
-										</goals>
-									</pluginExecutionFilter>
-									<action>
-										<ignore />
-									</action>
-								</pluginExecution>
 							</pluginExecutions>
 						</lifecycleMappingMetadata>
 					</configuration>


Mime
View raw message