Skip to content

Commit

Permalink
Segments should not have a generics type #207
Browse files Browse the repository at this point in the history
... moving the generics boundary from DataObject to Persistent
for tasks. TODO: there's very little reason for the tasks to have a generics type
  • Loading branch information
andrus committed Oct 22, 2022
1 parent 2016b52 commit 7c40f05
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.nhl.link.move.runtime.task;

import com.nhl.link.move.CreateBuilder;
import org.apache.cayenne.DataObject;

import com.nhl.link.move.CreateOrUpdateBuilder;
import com.nhl.link.move.DeleteBuilder;
import com.nhl.link.move.SourceKeysBuilder;
import org.apache.cayenne.Persistent;

public interface ITaskService {

Expand All @@ -16,26 +15,26 @@ public interface ITaskService {
*
* @since 2.6
*/
<T extends DataObject> CreateBuilder<T> create(Class<T> type);
<T extends Persistent> CreateBuilder<T> create(Class<T> type);

/**
* Returns a builder of "create-or-update" ETL synchronization task.
*
* @since 1.3
*/
<T extends DataObject> CreateOrUpdateBuilder<T> createOrUpdate(Class<T> type);
<T extends Persistent> CreateOrUpdateBuilder<T> createOrUpdate(Class<T> type);

/**
* Returns a builder of target delete ETL synchronization task.
*
* @since 1.3
*/
<T extends DataObject> DeleteBuilder<T> delete(Class<T> type);
<T extends Persistent> DeleteBuilder<T> delete(Class<T> type);

/**
* @since 1.3
*/
<T extends DataObject> SourceKeysBuilder extractSourceKeys(Class<T> type);
<T extends Persistent> SourceKeysBuilder extractSourceKeys(Class<T> type);

/**
* @since 1.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.nhl.link.move.valueconverter.ValueConverterFactory;
import com.nhl.link.move.writer.ITargetPropertyWriterService;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.map.ObjEntity;

Expand Down Expand Up @@ -61,7 +62,7 @@ public TaskService(
}

@Override
public <T extends DataObject> CreateBuilder<T> create(Class<T> type) {
public <T extends Persistent> CreateBuilder<T> create(Class<T> type) {

ObjEntity entity = lookupEntity(type);
TargetEntity targetEntity = targetEntityMap.get(entity);
Expand All @@ -81,7 +82,7 @@ public <T extends DataObject> CreateBuilder<T> create(Class<T> type) {
}

@Override
public <T extends DataObject> CreateOrUpdateBuilder<T> createOrUpdate(Class<T> type) {
public <T extends Persistent> CreateOrUpdateBuilder<T> createOrUpdate(Class<T> type) {

ObjEntity entity = lookupEntity(type);
TargetEntity targetEntity = targetEntityMap.get(entity);
Expand Down Expand Up @@ -111,7 +112,7 @@ protected ObjEntity lookupEntity(Class<?> type) {
}

@Override
public <T extends DataObject> SourceKeysBuilder extractSourceKeys(Class<T> type) {
public <T extends Persistent> SourceKeysBuilder extractSourceKeys(Class<T> type) {
ObjEntity targetEntity = targetCayenneService.entityResolver().getObjEntity(type);
return new DefaultSourceKeysBuilder(
targetEntityMap.get(targetEntity),
Expand All @@ -135,7 +136,7 @@ public SourceKeysBuilder extractSourceKeys(String targetEntityName) {
}

@Override
public <T extends DataObject> DeleteBuilder<T> delete(Class<T> type) {
public <T extends Persistent> DeleteBuilder<T> delete(Class<T> type) {

ObjEntity entity = targetCayenneService.entityResolver().getObjEntity(type);
if (entity == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import com.nhl.link.move.runtime.task.common.FkResolver;
import com.nhl.link.move.runtime.task.createorupdate.RowConverter;
import com.nhl.link.move.runtime.token.ITokenManager;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.Persistent;

import java.lang.annotation.Annotation;

/**
* @param <T>
* @since 2.6
*/
public class DefaultCreateBuilder<T extends DataObject> extends BaseTaskBuilder<DefaultCreateBuilder<T>> implements CreateBuilder<T> {
public class DefaultCreateBuilder<T extends Persistent> extends BaseTaskBuilder<DefaultCreateBuilder<T>> implements CreateBuilder<T> {

private final CreateTargetMapper mapper;
private final CreateTargetMerger merger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import com.nhl.link.move.runtime.task.MapperBuilder;
import com.nhl.link.move.runtime.task.common.FkResolver;
import com.nhl.link.move.runtime.token.ITokenManager;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.exp.property.Property;

import java.lang.annotation.Annotation;

/**
* A builder of an ETL task that matches source data with target data based on a certain unique attribute on both sides.
*/
public class DefaultCreateOrUpdateBuilder<T extends DataObject> extends BaseTaskBuilder<DefaultCreateOrUpdateBuilder<T>> implements CreateOrUpdateBuilder<T> {
public class DefaultCreateOrUpdateBuilder<T extends Persistent> extends BaseTaskBuilder<DefaultCreateOrUpdateBuilder<T>> implements CreateOrUpdateBuilder<T> {

private final Class<T> type;
private final CreateOrUpdateTargetMerger merger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.nhl.link.move.runtime.task.MapperBuilder;
import com.nhl.link.move.runtime.token.ITokenManager;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.exp.property.Property;

Expand All @@ -25,7 +26,7 @@
/**
* @since 1.3
*/
public class DefaultDeleteBuilder<T extends DataObject> extends BaseTaskBuilder<DefaultDeleteBuilder<T>> implements DeleteBuilder<T> {
public class DefaultDeleteBuilder<T extends Persistent> extends BaseTaskBuilder<DefaultDeleteBuilder<T>> implements DeleteBuilder<T> {

private final ITaskService taskService;
private final ITokenManager tokenManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.nhl.link.move.runtime.cayenne.ITargetCayenneService;
import com.nhl.link.move.runtime.task.BaseTask;
import com.nhl.link.move.runtime.token.ITokenManager;
import org.apache.cayenne.DataObject;
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.ResultIterator;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.query.ObjectSelect;
Expand All @@ -21,7 +21,7 @@
*
* @since 1.3
*/
public class DeleteTask<T extends DataObject> extends BaseTask {
public class DeleteTask<T extends Persistent> extends BaseTask {

private final Class<T> type;
private final Expression targetFilter;
Expand Down

0 comments on commit 7c40f05

Please sign in to comment.