Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Mar 21, 2012
1 parent 14fceee commit 52f0b1a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
Expand Up @@ -33,7 +33,7 @@
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeGroupLink;
import org.jumpmind.symmetric.model.RemoteNodeStatus;
import org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictSettingsNodeGroupLink;
import org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictSettingNodeGroupLink;

/**
* This service provides an API to load data into a SymmetricDS node's database
Expand All @@ -57,11 +57,13 @@ public interface IDataLoaderService {

public List<IncomingBatch> loadDataBatch(String batchData) throws IOException;

public List<ConflictSettingsNodeGroupLink> getConflictSettingsNodeGroupLinks(NodeGroupLink link, boolean refreshCache);
public List<ConflictSettingNodeGroupLink> getConflictSettingsNodeGroupLinks(NodeGroupLink link, boolean refreshCache);

public void delete(ConflictSettingsNodeGroupLink settings);
public List<ConflictSettingNodeGroupLink> getConflictSettingsNodeGroupLinks();

public void save(ConflictSettingsNodeGroupLink settings);
public void delete(ConflictSettingNodeGroupLink settings);

public void save(ConflictSettingNodeGroupLink settings);

public List<IncomingError> getIncomingErrors(long batchId, String nodeId);

Expand Down
Expand Up @@ -129,7 +129,7 @@ public class DataLoaderService extends AbstractService implements IDataLoaderSer

private Map<String, IDataLoaderFactory> dataLoaderFactories = new HashMap<String, IDataLoaderFactory>();

private Map<NodeGroupLink, List<ConflictSettingsNodeGroupLink>> conflictSettingsCache = new HashMap<NodeGroupLink, List<ConflictSettingsNodeGroupLink>>();
private Map<NodeGroupLink, List<ConflictSettingNodeGroupLink>> conflictSettingsCache = new HashMap<NodeGroupLink, List<ConflictSettingNodeGroupLink>>();

private long lastConflictCacheResetTimeInMs = 0;

Expand Down Expand Up @@ -441,8 +441,15 @@ protected IDataLoaderFactory getFactory(String channelId) {

return factory;
}

public List<ConflictSettingNodeGroupLink> getConflictSettingsNodeGroupLinks() {
List<ConflictSettingNodeGroupLink> list = new ArrayList<DataLoaderService.ConflictSettingNodeGroupLink>();
list = sqlTemplate.query(getSql("selectConflictSettingsSql"),
new ConflictSettingsNodeGroupLinkMapper());
return list;
}

public List<ConflictSettingsNodeGroupLink> getConflictSettingsNodeGroupLinks(
public List<ConflictSettingNodeGroupLink> getConflictSettingsNodeGroupLinks(
NodeGroupLink link, boolean refreshCache) {
if (link != null) {
long cacheTime = parameterService
Expand All @@ -455,7 +462,7 @@ public List<ConflictSettingsNodeGroupLink> getConflictSettingsNodeGroupLinks(
}
}

List<ConflictSettingsNodeGroupLink> list = conflictSettingsCache.get(link);
List<ConflictSettingNodeGroupLink> list = conflictSettingsCache.get(link);
if (list == null) {
list = sqlTemplate.query(
getSql("selectConflictSettingsSql",
Expand All @@ -469,15 +476,15 @@ public List<ConflictSettingsNodeGroupLink> getConflictSettingsNodeGroupLinks(

return list;
} else {
return new ArrayList<DataLoaderService.ConflictSettingsNodeGroupLink>(0);
return new ArrayList<DataLoaderService.ConflictSettingNodeGroupLink>(0);
}
}

public void delete(ConflictSettingsNodeGroupLink settings) {
public void delete(ConflictSettingNodeGroupLink settings) {
sqlTemplate.update(getSql("deleteConflictSettingsSql"), settings.getConflictSettingId());
}

public void save(ConflictSettingsNodeGroupLink setting) {
public void save(ConflictSettingNodeGroupLink setting) {
this.lastConflictCacheResetTimeInMs = 0;
if (sqlTemplate.update(getSql("updateConflictSettingsSql"), setting.getNodeGroupLink()
.getSourceNodeGroupId(), setting.getNodeGroupLink().getTargetNodeGroupId(), setting
Expand Down Expand Up @@ -537,9 +544,9 @@ protected void setTransportManager(ITransportManager transportManager) {
}

class ConflictSettingsNodeGroupLinkMapper implements
ISqlRowMapper<ConflictSettingsNodeGroupLink> {
public ConflictSettingsNodeGroupLink mapRow(Row rs) {
ConflictSettingsNodeGroupLink setting = new ConflictSettingsNodeGroupLink();
ISqlRowMapper<ConflictSettingNodeGroupLink> {
public ConflictSettingNodeGroupLink mapRow(Row rs) {
ConflictSettingNodeGroupLink setting = new ConflictSettingNodeGroupLink();
setting.setNodeGroupLink(new NodeGroupLink(rs.getString("source_node_group_id"), rs
.getString("target_node_group_id")));
setting.setTargetChannelId(rs.getString("target_channel_id"));
Expand Down Expand Up @@ -773,7 +780,7 @@ public IncomingBatch getCurrentBatch() {
}
}

public static class ConflictSettingsNodeGroupLink extends ConflictSetting {
public static class ConflictSettingNodeGroupLink extends ConflictSetting {
private static final long serialVersionUID = 1L;
protected NodeGroupLink nodeGroupLink;

Expand Down
Expand Up @@ -431,8 +431,8 @@

<table name="conflict_setting" description="Defines how conflicts in row data should be handled during the load process.">
<column name="conflict_setting_id" type="VARCHAR" size="50" required="true" primaryKey="true" description="Unique identifier for a specific conflict detection setting." />
<column name="source_node_group_id" type="VARCHAR" size="50" required="true" primaryKey="true" description="The source node group for which this setting will be applied to. References a node group link." />
<column name="target_node_group_id" type="VARCHAR" size="50" required="true" primaryKey="true" description="The target node group for which this setting will be applied to. References a node group link." />
<column name="source_node_group_id" type="VARCHAR" size="50" required="true" description="The source node group for which this setting will be applied to. References a node group link." />
<column name="target_node_group_id" type="VARCHAR" size="50" required="true" description="The target node group for which this setting will be applied to. References a node group link." />
<column name="target_channel_id" type="VARCHAR" size="20" description="Optional channel that this setting will be applied to." />
<column name="target_catalog_name" type="VARCHAR" size="128" description="Optional database catalog that the target table belongs to. Only use this if the target table is not in the default catalog." />
<column name="target_schema_name" type="VARCHAR" size="128" description="Optional database schema that the target table belongs to. Only use this if the target table is not in the default schema." />
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.service.IDataLoaderService;
import org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictSettingsNodeGroupLink;
import org.jumpmind.symmetric.service.impl.DataLoaderService.ConflictSettingNodeGroupLink;
import org.jumpmind.symmetric.transport.MockTransportManager;
import org.jumpmind.symmetric.transport.internal.InternalIncomingTransport;
import org.junit.After;
Expand Down Expand Up @@ -340,7 +340,7 @@ public void testDataIntregrityError() throws Exception {
String[] values = { getNextId(), "string3", "string not null3", "char3", "char not null3",
"2007-01-02 00:00:00.0", "2007-02-03 04:05:06.0", "0", "47", "67.89", "0.474" };

ConflictSettingsNodeGroupLink conflictSettings = new ConflictSettingsNodeGroupLink();
ConflictSettingNodeGroupLink conflictSettings = new ConflictSettingNodeGroupLink();
conflictSettings.setNodeGroupLink(TestConstants.TEST_2_ROOT);
conflictSettings.setConflictSettingId("dont_fallback");
conflictSettings.setResolveInsertType(ResolveInsertConflict.MANUAL);
Expand Down

0 comments on commit 52f0b1a

Please sign in to comment.