You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/12/07 10:09:33 UTC
[04/30] cayenne git commit: CAY-2377. Remove AntDataPortDelegate with
usage, DataPort, DataPortDelegate
CAY-2377. Remove AntDataPortDelegate with usage, DataPort, DataPortDelegate
CAY-2377. Remove InvalidationFunction
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/ad4d5bd4
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/ad4d5bd4
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/ad4d5bd4
Branch: refs/heads/master
Commit: ad4d5bd42bae6fd27393a85beb0290134c41c089
Parents: b3f7402
Author: Arseni Bulatski <an...@gmail.com>
Authored: Tue Oct 24 10:42:47 2017 +0300
Committer: Arseni Bulatski <an...@gmail.com>
Committed: Wed Nov 15 10:27:46 2017 +0300
----------------------------------------------------------------------
.../cayenne/tools/AntDataPortDelegate.java | 170 ----------
.../org/apache/cayenne/tools/DataPortTask.java | 209 ------------
.../org/apache/cayenne/tools/antlib.xml | 1 -
.../cayenne/tools/AntDataPortDelegateTest.java | 53 ---
.../invalidation/InvalidationFunction.java | 39 ---
.../dbsync/filter/NamePatternMatcher.java | 34 --
.../org/apache/cayenne/access/DataPort.java | 324 -------------------
.../apache/cayenne/access/DataPortDelegate.java | 77 -----
docs/doc/src/main/resources/UPGRADE.txt | 11 +
.../cayenne/wocompat/EOModelProcessor.java | 24 --
10 files changed, 11 insertions(+), 931 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
deleted file mode 100644
index de001bd..0000000
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/AntDataPortDelegate.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.access.DataPortDelegate;
-import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.Query;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * DataPortDelegate implementation that works in the context of Ant DataPortTask
- * task execution, performing entity filtering and logging functions.
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- * package.
- * @deprecated since 4.0
- */
-@Deprecated
-class AntDataPortDelegate implements DataPortDelegate {
-
- protected Task parentTask;
-
- protected Pattern[] mapFilters;
-
- protected long timestamp;
- protected DbEntity lastEntity;
-
- protected NamePatternMatcher namePatternMatcher;
-
- // exists for testing and such
- AntDataPortDelegate() {
- mapFilters = new Pattern[] {};
- }
-
- AntDataPortDelegate(Task parentTask, String mapsPattern,
- String includeEntitiesPattern, String excludeEntitiesPattern) {
- this.parentTask = parentTask;
-
- AntLogger logger = new AntLogger(parentTask);
-
- this.namePatternMatcher = NamePatternMatcher.build(logger, includeEntitiesPattern, excludeEntitiesPattern);
- this.mapFilters = NamePatternMatcher.createPatterns(logger, mapsPattern);
- }
-
- /**
- * Applies preconfigured list of filters to the list, removing entities that
- * do not pass the filter.
- */
- protected List filterEntities(List entities) {
- if (entities == null || entities.isEmpty()) {
- return entities;
- }
-
- Iterator it = entities.iterator();
- while (it.hasNext()) {
- DbEntity entity = (DbEntity) it.next();
-
- if (!passedDataMapFilter(entity.getDataMap())) {
- it.remove();
- }
- }
-
- namePatternMatcher.filter(entities);
-
- return entities;
- }
-
- /**
- * Returns true if the DataMap passes a set of DataMap filters or if there
- * is no DataMap filters.
- */
- protected boolean passedDataMapFilter(DataMap map) {
- if (mapFilters.length == 0) {
- return true;
- }
-
- if (map == null) {
- return true;
- }
-
- String mapName = map.getName();
- for (Pattern mapFilter : mapFilters) {
- if (mapFilter.matcher(mapName).find()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Implements the delegate method to filter the list of entities applying
- * filtering rules encapsulated by this object.
- */
- public List willPortEntities(DataPort portTool, List entities) {
- return filterEntities(entities);
- }
-
- /**
- * Logs entity porting event using Ant logger.
- */
- public Query willPortEntity(DataPort portTool, DbEntity entity, Query query) {
- parentTask.log("Porting '" + entity.getName() + "'");
- lastEntity = entity;
- timestamp = System.currentTimeMillis();
- return query;
- }
-
- public void didPortEntity(DataPort portTool, DbEntity entity, int rowCount) {
- String timestampLabel = "";
- if (lastEntity == entity) {
- timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
- + " ms.";
- }
-
- String label = (rowCount == 1) ? "1 row transferred" : rowCount
- + " rows transferred";
- parentTask.log("Done porting " + entity.getName() + ", " + label
- + timestampLabel, Project.MSG_VERBOSE);
- }
-
- public List willCleanData(DataPort portTool, List entities) {
- return filterEntities(entities);
- }
-
- public Query willCleanData(DataPort portTool, DbEntity entity, Query query) {
- parentTask.log("Deleting " + entity.getName(), Project.MSG_VERBOSE);
- lastEntity = entity;
- timestamp = System.currentTimeMillis();
- return query;
- }
-
- public void didCleanData(DataPort portTool, DbEntity entity, int rowCount) {
- String timestampLabel = "";
- if (lastEntity == entity) {
- timestampLabel = " in " + (System.currentTimeMillis() - timestamp)
- + " ms.";
- }
-
- String label = (rowCount == 1) ? "1 row deleted" : rowCount
- + " rows deleted";
- parentTask.log("Done deleting " + entity.getName() + ", " + label
- + timestampLabel, Project.MSG_VERBOSE);
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
deleted file mode 100644
index eade13c..0000000
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DataPortTask.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.access.DataDomain;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.DataPort;
-import org.apache.cayenne.configuration.Constants;
-import org.apache.cayenne.configuration.server.ServerRuntime;
-import org.apache.cayenne.di.Key;
-import org.apache.cayenne.di.Module;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.resource.FilesystemResourceLocator;
-import org.apache.cayenne.resource.ResourceLocator;
-import org.apache.cayenne.util.Util;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * A "cdataport" Ant task implementing a frontend to DataPort allowing porting
- * database data using Ant build scripts.
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- * package.
- * @deprecated since 4.0
- */
-@Deprecated
-public class DataPortTask extends CayenneTask {
-
- protected File projectFile;
- protected String maps;
- protected String srcNode;
- protected String destNode;
- protected String includeTables;
- protected String excludeTables;
- protected boolean cleanDest = true;
-
- public DataPortTask() {
- // set defaults
- this.cleanDest = true;
- }
-
- @Override
- public void execute() throws BuildException {
-
- log("*** 'cdataport' task is deprecated and will be removed after 4.0",
- Project.MSG_WARN);
-
- validateParameters();
-
- String projectFileLocation = projectFile.getName();
- Module dataPortModule = binder -> {
- FilesystemResourceLocator filesystemResourceLocator = new FilesystemResourceLocator(projectFile);
- binder.bind(ResourceLocator.class).toInstance(filesystemResourceLocator);
- binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR))
- .toInstance(filesystemResourceLocator);
- };
-
- ServerRuntime runtime = new ServerRuntime(projectFileLocation,
- dataPortModule);
- DataDomain domain;
-
- ClassLoader threadContextClassLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- // need to set context class loader so that cayenne can find jdbc
- // driver and
- // PasswordEncoder
- // TODO: andrus 04/11/2010 is this still relevant in 3.1?
- Thread.currentThread().setContextClassLoader(
- getClass().getClassLoader());
-
- domain = runtime.getDataDomain();
- } catch (Exception ex) {
- throw new BuildException(
- "Error loading Cayenne configuration from " + projectFile,
- ex);
- } finally {
- // set back to original ClassLoader
- Thread.currentThread().setContextClassLoader(
- threadContextClassLoader);
- }
-
- // perform project validation
- DataNode source = domain.getDataNode(srcNode);
- if (source == null) {
- throw new BuildException("srcNode not found in the project: "
- + srcNode);
- }
-
- DataNode destination = domain.getDataNode(destNode);
- if (destination == null) {
- throw new BuildException("destNode not found in the project: "
- + destNode);
- }
-
- log("Porting from '" + srcNode + "' to '" + destNode + "'.");
-
- AntDataPortDelegate portDelegate = new AntDataPortDelegate(this, maps,
- includeTables, excludeTables);
- DataPort dataPort = new DataPort(portDelegate);
- dataPort.setEntities(getAllEntities(source, destination));
- dataPort.setCleaningDestination(cleanDest);
- dataPort.setSourceNode(source);
- dataPort.setDestinationNode(destination);
-
- try {
- dataPort.execute();
- } catch (Exception e) {
- Throwable topOfStack = Util.unwindException(e);
- throw new BuildException("Error porting data: "
- + topOfStack.getMessage(), topOfStack);
- }
- }
-
- protected Collection<DbEntity> getAllEntities(DataNode source,
- DataNode target) {
- // use a set to exclude duplicates, though a valid project will probably
- // have
- // none...
- Collection<DbEntity> allEntities = new HashSet<DbEntity>();
-
- for (DataMap map : source.getDataMaps()) {
- allEntities.addAll(map.getDbEntities());
- }
-
- for (DataMap map : target.getDataMaps()) {
- allEntities.addAll(map.getDbEntities());
- }
-
- log("Number of entities: " + allEntities.size(), Project.MSG_VERBOSE);
-
- if (allEntities.size() == 0) {
- log("No entities found for either source or target.");
- }
- return allEntities;
- }
-
- protected void validateParameters() throws BuildException {
- if (projectFile == null) {
- throw new BuildException(
- "Required 'projectFile' parameter is missing.");
- }
-
- if (!projectFile.exists()) {
- throw new BuildException("'projectFile' does not exist: "
- + projectFile);
- }
-
- if (srcNode == null) {
- throw new BuildException("Required 'srcNode' parameter is missing.");
- }
-
- if (destNode == null) {
- throw new BuildException(
- "Required 'destNode' parameter is missing.");
- }
- }
-
- public void setDestNode(String destNode) {
- this.destNode = destNode;
- }
-
- public void setExcludeTables(String excludeTables) {
- this.excludeTables = excludeTables;
- }
-
- public void setIncludeTables(String includeTables) {
- this.includeTables = includeTables;
- }
-
- public void setMaps(String maps) {
- this.maps = maps;
- }
-
- public void setProjectFile(File projectFile) {
- this.projectFile = projectFile;
- }
-
- public void setSrcNode(String srcNode) {
- this.srcNode = srcNode;
- }
-
- public void setCleanDest(boolean flag) {
- this.cleanDest = flag;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml b/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
index bfebaf6..3a29e74 100644
--- a/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
+++ b/cayenne-ant/src/main/resources/org/apache/cayenne/tools/antlib.xml
@@ -20,6 +20,5 @@
<antlib>
<taskdef name="cgen" classname="org.apache.cayenne.tools.CayenneGeneratorTask"/>
<taskdef name="cdbgen" classname="org.apache.cayenne.tools.DbGeneratorTask"/>
- <taskdef name="cdataport" classname="org.apache.cayenne.tools.DataPortTask"/>
<taskdef name="cdbimport" classname="org.apache.cayenne.tools.DbImporterTask"/>
</antlib>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java b/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
deleted file mode 100644
index 584d4c8..0000000
--- a/cayenne-ant/src/test/java/org/apache/cayenne/tools/AntDataPortDelegateTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.tools;
-
-import org.apache.cayenne.map.DataMap;
-import org.junit.Test;
-
-import java.util.regex.Pattern;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@Deprecated
-public class AntDataPortDelegateTest {
-
- @Test
- public void testPassedDataMapFilter() {
- AntDataPortDelegate delegate = new AntDataPortDelegate();
-
- // filtering should be done based on map name
-
- DataMap map = new DataMap();
- assertTrue(delegate.passedDataMapFilter(map));
-
- map.setName("A");
- assertTrue(delegate.passedDataMapFilter(map));
-
- delegate.mapFilters = new Pattern[] {
- Pattern.compile("B")
- };
- assertFalse(delegate.passedDataMapFilter(map));
-
- map.setName("BBBB");
- assertTrue(delegate.passedDataMapFilter(map));
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java
----------------------------------------------------------------------
diff --git a/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java b/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java
deleted file mode 100644
index 96f2db9..0000000
--- a/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.cache.invalidation;
-
-import org.apache.cayenne.Persistent;
-
-import java.util.Collection;
-import java.util.function.Function;
-
-/**
- * @since 4.0
- * @deprecated since 4.1 plain Function>Persistent, Collection>CacheGroupDescriptor>> can be used.
- */
-@Deprecated
-public interface InvalidationFunction extends Function<Persistent, Collection<CacheGroupDescriptor>> {
-
- /**
- * @return collection of cache groups to invalidate for given object
- */
- Collection<CacheGroupDescriptor> apply(Persistent persistent);
-
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
index a70345c..4697c9a 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/filter/NamePatternMatcher.java
@@ -59,40 +59,6 @@ public class NamePatternMatcher implements NameFilter {
}
/**
- * Applies preconfigured list of filters to the list, removing entities that do not
- * pass the filter.
- *
- * @deprecated since 3.0 still used by AntDataPortDelegate, which itself should
- * probably be deprecated
- */
- @Deprecated
- public List<?> filter(List<?> items) {
- if (items == null || items.isEmpty()) {
- return items;
- }
-
- if (itemIncludeFilters.length == 0 && itemExcludeFilters.length == 0) {
- return items;
- }
-
- Iterator<?> it = items.iterator();
- while (it.hasNext()) {
- CayenneMapEntry entity = (CayenneMapEntry) it.next();
-
- if (!passedIncludeFilter(entity.getName())) {
- it.remove();
- continue;
- }
-
- if (!passedExcludeFilter(entity.getName())) {
- it.remove();
- }
- }
-
- return items;
- }
-
- /**
* Returns an array of Patterns. Takes a comma-separated list of patterns, attempting
* to convert them to the java.util.regex.Pattern syntax. E.g.
* <p>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-server/src/main/java/org/apache/cayenne/access/DataPort.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DataPort.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DataPort.java
deleted file mode 100644
index 8dbad91..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DataPort.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cayenne.CayenneException;
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.ResultIterator;
-import org.apache.cayenne.access.util.DoNothingOperationObserver;
-import org.apache.cayenne.access.util.IteratedSelectObserver;
-import org.apache.cayenne.ashwood.AshwoodEntitySorter;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.EntitySorter;
-import org.apache.cayenne.query.InsertBatchQuery;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.SelectQuery;
-
-/**
- * An engine to port data between two DataNodes. These nodes can potentially
- * connect to databases from different vendors. The only assumption is that all
- * of the DbEntities (tables) being ported are present in both source and
- * destination databases and are adequately described by Cayenne mapping.
- * <p>
- * DataPort implements a Cayenne-based algorithm to read data from source
- * DataNode and write to destination DataNode. It uses DataPortDelegate
- * interface to externalize various things, such as determining what entities to
- * port (include/exclude from port based on some criteria), logging the progress
- * of port operation, qualifying the queries, etc.
- * </p>
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples
- * package.
- * @deprecated since 4.0
- */
-@Deprecated
-public class DataPort {
-
- public static final int INSERT_BATCH_SIZE = 1000;
-
- protected DataNode sourceNode;
- protected DataNode destinationNode;
- protected Collection entities;
- protected boolean cleaningDestination;
- protected DataPortDelegate delegate;
- protected int insertBatchSize;
-
- public DataPort() {
- this.insertBatchSize = INSERT_BATCH_SIZE;
- }
-
- /**
- * Creates a new DataPort instance, setting its delegate.
- */
- public DataPort(DataPortDelegate delegate) {
- this.delegate = delegate;
- }
-
- /**
- * Runs DataPort. The instance must be fully configured by the time this
- * method is invoked, having its delegate, source and destinatio nodes, and
- * a list of entities set up.
- */
- public void execute() throws CayenneException {
- // sanity check
- if (sourceNode == null) {
- throw new CayenneException("Can't port data, source node is null.");
- }
-
- if (destinationNode == null) {
- throw new CayenneException("Can't port data, destination node is null.");
- }
-
- // the simple equality check may actually detect problems with
- // misconfigred nodes
- // it is not as dumb as it may look at first
- if (sourceNode == destinationNode) {
- throw new CayenneException("Can't port data, source and target nodes are the same.");
- }
-
- if (entities == null || entities.isEmpty()) {
- return;
- }
-
- // sort entities for insertion
- List sorted = new ArrayList(entities);
- EntitySorter sorter = new AshwoodEntitySorter();
- sorter.setEntityResolver(new EntityResolver(destinationNode.getDataMaps()));
- sorter.sortDbEntities(sorted, false);
-
- if (cleaningDestination) {
- // reverse insertion order for deletion
- List entitiesInDeleteOrder = new ArrayList(sorted.size());
- entitiesInDeleteOrder.addAll(sorted);
- Collections.reverse(entitiesInDeleteOrder);
- processDelete(entitiesInDeleteOrder);
- }
-
- processInsert(sorted);
- }
-
- /**
- * Cleans up destination tables data.
- */
- protected void processDelete(List entities) {
- // Allow delegate to modify the list of entities
- // any way it wants. For instance delegate may filter
- // or sort the list (though it doesn't have to, and can simply
- // pass through the original list).
- if (delegate != null) {
- entities = delegate.willCleanData(this, entities);
- }
-
- if (entities == null || entities.isEmpty()) {
- return;
- }
-
- // Delete data from entities one by one
- Iterator it = entities.iterator();
- while (it.hasNext()) {
- DbEntity entity = (DbEntity) it.next();
-
- Query query = new SQLTemplate(entity, "DELETE FROM " + entity.getFullyQualifiedName());
-
- // notify delegate that delete is about to happen
- if (delegate != null) {
- query = delegate.willCleanData(this, entity, query);
- }
-
- final int[] count = new int[] { -1 };
-
- // perform delete query
- OperationObserver observer = new DoNothingOperationObserver() {
-
- @Override
- public void nextCount(Query query, int resultCount) {
- count[0] = resultCount;
- }
- };
- destinationNode.performQueries(Collections.singletonList(query), observer);
-
- // notify delegate that delete just happened
- if (delegate != null) {
- delegate.didCleanData(this, entity, count[0]);
- }
- }
- }
-
- /**
- * Reads source data from source, saving it to destination.
- */
- protected void processInsert(List entities) throws CayenneException {
- // Allow delegate to modify the list of entities
- // any way it wants. For instance delegate may filter
- // or sort the list (though it doesn't have to, and can simply
- // pass through the original list).
- if (delegate != null) {
- entities = delegate.willCleanData(this, entities);
- }
-
- if (entities == null || entities.isEmpty()) {
- return;
- }
-
- // Create an observer for to get the iterated result
- // instead of getting each table as a list
- IteratedSelectObserver observer = new IteratedSelectObserver();
-
- OperationObserver insertObserver = new DoNothingOperationObserver();
-
- // process ordered list of entities one by one
- Iterator it = entities.iterator();
- while (it.hasNext()) {
-
- DbEntity entity = (DbEntity) it.next();
-
- SelectQuery<DataRow> select = new SelectQuery<DataRow>(entity);
- select.setFetchingDataRows(true);
-
- // delegate is allowed to substitute query
- Query query = (delegate != null) ? delegate.willPortEntity(this, entity, select) : select;
-
- sourceNode.performQueries(Collections.singletonList(query), observer);
-
- InsertBatchQuery insert = new InsertBatchQuery(entity, INSERT_BATCH_SIZE);
-
- try (ResultIterator<?> result = observer.getResultIterator();) {
-
- // Split insertions into the same table into batches.
- // This will allow to process tables of arbitrary size
- // and not run out of memory.
- int currentRow = 0;
-
- // even if we don't use intermediate batch commits, we still
- // need to
- // estimate batch insert size
- int batchSize = insertBatchSize > 0 ? insertBatchSize : INSERT_BATCH_SIZE;
-
- while (result.hasNextRow()) {
- if (insertBatchSize > 0 && currentRow > 0 && currentRow % insertBatchSize == 0) {
- // end of the batch detected... commit and start a new
- // insert
- // query
- destinationNode.performQueries(Collections.singletonList((Query) insert), insertObserver);
- insert = new InsertBatchQuery(entity, batchSize);
- }
-
- currentRow++;
-
- Map<String, Object> nextRow = (DataRow) result.nextRow();
- insert.add(nextRow);
- }
-
- // commit remaining batch if needed
- if (insert.getRows().size() > 0) {
- destinationNode.performQueries(Collections.singletonList((Query) insert), insertObserver);
- }
-
- if (delegate != null) {
- delegate.didPortEntity(this, entity, currentRow);
- }
- }
- }
- }
-
- public Collection getEntities() {
- return entities;
- }
-
- public DataNode getSourceNode() {
- return sourceNode;
- }
-
- public DataNode getDestinationNode() {
- return destinationNode;
- }
-
- /**
- * Sets the initial list of entities to process. This list can be later
- * modified by the delegate.
- */
- public void setEntities(Collection entities) {
- this.entities = entities;
- }
-
- /**
- * Sets the DataNode serving as a source of the ported data.
- */
- public void setSourceNode(DataNode sourceNode) {
- this.sourceNode = sourceNode;
- }
-
- /**
- * Sets the DataNode serving as a destination of the ported data.
- */
- public void setDestinationNode(DataNode destinationNode) {
- this.destinationNode = destinationNode;
- }
-
- /**
- * Returns previously initialized DataPortDelegate object.
- */
- public DataPortDelegate getDelegate() {
- return delegate;
- }
-
- public void setDelegate(DataPortDelegate delegate) {
- this.delegate = delegate;
- }
-
- /**
- * Returns true if a DataPort was configured to delete all data from the
- * destination tables.
- */
- public boolean isCleaningDestination() {
- return cleaningDestination;
- }
-
- /**
- * Defines whether DataPort should delete all data from destination tables
- * before doing the port.
- */
- public void setCleaningDestination(boolean cleaningDestination) {
- this.cleaningDestination = cleaningDestination;
- }
-
- public int getInsertBatchSize() {
- return insertBatchSize;
- }
-
- /**
- * Sets a parameter used for tuning insert batches. If set to a value
- * greater than zero, DataPort will commit every N rows. If set to value
- * less or equal to zero, DataPort will commit only once at the end of the
- * insert.
- */
- public void setInsertBatchSize(int insertBatchSize) {
- this.insertBatchSize = insertBatchSize;
- }
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/cayenne-server/src/main/java/org/apache/cayenne/access/DataPortDelegate.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DataPortDelegate.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DataPortDelegate.java
deleted file mode 100644
index 199031b..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DataPortDelegate.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access;
-
-import java.util.List;
-
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.query.Query;
-
-/**
- * Interface for callback and delegate methods allowing implementing classes to control
- * various aspects of data porting via DataPort. DataPort instance will invoke appropriate
- * delegate methods during different stages of porting process.
- *
- * @since 1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples package.
- * @deprecated since 4.0
- */
-@Deprecated
-public interface DataPortDelegate {
-
- /**
- * Allows delegate to sort or otherwise alter a list of DbEntities right before the
- * port starts.
- */
- List willPortEntities(DataPort portTool, List entities);
-
- /**
- * Invoked by DataPort right before the start of data port for a given entity. Allows
- * delegate to handle such things like logging, etc. Also makes it possible to
- * substitute or alter the select query used to fecth the source data, e.g. set a
- * limiting qualifier.
- */
- Query willPortEntity(DataPort portTool, DbEntity entity, Query query);
-
- /**
- * Invoked by DataPort right after the end of data port for a given entity. Allows
- * delegate to handle such things like logging, etc.
- */
- void didPortEntity(DataPort portTool, DbEntity entity, int rowCount);
-
- /**
- * Allows delegate to sort or otherwise alter a list of DbEntities right before data
- * cleanup starts.
- */
- List willCleanData(DataPort portTool, List entities);
-
- /**
- * Invoked by DataPort right before the start of data cleanup for a given entity.
- * Allows delegate to handle such things like logging, etc. Also makes it possible to
- * substitute or alter the delete query used to cleanup the data, e.g. set a limiting
- * qualifier.
- */
- Query willCleanData(DataPort portTool, DbEntity entity, Query query);
-
- /**
- * Invoked by DataPort right after the end of data cleanup for a given entity. Allows
- * delegate to handle such things like logging, etc.
- */
- void didCleanData(DataPort portTool, DbEntity entity, int rowCount);
-}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/docs/doc/src/main/resources/UPGRADE.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/UPGRADE.txt b/docs/doc/src/main/resources/UPGRADE.txt
index 8a62c7f..5ccc1d7 100644
--- a/docs/doc/src/main/resources/UPGRADE.txt
+++ b/docs/doc/src/main/resources/UPGRADE.txt
@@ -82,6 +82,17 @@ UPGRADING TO 4.1.M2
- removed static final boolean REMOTE_NOTIFICATION_DEFAULT = false; {without usages} in org.apache.cayenne.access.DataRowStore;
- removed boolean notifyingRemoteListeners; {since 4.0 does nothing} in org.apache.cayenne.access.DataRowStore;
- removed boolean isNotifyingRemoteListeners(); void setNotifyingRemoteListeners(boolean notifyingRemoteListeners); {since 4.0 never used} in org.apache.cayenne.access.DataRowStore;
+ - removed <taskdef name="cdataport" classname="org.apache.cayenne.tools.DataPortTask"/> in org.apache.cayenne.tools.antlib.xml;
+ - removed org.apache.cayenne.tools.AntDataPortDelegate and org.apache.cayenne.tools.DataPortTask;
+ - removed AntDataPortDelegateTest in org.apache.cayenne.tools.AntDataPortDelegateTest;
+ - removed List<?> filter(List<?> items) in org.apache.cayenne.dbsync.NamePatternMatcher {begore used in AntDataPortDelegate wich was removed};
+ - removed org.apache.cayenne.access.DataPort;
+ - removed org.apache.cayenne.access.DataPortDelegate;
+ - removed org.apache.cayenne.cache.invalidation.InvalidationFunction;
+ - removed DataMap loadEOModel(String path) {since 4.0 in favor of loadEOModel(URL)} in org.apache.cayenne.wocompat;
+ - removed DataMap loadEOModel(String path, boolean generateClientClass) {since 4.0 in favor of loadEOModel(URL, boolean)} in org.apache.cayenne.wocompat;
+ - removed Map loadModeIndex(URL url) {since 4.0 in favor of loadModeIndex(URL)} in org.apache.cayenne.wocompat;
+
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad4d5bd4/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
index 18fc903..795119e 100644
--- a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
+++ b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java
@@ -72,14 +72,6 @@ public class EOModelProcessor {
}
/**
- * @deprecated since 4.0 in favor of {@link #loadModeIndex(URL)}.
- */
- @Deprecated
- public Map loadModeIndex(String path) throws Exception {
- return loadModeIndex(new File(path).toURI().toURL());
- }
-
- /**
* Returns index.eomodeld contents as a Map.
*
* @since 4.0
@@ -104,22 +96,6 @@ public class EOModelProcessor {
}
/**
- * @deprecated since 4.0 in favor of {@link #loadEOModel(URL)}.
- */
- @Deprecated
- public DataMap loadEOModel(String path) throws Exception {
- return loadEOModel(path, false);
- }
-
- /**
- * @deprecated since 4.0 in favor of {@link #loadEOModel(URL, boolean)}.
- */
- @Deprecated
- public DataMap loadEOModel(String path, boolean generateClientClass) throws Exception {
- return loadEOModel(new File(path).toURI().toURL(), generateClientClass);
- }
-
- /**
* Performs EOModel loading.
*
* @param url