@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(getClass().getSimpleName()).append(":[id='").append(getId()).append("', name='").append(name) .append("', description='").append(getDescription()).append("', delay='").append(getDelay()) .append("', recurrence='").append(getRecurrence()).append("', enabled='").append(isEnabled()) .append("', script='").append(getScript()).append("']").toString(); }
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", name=<").append(getName() == null ? "\\0" : BeansUtils.createEscaping(getName())).append(">").append( ", description=<").append(getDescription() == null ? "\\0" : BeansUtils.createEscaping(getDescription())).append(">").append( ", delay=<").append(this.getDelay()).append(">").append( ", recurrence=<").append(this.getRecurrence()).append(">").append( ", enabled=<").append(this.isEnabled()).append(">").append( ", script=<").append(getScript() == null ? "\\0" : BeansUtils.createEscaping(getScript())).append(">").append( ']').toString(); }
@Override public Task call() throws TaskExecutionException { getTask().setGenStartTime(new Date(System.currentTimeMillis())); Service service = getTask().getService(); log.info("[{}] Executing GEN worker for Task with Service ID: {} and Facility ID: {}.", getTask().getId(), getTask().getServiceId(), getTask().getFacilityId()); ProcessBuilder pb = new ProcessBuilder(service.getScript(), "-f", String.valueOf(getTask().getFacilityId())); try { // start the script and wait for results super.execute(pb); // set gen end time getTask().setGenEndTime(new Date(System.currentTimeMillis())); if (getReturnCode() != 0) { log.error("[{}] GEN worker failed for Task. Ret code {}, STDOUT: {}, STDERR: {}", getTask().getId(), getReturnCode(), getStdout(), getStderr()); throw new TaskExecutionException(task, getReturnCode(), getStdout(), getStderr()); } else { log.info("[{}] GEN worker finished for Task. Ret code {}, STDOUT: {}, STDERR: {}", getTask().getId(), getReturnCode(), getStdout(), getStderr()); return getTask(); } } catch (IOException e) { log.error("[{}] GEN worker failed for Task. IOException: {}.", task.getId(), e); throw new TaskExecutionException(task, e); } catch (InterruptedException e) { log.warn("[{}] GEN worker failed for Task. Execution was interrupted {}.", task.getId(), e); throw new TaskExecutionException(task, e); } }
public ServiceForGUI(Service service){ setId(service.getId()); setName(service.getName()); setDescription(service.getDescription()); setDelay(service.getDelay()); setRecurrence(service.getRecurrence()); setScript(service.getScript()); setEnabled(service.isEnabled()); }
service.getScript(), task.getFacility().getName(), sendTask.getDestination().getDestination(),