Search in sources :

Example 31 with Command

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();
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 32 with Command

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");
}
Also used : UserCredential(es.bsc.compss.ui.auth.UserCredential) Session(org.zkoss.zk.ui.Session) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 33 with Command

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");
    }
}
Also used : UserCredential(es.bsc.compss.ui.auth.UserCredential) Session(org.zkoss.zk.ui.Session) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 34 with Command

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");
}
Also used : UserCredential(es.bsc.compss.ui.auth.UserCredential) Session(org.zkoss.zk.ui.Session) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 35 with Command

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");
}
Also used : Media(org.zkoss.util.media.Media) File(java.io.File) Command(org.zkoss.bind.annotation.Command)

Aggregations

Command (org.zkoss.bind.annotation.Command)62 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)44 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 File (java.io.File)12 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 MessageUtil (org.openforis.collect.designer.util.MessageUtil)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 FileInputStream (java.io.FileInputStream)5 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)5 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 Media (org.zkoss.util.media.Media)5 Window (org.zkoss.zul.Window)5 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 IOException (java.io.IOException)4 Date (java.util.Date)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)3 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)3