Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added JobStepDefinition filtering on add dialog #2191

Merged
merged 1 commit into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.kapua.commons.setting.SettingKey;

public enum ConsoleSettingKeys implements SettingKey {

SKIN_RESOURCE_DIR("console.skin.resource.dir"), //

LOGIN_BACKGROUND_CREDITS("console.login.background.credits"), //
Expand All @@ -31,6 +32,8 @@ public enum ConsoleSettingKeys implements SettingKey {
DEVICE_MAP_ENABLED("console.device.map.enabled"), //
DEVICE_MAP_TILE_URI("console.device.map.tile.uri"), //

JOB_STEP_DEFINITION_EXCLUDE_REGEX("console.job.step.definition.exclude.regex"),

FILE_UPLOAD_SIZE_MAX("console.file.upload.size.max"), //
FILE_UPLOAD_INMEMORY_SIZE_THRESHOLD("console.file.upload.inmemory.size.threshold"), //

Expand All @@ -46,6 +49,7 @@ private ConsoleSettingKeys(String key) {
this.key = key;
}

@Override
public String key() {
return key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

import com.extjs.gxt.ui.client.data.BaseListLoadResult;
import com.extjs.gxt.ui.client.data.ListLoadResult;
import com.google.common.base.Strings;
import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException;
import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet;
import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler;
import org.eclipse.kapua.app.console.module.api.setting.ConsoleSetting;
import org.eclipse.kapua.app.console.module.api.setting.ConsoleSettingKeys;
import org.eclipse.kapua.app.console.module.job.shared.model.GwtJobStepDefinition;
import org.eclipse.kapua.app.console.module.job.shared.model.GwtJobStepProperty;
import org.eclipse.kapua.app.console.module.job.shared.service.GwtJobStepDefinitionService;
Expand All @@ -33,15 +36,26 @@

public class GwtJobStepDefinitionServiceImpl extends KapuaRemoteServiceServlet implements GwtJobStepDefinitionService {

private static final KapuaLocator LOCATOR = KapuaLocator.getInstance();

private static final JobStepDefinitionService JOB_STEP_DEFINITION_SERVICE = LOCATOR.getService(JobStepDefinitionService.class);
private static final JobStepDefinitionFactory JOB_STEP_DEFINITION_FACTORY = LOCATOR.getFactory(JobStepDefinitionFactory.class);

private static final ConsoleSetting CONSOLE_SETTING = ConsoleSetting.getInstance();

private static final String JOB_STEP_DEFINITION_EXCLUDE_REGEX = CONSOLE_SETTING.getString(ConsoleSettingKeys.JOB_STEP_DEFINITION_EXCLUDE_REGEX);

@Override
public ListLoadResult<GwtJobStepDefinition> findAll() throws GwtKapuaException {
List<GwtJobStepDefinition> gwtJobStepDefinitionList = new ArrayList<GwtJobStepDefinition>();
try {
KapuaLocator locator = KapuaLocator.getInstance();
JobStepDefinitionService jobStepDefinitionService = locator.getService(JobStepDefinitionService.class);
JobStepDefinitionFactory jobStepDefinitionFactory = locator.getFactory(JobStepDefinitionFactory.class);
JobStepDefinitionListResult result = jobStepDefinitionService.query(jobStepDefinitionFactory.newQuery(null));
JobStepDefinitionListResult result = JOB_STEP_DEFINITION_SERVICE.query(JOB_STEP_DEFINITION_FACTORY.newQuery(null));
for (JobStepDefinition jsd : result.getItems()) {

if (!Strings.isNullOrEmpty(JOB_STEP_DEFINITION_EXCLUDE_REGEX) && jsd.getName().matches(JOB_STEP_DEFINITION_EXCLUDE_REGEX)) {
continue;
}

GwtJobStepDefinition gwtJobStepDefinition = KapuaGwtJobModelConverter.convertJobStepDefinition(jsd);

setEnumOnJobStepProperty(gwtJobStepDefinition.getStepProperties());
Expand All @@ -61,9 +75,7 @@ public GwtJobStepDefinition find(String gwtJobStepDefinitionId) throws GwtKapuaE

GwtJobStepDefinition gwtJobStepDefinition = null;
try {
KapuaLocator locator = KapuaLocator.getInstance();
JobStepDefinitionService jobStepDefinitionService = locator.getService(JobStepDefinitionService.class);
JobStepDefinition jobStepDefinition = jobStepDefinitionService.find(null, jobStepDefinitionId);
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(null, jobStepDefinitionId);
if (jobStepDefinition != null) {
gwtJobStepDefinition = KapuaGwtJobModelConverter.convertJobStepDefinition(jobStepDefinition);

Expand Down