CAY-2377. Remove org.apache.cayenne.lifecycle.changeset and org.apache.cayenne.lifecycle.audit
CAY-2377. Remove all audit tests Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/0ece129d Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/0ece129d Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/0ece129d Branch: refs/heads/master Commit: 0ece129d908f0a0d783413d4a3780edce459e47f Parents: ad4d5bd Author: Arseni Bulatski <ancars...@gmail.com> Authored: Tue Oct 24 11:44:36 2017 +0300 Committer: Arseni Bulatski <ancars...@gmail.com> Committed: Wed Nov 15 10:27:46 2017 +0300 ---------------------------------------------------------------------- .../cayenne/lifecycle/audit/Auditable.java | 47 ---- .../lifecycle/audit/AuditableAggregator.java | 72 ------ .../cayenne/lifecycle/audit/AuditableChild.java | 62 ----- .../audit/AuditableEntityDescriptor.java | 82 ------ .../lifecycle/audit/AuditableFilter.java | 247 ------------------ .../lifecycle/audit/AuditableOperation.java | 32 --- .../lifecycle/audit/AuditableProcessor.java | 45 ---- .../cayenne/lifecycle/changeset/ChangeSet.java | 47 ---- .../lifecycle/changeset/ChangeSetFilter.java | 74 ------ .../lifecycle/changeset/GenericChangeSet.java | 137 ---------- .../lifecycle/changeset/PropertyChange.java | 54 ---- .../lifecycle/audit/AuditableFilterIT.java | 250 ------------------- .../lifecycle/audit/AuditableFilterTest.java | 184 -------------- .../lifecycle/audit/MockAuditableChild.java | 26 -- .../apache/cayenne/lifecycle/db/Auditable1.java | 29 --- .../apache/cayenne/lifecycle/db/Auditable2.java | 29 --- .../cayenne/lifecycle/db/AuditableChild1.java | 27 -- .../cayenne/lifecycle/db/AuditableChild2.java | 25 -- .../cayenne/lifecycle/db/AuditableChild3.java | 27 -- .../lifecycle/db/AuditableChildUuid.java | 30 --- .../cayenne/lifecycle/db/auto/_Auditable1.java | 43 ---- .../cayenne/lifecycle/db/auto/_Auditable2.java | 51 ---- .../lifecycle/db/auto/_AuditableChild1.java | 38 --- .../lifecycle/db/auto/_AuditableChild2.java | 38 --- .../lifecycle/db/auto/_AuditableChild3.java | 46 ---- .../lifecycle/db/auto/_AuditableChildUuid.java | 43 ---- .../lifecycle/unit/AuditableServerCase.java | 83 ------ .../src/test/resources/lifecycle-map.map.xml | 76 ------ docs/doc/src/main/resources/UPGRADE.txt | 7 +- 29 files changed, 6 insertions(+), 1945 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java deleted file mode 100644 index 5306881..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java +++ /dev/null @@ -1,47 +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.lifecycle.audit; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An annotation that adds auditing behavior to DataObjects. - * - * @since 3.1 - * @deprecated since 4.0. A preferred way to implement Audit functionality is via cayenne-commitlog module and - * {@link org.apache.cayenne.commitlog.CommitLog} annotation. - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@Deprecated -public @interface Auditable { - - /** - * Returns an array of entity properties that should be excluded from audit. - */ - String[] ignoredProperties() default {}; - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java deleted file mode 100644 index 29b4e4b..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java +++ /dev/null @@ -1,72 +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.lifecycle.audit; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.cayenne.Persistent; - -/** - * Aggregates audit events per audit root object, and passes them to delegate - * processor at the end of the transaction. - * - * @since 3.1 - */ -@Deprecated -class AuditableAggregator { - - private static final int[] OP_PRECEDENCE; - - static { - OP_PRECEDENCE = new int[AuditableOperation.values().length]; - - // decreasing precedence of operations when recording audits is DELETE, - // INSERT, UPDATE - OP_PRECEDENCE[AuditableOperation.DELETE.ordinal()] = 3; - OP_PRECEDENCE[AuditableOperation.INSERT.ordinal()] = 2; - OP_PRECEDENCE[AuditableOperation.UPDATE.ordinal()] = 1; - } - - private AuditableProcessor delegate; - - private Map<Persistent, AuditableOperation> ops; - - AuditableAggregator(AuditableProcessor delegate) { - this.delegate = delegate; - this.ops = new IdentityHashMap<>(); - } - - void audit(Persistent object, AuditableOperation operation) { - AuditableOperation oldOp = ops.put(object, operation); - if (oldOp != null) { - if (OP_PRECEDENCE[operation.ordinal()] < OP_PRECEDENCE[oldOp.ordinal()]) { - ops.put(object, oldOp); - } - } - } - - void postSync() { - for (Entry<Persistent, AuditableOperation> op : ops.entrySet()) { - delegate.audit(op.getKey(), op.getValue()); - } - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableChild.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableChild.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableChild.java deleted file mode 100644 index ad50293..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableChild.java +++ /dev/null @@ -1,62 +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.lifecycle.audit; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A built-in annotation used to tag an object that is not auditable on its own, but whose - * changes should be tracked together with changes of another ("parent") object. This - * annotation allows to group changes in a closely related subtree of objects. Either - * {@link #value()} or {@link #objectIdRelationship()} must be set to a non-empty String, - * so that a processor of AuditableChild could find the parent of the annotated object. - * - * @{@link org.apache.cayenne.commitlog.CommitLog} annotation. - * @since 3.1 - * @deprecated since 4.0. A preferred way to implement Audit functionality is via cayenne-commitlog module and - * {@link org.apache.cayenne.commitlog.CommitLog} annotation. Unfortunately cayenne-commitlog does not provide - * functionality to group changes for parent and child entities into a single event. So AuditableChild functionality - * will have to be manually reimplemented in a custom {@link org.apache.cayenne.commitlog.CommitLogListener}. - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@Deprecated -public @interface AuditableChild { - - /** - * Returns the name of a to-one relationship from an annotated object to the "parent" - * object that should be audited when annotated object is changed. - */ - String value() default ""; - - /** - * Returns the name of the property of the annotated entity of the relationship that - * stores a String "FK" of a related "parent" entity. - */ - String objectIdRelationship() default ""; - - String[] ignoredProperties() default {}; -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableEntityDescriptor.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableEntityDescriptor.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableEntityDescriptor.java deleted file mode 100644 index a6e2a7a..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableEntityDescriptor.java +++ /dev/null @@ -1,82 +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.lifecycle.audit; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.Persistent; -import org.apache.cayenne.lifecycle.changeset.ChangeSet; -import org.apache.cayenne.lifecycle.changeset.ChangeSetFilter; -import org.apache.cayenne.lifecycle.changeset.PropertyChange; -import org.apache.cayenne.map.ObjEntity; -import org.apache.cayenne.map.ObjRelationship; - -@Deprecated -class AuditableEntityDescriptor { - - private Collection<String> ignoredProperties; - - AuditableEntityDescriptor(ObjEntity auditableEntity, String[] ignoredProperties) { - - this.ignoredProperties = new HashSet<>(); - - // ignore runtime relationships - for (ObjRelationship relationship : auditableEntity.getRelationships()) { - if (relationship.isRuntime()) { - this.ignoredProperties.add(relationship.getName()); - } - } - - // ignore explicitly specified properties - if (ignoredProperties != null) { - for (String property : ignoredProperties) { - this.ignoredProperties.add(property); - } - } - } - - boolean auditableChange(Persistent object) { - if (ignoredProperties.isEmpty()) { - return true; - } - - ChangeSet changeSet = ChangeSetFilter.preCommitChangeSet(); - if (changeSet == null) { - throw new CayenneRuntimeException( - "Required ChangeSetFilter is not installed, or is in the wrong place in the filter chain."); - } - - Map<String, PropertyChange> changes = changeSet.getChanges(object); - - if (changes.size() > ignoredProperties.size()) { - return true; - } - - for (String key : changes.keySet()) { - if (!ignoredProperties.contains(key)) { - return true; - } - } - - return false; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java deleted file mode 100644 index 50887da..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java +++ /dev/null @@ -1,247 +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.lifecycle.audit; - -import org.apache.cayenne.DataChannel; -import org.apache.cayenne.DataChannelFilter; -import org.apache.cayenne.DataChannelFilterChain; -import org.apache.cayenne.DataObject; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.Persistent; -import org.apache.cayenne.QueryResponse; -import org.apache.cayenne.annotation.PostPersist; -import org.apache.cayenne.annotation.PostRemove; -import org.apache.cayenne.annotation.PostUpdate; -import org.apache.cayenne.graph.GraphDiff; -import org.apache.cayenne.lifecycle.changeset.ChangeSetFilter; -import org.apache.cayenne.map.EntityResolver; -import org.apache.cayenne.map.ObjEntity; -import org.apache.cayenne.query.Query; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * A {@link DataChannelFilter} that enables audit of entities annotated with - * {@link Auditable} and {@link AuditableChild}. Note that this filter relies on - * {@link ChangeSetFilter} presence in the DataDomain filter chain to be able to - * analyze ignored properties. - * - * @since 3.1 - * @deprecated since 4.0, use {@link org.apache.cayenne.commitlog.CommitLogFilter}. - */ -@Deprecated -public class AuditableFilter implements DataChannelFilter { - - private ThreadLocal<AuditableAggregator> threadAggregator; - private ConcurrentMap<String, AuditableEntityDescriptor> entityDescriptors; - protected AuditableProcessor processor; - protected EntityResolver entityResolver; - - /** - * @since 4.0 - */ - public AuditableFilter(AuditableProcessor processor) { - this.processor = processor; - this.entityDescriptors = new ConcurrentHashMap<>(); - this.threadAggregator = new ThreadLocal<>(); - } - - /** - * @deprecated since 3.1 use {@link #AuditableFilter(AuditableProcessor)} - * constructor - EntityResolver will be initialized in 'init'. - */ - @Deprecated - public AuditableFilter(EntityResolver entityResolver, AuditableProcessor processor) { - this(processor); - } - - public void init(DataChannel channel) { - this.entityResolver = channel.getEntityResolver(); - } - - public QueryResponse onQuery(ObjectContext originatingContext, Query query, DataChannelFilterChain filterChain) { - return filterChain.onQuery(originatingContext, query); - } - - public GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType, - DataChannelFilterChain filterChain) { - - GraphDiff response; - - try { - response = filterChain.onSync(originatingContext, changes, syncType); - if (syncType == DataChannel.FLUSH_CASCADE_SYNC || syncType == DataChannel.FLUSH_NOCASCADE_SYNC) { - postSync(); - } - } finally { - cleanupPostSync(); - } - - return response; - } - - /** - * A method called at the end of every - * {@link #onSync(ObjectContext, GraphDiff, int, DataChannelFilterChain)} - * invocation. This implementation uses it for cleaning up thread-local - * state of the filter. Subclasses may override it to do their own cleanup, - * and are expected to call super. - */ - protected void cleanupPostSync() { - threadAggregator.set(null); - } - - void postSync() { - AuditableAggregator aggregator = threadAggregator.get(); - if (aggregator != null) { - // must reset thread aggregator before processing the audit - // operations - // to avoid an endless processing loop if audit processor commits - // something - threadAggregator.set(null); - aggregator.postSync(); - } - } - - private AuditableAggregator getAggregator() { - AuditableAggregator aggregator = threadAggregator.get(); - if (aggregator == null) { - aggregator = new AuditableAggregator(processor); - threadAggregator.set(aggregator); - } - - return aggregator; - } - - @PostPersist(entityAnnotations = Auditable.class) - void insertAudit(Persistent object) { - getAggregator().audit(object, AuditableOperation.INSERT); - } - - @PostRemove(entityAnnotations = Auditable.class) - void deleteAudit(Persistent object) { - getAggregator().audit(object, AuditableOperation.DELETE); - } - - @PostUpdate(entityAnnotations = Auditable.class) - void updateAudit(Persistent object) { - if (isAuditableUpdate(object, false)) { - getAggregator().audit(object, AuditableOperation.UPDATE); - } - } - - // only catching child updates... child insert/delete presumably causes an - // event on - // the owner object - - @PostUpdate(entityAnnotations = AuditableChild.class) - void updateAuditChild(Persistent object) { - - if (isAuditableUpdate(object, true)) { - - Persistent parent = getParent(object); - - if (parent != null) { - // not calling 'updateAudit' to skip checking - // 'isAuditableUpdate' on - // parent - getAggregator().audit(parent, AuditableOperation.UPDATE); - } else { - // TODO: maybe log this fact... shouldn't normally happen, but I - // can - // imagine certain combinations of object graphs, disconnected - // relationships, delete rules, etc. may cause this - } - } - } - - protected Persistent getParent(Persistent object) { - - if (object == null) { - throw new NullPointerException("Null object"); - } - - if (!(object instanceof DataObject)) { - throw new IllegalArgumentException("Object is not a DataObject: " + object.getClass().getName()); - } - - DataObject dataObject = (DataObject) object; - - AuditableChild annotation = dataObject.getClass().getAnnotation(AuditableChild.class); - if (annotation == null) { - throw new IllegalArgumentException("No 'AuditableChild' annotation found"); - } - - String propertyPath = annotation.value(); - - if (propertyPath.equals("")) { - propertyPath = objectIdRelationshipName(annotation.objectIdRelationship()); - } - - if (propertyPath == null || propertyPath.equals("")) { - throw new IllegalStateException("Either 'value' or 'objectIdRelationship' of @AuditableChild must be set"); - } - - return (Persistent) dataObject.readNestedProperty(propertyPath); - } - - // TODO: It's a temporary clone method of {@link - // org.apache.cayenne.lifecycle.relationship.ObjectIdRelationshipHandler#objectIdRelationshipName(String)}. - // Needs to be encapsulated to some separate class to avoid a code - // duplication - private String objectIdRelationshipName(String uuidPropertyName) { - return "cay:related:" + uuidPropertyName; - } - - protected boolean isAuditableUpdate(Persistent object, boolean child) { - AuditableEntityDescriptor descriptor = getEntityDescriptor(object, child); - return descriptor.auditableChange(object); - } - - private AuditableEntityDescriptor getEntityDescriptor(Persistent object, boolean child) { - - ObjEntity entity = entityResolver.getObjEntity(object); - - AuditableEntityDescriptor descriptor = entityDescriptors.get(entity.getName()); - if (descriptor == null) { - - String[] ignoredProperties; - - if (child) { - AuditableChild annotation = object.getClass().getAnnotation(AuditableChild.class); - ignoredProperties = annotation != null ? annotation.ignoredProperties() : null; - } else { - Auditable annotation = object.getClass().getAnnotation(Auditable.class); - ignoredProperties = annotation != null ? annotation.ignoredProperties() : null; - } - - descriptor = new AuditableEntityDescriptor(entity, ignoredProperties); - - AuditableEntityDescriptor existingDescriptor = entityDescriptors.putIfAbsent(entity.getName(), descriptor); - - if (existingDescriptor != null) { - descriptor = existingDescriptor; - } - } - - return descriptor; - - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableOperation.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableOperation.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableOperation.java deleted file mode 100644 index bc52ebf..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableOperation.java +++ /dev/null @@ -1,32 +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.lifecycle.audit; - -/** - * An enum of possible operations that can be audited. - * - * @since 3.1 - * @deprecated since 4.0, use {@link org.apache.cayenne.lifecycle.postcommit.PostCommitFilter} - * @see org.apache.cayenne.lifecycle.changemap.ObjectChangeType - */ -@Deprecated -public enum AuditableOperation { - - INSERT, UPDATE, DELETE; -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableProcessor.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableProcessor.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableProcessor.java deleted file mode 100644 index fc085f7..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableProcessor.java +++ /dev/null @@ -1,45 +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.lifecycle.audit; - -import org.apache.cayenne.Persistent; - -/** - * A superclass of application specific handlers of the {@link Auditable} - * annotation, that provides basic needed callbacks. - * - * @since 3.1 - * @deprecated since 4.0, use {@link org.apache.cayenne.lifecycle.postcommit.PostCommitFilter} - */ -public interface AuditableProcessor { - - /** - * A method called by {@link AuditableFilter} that should audit records as - * appropriate in a given application. Implementors may insert audit records - * in DB, log a message, etc. - * - * @param object - * the root auditable object. This is an object that is either - * annotated with {@link Auditable} or pointed to by another - * object annotated with {@link AuditableChild}. - * @param operation - * a type of object change. - */ - void audit(Persistent object, AuditableOperation operation); -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSet.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSet.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSet.java deleted file mode 100644 index 2fbaeb7..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSet.java +++ /dev/null @@ -1,47 +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.lifecycle.changeset; - -import java.util.Map; - -import org.apache.cayenne.Persistent; -import org.apache.cayenne.graph.GraphDiff; - -/** - * Represents a set of changes to persistent objects corresponding to a certain lifecycle - * stage. The changes are presented in a more usable form compared to the internal Cayenne - * representation as {@link GraphDiff}. One or more changes to the same property of the - * same object are all combined in a single {@link PropertyChange} instance. - * - * @since 3.1 - * @deprecated since 4.0 in favour of {@link org.apache.cayenne.lifecycle.postcommit.PostCommitFilter} - * - * @see org.apache.cayenne.lifecycle.changemap.ChangeMap - */ -@Deprecated -public interface ChangeSet { - - public static final String OBJECT_ID_PROPERTY_NAME = "cayenne:objectId"; - - /** - * Returns a map of changes for a given object in its context, keyed by property name. - * If the object is unchanged, an empty map is returned. - */ - Map<String, PropertyChange> getChanges(Persistent object); -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSetFilter.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSetFilter.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSetFilter.java deleted file mode 100644 index 141e838..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/ChangeSetFilter.java +++ /dev/null @@ -1,74 +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.lifecycle.changeset; - -import org.apache.cayenne.DataChannel; -import org.apache.cayenne.DataChannelFilter; -import org.apache.cayenne.DataChannelFilterChain; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.QueryResponse; -import org.apache.cayenne.graph.GraphDiff; -import org.apache.cayenne.query.Query; - -/** - * A {@link DataChannelFilter} that provides interested parties with a thread-local access - * to the current commit changeset. It will only return a non-null change set when commit - * within the scope of the filter - * {@link #onSync(ObjectContext, GraphDiff, int, DataChannelFilterChain)} method. The - * filter is intended to be used by pre-commit and post-commit listeners. - * - * @since 3.1 - * @deprecated since 4.0 in favour of {@link org.apache.cayenne.lifecycle.postcommit.PostCommitFilter} - */ -@Deprecated -public class ChangeSetFilter implements DataChannelFilter { - - private static final ThreadLocal<ChangeSet> PRE_COMMIT_CHANGE_SET = new ThreadLocal<ChangeSet>(); - - public static ChangeSet preCommitChangeSet() { - return PRE_COMMIT_CHANGE_SET.get(); - } - - public void init(DataChannel channel) { - // noop.. - } - - public QueryResponse onQuery( - ObjectContext originatingContext, - Query query, - DataChannelFilterChain filterChain) { - return filterChain.onQuery(originatingContext, query); - } - - public GraphDiff onSync( - ObjectContext originatingContext, - GraphDiff changes, - int syncType, - DataChannelFilterChain filterChain) { - - try { - PRE_COMMIT_CHANGE_SET.set(new GenericChangeSet(changes)); - return filterChain.onSync(originatingContext, changes, syncType); - } - finally { - PRE_COMMIT_CHANGE_SET.set(null); - } - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/GenericChangeSet.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/GenericChangeSet.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/GenericChangeSet.java deleted file mode 100644 index c855411..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/GenericChangeSet.java +++ /dev/null @@ -1,137 +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.lifecycle.changeset; - -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.Persistent; -import org.apache.cayenne.graph.GraphChangeHandler; -import org.apache.cayenne.graph.GraphDiff; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * A {@link ChangeSet} implemented as a wrapper on top of {@link GraphDiff} of unspecified - * nature. - * <p> - * Synchronization note: While this class is thread safe, but is not generally intended - * for use in multi-threaded manner. It is common to use it within a single transaction - * thread. - * - * @since 3.1 - * @deprecated since 4.0 - * @see org.apache.cayenne.lifecycle.changemap.ChangeMap - */ -@Deprecated -public class GenericChangeSet implements ChangeSet { - - private GraphDiff diff; - private Map<ObjectId, Map<String, PropertyChange>> changes; - - public GenericChangeSet(GraphDiff diff) { - this.diff = diff; - } - - public Map<String, PropertyChange> getChanges(Persistent object) { - Map<String, PropertyChange> changes = getChanges().get(object.getObjectId()); - return changes != null ? changes : Collections.<String, PropertyChange>emptyMap(); - } - - private Map<ObjectId, Map<String, PropertyChange>> getChanges() { - if (changes == null) { - changes = parseDiff(); - } - - return changes; - } - - private Map<ObjectId, Map<String, PropertyChange>> parseDiff() { - - final Map<ObjectId, Map<String, PropertyChange>> changes = new HashMap<>(); - - diff.apply(new GraphChangeHandler() { - - private Map<String, PropertyChange> getChangeMap(Object id) { - Map<String, PropertyChange> map = changes.get(id); - - if (map == null) { - map = new HashMap<>(); - changes.put((ObjectId) id, map); - } - - return map; - } - - PropertyChange getChange(Object id, String property, Object oldValue) { - Map<String, PropertyChange> map = getChangeMap(id); - - PropertyChange change = map.get(property); - if (change == null) { - change = new PropertyChange(property, oldValue); - map.put(property, change); - } - - return change; - } - - public void nodeRemoved(Object nodeId) { - // noop, don't care, we'll still track the changes for deleted objects. - } - - public void nodeCreated(Object nodeId) { - // noop (??) - } - - public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { - // record the fact of relationship change... TODO: analyze relationship - // semantics and record changset values - getChange((ObjectId)nodeId, (String) arcId, null); - } - - public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { - // record the fact of relationship change... TODO: analyze relationship - // semantics and record changset values - getChange((ObjectId)nodeId, (String) arcId, null); - } - - public void nodePropertyChanged( - Object nodeId, - String property, - Object oldValue, - Object newValue) { - getChange(nodeId, property, oldValue).setNewValue(newValue); - } - - public void nodeIdChanged(Object nodeId, Object newId) { - - // store the same change set under old and new ids to allow lookup before - // and after the commit - Map<String, PropertyChange> map = getChangeMap(nodeId); - changes.put((ObjectId) newId, map); - - // record a change for a special ID "property" - getChange(nodeId, OBJECT_ID_PROPERTY_NAME, nodeId).setNewValue(newId); - } - - }); - - return changes; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/PropertyChange.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/PropertyChange.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/PropertyChange.java deleted file mode 100644 index 4c2d957..0000000 --- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/changeset/PropertyChange.java +++ /dev/null @@ -1,54 +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.lifecycle.changeset; - -/** - * A change to a single object property. - * - * @since 3.1 - * @deprecated since 4.0 - */ -@Deprecated -public class PropertyChange { - - private String propertyName; - private Object oldValue; - private Object newValue; - - PropertyChange(String propertyName, Object oldValue) { - this.propertyName = propertyName; - this.oldValue = oldValue; - } - - public Object getOldValue() { - return oldValue; - } - - public Object getNewValue() { - return newValue; - } - - public String getPropertyName() { - return propertyName; - } - - void setNewValue(Object newValue) { - this.newValue = newValue; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterIT.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterIT.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterIT.java deleted file mode 100644 index 730f51b..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterIT.java +++ /dev/null @@ -1,250 +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.lifecycle.audit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; - -import org.apache.cayenne.Cayenne; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.Persistent; -import org.apache.cayenne.access.DataDomain; -import org.apache.cayenne.lifecycle.changeset.ChangeSetFilter; -import org.apache.cayenne.lifecycle.db.Auditable1; -import org.apache.cayenne.lifecycle.db.Auditable2; -import org.apache.cayenne.lifecycle.db.AuditableChild1; -import org.apache.cayenne.lifecycle.db.AuditableChild2; -import org.apache.cayenne.lifecycle.db.AuditableChild3; -import org.apache.cayenne.lifecycle.db.AuditableChildUuid; -import org.apache.cayenne.lifecycle.id.IdCoder; -import org.apache.cayenne.lifecycle.relationship.ObjectIdRelationshipHandler; -import org.apache.cayenne.lifecycle.unit.AuditableServerCase; -import org.junit.Test; - -@Deprecated -public class AuditableFilterIT extends AuditableServerCase { - - @Test - public void testAudit_IgnoreRuntimeRelationships() throws Exception { - - auditable1.insert(1, "xx"); - auditable1.insert(2, "yy"); - auditable1.insert(3, "aa"); - auditableChild2.insert(1, 1, "zz"); - - DataDomain domain = runtime.getDataDomain(); - - Processor processor = new Processor(); - - AuditableFilter filter = new AuditableFilter(processor); - domain.addFilter(filter); - - // prerequisite for BaseAuditableProcessor use - ChangeSetFilter changeSetFilter = new ChangeSetFilter(); - domain.addFilter(changeSetFilter); - - ObjectContext context = runtime.newContext(); - - Auditable1 a2 = Cayenne.objectForPK(context, Auditable1.class, 2); - AuditableChild2 a21 = Cayenne.objectForPK(context, AuditableChild2.class, 1); - - a21.setParent(a2); - a21.setCharProperty1("XYZA"); - context.commitChanges(); - - assertEquals(0, processor.size); - - processor.reset(); - - Auditable1 a3 = Cayenne.objectForPK(context, Auditable1.class, 3); - a21.setParent(a3); - a3.setCharProperty1("12"); - - context.commitChanges(); - assertEquals(1, processor.size); - assertTrue(processor.audited.get(AuditableOperation.UPDATE).contains(a3)); - } - - @Test - public void testAudit_IncludeToManyRelationships() throws Exception { - - auditable1.insert(1, "xx"); - auditable1.insert(2, "yy"); - auditableChild1.insert(1, 1, "zz"); - - DataDomain domain = runtime.getDataDomain(); - - Processor processor = new Processor(); - - AuditableFilter filter = new AuditableFilter(processor); - domain.addFilter(filter); - - // prerequisite for BaseAuditableProcessor use - ChangeSetFilter changeSetFilter = new ChangeSetFilter(); - domain.addFilter(changeSetFilter); - - ObjectContext context = runtime.newContext(); - - Auditable1 a2 = Cayenne.objectForPK(context, Auditable1.class, 2); - AuditableChild1 a21 = Cayenne.objectForPK(context, AuditableChild1.class, 1); - - a21.setParent(a2); - context.commitChanges(); - - assertEquals(2, processor.size); - - assertTrue(processor.audited.get(AuditableOperation.UPDATE).contains(a2)); - assertTrue(processor.audited.get(AuditableOperation.UPDATE) - .contains(Cayenne.objectForPK(context, Auditable1.class, 1))); - } - - @Test - public void testAudit_IgnoreProperties() throws Exception { - - auditable2.insert(1, "P1_1", "P2_1"); - auditable2.insert(2, "P1_2", "P2_2"); - auditable2.insert(3, "P1_3", "P2_3"); - - DataDomain domain = runtime.getDataDomain(); - - Processor processor = new Processor(); - - AuditableFilter filter = new AuditableFilter(processor); - domain.addFilter(filter); - - // prerequisite for BaseAuditableProcessor use - ChangeSetFilter changeSetFilter = new ChangeSetFilter(); - domain.addFilter(changeSetFilter); - - ObjectContext context = runtime.newContext(); - - Auditable2 a1 = Cayenne.objectForPK(context, Auditable2.class, 1); - Auditable2 a2 = Cayenne.objectForPK(context, Auditable2.class, 2); - Auditable2 a3 = Cayenne.objectForPK(context, Auditable2.class, 3); - - a1.setCharProperty1("__"); - a2.setCharProperty2("__"); - a3.setCharProperty1("__"); - a3.setCharProperty2("__"); - - context.commitChanges(); - - assertEquals(2, processor.size); - assertTrue(processor.audited.get(AuditableOperation.UPDATE).contains(a2)); - assertTrue(processor.audited.get(AuditableOperation.UPDATE).contains(a3)); - } - - @Test - public void testAuditableChild_IgnoreProperties() throws Exception { - - auditable2.insert(1, "P1_1", "P2_1"); - auditable2.insert(2, "P1_2", "P2_2"); - auditableChild3.insert(1, 1, "C", "D"); - - DataDomain domain = runtime.getDataDomain(); - - Processor processor = new Processor(); - - AuditableFilter filter = new AuditableFilter(processor); - domain.addFilter(filter); - - // prerequisite for BaseAuditableProcessor use - ChangeSetFilter changeSetFilter = new ChangeSetFilter(); - domain.addFilter(changeSetFilter); - - ObjectContext context = runtime.newContext(); - - AuditableChild3 ac1 = Cayenne.objectForPK(context, AuditableChild3.class, 1); - - // a change to ignored property should not cause an audit event - ac1.setCharProperty1("X_X"); - - context.commitChanges(); - assertEquals(0, processor.size); - - processor.reset(); - ac1.setCharProperty2("XXXXX"); - context.commitChanges(); - assertEquals(1, processor.size); - } - - @Test - public void testAuditableChild_objectIdRelationship() throws Exception { - auditable1.insert(1, "xx"); - auditableChildUuid.insert(1, "Auditable1:1", "xxx", "yyy"); - - DataDomain domain = runtime.getDataDomain(); - Processor processor = new Processor(); - - AuditableFilter filter = new AuditableFilter(processor); - domain.addFilter(filter); - - // prerequisite for BaseAuditableProcessor use - ChangeSetFilter changeSetFilter = new ChangeSetFilter(); - domain.addFilter(changeSetFilter); - - ObjectContext context = runtime.newContext(); - AuditableChildUuid ac = Cayenne.objectForPK(context, AuditableChildUuid.class, 1); - Auditable1 a1 = Cayenne.objectForPK(context, Auditable1.class, 1); - IdCoder refHandler = new IdCoder(domain.getEntityResolver()); - ObjectIdRelationshipHandler handler = new ObjectIdRelationshipHandler(refHandler); - handler.relate(ac, a1); - - ac.setCharProperty1("xxxx"); - context.commitChanges(); - assertEquals(1, processor.size); - Collection<Object> auditables = processor.audited.get(AuditableOperation.UPDATE); - assertSame(a1, auditables.toArray()[0]); - - ac.setCharProperty2("yyyy"); - context.commitChanges(); - assertEquals(2, processor.size); - assertSame(a1, auditables.toArray()[1]); - } - - private final class Processor implements AuditableProcessor { - - Map<AuditableOperation, Collection<Object>> audited; - int size; - - Processor() { - reset(); - } - - void reset() { - - audited = new EnumMap<>(AuditableOperation.class); - - for (AuditableOperation op : AuditableOperation.values()) { - audited.put(op, new ArrayList<>()); - } - } - - public void audit(Persistent object, AuditableOperation operation) { - audited.get(operation).add(object); - size++; - } - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java deleted file mode 100644 index 9f8eb08..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java +++ /dev/null @@ -1,184 +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.lifecycle.audit; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.DataChannel; -import org.apache.cayenne.DataChannelFilterChain; -import org.apache.cayenne.DataObject; -import org.apache.cayenne.ObjectContext; -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.Persistent; -import org.apache.cayenne.configuration.server.ServerRuntime; -import org.apache.cayenne.graph.GraphDiff; -import org.apache.cayenne.lifecycle.db.Auditable1; -import org.apache.cayenne.lifecycle.db.AuditableChildUuid; -import org.apache.cayenne.lifecycle.id.IdCoder; -import org.apache.cayenne.lifecycle.relationship.ObjectIdRelationshipHandler; -import org.apache.cayenne.map.EntityResolver; -import org.apache.cayenne.map.ObjEntity; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@Deprecated -public class AuditableFilterTest { - - private AuditableProcessor processor; - private ServerRuntime runtime; - private AuditableFilter filter; - - @Before - public void setUp() throws Exception { - - EntityResolver resolver = mock(EntityResolver.class); - - ObjEntity objectEntity = new ObjEntity("CayenneDataObject"); - when(resolver.lookupObjEntity(any(Object.class))).thenReturn(objectEntity); - when(resolver.getObjEntity(any(Persistent.class))).thenReturn(objectEntity); - when(resolver.getObjEntity(any(Class.class))).thenReturn(objectEntity); - - DataChannel channel = mock(DataChannel.class); - when(channel.getEntityResolver()).thenReturn(resolver); - - this.processor = mock(AuditableProcessor.class); - this.runtime = ServerRuntime.builder().addConfig("cayenne-lifecycle.xml").build(); - this.filter = new AuditableFilter(processor); - this.filter.init(channel); - } - - @After - public void tearDown() throws Exception { - runtime.shutdown(); - } - - @Test - public void testInsertAudit() { - - Persistent audited = mock(Persistent.class); - filter.insertAudit(audited); - filter.postSync(); - - verify(processor).audit(audited, AuditableOperation.INSERT); - } - - @Test - public void testDeleteAudit() { - - Persistent audited = mock(Persistent.class); - filter.deleteAudit(audited); - filter.postSync(); - - verify(processor).audit(audited, AuditableOperation.DELETE); - } - - @Test - public void testUpdateAudit() { - - Persistent audited = mock(Persistent.class); - filter.updateAudit(audited); - filter.postSync(); - - verify(processor).audit(audited, AuditableOperation.UPDATE); - } - - @Test - public void testUpdateAuditChild() { - - Persistent auditedParent = mock(Persistent.class); - DataObject audited = new MockAuditableChild(); - audited.setObjectId(new ObjectId("MockAuditableChild", "a", 1)); - audited.writeProperty("parent", auditedParent); - filter.updateAuditChild(audited); - filter.postSync(); - - verify(processor).audit(auditedParent, AuditableOperation.UPDATE); - } - - @Test - public void testUpdateAuditChildByObjectIdRelationship() { - - ObjectContext context = runtime.newContext(); - Auditable1 auditedParent = context.newObject(Auditable1.class); - AuditableChildUuid audited = context.newObject(AuditableChildUuid.class); - - IdCoder refHandler = new IdCoder(context.getEntityResolver()); - ObjectIdRelationshipHandler handler = new ObjectIdRelationshipHandler(refHandler); - handler.relate(audited, auditedParent); - context.commitChanges(); - - filter.updateAuditChild(audited); - filter.postSync(); - verify(processor).audit(auditedParent, AuditableOperation.UPDATE); - } - - @Test - public void testOnSyncPassThrough() { - - ObjectContext context = mock(ObjectContext.class); - GraphDiff changes = mock(GraphDiff.class); - - DataChannelFilterChain chain = mock(DataChannelFilterChain.class); - - filter.onSync(context, changes, DataChannel.FLUSH_CASCADE_SYNC, chain); - verify(chain).onSync(context, changes, DataChannel.FLUSH_CASCADE_SYNC); - - filter.onSync(context, changes, DataChannel.ROLLBACK_CASCADE_SYNC, chain); - verify(chain).onSync(context, changes, DataChannel.ROLLBACK_CASCADE_SYNC); - } - - @Test - public void testOnSyncAuditEventsCollapse() { - - ObjectContext context = mock(ObjectContext.class); - GraphDiff changes = mock(GraphDiff.class); - - final DataObject auditedParent1 = new CayenneDataObject(); - final DataObject audited11 = new MockAuditableChild(); - audited11.writeProperty("parent", auditedParent1); - final DataObject audited12 = new MockAuditableChild(); - audited12.writeProperty("parent", auditedParent1); - final DataObject audited13 = new MockAuditableChild(); - audited13.writeProperty("parent", auditedParent1); - - DataChannelFilterChain chain = mock(DataChannelFilterChain.class); - when(chain.onSync(context, changes, DataChannel.FLUSH_CASCADE_SYNC)).thenAnswer(new Answer<GraphDiff>() { - - public GraphDiff answer(InvocationOnMock invocation) throws Throwable { - filter.updateAudit(auditedParent1); - filter.updateAuditChild(audited11); - filter.updateAuditChild(audited12); - filter.updateAuditChild(audited13); - return mock(GraphDiff.class); - } - }); - - filter.onSync(context, changes, DataChannel.FLUSH_CASCADE_SYNC, chain); - - verify(chain).onSync(context, changes, DataChannel.FLUSH_CASCADE_SYNC); - verify(processor).audit(auditedParent1, AuditableOperation.UPDATE); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/MockAuditableChild.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/MockAuditableChild.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/MockAuditableChild.java deleted file mode 100644 index a33ecb3..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/MockAuditableChild.java +++ /dev/null @@ -1,26 +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.lifecycle.audit; - -import org.apache.cayenne.CayenneDataObject; - -@AuditableChild("parent") -public class MockAuditableChild extends CayenneDataObject { - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable1.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable1.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable1.java deleted file mode 100644 index 4cb7ff1..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable1.java +++ /dev/null @@ -1,29 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.audit.Auditable; -import org.apache.cayenne.lifecycle.db.auto._Auditable1; - -@Auditable -public class Auditable1 extends _Auditable1 { - - private static final long serialVersionUID = 8458581370578140962L; - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable2.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable2.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable2.java deleted file mode 100644 index 6f81ffa..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/Auditable2.java +++ /dev/null @@ -1,29 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.audit.Auditable; -import org.apache.cayenne.lifecycle.db.auto._Auditable2; - -@Auditable(ignoredProperties = "charProperty1") -public class Auditable2 extends _Auditable2 { - - private static final long serialVersionUID = 5203324250911707978L; - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild1.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild1.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild1.java deleted file mode 100644 index 9039a08..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild1.java +++ /dev/null @@ -1,27 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.db.auto._AuditableChild1; - -public class AuditableChild1 extends _AuditableChild1 { - - private static final long serialVersionUID = 7967782239405764614L; - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild2.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild2.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild2.java deleted file mode 100644 index 547f8fc..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild2.java +++ /dev/null @@ -1,25 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.db.auto._AuditableChild2; - -public class AuditableChild2 extends _AuditableChild2 { - private static final long serialVersionUID = 1L; -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild3.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild3.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild3.java deleted file mode 100644 index 556eaaa..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChild3.java +++ /dev/null @@ -1,27 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.audit.AuditableChild; -import org.apache.cayenne.lifecycle.db.auto._AuditableChild3; - -@AuditableChild(value = "parent", ignoredProperties = "charProperty1") -public class AuditableChild3 extends _AuditableChild3 { - private static final long serialVersionUID = 1L; -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChildUuid.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChildUuid.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChildUuid.java deleted file mode 100644 index 38becd8..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/AuditableChildUuid.java +++ /dev/null @@ -1,30 +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.lifecycle.db; - -import org.apache.cayenne.lifecycle.audit.AuditableChild; -import org.apache.cayenne.lifecycle.db.auto._AuditableChildUuid; -import org.apache.cayenne.lifecycle.relationship.ObjectIdRelationship; - -@ObjectIdRelationship("uuid") -@AuditableChild(objectIdRelationship = "uuid") -public class AuditableChildUuid extends _AuditableChildUuid { - - private static final long serialVersionUID = 1L; -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable1.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable1.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable1.java deleted file mode 100644 index df212a1..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable1.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import java.util.List; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; -import org.apache.cayenne.lifecycle.db.AuditableChild1; - -/** - * Class _Auditable1 was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _Auditable1 extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<List<AuditableChild1>> CHILDREN1 = Property.create("children1", List.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void addToChildren1(AuditableChild1 obj) { - addToManyTarget("children1", obj, true); - } - public void removeFromChildren1(AuditableChild1 obj) { - removeToManyTarget("children1", obj, true); - } - @SuppressWarnings("unchecked") - public List<AuditableChild1> getChildren1() { - return (List<AuditableChild1>)readProperty("children1"); - } - - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable2.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable2.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable2.java deleted file mode 100644 index ea7a51b..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_Auditable2.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import java.util.List; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; -import org.apache.cayenne.lifecycle.db.AuditableChild3; - -/** - * Class _Auditable2 was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _Auditable2 extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<String> CHAR_PROPERTY2 = Property.create("charProperty2", String.class); - public static final Property<List<AuditableChild3>> CHILDREN = Property.create("children", List.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void setCharProperty2(String charProperty2) { - writeProperty("charProperty2", charProperty2); - } - public String getCharProperty2() { - return (String)readProperty("charProperty2"); - } - - public void addToChildren(AuditableChild3 obj) { - addToManyTarget("children", obj, true); - } - public void removeFromChildren(AuditableChild3 obj) { - removeToManyTarget("children", obj, true); - } - @SuppressWarnings("unchecked") - public List<AuditableChild3> getChildren() { - return (List<AuditableChild3>)readProperty("children"); - } - - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild1.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild1.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild1.java deleted file mode 100644 index 96f21b0..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild1.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; -import org.apache.cayenne.lifecycle.db.Auditable1; - -/** - * Class _AuditableChild1 was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _AuditableChild1 extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<Auditable1> PARENT = Property.create("parent", Auditable1.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void setParent(Auditable1 parent) { - setToOneTarget("parent", parent, true); - } - - public Auditable1 getParent() { - return (Auditable1)readProperty("parent"); - } - - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild2.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild2.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild2.java deleted file mode 100644 index 9a5cc2c..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild2.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; -import org.apache.cayenne.lifecycle.db.Auditable1; - -/** - * Class _AuditableChild2 was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _AuditableChild2 extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<Auditable1> PARENT = Property.create("parent", Auditable1.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void setParent(Auditable1 parent) { - setToOneTarget("parent", parent, true); - } - - public Auditable1 getParent() { - return (Auditable1)readProperty("parent"); - } - - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild3.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild3.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild3.java deleted file mode 100644 index fb2f26a..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChild3.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; -import org.apache.cayenne.lifecycle.db.Auditable2; - -/** - * Class _AuditableChild3 was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _AuditableChild3 extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<String> CHAR_PROPERTY2 = Property.create("charProperty2", String.class); - public static final Property<Auditable2> PARENT = Property.create("parent", Auditable2.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void setCharProperty2(String charProperty2) { - writeProperty("charProperty2", charProperty2); - } - public String getCharProperty2() { - return (String)readProperty("charProperty2"); - } - - public void setParent(Auditable2 parent) { - setToOneTarget("parent", parent, true); - } - - public Auditable2 getParent() { - return (Auditable2)readProperty("parent"); - } - - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChildUuid.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChildUuid.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChildUuid.java deleted file mode 100644 index d269c8a..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/db/auto/_AuditableChildUuid.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.cayenne.lifecycle.db.auto; - -import org.apache.cayenne.CayenneDataObject; -import org.apache.cayenne.exp.Property; - -/** - * Class _AuditableChildUuid was generated by Cayenne. - * It is probably a good idea to avoid changing this class manually, - * since it may be overwritten next time code is regenerated. - * If you need to make any customizations, please use subclass. - */ -public abstract class _AuditableChildUuid extends CayenneDataObject { - - private static final long serialVersionUID = 1L; - - public static final String ID_PK_COLUMN = "ID"; - - public static final Property<String> CHAR_PROPERTY1 = Property.create("charProperty1", String.class); - public static final Property<String> CHAR_PROPERTY2 = Property.create("charProperty2", String.class); - public static final Property<String> UUID = Property.create("uuid", String.class); - - public void setCharProperty1(String charProperty1) { - writeProperty("charProperty1", charProperty1); - } - public String getCharProperty1() { - return (String)readProperty("charProperty1"); - } - - public void setCharProperty2(String charProperty2) { - writeProperty("charProperty2", charProperty2); - } - public String getCharProperty2() { - return (String)readProperty("charProperty2"); - } - - public void setUuid(String uuid) { - writeProperty("uuid", uuid); - } - public String getUuid() { - return (String)readProperty("uuid"); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ece129d/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/AuditableServerCase.java ---------------------------------------------------------------------- diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/AuditableServerCase.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/AuditableServerCase.java deleted file mode 100644 index b63f1f0..0000000 --- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/AuditableServerCase.java +++ /dev/null @@ -1,83 +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.lifecycle.unit; - -import org.apache.cayenne.configuration.server.ServerRuntime; -import org.apache.cayenne.configuration.server.ServerRuntimeBuilder; -import org.apache.cayenne.test.jdbc.DBHelper; -import org.apache.cayenne.test.jdbc.TableHelper; -import org.junit.After; -import org.junit.Before; - -/** - * A superclass of integration tests for cayenne-lifecycle. - */ -public abstract class AuditableServerCase { - - protected ServerRuntime runtime; - - protected TableHelper auditable1; - protected TableHelper auditableChild1; - protected TableHelper auditableChild2; - - protected TableHelper auditable2; - protected TableHelper auditableChild3; - protected TableHelper auditableChildUuid; - - @Before - public void startCayenne() throws Exception { - this.runtime = configureCayenne().build(); - - DBHelper dbHelper = new DBHelper(runtime.getDataSource()); - - this.auditable1 = new TableHelper(dbHelper, "AUDITABLE1").setColumns("ID", "CHAR_PROPERTY1"); - - this.auditableChild1 = new TableHelper(dbHelper, "AUDITABLE_CHILD1").setColumns("ID", "AUDITABLE1_ID", - "CHAR_PROPERTY1"); - - this.auditableChild2 = new TableHelper(dbHelper, "AUDITABLE_CHILD2").setColumns("ID", "AUDITABLE1_ID", - "CHAR_PROPERTY1"); - - this.auditable2 = new TableHelper(dbHelper, "AUDITABLE2").setColumns("ID", "CHAR_PROPERTY1", "CHAR_PROPERTY2"); - - this.auditableChild3 = new TableHelper(dbHelper, "AUDITABLE_CHILD3").setColumns("ID", "AUDITABLE2_ID", - "CHAR_PROPERTY1", "CHAR_PROPERTY2"); - - this.auditableChildUuid = new TableHelper(dbHelper, "AUDITABLE_CHILD_UUID").setColumns("ID", "UUID", - "CHAR_PROPERTY1", "CHAR_PROPERTY2"); - - this.auditableChild1.deleteAll(); - this.auditableChild2.deleteAll(); - this.auditable1.deleteAll(); - this.auditableChild3.deleteAll(); - this.auditable2.deleteAll(); - this.auditableChildUuid.deleteAll(); - } - - protected ServerRuntimeBuilder configureCayenne() { - return ServerRuntime.builder().addConfig("cayenne-lifecycle.xml"); - } - - @After - public void shutdownCayenne() { - if (runtime != null) { - runtime.shutdown(); - } - } -}