Skip to content

Commit

Permalink
SYNCT-57: Corrections after review.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkornowski committed Dec 20, 2017
1 parent 312f176 commit 676f3dd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 19 deletions.
Expand Up @@ -26,8 +26,8 @@ public class Sync2ModuleActivator extends BaseModuleActivator {
* @see #started()
*/
public void started() {
LOGGER.info("Started Sync2 Module");
Context.getRegisteredComponents(SyncSchedulerServiceImpl.class).get(0).runSyncScheduler();
LOGGER.info("Started Sync2 Module");
}

/**
Expand Down
@@ -1,12 +1,10 @@
package org.openmrs.module.sync2.api.impl;

import org.openmrs.api.context.Context;
import org.openmrs.module.sync2.SyncConstants;
import org.openmrs.module.sync2.api.SyncConfigurationService;
import org.openmrs.module.sync2.api.exceptions.SyncException;
import org.openmrs.module.sync2.api.model.configuration.SyncConfiguration;
import org.openmrs.module.sync2.api.scheduler.SyncSchedulerService;
import org.openmrs.module.sync2.api.scheduler.impl.SyncSchedulerServiceImpl;
import org.openmrs.module.sync2.api.utils.SyncUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down
Expand Up @@ -20,9 +20,7 @@ public void execute() {
parentFeedReader = Context.getRegisteredComponent("sync2.parentFeedReader", ParentFeedReaderImpl.class);

if (!isExecuting) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Starting Sync 2.0 Pull Task...");
}
LOGGER.info("Starting Sync 2.0 Pull Task...");

startExecuting();
try {
Expand Down
Expand Up @@ -20,9 +20,7 @@ public void execute() {
localFeedReader = Context.getRegisteredComponent("sync2.localFeedReader", LocalFeedReaderImpl.class);

if (!isExecuting) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Starting Sync 2.0 Push Task...");
}
LOGGER.info("Starting Sync 2.0 Push Task...");

startExecuting();
try {
Expand Down
@@ -1,7 +1,5 @@
package org.openmrs.module.sync2.api.scheduler;

import org.openmrs.scheduler.TaskDefinition;

public interface SyncSchedulerService {

void runSyncScheduler();
Expand Down
Expand Up @@ -28,24 +28,24 @@ public class SyncSchedulerServiceImpl extends BaseOpenmrsService implements Sync
private static final String PUSH_TASK_DESCRIPTION = "Task for Sync 2.0 pushing data to the parent instance.";

@Autowired
SyncConfigurationService syncConfigurationService;
private SyncConfigurationService syncConfigurationService;


public void runSyncScheduler() {
if (isPullEnabled()) {
setPullTask();
schedulePullTask();
} else {
stopSyncTask(PULL_TASK_NAME);
}

if (isPushEnabled()) {
setPushTask();
schedulePushTask();
} else {
stopSyncTask(PULL_TASK_NAME);
stopSyncTask(PUSH_TASK_NAME);
}
}

private void setPullTask() {
private void schedulePullTask() {
TaskDefinition pullTask = createTask(PULL_TASK_NAME, PULL_TASK_DESCRIPTION, PULL_TASK_CLASS,
Long.valueOf(getPullIntervalInSeconds()));

Expand All @@ -58,7 +58,7 @@ private void setPullTask() {
}
}

private TaskDefinition setPushTask() {
private TaskDefinition schedulePushTask() {
TaskDefinition pushTask = createTask(PUSH_TASK_NAME, PUSH_TASK_DESCRIPTION, PUSH_TASK_CLASS,
Long.valueOf(getPushIntervalInSeconds()));

Expand Down
Expand Up @@ -18,8 +18,6 @@
import java.util.Arrays;
import java.util.List;

import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

public class SyncConfigurationServiceImplTest {
Expand Down

0 comments on commit 676f3dd

Please sign in to comment.