Search in sources :

Example 1 with BindingsResults

use of it.unibo.arces.wot.sepa.commons.sparql.BindingsResults in project SEPA by arces-wot.

the class Dashboard method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    namespacesDM = new DefaultTableModel(0, 0) {

        /**
         */
        private static final long serialVersionUID = 6788045463932990156L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    namespacesDM.setColumnIdentifiers(namespacesHeader);
    propertiesDM = new DefaultTableModel(0, 0) {

        /**
         */
        private static final long serialVersionUID = -5161490469556412655L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    propertiesDM.setColumnIdentifiers(propertiesHeader);
    frmSepaDashboard = new JFrame();
    frmSepaDashboard.setTitle(versionLabel);
    frmSepaDashboard.setBounds(100, 100, 925, 768);
    frmSepaDashboard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 925, 0 };
    gridBagLayout.rowHeights = new int[] { 78, 651, 39, 0 };
    gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    frmSepaDashboard.getContentPane().setLayout(gridBagLayout);
    JPanel configuration = new JPanel();
    GridBagConstraints gbc_configuration = new GridBagConstraints();
    gbc_configuration.insets = new Insets(0, 0, 5, 0);
    gbc_configuration.fill = GridBagConstraints.BOTH;
    gbc_configuration.gridx = 0;
    gbc_configuration.gridy = 0;
    frmSepaDashboard.getContentPane().add(configuration, gbc_configuration);
    configuration.setBorder(new TitledBorder(null, "Configuration", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_configuration = new GridBagLayout();
    gbl_configuration.columnWidths = new int[] { 46, 45, 31, 20, 0, 24, 0, 0, 0, 0, 0, 0, 37, 0 };
    gbl_configuration.rowHeights = new int[] { 9, -25, 0 };
    gbl_configuration.columnWeights = new double[] { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configuration.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    configuration.setLayout(gbl_configuration);
    JLabel label1 = new JLabel("URL:");
    label1.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label1 = new GridBagConstraints();
    gbc_label1.anchor = GridBagConstraints.EAST;
    gbc_label1.insets = new Insets(0, 0, 5, 5);
    gbc_label1.gridx = 0;
    gbc_label1.gridy = 0;
    configuration.add(label1, gbc_label1);
    JButton btnLoadXmlProfile = new JButton("Load SAP profile");
    btnLoadXmlProfile.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // String path = appProperties.getProperty("path");
            final JFileChooser fc = new JFileChooser(appProperties.getProperty("appProfile"));
            // final JFileChooser fc = new
            // JFileChooser("/Users/luca/Documents/SEPAProject/WOTDemo/tools/");
            DashboardFileFilter filter = new DashboardFileFilter("JSON SAP Profile (.jsap)", ".jsap");
            fc.setFileFilter(filter);
            int returnVal = fc.showOpenDialog(frmSepaDashboard);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String fileName = fc.getSelectedFile().getPath();
                if (loadSAP(fileName)) {
                    FileOutputStream out = null;
                    try {
                        out = new FileOutputStream("dashboard.properties");
                    } catch (FileNotFoundException e3) {
                        logger.error(e3.getMessage());
                        return;
                    }
                    appProperties = new Properties();
                    appProperties.put("appProfile", fileName);
                    try {
                        appProperties.store(out, "Dashboard properties");
                    } catch (IOException e1) {
                        logger.error(e1.getMessage());
                    }
                    try {
                        out.close();
                    } catch (IOException e2) {
                        logger.error(e2.getMessage());
                    }
                }
            }
        }
    });
    labelUrl = new JLabel("---");
    GridBagConstraints gbc_labelUrl = new GridBagConstraints();
    gbc_labelUrl.anchor = GridBagConstraints.WEST;
    gbc_labelUrl.insets = new Insets(0, 0, 5, 5);
    gbc_labelUrl.gridx = 1;
    gbc_labelUrl.gridy = 0;
    configuration.add(labelUrl, gbc_labelUrl);
    JLabel label2 = new JLabel("http:");
    label2.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label2 = new GridBagConstraints();
    gbc_label2.insets = new Insets(0, 0, 5, 5);
    gbc_label2.gridx = 2;
    gbc_label2.gridy = 0;
    configuration.add(label2, gbc_label2);
    labelHttpPort = new JLabel("---");
    GridBagConstraints gbc_labelHttpPort = new GridBagConstraints();
    gbc_labelHttpPort.anchor = GridBagConstraints.WEST;
    gbc_labelHttpPort.insets = new Insets(0, 0, 5, 5);
    gbc_labelHttpPort.gridx = 3;
    gbc_labelHttpPort.gridy = 0;
    configuration.add(labelHttpPort, gbc_labelHttpPort);
    JLabel lblWs = new JLabel("ws:");
    lblWs.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblWs = new GridBagConstraints();
    gbc_lblWs.insets = new Insets(0, 0, 5, 5);
    gbc_lblWs.gridx = 4;
    gbc_lblWs.gridy = 0;
    configuration.add(lblWs, gbc_lblWs);
    labelWsPort = new JLabel("---");
    GridBagConstraints gbc_labelWsPort = new GridBagConstraints();
    gbc_labelWsPort.anchor = GridBagConstraints.WEST;
    gbc_labelWsPort.insets = new Insets(0, 0, 5, 5);
    gbc_labelWsPort.gridx = 5;
    gbc_labelWsPort.gridy = 0;
    configuration.add(labelWsPort, gbc_labelWsPort);
    JLabel lblUpdate = new JLabel("update:");
    lblUpdate.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblUpdate = new GridBagConstraints();
    gbc_lblUpdate.insets = new Insets(0, 0, 5, 5);
    gbc_lblUpdate.gridx = 6;
    gbc_lblUpdate.gridy = 0;
    configuration.add(lblUpdate, gbc_lblUpdate);
    labelUpdatePath = new JLabel("---");
    GridBagConstraints gbc_labelUpdatepath = new GridBagConstraints();
    gbc_labelUpdatepath.anchor = GridBagConstraints.WEST;
    gbc_labelUpdatepath.insets = new Insets(0, 0, 5, 5);
    gbc_labelUpdatepath.gridx = 7;
    gbc_labelUpdatepath.gridy = 0;
    configuration.add(labelUpdatePath, gbc_labelUpdatepath);
    JLabel lblQuery = new JLabel("query:");
    lblQuery.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblQuery = new GridBagConstraints();
    gbc_lblQuery.insets = new Insets(0, 0, 5, 5);
    gbc_lblQuery.gridx = 8;
    gbc_lblQuery.gridy = 0;
    configuration.add(lblQuery, gbc_lblQuery);
    labelQueryPath = new JLabel("---");
    GridBagConstraints gbc_labelQueryPath = new GridBagConstraints();
    gbc_labelQueryPath.anchor = GridBagConstraints.WEST;
    gbc_labelQueryPath.insets = new Insets(0, 0, 5, 5);
    gbc_labelQueryPath.gridx = 9;
    gbc_labelQueryPath.gridy = 0;
    configuration.add(labelQueryPath, gbc_labelQueryPath);
    JLabel lblSubscribe = new JLabel("subscribe:");
    lblSubscribe.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblSubscribe = new GridBagConstraints();
    gbc_lblSubscribe.insets = new Insets(0, 0, 5, 5);
    gbc_lblSubscribe.gridx = 10;
    gbc_lblSubscribe.gridy = 0;
    configuration.add(lblSubscribe, gbc_lblSubscribe);
    labelSubscribePath = new JLabel("---");
    GridBagConstraints gbc_labelSubscribePath = new GridBagConstraints();
    gbc_labelSubscribePath.anchor = GridBagConstraints.WEST;
    gbc_labelSubscribePath.insets = new Insets(0, 0, 5, 5);
    gbc_labelSubscribePath.gridx = 11;
    gbc_labelSubscribePath.gridy = 0;
    configuration.add(labelSubscribePath, gbc_labelSubscribePath);
    GridBagConstraints gbc_btnLoadXmlProfile = new GridBagConstraints();
    gbc_btnLoadXmlProfile.insets = new Insets(0, 0, 5, 0);
    gbc_btnLoadXmlProfile.anchor = GridBagConstraints.NORTHEAST;
    gbc_btnLoadXmlProfile.gridx = 12;
    gbc_btnLoadXmlProfile.gridy = 0;
    configuration.add(btnLoadXmlProfile, gbc_btnLoadXmlProfile);
    JLabel label3 = new JLabel("https:");
    label3.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_label3 = new GridBagConstraints();
    gbc_label3.insets = new Insets(0, 0, 0, 5);
    gbc_label3.gridx = 2;
    gbc_label3.gridy = 1;
    configuration.add(label3, gbc_label3);
    labelHttpsPort = new JLabel("---");
    GridBagConstraints gbc_labelHttpsPort = new GridBagConstraints();
    gbc_labelHttpsPort.anchor = GridBagConstraints.WEST;
    gbc_labelHttpsPort.insets = new Insets(0, 0, 0, 5);
    gbc_labelHttpsPort.gridx = 3;
    gbc_labelHttpsPort.gridy = 1;
    configuration.add(labelHttpsPort, gbc_labelHttpsPort);
    JLabel lblWss = new JLabel("wss:");
    lblWss.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblWss = new GridBagConstraints();
    gbc_lblWss.insets = new Insets(0, 0, 0, 5);
    gbc_lblWss.gridx = 4;
    gbc_lblWss.gridy = 1;
    configuration.add(lblWss, gbc_lblWss);
    labelWssPort = new JLabel("---");
    GridBagConstraints gbc_labelWssPort = new GridBagConstraints();
    gbc_labelWssPort.anchor = GridBagConstraints.WEST;
    gbc_labelWssPort.insets = new Insets(0, 0, 0, 5);
    gbc_labelWssPort.gridx = 5;
    gbc_labelWssPort.gridy = 1;
    configuration.add(labelWssPort, gbc_labelWssPort);
    JLabel lblNewLabel = new JLabel("secure:");
    lblNewLabel.setFont(new Font("Lucida Grande", Font.BOLD, 13));
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
    gbc_lblNewLabel.gridx = 6;
    gbc_lblNewLabel.gridy = 1;
    configuration.add(lblNewLabel, gbc_lblNewLabel);
    labelSecurePath = new JLabel("---");
    GridBagConstraints gbc_labelSecurePath = new GridBagConstraints();
    gbc_labelSecurePath.anchor = GridBagConstraints.WEST;
    gbc_labelSecurePath.insets = new Insets(0, 0, 0, 5);
    gbc_labelSecurePath.gridx = 7;
    gbc_labelSecurePath.gridy = 1;
    configuration.add(labelSecurePath, gbc_labelSecurePath);
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
    gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
    gbc_tabbedPane.fill = GridBagConstraints.BOTH;
    gbc_tabbedPane.gridx = 0;
    gbc_tabbedPane.gridy = 1;
    frmSepaDashboard.getContentPane().add(tabbedPane, gbc_tabbedPane);
    JPanel primitives = new JPanel();
    tabbedPane.addTab("Primitives", null, primitives, null);
    primitives.setBorder(new TitledBorder(null, "Primitives", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_primitives = new GridBagLayout();
    gbl_primitives.columnWidths = new int[] { 684, 0, 0 };
    gbl_primitives.rowHeights = new int[] { 114, 115, 0, 0, 0 };
    gbl_primitives.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_primitives.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    primitives.setLayout(gbl_primitives);
    JSplitPane splitPanel_Update = new JSplitPane();
    splitPanel_Update.setResizeWeight(0.5);
    GridBagConstraints gbc_splitPanel_Update = new GridBagConstraints();
    gbc_splitPanel_Update.insets = new Insets(0, 0, 5, 5);
    gbc_splitPanel_Update.fill = GridBagConstraints.BOTH;
    gbc_splitPanel_Update.gridx = 0;
    gbc_splitPanel_Update.gridy = 0;
    primitives.add(splitPanel_Update, gbc_splitPanel_Update);
    JPanel panel_4 = new JPanel();
    splitPanel_Update.setLeftComponent(panel_4);
    GridBagLayout gbl_panel_4 = new GridBagLayout();
    gbl_panel_4.columnWidths = new int[] { 66, 0 };
    gbl_panel_4.rowHeights = new int[] { 17, 75, 0 };
    gbl_panel_4.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_4.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_4.setLayout(gbl_panel_4);
    JLabel lblUpdates = new JLabel("UPDATEs");
    GridBagConstraints gbc_lblUpdates = new GridBagConstraints();
    gbc_lblUpdates.anchor = GridBagConstraints.NORTH;
    gbc_lblUpdates.insets = new Insets(0, 0, 5, 0);
    gbc_lblUpdates.gridx = 0;
    gbc_lblUpdates.gridy = 0;
    panel_4.add(lblUpdates, gbc_lblUpdates);
    lblUpdates.setFont(new Font("Lucida Grande", Font.BOLD, 14));
    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 1;
    panel_4.add(scrollPane, gbc_scrollPane);
    updatesList = new JList<String>(updateListDM);
    scrollPane.setViewportView(updatesList);
    updatesList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (updatesList.getSelectedIndex() != -1) {
                    String sparql = appProfile.update(updatesList.getSelectedValue());
                    sparql = sparql.replaceFirst("\n", "");
                    sparql = sparql.replaceAll("\t", "");
                    sparql = sparql.trim();
                    SPARQLUpdate.setText(sparql);
                    Bindings bindings = appProfile.updateBindings(updatesList.getSelectedValue());
                    updateForcedBindingsDM.clearBindings();
                    if (bindings == null)
                        return;
                    for (String var : bindings.getVariables()) {
                        updateForcedBindingsDM.addBindings(var, bindings.isLiteral(var));
                    }
                }
            }
        }
    });
    updatesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel panel_5 = new JPanel();
    splitPanel_Update.setRightComponent(panel_5);
    GridBagLayout gbl_panel_5 = new GridBagLayout();
    gbl_panel_5.columnWidths = new int[] { 101, 0 };
    gbl_panel_5.rowHeights = new int[] { 16, 0, 0 };
    gbl_panel_5.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_5.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_5.setLayout(gbl_panel_5);
    JLabel lblForcedBindings = new JLabel("Forced bindings");
    GridBagConstraints gbc_lblForcedBindings = new GridBagConstraints();
    gbc_lblForcedBindings.anchor = GridBagConstraints.NORTH;
    gbc_lblForcedBindings.insets = new Insets(0, 0, 5, 0);
    gbc_lblForcedBindings.gridx = 0;
    gbc_lblForcedBindings.gridy = 0;
    panel_5.add(lblForcedBindings, gbc_lblForcedBindings);
    JScrollPane scrollPane_2 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_2 = new GridBagConstraints();
    gbc_scrollPane_2.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_2.gridx = 0;
    gbc_scrollPane_2.gridy = 1;
    panel_5.add(scrollPane_2, gbc_scrollPane_2);
    updateForcedBindings = new JTable(updateForcedBindingsDM);
    scrollPane_2.setViewportView(updateForcedBindings);
    JSplitPane splitPanel_Subscribe = new JSplitPane();
    GridBagConstraints gbc_splitPanel_Subscribe = new GridBagConstraints();
    gbc_splitPanel_Subscribe.insets = new Insets(0, 0, 5, 0);
    gbc_splitPanel_Subscribe.fill = GridBagConstraints.BOTH;
    gbc_splitPanel_Subscribe.gridx = 1;
    gbc_splitPanel_Subscribe.gridy = 0;
    primitives.add(splitPanel_Subscribe, gbc_splitPanel_Subscribe);
    JPanel panel_6 = new JPanel();
    splitPanel_Subscribe.setLeftComponent(panel_6);
    GridBagLayout gbl_panel_6 = new GridBagLayout();
    gbl_panel_6.columnWidths = new int[] { 193, 0 };
    gbl_panel_6.rowHeights = new int[] { 17, 72, 0 };
    gbl_panel_6.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_6.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_6.setLayout(gbl_panel_6);
    JLabel lblSubscribes = new JLabel("SUBSCRIBEs");
    GridBagConstraints gbc_lblSubscribes = new GridBagConstraints();
    gbc_lblSubscribes.anchor = GridBagConstraints.NORTH;
    gbc_lblSubscribes.insets = new Insets(0, 0, 5, 0);
    gbc_lblSubscribes.gridx = 0;
    gbc_lblSubscribes.gridy = 0;
    panel_6.add(lblSubscribes, gbc_lblSubscribes);
    lblSubscribes.setFont(new Font("Lucida Grande", Font.BOLD, 14));
    JScrollPane scrollPane_3 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_3 = new GridBagConstraints();
    gbc_scrollPane_3.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_3.gridx = 0;
    gbc_scrollPane_3.gridy = 1;
    panel_6.add(scrollPane_3, gbc_scrollPane_3);
    subscribesList = new JList<String>(subscribeListDM);
    subscribesList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (subscribesList.getSelectedIndex() != -1) {
                    String sparql = appProfile.subscribe(subscribesList.getSelectedValue());
                    sparql = sparql.replaceFirst("\n", "");
                    sparql = sparql.replaceAll("\t", "");
                    sparql = sparql.trim();
                    SPARQLSubscribe.setText(sparql);
                }
                Bindings bindings = appProfile.subscribeBindings(subscribesList.getSelectedValue());
                subscribeForcedBindingsDM.clearBindings();
                if (bindings == null)
                    return;
                for (String var : bindings.getVariables()) {
                    subscribeForcedBindingsDM.addBindings(var, bindings.isLiteral(var));
                }
            }
        }
    });
    scrollPane_3.setViewportView(subscribesList);
    subscribesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JPanel panel_7 = new JPanel();
    splitPanel_Subscribe.setRightComponent(panel_7);
    GridBagLayout gbl_panel_7 = new GridBagLayout();
    gbl_panel_7.columnWidths = new int[] { 454, 0 };
    gbl_panel_7.rowHeights = new int[] { 16, 126, 0 };
    gbl_panel_7.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_panel_7.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    panel_7.setLayout(gbl_panel_7);
    JLabel lblForcedBindings_1 = new JLabel("Forced bindings");
    GridBagConstraints gbc_lblForcedBindings_1 = new GridBagConstraints();
    gbc_lblForcedBindings_1.anchor = GridBagConstraints.NORTH;
    gbc_lblForcedBindings_1.insets = new Insets(0, 0, 5, 0);
    gbc_lblForcedBindings_1.gridx = 0;
    gbc_lblForcedBindings_1.gridy = 0;
    panel_7.add(lblForcedBindings_1, gbc_lblForcedBindings_1);
    JScrollPane scrollPane_1 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
    gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_1.gridx = 0;
    gbc_scrollPane_1.gridy = 1;
    panel_7.add(scrollPane_1, gbc_scrollPane_1);
    subscribeForcedBindings = new JTable(subscribeForcedBindingsDM);
    scrollPane_1.setViewportView(subscribeForcedBindings);
    JScrollPane scrollPane_Update = new JScrollPane();
    GridBagConstraints gbc_scrollPane_Update = new GridBagConstraints();
    gbc_scrollPane_Update.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_Update.insets = new Insets(0, 0, 5, 5);
    gbc_scrollPane_Update.gridx = 0;
    gbc_scrollPane_Update.gridy = 1;
    primitives.add(scrollPane_Update, gbc_scrollPane_Update);
    SPARQLUpdate = new JTextArea();
    scrollPane_Update.setViewportView(SPARQLUpdate);
    SPARQLUpdate.setLineWrap(true);
    btnUpdate = new JButton("UPDATE");
    btnUpdate.setEnabled(false);
    btnUpdate.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Bindings forced = new Bindings();
            for (int index = 0; index < updateForcedBindingsDM.getRowCount(); index++) {
                String value = (String) updateForcedBindingsDM.getValueAt(index, 1);
                String var = (String) updateForcedBindingsDM.getValueAt(index, 0);
                boolean literal = (boolean) updateForcedBindingsDM.getValueAt(index, 2);
                if (value.equals("")) {
                    lblInfo.setText("Please specify binding value: " + var);
                    lblInfo.setToolTipText("Please specify binding value: " + var);
                    return;
                }
                if (literal)
                    forced.addBinding(var, new RDFTermLiteral(value));
                else
                    forced.addBinding(var, new RDFTermURI(value));
            }
            String update = SPARQLUpdate.getText().replaceAll("[\n\t]", "");
            long start = System.currentTimeMillis();
            Response result = sepaClient.update(update, forced);
            long stop = System.currentTimeMillis();
            String status = "DONE";
            if (result.isError()) {
                status = "FAILED " + ((ErrorResponse) result).getErrorMessage();
            }
            lblInfo.setText("UPDATE (" + (stop - start) + " ms): " + status);
            lblInfo.setToolTipText("UPDATE (" + (stop - start) + " ms): " + status);
        }
    });
    JScrollPane scrollPane_Subscribe = new JScrollPane();
    GridBagConstraints gbc_scrollPane_Subscribe = new GridBagConstraints();
    gbc_scrollPane_Subscribe.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_Subscribe.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane_Subscribe.gridx = 1;
    gbc_scrollPane_Subscribe.gridy = 1;
    primitives.add(scrollPane_Subscribe, gbc_scrollPane_Subscribe);
    SPARQLSubscribe = new JTextArea();
    scrollPane_Subscribe.setViewportView(SPARQLSubscribe);
    SPARQLSubscribe.setLineWrap(true);
    GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
    gbc_btnUpdate.insets = new Insets(0, 0, 5, 5);
    gbc_btnUpdate.gridx = 0;
    gbc_btnUpdate.gridy = 2;
    primitives.add(btnUpdate, gbc_btnUpdate);
    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.insets = new Insets(0, 0, 5, 0);
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 1;
    gbc_panel.gridy = 2;
    primitives.add(panel, gbc_panel);
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel.rowHeights = new int[] { 0, 0 };
    gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_panel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    panel.setLayout(gbl_panel);
    btnQuery = new JButton("QUERY");
    btnQuery.setEnabled(false);
    btnQuery.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Bindings forced = new Bindings();
            for (int index = 0; index < subscribeForcedBindings.getRowCount(); index++) {
                String value = (String) subscribeForcedBindings.getValueAt(index, 1);
                boolean literal = (boolean) subscribeForcedBindings.getValueAt(index, 2);
                String var = (String) subscribeForcedBindings.getValueAt(index, 0);
                if (value.equals("")) {
                    lblInfo.setText("Please specify binding value: " + var);
                    lblInfo.setToolTipText("Please specify binding value: " + var);
                    return;
                }
                if (literal)
                    forced.addBinding(var, new RDFTermLiteral(value));
                else
                    forced.addBinding(var, new RDFTermURI(value));
            }
            String query = SPARQLSubscribe.getText().replaceAll("[\n\t]", "");
            lblInfo.setText("Running query...");
            long start = System.currentTimeMillis();
            response = sepaClient.query(query, forced);
            long stop = System.currentTimeMillis();
            String status = "DONE";
            if (response.isError()) {
                status = "FAILED " + ((ErrorResponse) response).getErrorMessage();
            } else {
                bindingsDM.clear();
                BindingsResults ret = ((QueryResponse) response).getBindingsResults();
                bindingsDM.setAddedResults(ret, null);
                status = " " + ret.size() + " bindings results";
            }
            lblInfo.setText("QUERY (" + (stop - start) + " ms) :" + status);
            lblInfo.setToolTipText("QUERY (" + (stop - start) + " ms) :" + status);
        }
    });
    GridBagConstraints gbc_btnQuery = new GridBagConstraints();
    gbc_btnQuery.insets = new Insets(0, 0, 0, 5);
    gbc_btnQuery.gridx = 0;
    gbc_btnQuery.gridy = 0;
    panel.add(btnQuery, gbc_btnQuery);
    btnSubscribe = new JButton("SUBSCRIBE");
    btnSubscribe.setEnabled(false);
    btnSubscribe.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (btnSubscribe.getText().equals("SUBSCRIBE")) {
                Bindings forced = new Bindings();
                for (int index = 0; index < subscribeForcedBindings.getRowCount(); index++) {
                    String value = (String) subscribeForcedBindings.getValueAt(index, 1);
                    boolean literal = (boolean) subscribeForcedBindings.getValueAt(index, 2);
                    String var = (String) subscribeForcedBindings.getValueAt(index, 0);
                    if (value.equals("")) {
                        lblInfo.setText("Please specify binding value: " + var);
                        lblInfo.setToolTipText("Please specify binding value: " + var);
                        return;
                    }
                    ;
                    if (literal)
                        forced.addBinding(var, new RDFTermLiteral(value));
                    else
                        forced.addBinding(var, new RDFTermURI(value));
                }
                String query = SPARQLSubscribe.getText().replaceAll("[\n\t]", "");
                response = sepaClient.subscribe(query, forced);
                if (response.getClass().equals(ErrorResponse.class)) {
                    lblInfo.setText(response.toString());
                    lblInfo.setToolTipText(response.toString());
                    return;
                }
                // SPUID and results
                String spuid = ((SubscribeResponse) response).getSpuid();
                BindingsResults ret = ((SubscribeResponse) response).getBindingsResults();
                // Subscription panel
                JPanel sub = new JPanel();
                // Results label
                JLabel infoLabel = new JLabel();
                infoLabel.setText("Subscribed. First results: " + ret.size());
                subscriptionResultsLabels.put(spuid, infoLabel);
                // Results table
                subscriptionResultsDM.put(spuid, new BindingsTableModel());
                JTable bindingsResultsTable = new JTable(subscriptionResultsDM.get(spuid));
                bindingsResultsTable.setDefaultRenderer(Object.class, bindingsRender);
                bindingsResultsTable.setAutoCreateRowSorter(true);
                bindingsResultsTable.registerKeyboardAction(new CopyAction(), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), JComponent.WHEN_FOCUSED);
                bindingsResultsTable.setCellSelectionEnabled(true);
                subscriptionResultsTables.put(spuid, bindingsResultsTable);
                subscriptionResultsDM.get(spuid).setAddedResults(ret, spuid);
                JScrollPane bindingsResults = new JScrollPane();
                bindingsResults.setViewportView(bindingsResultsTable);
                // Unsubscribe button
                JButton unsubscribeButton = new JButton(spuid);
                unsubscribeButton.setEnabled(true);
                unsubscribeButton.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        response = sepaClient.unsubscribe(spuid);
                        // if (response.isUnsubscribeResponse()) {
                        subscriptions.remove(sub);
                        subscriptionResultsDM.remove(spuid);
                        subscriptionResultsLabels.remove(spuid);
                        subscriptionResultsTables.remove(spuid);
                    // }
                    }
                });
                // Query label
                JLabel queryLabel = new JLabel("<html>" + query + " forced bindings: " + forced.toString() + "</html>");
                queryLabel.setFont(new Font("Arial", Font.BOLD, 14));
                // Layout
                GridBagConstraints layoutFill = new GridBagConstraints();
                layoutFill.fill = GridBagConstraints.BOTH;
                sub.setLayout(new BoxLayout(sub, BoxLayout.Y_AXIS));
                sub.setName(subscribesList.getSelectedValue());
                // Add components
                sub.add(queryLabel);
                sub.add(unsubscribeButton);
                sub.add(bindingsResults);
                sub.add(infoLabel);
                subscriptions.add(sub, layoutFill);
            }
        }
    });
    GridBagConstraints gbc_btnSubscribe = new GridBagConstraints();
    gbc_btnSubscribe.gridx = 1;
    gbc_btnSubscribe.gridy = 0;
    panel.add(btnSubscribe, gbc_btnSubscribe);
    JScrollPane bindingsResults = new JScrollPane();
    GridBagConstraints gbc_bindingsResults = new GridBagConstraints();
    gbc_bindingsResults.fill = GridBagConstraints.BOTH;
    gbc_bindingsResults.gridwidth = 2;
    gbc_bindingsResults.gridx = 0;
    gbc_bindingsResults.gridy = 3;
    primitives.add(bindingsResults, gbc_bindingsResults);
    bindingsResultsTable = new JTable(bindingsDM);
    bindingsResults.setViewportView(bindingsResultsTable);
    bindingsResultsTable.setDefaultRenderer(Object.class, bindingsRender);
    bindingsResultsTable.setAutoCreateRowSorter(true);
    bindingsResultsTable.registerKeyboardAction(new CopyAction(), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), JComponent.WHEN_FOCUSED);
    bindingsResultsTable.setCellSelectionEnabled(true);
    subscriptions = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("Subscriptions", null, subscriptions, null);
    JPanel namespaces = new JPanel();
    tabbedPane.addTab("Namespaces", null, namespaces, null);
    namespaces.setBorder(new TitledBorder(null, "Namespaces", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_namespaces = new GridBagLayout();
    gbl_namespaces.columnWidths = new int[] { 0, 0, 0 };
    gbl_namespaces.rowHeights = new int[] { 43, 0 };
    gbl_namespaces.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_namespaces.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
    namespaces.setLayout(gbl_namespaces);
    JScrollPane scrollPane_4 = new JScrollPane();
    GridBagConstraints gbc_scrollPane_4 = new GridBagConstraints();
    gbc_scrollPane_4.gridwidth = 2;
    gbc_scrollPane_4.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane_4.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_4.gridx = 0;
    gbc_scrollPane_4.gridy = 0;
    namespaces.add(scrollPane_4, gbc_scrollPane_4);
    namespacesTable = new JTable(namespacesDM);
    scrollPane_4.setViewportView(namespacesTable);
    JPanel infoPanel = new JPanel();
    GridBagConstraints gbc_infoPanel = new GridBagConstraints();
    gbc_infoPanel.anchor = GridBagConstraints.SOUTH;
    gbc_infoPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_infoPanel.gridx = 0;
    gbc_infoPanel.gridy = 2;
    frmSepaDashboard.getContentPane().add(infoPanel, gbc_infoPanel);
    GridBagLayout gbl_infoPanel = new GridBagLayout();
    gbl_infoPanel.columnWidths = new int[] { 73, 0, 0, 97, 76, 0 };
    gbl_infoPanel.rowHeights = new int[] { 29, 0 };
    gbl_infoPanel.columnWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    gbl_infoPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    infoPanel.setLayout(gbl_infoPanel);
    lblInfo = new JLabel("Info");
    GridBagConstraints gbc_lblInfo = new GridBagConstraints();
    gbc_lblInfo.anchor = GridBagConstraints.WEST;
    gbc_lblInfo.insets = new Insets(0, 10, 0, 5);
    gbc_lblInfo.gridx = 0;
    gbc_lblInfo.gridy = 0;
    infoPanel.add(lblInfo, gbc_lblInfo);
    ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
    chckbxClearonnotify = new JCheckBox("ClearOnNotify");
    chckbxClearonnotify.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
        }
    });
    GridBagConstraints gbc_chckbxClearonnotify = new GridBagConstraints();
    gbc_chckbxClearonnotify.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxClearonnotify.gridx = 1;
    gbc_chckbxClearonnotify.gridy = 0;
    infoPanel.add(chckbxClearonnotify, gbc_chckbxClearonnotify);
    JCheckBox chckbxQname = new JCheckBox("Qname");
    chckbxQname.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            bindingsRender.showAsQName(chckbxQname.isSelected());
            bindingsDM.fireTableDataChanged();
            for (BindingsTableModel table : subscriptionResultsDM.values()) {
                table.fireTableDataChanged();
            }
        }
    });
    chckbxQname.setSelected(true);
    GridBagConstraints gbc_chckbxQname = new GridBagConstraints();
    gbc_chckbxQname.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxQname.gridx = 2;
    gbc_chckbxQname.gridy = 0;
    infoPanel.add(chckbxQname, gbc_chckbxQname);
    chckbxAutoscroll = new JCheckBox("Autoscroll");
    GridBagConstraints gbc_chckbxAutoscroll = new GridBagConstraints();
    gbc_chckbxAutoscroll.anchor = GridBagConstraints.WEST;
    gbc_chckbxAutoscroll.insets = new Insets(0, 0, 0, 5);
    gbc_chckbxAutoscroll.gridx = 3;
    gbc_chckbxAutoscroll.gridy = 0;
    infoPanel.add(chckbxAutoscroll, gbc_chckbxAutoscroll);
    chckbxAutoscroll.setSelected(true);
    JButton btnClean = new JButton("Clear");
    GridBagConstraints gbc_btnClean = new GridBagConstraints();
    gbc_btnClean.anchor = GridBagConstraints.NORTHWEST;
    gbc_btnClean.gridx = 4;
    gbc_btnClean.gridy = 0;
    infoPanel.add(btnClean, gbc_btnClean);
    btnClean.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (primitives.isShowing()) {
                bindingsDM.clear();
                lblInfo.setText("Results cleaned");
                lblInfo.setToolTipText("Results cleaned");
            } else {
                for (String spuid : subscriptionResultsTables.keySet()) {
                    if (subscriptionResultsTables.get(spuid).isShowing()) {
                        subscriptionResultsDM.get(spuid).clear();
                        subscriptionResultsLabels.get(spuid).setText("Results cleaned");
                    }
                }
            }
        }
    });
    bindingsRender.setNamespaces(namespacesDM);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JTabbedPane(javax.swing.JTabbedPane) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) FileNotFoundException(java.io.FileNotFoundException) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) TitledBorder(javax.swing.border.TitledBorder) Properties(java.util.Properties) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral) Font(java.awt.Font) JFrame(javax.swing.JFrame) ChangeListener(javax.swing.event.ChangeListener) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) Response(it.unibo.arces.wot.sepa.commons.response.Response) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ChangeEvent(javax.swing.event.ChangeEvent) FileOutputStream(java.io.FileOutputStream) JTable(javax.swing.JTable) JSplitPane(javax.swing.JSplitPane)

Example 2 with BindingsResults

use of it.unibo.arces.wot.sepa.commons.sparql.BindingsResults in project SEPA by arces-wot.

the class SPUNaive method processInternal.

@Override
public Response processInternal(UpdateResponse update, int timeout) {
    logger.debug("* PROCESSING *" + request);
    Response ret;
    try {
        // Query the SPARQL processing service
        ret = queryProcessor.process(request, timeout);
        if (ret.getClass().equals(ErrorResponse.class)) {
            logger.error(ret);
            return ret;
        }
        // Current and previous bindings
        BindingsResults results = ((QueryResponse) ret).getBindingsResults();
        BindingsResults currentBindings = new BindingsResults(results);
        // Initialize the results with the current bindings
        BindingsResults added = new BindingsResults(results.getVariables(), null);
        BindingsResults removed = new BindingsResults(results.getVariables(), null);
        // Create empty bindings if null
        if (lastBindings == null)
            lastBindings = new BindingsResults(null, null);
        logger.debug("Current bindings: " + currentBindings);
        logger.debug("Last bindings: " + lastBindings);
        // Find removed bindings
        long start = System.nanoTime();
        for (Bindings solution : lastBindings.getBindings()) {
            if (!results.contains(solution) && !solution.isEmpty())
                removed.add(solution);
            else
                results.remove(solution);
        }
        long stop = System.nanoTime();
        logger.debug("Removed bindings: " + removed + " found in " + (stop - start) + " ns");
        // Find added bindings
        start = System.nanoTime();
        for (Bindings solution : results.getBindings()) {
            if (!lastBindings.contains(solution) && !solution.isEmpty())
                added.add(solution);
        }
        stop = System.nanoTime();
        logger.debug("Added bindings: " + added + " found in " + (stop - start) + " ns");
        // Update the last bindings with the current ones
        lastBindings = currentBindings;
        // Send notification (or end processing indication)
        if (!added.isEmpty() || !removed.isEmpty())
            ret = new Notification(getUUID(), new ARBindingsResults(added, removed), sequence++);
    } catch (Exception e) {
        ret = new ErrorResponse(500, e.getMessage());
    }
    return ret;
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) UpdateResponse(it.unibo.arces.wot.sepa.commons.response.UpdateResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) Notification(it.unibo.arces.wot.sepa.commons.response.Notification) SEPAProtocolException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse)

Example 3 with BindingsResults

use of it.unibo.arces.wot.sepa.commons.sparql.BindingsResults in project SEPA by arces-wot.

the class SPUNaive method init.

@Override
public boolean init() {
    logger.debug("Process SPARQL query " + request);
    // Process the SPARQL query
    Response ret = queryProcessor.process(request, ProcessorBeans.getQueryTimeout());
    if (ret.getClass().equals(ErrorResponse.class)) {
        logger.error("Not initialized");
        return false;
    }
    lastBindings = ((QueryResponse) ret).getBindingsResults();
    firstResults = new BindingsResults(lastBindings);
    logger.debug("First results: " + firstResults.toString());
    return true;
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) UpdateResponse(it.unibo.arces.wot.sepa.commons.response.UpdateResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults)

Example 4 with BindingsResults

use of it.unibo.arces.wot.sepa.commons.sparql.BindingsResults in project SEPA by arces-wot.

the class SPUNaive method postUpdateInternalProcessing.

@Override
public Notification postUpdateInternalProcessing(UpdateResponse res) throws SEPAProcessingException {
    logger.log(Level.getLevel("spu"), "@postUpdateInternalProcessing");
    Response ret = null;
    // Query the SPARQL processing service
    try {
        logger.log(Level.getLevel("spu"), "Query endpoint");
        ret = manager.processQuery(subscribe);
    } catch (SEPASecurityException | IOException e) {
        if (logger.isTraceEnabled())
            e.printStackTrace();
        logger.log(Level.getLevel("spu"), "SEPASecurityException " + e.getMessage());
        throw new SEPAProcessingException("postUpdateInternalProcessing exception " + e.getMessage());
    }
    if (ret.isError()) {
        logger.log(Level.getLevel("spu"), "SEPAProcessingException " + ret);
        throw new SEPAProcessingException("postUpdateInternalProcessing exception " + ret.toString());
    }
    // Current and previous bindings
    BindingsResults results = ((QueryResponse) ret).getBindingsResults();
    BindingsResults currentBindings = new BindingsResults(results);
    // Initialize the results with the current bindings
    BindingsResults added = new BindingsResults(results.getVariables(), null);
    BindingsResults removed = new BindingsResults(results.getVariables(), null);
    // Create empty bindings if null
    if (lastBindings == null)
        lastBindings = new BindingsResults(null, null);
    logger.trace("Current bindings: " + currentBindings);
    logger.trace("Last bindings: " + lastBindings);
    // Find removed bindings
    long start = System.nanoTime();
    for (Bindings solution : lastBindings.getBindings()) {
        if (!results.contains(solution) && !solution.isEmpty())
            removed.add(solution);
        else
            results.remove(solution);
    }
    long stop = System.nanoTime();
    logger.trace("Removed bindings: " + removed + " found in " + (stop - start) + " ns");
    // Find added bindings
    start = System.nanoTime();
    for (Bindings solution : results.getBindings()) {
        if (!lastBindings.contains(solution) && !solution.isEmpty())
            added.add(solution);
    }
    stop = System.nanoTime();
    logger.trace("Added bindings: " + added + " found in " + (stop - start) + " ns");
    // Update the last bindings with the current ones
    lastBindings = currentBindings;
    // Send notification (or end processing indication)
    if (!added.isEmpty() || !removed.isEmpty()) {
        logger.log(Level.getLevel("spu"), "Send notification");
        return new Notification(getSPUID(), new ARBindingsResults(added, removed));
    }
    logger.log(Level.getLevel("spu"), "Nothing to be notified");
    return null;
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) UpdateResponse(it.unibo.arces.wot.sepa.commons.response.UpdateResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) SEPASecurityException(it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException) IOException(java.io.IOException) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) SEPAProcessingException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAProcessingException) Notification(it.unibo.arces.wot.sepa.commons.response.Notification)

Example 5 with BindingsResults

use of it.unibo.arces.wot.sepa.commons.sparql.BindingsResults in project SEPA by arces-wot.

the class Consumer method onSemanticEvent.

@Override
public final void onSemanticEvent(Notification notify) {
    ARBindingsResults results = notify.getARBindingsResults();
    BindingsResults added = results.getAddedBindings();
    BindingsResults removed = results.getRemovedBindings();
    logger.debug("onSemanticEvent: " + notify.getSpuid() + " " + notify.getSequence());
    if (notify.getSequence() == 0) {
        onFirstResults(added);
        return;
    }
    onResults(results);
    // Dispatch different notifications based on notify content
    if (!added.isEmpty())
        onAddedResults(added);
    if (!removed.isEmpty())
        onRemovedResults(removed);
}
Also used : ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults) BindingsResults(it.unibo.arces.wot.sepa.commons.sparql.BindingsResults) ARBindingsResults(it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults)

Aggregations

ARBindingsResults (it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults)5 BindingsResults (it.unibo.arces.wot.sepa.commons.sparql.BindingsResults)5 QueryResponse (it.unibo.arces.wot.sepa.commons.response.QueryResponse)4 Response (it.unibo.arces.wot.sepa.commons.response.Response)4 ErrorResponse (it.unibo.arces.wot.sepa.commons.response.ErrorResponse)3 UpdateResponse (it.unibo.arces.wot.sepa.commons.response.UpdateResponse)3 Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)3 Notification (it.unibo.arces.wot.sepa.commons.response.Notification)2 SubscribeResponse (it.unibo.arces.wot.sepa.commons.response.SubscribeResponse)2 IOException (java.io.IOException)2 SEPAProcessingException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProcessingException)1 SEPAProtocolException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException)1 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)1 RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)1 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1