use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class RuntimeLogViewModel method update.
@Command
@NotifyChange({ "runtimeLog", "filter" })
public void update() {
if (!Properties.getBasePath().equals("")) {
// Check if applicaction has changed
String newPath = Properties.getBasePath() + File.separator + Constants.RUNTIME_LOG;
if (!this.runtimeLogPath.equals(newPath)) {
// Load new application
this.runtimeLogPath = newPath;
this.lastParsedLine = 0;
this.content = "";
this.filter = "";
}
// Parse
logger.debug("Parsing runtime.log file...");
try (BufferedReader br = new BufferedReader(new FileReader(this.runtimeLogPath))) {
StringBuilder sb = new StringBuilder("");
String line = br.readLine();
int i = 0;
while (line != null) {
if (i > this.lastParsedLine) {
if (line.contains(filter)) {
sb.append(line).append("\n");
}
}
i = i + 1;
line = br.readLine();
}
this.content += sb.toString();
this.lastParsedLine = i - 1;
} catch (IOException ioe) {
logger.error("Cannot parse runtime.log file: " + this.runtimeLogPath, ioe);
}
} else {
// Load default value
this.clear();
}
}
use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class ViewModel method updateRuntimeLog.
@Command
@NotifyChange("runtimeLogViewModel")
public void updateRuntimeLog() {
logger.debug("Loading Monitored Application...");
Application monitoredApp = new Application();
Session session = Sessions.getCurrent();
if (session != null) {
UserCredential userCred = ((UserCredential) session.getAttribute("userCredential"));
if (userCred != null) {
monitoredApp = userCred.getMonitoredApp();
}
}
logger.debug("Loaded Monitored Application: " + monitoredApp.getName());
logger.debug("Updating RuntimeLog...");
if (monitoredApp.getName() != "") {
if (selectedTab.equals(Constants.runtimeLogTabName)) {
runtimeLogViewModel.update();
} else {
runtimeLogViewModel.clear();
}
} else {
runtimeLogViewModel.clear();
}
logger.info("Runtime.log updated");
}
use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class ViewModel method update.
@Command
@NotifyChange({ "resourcesViewModel", "coresViewModel", "currentGraphViewModel", "completeGraphViewModel", "loadChartViewModel", "statisticsViewModel", "runtimeLogViewModel" })
public void update() {
logger.debug("Loading Monitored Application...");
Application monitoredApp = new Application();
Session session = Sessions.getCurrent();
if (session != null) {
UserCredential userCred = ((UserCredential) session.getAttribute("userCredential"));
if (userCred != null) {
monitoredApp = userCred.getMonitoredApp();
}
}
logger.info("Loaded Monitored Application: " + monitoredApp.getName());
if (monitoredApp.getName() != "") {
if (selectedTab.equals(Constants.resourcesInformationTabName)) {
logger.debug("Updating Resources Information...");
// Monitor XML parse
logger.debug("Parsing Monitor XML File...");
MonitorXmlParser.parseResources();
logger.debug("Monitor XML File parsed");
// Update
resourcesViewModel.update(MonitorXmlParser.getWorkersDataArray());
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.tasksInformationTabName)) {
logger.debug("Updating Jobs Information...");
// Monitoring parse
logger.debug("Parsing Monitor XML File...");
MonitorXmlParser.parseCores();
logger.debug("Monitor XML File parsed");
// Update
coresViewModel.update(MonitorXmlParser.getCoresDataArray());
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.currentTasksGraphTabName)) {
logger.debug("Updating Current Tasks Graph...");
// Monitor XML parse
logger.debug("Parsing Monitor XML File...");
MonitorXmlParser.parseCores();
logger.debug("Monitor XML File parsed");
// Update
coresViewModel.update(MonitorXmlParser.getCoresDataArray());
currentGraphViewModel.update(monitoredApp);
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.completeTasksGraphTabName)) {
logger.debug("Updating Complete Tasks Graph...");
// Monitor XML parse
logger.debug("Parsing Monitor XML File...");
MonitorXmlParser.parseCores();
logger.debug("Monitor XML File parsed");
// Update
coresViewModel.update(MonitorXmlParser.getCoresDataArray());
completeGraphViewModel.update(monitoredApp);
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.loadChartTabName)) {
logger.debug("Updating Resouces Load Chart...");
// Update
loadChartViewModel.update();
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.statisticsTabName)) {
logger.debug("Updating statistics...");
// Monitor XML parse
logger.debug("Parsing Monitor XML File...");
MonitorXmlParser.parseStatistics();
logger.debug("Monitor XML File parsed");
// Update
statisticsViewModel.update(MonitorXmlParser.getStatisticsParameters());
logger.info("Structures updated");
} else if (selectedTab.equals(Constants.runtimeLogTabName)) {
// Check messagebox result
if (runtimeLogConfirmation == 0) {
logger.debug("Messagebox confirmation received. Loading runtime.log");
this.updateRuntimeLog();
// Reset messagebox handler to avoid automatic refresh
runtimeLogConfirmation = -1;
} else if (runtimeLogConfirmation == 1) {
logger.debug("Messagebox denied");
// Reset messagebox handler to avoid automatic refresh
runtimeLogConfirmation = -1;
}
} else if (selectedTab.equals(Constants.executionInformationTabName)) {
// Nothing to do. This tab doesn't have automatic update
} else {
logger.info("No Information Tab selected");
}
} else {
resourcesViewModel.clear();
coresViewModel.clear();
currentGraphViewModel.clear();
completeGraphViewModel.clear();
loadChartViewModel.clear();
statisticsViewModel.clear();
runtimeLogViewModel.clear();
logger.info("No Application Selected");
}
}
use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.
the class ViewModel method updateExecutionInformation.
@Command
@NotifyChange("executionInformationViewModel")
public void updateExecutionInformation() {
logger.debug("Loading Monitored Application...");
Application monitoredApp = new Application();
Session session = Sessions.getCurrent();
if (session != null) {
UserCredential userCred = ((UserCredential) session.getAttribute("userCredential"));
if (userCred != null) {
monitoredApp = userCred.getMonitoredApp();
}
}
logger.debug("Loaded Monitored Application: " + monitoredApp.getName());
logger.debug("Updating Execution Information...");
if (monitoredApp.getName() != "") {
if (selectedTab.equals(Constants.executionInformationTabName)) {
executionInformationViewModel.update();
}
} else {
executionInformationViewModel.clear();
}
logger.info("Execution Information updated");
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class SchemaAttributesImportVM method fileUploaded.
@Command
public void fileUploaded(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent event) {
Media media = event.getMedia();
String fileName = media.getName();
String extension = FilenameUtils.getExtension(fileName);
File tempFile;
if (Files.CSV_FILE_EXTENSION.equalsIgnoreCase(extension)) {
tempFile = OpenForisIOUtils.copyToTempFile(media.getReaderData(), extension);
} else {
tempFile = OpenForisIOUtils.copyToTempFile(media.getReaderData(), extension);
}
this.uploadedFile = tempFile;
this.uploadedFileName = fileName;
notifyChange("uploadedFileName");
}
Aggregations