/////////////////////////////////////////////////////////////////
764796
public void parseDiagramInterchangeElements() {
    // Multiple BPMNDiagram possible
    List<Element> diagrams = rootElement.elementsNS(BPMN_DI_NS, "BPMNDiagram");
    if (!diagrams.isEmpty()) {
      for (Element diagramElement : diagrams) {
        parseBPMNDiagram(diagramElement);
      }
    }
  }
1183142
function onCreating(model, attrs, options) {
            if (!model.get('author_id')) {
                if (model.get('authors')) {
                    model.set('author_id', model.get('authors')[0].id);
                } else {
                    model.set('author_id', this.contextUser(options));
                }
            }

            if (!model.get('authors')) {
                model.set('authors', [{
                    id: model.get('author_id')
                }]);
            }

            return this._handleOptions('onCreating')(model, attrs, options);
        }
799726
void onDataSetSelected() {
        String selectedUUID = view.getSelectedDataSetId();
        for (DataSetDef dataSetDef : _dataSetDefList) {
            if (dataSetDef.getUUID().equals(selectedUUID)) {
                fetchMetadata(selectedUUID,
                              new RemoteCallback<DataSetMetadata>() {

                                  public void callback(DataSetMetadata metadata) {
                                      dataSetLookup = lookupConstraints.newDataSetLookup(metadata);
                                      updateDataSetLookup();
                                      changeEvent.fire(new DataSetLookupChangedEvent(dataSetLookup));
                                  }
                              });
            }
        }
    }
1276100
@Override
  protected void reserveInternal(int newCapacity) {
    if (isArray() || type instanceof MapType) {
      int[] newLengths = new int[newCapacity];
      int[] newOffsets = new int[newCapacity];
      if (this.arrayLengths != null) {
        System.arraycopy(this.arrayLengths, 0, newLengths, 0, capacity);
        System.arraycopy(this.arrayOffsets, 0, newOffsets, 0, capacity);
      }
      arrayLengths = newLengths;
      arrayOffsets = newOffsets;
    } else if (type instanceof BooleanType) {
      if (byteData == null || byteData.length < newCapacity) {
        byte[] newData = new byte[newCapacity];
        if (byteData != null) System.arraycopy(byteData, 0, newData, 0, capacity);
        byteData = newData;
      }
    } else if (type instanceof ByteType) {
      if (byteData == null || byteData.length < newCapacity) {
        byte[] newData = new byte[newCapacity];
        if (byteData != null) System.arraycopy(byteData, 0, newData, 0, capacity);
        byteData = newData;
      }
    } else if (type instanceof ShortType) {
      if (shortData == null || shortData.length < newCapacity) {
        short[] newData = new short[newCapacity];
        if (shortData != null) System.arraycopy(shortData, 0, newData, 0, capacity);
        shortData = newData;
      }
    } else if (type instanceof IntegerType || type instanceof DateType ||
      DecimalType.is32BitDecimalType(type)) {
      if (intData == null || intData.length < newCapacity) {
        int[] newData = new int[newCapacity];
        if (intData != null) System.arraycopy(intData, 0, newData, 0, capacity);
        intData = newData;
      }
    } else if (type instanceof LongType || type instanceof TimestampType ||
        DecimalType.is64BitDecimalType(type)) {
      if (longData == null || longData.length < newCapacity) {
        long[] newData = new long[newCapacity];
        if (longData != null) System.arraycopy(longData, 0, newData, 0, capacity);
        longData = newData;
      }
    } else if (type instanceof FloatType) {
      if (floatData == null || floatData.length < newCapacity) {
        float[] newData = new float[newCapacity];
        if (floatData != null) System.arraycopy(floatData, 0, newData, 0, capacity);
        floatData = newData;
      }
    } else if (type instanceof DoubleType) {
      if (doubleData == null || doubleData.length < newCapacity) {
        double[] newData = new double[newCapacity];
        if (doubleData != null) System.arraycopy(doubleData, 0, newData, 0, capacity);
        doubleData = newData;
      }
    } else if (childColumns != null) {
      // Nothing to store.
    } else {
      throw new RuntimeException("Unhandled " + type);
    }

    byte[] newNulls = new byte[newCapacity];
    if (nulls != null) System.arraycopy(nulls, 0, newNulls, 0, capacity);
    nulls = newNulls;

    capacity = newCapacity;
  }
1323653
private void checkIndices(int row, int col) {
        if (row < 0 || col < 0 || row >= rows || col >= cols) {
            throw new IndexOutOfBoundsException();
        }
    }
102814
private void initSelectBoxes() {

        m_atNumber.getOpener().setStyleName(
            org.opencms.acacia.client.css.I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().selectBoxSelected());
        m_atNumber.getSelectorPopup().addStyleName(I_CmsLayoutBundle.INSTANCE.globalWidgetCss().selectBoxPopup());
        m_atNumber.setWidth("80px");
        m_atNumber.addOption(
            WeekOfMonth.FIRST.toString(),
            Messages.get().key(Messages.GUI_SERIALDATE_WEEKDAYNUMBER_1_0));
        m_atNumber.addOption(
            WeekOfMonth.SECOND.toString(),
            Messages.get().key(Messages.GUI_SERIALDATE_WEEKDAYNUMBER_2_0));
        m_atNumber.addOption(
            WeekOfMonth.THIRD.toString(),
            Messages.get().key(Messages.GUI_SERIALDATE_WEEKDAYNUMBER_3_0));
        m_atNumber.addOption(
            WeekOfMonth.FOURTH.toString(),
            Messages.get().key(Messages.GUI_SERIALDATE_WEEKDAYNUMBER_4_0));
        m_atNumber.addOption(
            WeekOfMonth.LAST.toString(),
            Messages.get().key(Messages.GUI_SERIALDATE_WEEKDAYNUMBER_5_0));
        m_atDay.getOpener().setStyleName(
            org.opencms.acacia.client.css.I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().selectBoxSelected());
        m_atDay.getSelectorPopup().addStyleName(I_CmsLayoutBundle.INSTANCE.globalWidgetCss().selectBoxPopup());
        m_atDay.setWidth("100px");
        m_atDay.addOption(WeekDay.SUNDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_SUNDAY_0));
        m_atDay.addOption(WeekDay.MONDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_MONDAY_0));
        m_atDay.addOption(WeekDay.TUESDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_TUESDAY_0));
        m_atDay.addOption(WeekDay.WEDNESDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_WEDNESDAY_0));
        m_atDay.addOption(WeekDay.THURSDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_THURSDAY_0));
        m_atDay.addOption(WeekDay.FRIDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_FRIDAY_0));
        m_atDay.addOption(WeekDay.SATURDAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DAY_SATURDAY_0));

        m_atMonth.getOpener().setStyleName(
            org.opencms.acacia.client.css.I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().selectBoxSelected());
        m_everyMonth.getSelectorPopup().addStyleName(I_CmsLayoutBundle.INSTANCE.globalWidgetCss().selectBoxPopup());
        m_atMonth.setWidth("100px");
        m_atMonth.addOption(Month.JANUARY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JAN_0));
        m_atMonth.addOption(Month.FEBRUARY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_FEB_0));
        m_atMonth.addOption(Month.MARCH.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_MAR_0));
        m_atMonth.addOption(Month.APRIL.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_APR_0));
        m_atMonth.addOption(Month.MAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_MAY_0));
        m_atMonth.addOption(Month.JUNE.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JUN_0));
        m_atMonth.addOption(Month.JULY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JUL_0));
        m_atMonth.addOption(Month.AUGUST.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_AUG_0));
        m_atMonth.addOption(Month.SEPTEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_SEP_0));
        m_atMonth.addOption(Month.OCTOBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_OCT_0));
        m_atMonth.addOption(Month.NOVEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_NOV_0));
        m_atMonth.addOption(Month.DECEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_DEC_0));

        m_everyMonth.getOpener().setStyleName(
            org.opencms.acacia.client.css.I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().selectBoxSelected());
        m_everyMonth.getSelectorPopup().addStyleName(I_CmsLayoutBundle.INSTANCE.globalWidgetCss().selectBoxPopup());
        m_everyMonth.setWidth("100px");
        m_everyMonth.addOption(Month.JANUARY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JAN_0));
        m_everyMonth.addOption(Month.FEBRUARY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_FEB_0));
        m_everyMonth.addOption(Month.MARCH.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_MAR_0));
        m_everyMonth.addOption(Month.APRIL.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_APR_0));
        m_everyMonth.addOption(Month.MAY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_MAY_0));
        m_everyMonth.addOption(Month.JUNE.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JUN_0));
        m_everyMonth.addOption(Month.JULY.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_JUL_0));
        m_everyMonth.addOption(Month.AUGUST.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_AUG_0));
        m_everyMonth.addOption(Month.SEPTEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_SEP_0));
        m_everyMonth.addOption(Month.OCTOBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_OCT_0));
        m_everyMonth.addOption(Month.NOVEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_NOV_0));
        m_everyMonth.addOption(Month.DECEMBER.toString(), Messages.get().key(Messages.GUI_SERIALDATE_YEARLY_DEC_0));

    }
1363690
@Override
    public void onCreate(SQLiteDatabase db) {
        try {
            if(builder.tables == null){
                throw new SQLiteHelperException("The array of String tables can't be null!!");
            }
            executePragma(db);

            builder.onCreateCallback.onCreate(db);
        } catch (SQLiteHelperException e) {
            Log.e(this.getClass().toString(), Log.getStackTraceString(e), e);
        }
    }
926579
public void make()
    throws Exception
  {
    for (int i = 0; i < _makeList.size(); i++) {
      Make make = _makeList.get(i);

      make.make();
    }
  }
853206
@Override
    public void configure(String parameters) {
        if (parameters.isEmpty()) {
            return;
        }
        LinkedList<Double> values = new LinkedList<Double>();

        List<String> strValues = Op.split(parameters, " ");
        for (String strValue : strValues) {
            values.add(Op.toDouble(strValue));
        }

        if (values.size() % 2 == 0) {
            setHeight(1.0);
        } else {
            setHeight(values.removeLast());
        }
        setXY(toPairs(values));
    }
398336
@Override
    public void actionCommit() {

        List<Throwable> errors = new ArrayList<Throwable>();

        boolean isEmail = (getParamMsgtype() != null) && getParamMsgtype().equals(MSGTYPE_EMAIL);

        if ((m_groups == null) || m_groups.isEmpty()) {
            setCommitErrors(
                Collections.singletonList((Throwable)new CmsIllegalStateException(
                    Messages.get().container(Messages.ERR_NO_SELECTED_GROUP_0))));
            return;
        }

        boolean hasUser = false;
        Iterator<String> itGroups = getGroups().iterator();
        while (!hasUser && itGroups.hasNext()) {
            String groupName = itGroups.next();
            try {
                Iterator<CmsUser> itUsers = getCms().getUsersOfGroup(groupName, true).iterator();
                while (!hasUser && itUsers.hasNext()) {
                    CmsUser user = itUsers.next();
                    if (!isEmail) {
                        if (!OpenCms.getSessionManager().getSessionInfos(user.getId()).isEmpty()) {
                            hasUser = true;
                        }
                    } else {
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(user.getEmail())) {
                            hasUser = true;
                        }
                    }
                }
            } catch (CmsException e) {
                // should never happen
            }
        }

        if (!hasUser) {
            setCommitErrors(
                Collections.singletonList((Throwable)new CmsIllegalStateException(
                    Messages.get().container(Messages.ERR_NO_SELECTED_RECEIVERS_0))));
            return;
        }

        try {
            Set<String> groups = new HashSet<String>(m_groups);
            Map<String, String[]> params = new HashMap<String, String[]>();
            params.put(CmsToolDialog.PARAM_STYLE, new String[] {CmsToolDialog.STYLE_NEW});
            params.put(
                CmsSendEmailGroupsDialog.PARAM_GROUPS,
                new String[] {CmsStringUtil.collectionAsString(groups, CmsHtmlList.ITEM_SEPARATOR)});
            params.put(
                CmsDialog.PARAM_CLOSELINK,
                new String[] {CmsToolManager.linkForToolPath(getJsp(), "/workplace/broadcast")});

            if (isEmail) {
                getToolManager().jspForwardPage(
                    this,
                    "/system/workplace/admin/workplace/groups_send_email.jsp",
                    params);
            } else {
                getToolManager().jspForwardPage(
                    this,
                    "/system/workplace/admin/workplace/groups_send_popup.jsp",
                    params);
            }
        } catch (Throwable t) {
            errors.add(t);
        }
        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
1191621
void submit() {

        List<CmsUUID> selectedIds = getSelectedIds();
        List<CmsUUID> updated = Lists.newArrayList();
        CmsObject cms = m_dialogContext.getCms();
        try {
            for (CmsUUID selectedId : selectedIds) {
                cms.restoreDeletedResource(selectedId);
                updated.add(selectedId);
            }
            m_dialogContext.finish(updated);
        } catch (CmsException e) {
            m_dialogContext.error(e);
        }
    }
917582
function(data) {
            if (data.row.index === 5) {
                data.cell.styles.fillColor = [40, 170, 100];
            }

            if ((data.row.section === 'head' || data.row.section === 'foot') && data.column.dataKey === "expenses") {
                data.cell.text = '' // Use an icon in didDrawCell instead
            }

            if (data.row.index === 0 && data.row.section === 'body' && data.column.dataKey === 'city') {
                data.cell.text = 'とうきょう'
            }
        }
771132
@Override
    public void handleSelection(final CmsResourceTypeBean selectedType) {

        CmsObject cms = A_CmsUI.getCmsObject();
        m_selectedType = selectedType;
        try {

            CmsNewResourceBuilder builder = new CmsNewResourceBuilder(cms);
            builder.addCallback(new I_Callback() {

                public void onError(Exception e) {

                    m_dialogContext.error(e);
                }

                public void onResourceCreated(CmsNewResourceBuilder builderParam) {

                    finish(Lists.newArrayList(builderParam.getCreatedResource().getStructureId()));
                }
            });

            m_selectedType = selectedType;

            Boolean useDefaultLocation = m_defaultLocationCheckbox.getValue();
            if (useDefaultLocation.booleanValue() && (m_selectedType.getCreatePath() != null)) {
                try {
                    CmsADEConfigData configData = OpenCms.getADEManager().lookupConfiguration(
                        cms,
                        m_folderResource.getRootPath());

                    CmsResourceTypeConfig typeConfig = configData.getResourceType(m_selectedType.getType());
                    if (typeConfig != null) {
                        typeConfig.configureCreateNewElement(cms, m_folderResource.getRootPath(), builder);
                    }
                } catch (Exception e) {
                    m_dialogContext.error(e);
                }

            } else {
                boolean explorerNameGenerationMode = false;
                String sitePath = cms.getRequestContext().removeSiteRoot(m_folderResource.getRootPath());
                String namePattern = m_selectedType.getNamePattern();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(namePattern)) {
                    namePattern = OpenCms.getWorkplaceManager().getDefaultNamePattern(m_selectedType.getType());
                    explorerNameGenerationMode = true;
                }
                String fileName = CmsStringUtil.joinPaths(sitePath, namePattern);
                builder.setPatternPath(fileName);
                builder.setType(m_selectedType.getType());
                builder.setExplorerNameGeneration(explorerNameGenerationMode);

            }
            CmsPropertyDialogExtension ext = new CmsPropertyDialogExtension(A_CmsUI.get(), null);
            CmsAppWorkplaceUi.get().disableGlobalShortcuts();
            ext.editPropertiesForNewResource(builder);
            finish(new ArrayList<CmsUUID>());

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
1163445
function buildOptions (provinceNodeElement, provinces) {
  var defaultValue = provinceNodeElement.getAttribute('data-default');

  provinces.forEach(function (option) {
    var optionElement = document.createElement('option');
    optionElement.value = option[0];
    optionElement.textContent = option[1];

    provinceNodeElement.appendChild(optionElement);
  })

  if (defaultValue && getOption(provinceNodeElement, defaultValue)) {
    provinceNodeElement.value = defaultValue;
  }
}
110711
@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        lblMappingID = new javax.swing.JLabel();
        pnlTestButton = new javax.swing.JPanel();
        cmdTestQuery = new javax.swing.JButton();
        lblTestQuery = new javax.swing.JLabel();
        pnlCommandButton = new javax.swing.JPanel();
        cmdInsertMapping = new javax.swing.JButton();
        cmdCancel = new javax.swing.JButton();
        txtMappingID = new javax.swing.JTextField();
        splitTargetSource = new javax.swing.JSplitPane();
        pnlTargetQueryEditor = new javax.swing.JPanel();
        lblTargetQuery = new javax.swing.JLabel();
        scrTargetQuery = new javax.swing.JScrollPane();
        txtTargetQuery = new javax.swing.JTextPane();
        splitSQL = new javax.swing.JSplitPane();
        pnlSourceQueryEditor = new javax.swing.JPanel();
        lblSourceQuery = new javax.swing.JLabel();
        scrSourceQuery = new javax.swing.JScrollPane();
        txtSourceQuery = new javax.swing.JTextPane();
        pnlQueryResult = new javax.swing.JPanel();
        scrQueryResult = new javax.swing.JScrollPane();
        tblQueryResult = new javax.swing.JTable();

        setFocusable(false);
        setMinimumSize(new java.awt.Dimension(600, 500));
        setPreferredSize(new java.awt.Dimension(600, 500));
        setLayout(new java.awt.GridBagLayout());

        lblMappingID.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblMappingID.setText("Mapping ID:");
        lblMappingID.setFocusable(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(8, 10, 8, 0);
        add(lblMappingID, gridBagConstraints);

        cmdTestQuery.setIcon(IconLoader.getImageIcon("images/execute.png"));
        cmdTestQuery.setMnemonic('t');
        cmdTestQuery.setText("Test SQL Query");
        cmdTestQuery.setToolTipText("Execute the SQL query in the SQL query text pane\nand display the first 100 results in the table.");
        cmdTestQuery.setActionCommand("Test SQL query");
        cmdTestQuery.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        cmdTestQuery.setContentAreaFilled(false);
        cmdTestQuery.setIconTextGap(5);
        cmdTestQuery.setMaximumSize(new java.awt.Dimension(115, 25));
        cmdTestQuery.setMinimumSize(new java.awt.Dimension(115, 25));
        cmdTestQuery.setPreferredSize(new java.awt.Dimension(115, 25));
        cmdTestQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdTestQueryActionPerformed(evt);
            }
        });
        pnlTestButton.add(cmdTestQuery);

        lblTestQuery.setText("(100 rows)");
        pnlTestButton.add(lblTestQuery);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.insets = new java.awt.Insets(4, 10, 0, 0);
        add(pnlTestButton, gridBagConstraints);

        pnlCommandButton.setFocusable(false);
        pnlCommandButton.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        cmdInsertMapping.setIcon(IconLoader.getImageIcon("images/accept.png"));
        cmdInsertMapping.setText("Accept");
        cmdInsertMapping.setToolTipText("This will add/edit the current mapping into the OBDA model");
        cmdInsertMapping.setActionCommand("OK");
        cmdInsertMapping.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        cmdInsertMapping.setContentAreaFilled(false);
        cmdInsertMapping.setIconTextGap(5);
        cmdInsertMapping.setPreferredSize(new java.awt.Dimension(90, 25));
        pnlCommandButton.add(cmdInsertMapping);

        cmdCancel.setIcon(IconLoader.getImageIcon("images/cancel.png"));
        cmdCancel.setText("Cancel");
        cmdCancel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        cmdCancel.setContentAreaFilled(false);
        cmdCancel.setIconTextGap(5);
        cmdCancel.setPreferredSize(new java.awt.Dimension(90, 25));
        cmdCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdCancelActionPerformed(evt);
            }
        });
        pnlCommandButton.add(cmdCancel);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 4);
        add(pnlCommandButton, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 10);
        add(txtMappingID, gridBagConstraints);

        splitTargetSource.setBorder(null);
        splitTargetSource.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        splitTargetSource.setResizeWeight(0.5);
        splitTargetSource.setDoubleBuffered(true);
        splitTargetSource.setFocusable(false);
        splitTargetSource.setMinimumSize(new java.awt.Dimension(600, 430));
        splitTargetSource.setOneTouchExpandable(true);
        splitTargetSource.setPreferredSize(new java.awt.Dimension(600, 430));

        pnlTargetQueryEditor.setFocusable(false);
        pnlTargetQueryEditor.setMinimumSize(new java.awt.Dimension(600, 180));
        pnlTargetQueryEditor.setPreferredSize(new java.awt.Dimension(600, 180));
        pnlTargetQueryEditor.setLayout(new java.awt.BorderLayout());

        lblTargetQuery.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblTargetQuery.setText("Target (Triples Template):");
        lblTargetQuery.setFocusable(false);
        pnlTargetQueryEditor.add(lblTargetQuery, java.awt.BorderLayout.NORTH);

        scrTargetQuery.setFocusable(false);
        scrTargetQuery.setMinimumSize(new java.awt.Dimension(600, 170));
        scrTargetQuery.setPreferredSize(new java.awt.Dimension(600, 170));

        txtTargetQuery.setFont(new java.awt.Font("Lucida Sans Typewriter", 0, 13)); // NOI18N
        txtTargetQuery.setFocusCycleRoot(false);
        txtTargetQuery.setMinimumSize(new java.awt.Dimension(600, 170));
        txtTargetQuery.setPreferredSize(new java.awt.Dimension(600, 170));
        scrTargetQuery.setViewportView(txtTargetQuery);

        pnlTargetQueryEditor.add(scrTargetQuery, java.awt.BorderLayout.CENTER);

        splitTargetSource.setLeftComponent(pnlTargetQueryEditor);

        splitSQL.setBorder(null);
        splitSQL.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        splitSQL.setResizeWeight(0.8);
        splitSQL.setFocusable(false);
        splitSQL.setMinimumSize(new java.awt.Dimension(600, 280));
        splitSQL.setOneTouchExpandable(true);
        splitSQL.setPreferredSize(new java.awt.Dimension(600, 280));

        pnlSourceQueryEditor.setFocusable(false);
        pnlSourceQueryEditor.setMinimumSize(new java.awt.Dimension(600, 150));
        pnlSourceQueryEditor.setPreferredSize(new java.awt.Dimension(600, 150));
        pnlSourceQueryEditor.setLayout(new java.awt.BorderLayout());

        lblSourceQuery.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblSourceQuery.setText("Source (SQL Query):");
        lblSourceQuery.setFocusable(false);
        pnlSourceQueryEditor.add(lblSourceQuery, java.awt.BorderLayout.NORTH);

        scrSourceQuery.setFocusable(false);

        txtSourceQuery.setFont(new java.awt.Font("Lucida Sans Typewriter", 0, 13)); // NOI18N
        txtSourceQuery.setFocusCycleRoot(false);
        scrSourceQuery.setViewportView(txtSourceQuery);

        pnlSourceQueryEditor.add(scrSourceQuery, java.awt.BorderLayout.CENTER);

        splitSQL.setTopComponent(pnlSourceQueryEditor);

        pnlQueryResult.setFocusable(false);
        pnlQueryResult.setMinimumSize(new java.awt.Dimension(600, 120));
        pnlQueryResult.setPreferredSize(new java.awt.Dimension(600, 120));
        pnlQueryResult.setLayout(new java.awt.BorderLayout());

        scrQueryResult.setFocusable(false);
        scrQueryResult.setPreferredSize(new java.awt.Dimension(454, 70));

        tblQueryResult.setMinimumSize(new java.awt.Dimension(600, 180));
        scrQueryResult.setViewportView(tblQueryResult);

        pnlQueryResult.add(scrQueryResult, java.awt.BorderLayout.CENTER);

        splitSQL.setBottomComponent(pnlQueryResult);

        splitTargetSource.setRightComponent(splitSQL);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
        add(splitTargetSource, gridBagConstraints);

        getAccessibleContext().setAccessibleName("Mapping editor");
    }
225808
public static void main(String args[]) throws Exception {

		// create Options object
		Options options = new Options();
		// add options
		options.addOption("path", true,
				"path to the Linear BDB index that contains the training vectors: e.g. C:/lef/BDB_1024/");
		options.addOption("d", true, "the dimensionality of the training vectors: e.g. 128 or 1024");
		options.addOption("m", true,
				"the number of subvectors to be created (d should be divided exactly by m)");
		options.addOption("c", true, "the number of centroids of each subquantizer: e.g. 256 or 1024");
		options.addOption("transform", true,
				"the type of transformation to apply before learning the product quantizer");
		options.addOption("samples", true, "how many learning vectors to use: e.g. 20000");
		options.addOption("i", true, "the maximum number of clustering iterations (default 100).");
		options.addOption("s", true, "the number of parallel execution slots to use in k-means clustering");

		options.addOption("split", false,
				"whether to also split the training vectors before learning the sub-quantizers");
		options.addOption("ivf", false,
				"whether product quantization will be combined with an inverted file (ivf)");
		options.addOption("cqfile", true, "path to the coarse quantizer file");
		options.addOption("cqcentroids", true, "number of coarse quantizer centroids: e.g. 8192");

		CommandLineParser parser = new PosixParser();
		CommandLine cmd = null;
		try {
			cmd = parser.parse(options, args);
		} catch (ParseException e) {
			System.out.println(e.getMessage());
			System.exit(0);
		}

		HelpFormatter formatter = new HelpFormatter();
		formatter.printHelp("Product quantization learning", options, true);

		// the following two parameters get the default value of false is they are
		// not passed in the console
		boolean split = cmd.hasOption("split");
		if (split) {
			System.out.println("Vectors will be splitted");
		} else {
			System.out.println("Splitting will not be performed");
		}
		String transformationType = null;
		if (cmd.getOptionValue("transform").equals("no")) {
			System.out.println("No transformation will be applied");
			transformationType = "no";
		} else if (cmd.getOptionValue("transform").equals("rr")) {
			System.out.println("Random Rotation will be applied");
			transformationType = "rr";
		} else if (cmd.getOptionValue("transform").equals("rp")) {
			System.out.println("Random Permutation will be applied");
			transformationType = "rp";
		} else {
			throw new Exception("Unsupported transformation type!");
		}
		boolean ivf = cmd.hasOption("ivf");
		String coarseQuantizerFile = "";
		int numCoarseCentroids = 0;
		if (ivf) {
			System.out.println("IVF will be used");
			// parse the other ivf related options
			if (cmd.getOptionValue("cqfile") == null) {
				throw new Exception("IVF selected but coarse quantizer file not given.");
			}
			coarseQuantizerFile = cmd.getOptionValue("cqfile");

			if (cmd.getOptionValue("cqcentroids") == null) {
				throw new Exception("IVF selected but number of coarse quantizer centroids not given.");
			}
			numCoarseCentroids = Integer.parseInt(cmd.getOptionValue("cqcentroids"));
		}

		int numVectors;
		if (cmd.getOptionValue("samples") == null) {
			System.out.println("Using the default 50000 samples for learning.");
			numVectors = 50000;
		} else {
			numVectors = Integer.parseInt(cmd.getOptionValue("samples"));
			System.out.println("Using " + numVectors + " samples for learning.");
		}

		int maxIterations;
		if (cmd.getOptionValue("i") == null) {
			System.out.println("Using the default 100 max iterations.");
			maxIterations = 100;
		} else {
			maxIterations = Integer.parseInt(cmd.getOptionValue("i"));
			System.out.println("Using " + maxIterations + " maximum iterations.");
		}

		String BDBpath = cmd.getOptionValue("path");
		if (cmd.getOptionValue("path") == null) {
			throw new Exception("The path to the training vectors is undefined!");
		}

		int numSlots = 1;
		if (cmd.getOptionValue("s") == null) {
			System.out.println("Using 1 execution slot!");
		}
		numSlots = Integer.parseInt(cmd.getOptionValue("s"));

		int vectorLength;
		if (cmd.getOptionValue("d") == null) {
			throw new Exception("The dimensionality of the training vectors is undefined!");
		}
		vectorLength = Integer.parseInt(cmd.getOptionValue("d"));

		int numProductCentroids;
		if (cmd.getOptionValue("d") == null) {
			throw new Exception("The number of centroids for each sub-quantizer is undefined!");
		}
		numProductCentroids = Integer.parseInt(cmd.getOptionValue("c"));

		int m;
		if (cmd.getOptionValue("m") == null) {
			throw new Exception("The number of sub-vectors is undefined!");
		}
		m = Integer.parseInt(cmd.getOptionValue("m"));
		// checking that m is valid
		int subVectorLength;// the dimensionality of the subvectors
		if (vectorLength % m != 0) { // d is not a multiple of m
			throw new Exception("d is not a multiple of m");
		}
		subVectorLength = vectorLength / m;

		RandomRotation rr = null;
		RandomPermutation rp = null;
		if (transformationType.equals("rr")) {
			rr = new RandomRotation(1, vectorLength);
		} else if (transformationType.equals("rp")) {
			rp = new RandomPermutation(1, vectorLength);
		}

		System.out.println("== Creating subquantizers using " + numVectors + " vectors ==");
		System.out.println("Vector dimensionality: " + vectorLength);
		System.out.println("Sub vector dimensionality: " + subVectorLength);
		System.out.println("Num centroids: " + numProductCentroids);
		System.out.println("Max iterations: " + maxIterations);

		// create a single file to store all the sub-quantizers of the product quantizer
		// construct the filename
		String subquantizersFilename = BDBpath + "/pq_" + vectorLength + "_" + m + "x"
				+ (int) (Math.log(numProductCentroids) / Math.log(2)) + "_" + numVectors;
		if (transformationType.equals("rr")) {
			subquantizersFilename += "_rr";
		} else if (transformationType.equals("rp")) {
			subquantizersFilename += "_rp";
		}
		if (ivf) {
			subquantizersFilename += "_ivf_c" + numCoarseCentroids;
		}
		subquantizersFilename += ".csv";
		BufferedWriter out = new BufferedWriter(new FileWriter(new String(subquantizersFilename)));

		// load the vectors from the Linear index (BDB store)
		Linear vectors = new Linear(vectorLength, numVectors, true, BDBpath, false, true, 0);
		// in case of ivf, load the coarse quantizer so that residual vectors can be computed.
		ResidualVectorComputation res = null;
		if (ivf) {
			double[][] coarseQuantizer = AbstractFeatureAggregator.readQuantizer(coarseQuantizerFile,
					numCoarseCentroids, vectorLength);
			res = new ResidualVectorComputation(coarseQuantizer, vectorLength, numCoarseCentroids);
		}

		// create one Instances object for learning each sub-quantizer
		Instances[] datasets = new Instances[m];
		// creating weka attributes
		ArrayList<Attribute> attributes = new ArrayList<Attribute>();
		for (int i = 0; i < subVectorLength; i++) {
			Attribute attr = new Attribute("feature" + (i + 1));
			attributes.add(attr);
		}
		for (int i = 0; i < m; i++) {
			datasets[i] = new Instances("subvectors", attributes, numVectors);
		}

		// load the sub-vectors into the corresponding Instances objects
		for (int i = 0; i < numVectors; i++) {
			double[] vector = vectors.getVector(i);
			// compute the residual vector if needed
			if (ivf) {
				vector = res.ComputeResidualVector(vector);
			}
			// apply the appropriate transformation
			if (transformationType.equals("rr")) {
				vector = rr.rotate(vector);
			} else if (transformationType.equals("rp")) {
				vector = rp.permute(vector);
			}
			// load each sub-vector into the corresponding Instances object
			for (int j = 0; j < m; j++) {
				double[] subVector = Arrays.copyOfRange(vector, j * subVectorLength, j * subVectorLength
						+ subVectorLength);
				DenseInstance instance = new DenseInstance(1.0, subVector);
				datasets[j].add(instance);
			}
		}

		// learning the sub-quantizers with k-means clustering
		for (int i = 0; i < m; i++) {
			System.out.println("Learning sub-quantizer " + (i + 1));
			double minSSE = Double.MAX_VALUE;
			SimpleKMeans bestClusterer = null;
			// try k-mean using numKmeansRepeats different random seeds and keep the one with lowest SSE
			for (int j = 0; j < numKmeansRepeats; j++) {
				// Create a new k-means instance
				SimpleKMeans clusterer = new SimpleKMeans();
				clusterer.setInitializationMethod(new SelectedTag(SimpleKMeans.KMEANS_PLUS_PLUS,
						SimpleKMeans.TAGS_SELECTION));
				clusterer.setNumExecutionSlots(numSlots);
				clusterer.setNumClusters(numProductCentroids);
				clusterer.setMaxIterations(maxIterations);
				// clusterer.setDebug(false);
				clusterer.setSeed(j + 1);
				// build the clusterer
				clusterer.buildClusterer(datasets[i]);
				double SSE = clusterer.getSquaredError();
				if (SSE < minSSE) {
					minSSE = SSE;
					bestClusterer = (SimpleKMeans) AbstractClusterer.makeCopy(clusterer);
				}
			}

			System.out.println("Mininum SSE: " + minSSE + " Seed: " + bestClusterer.getSeed());
			System.out.println("Saving best sub-quantizer in file..");
			// write the results of the clustering to the new file (csv formated)
			Instances clusterCentroids = bestClusterer.getClusterCentroids();
			for (int j = 0; j < clusterCentroids.numInstances(); j++) {
				Instance centroid = clusterCentroids.instance(j);
				for (int k = 0; k < centroid.numAttributes() - 1; k++) {
					out.write(centroid.value(k) + ",");
				}
				out.write(centroid.value(centroid.numAttributes() - 1) + "\n");
			}

			// check whether fewer than the desired clusters where generated and add fake centroids in that
			// case
			int numCentroidsMissing = numProductCentroids - clusterCentroids.numInstances();
			// add fake, distant centroids so that no vector is quantized in them
			if (numCentroidsMissing > 0) {
				System.out
						.println("Problem! Number of generated clusters is smaller that the desired one. Use more samples!");
				System.out.println("Non empty clusters: " + clusterCentroids.numInstances() + " instead of: "
						+ numProductCentroids);
				// System.exit(1);
				// Random rand = new Random(1);
				for (int k = 0; k < numCentroidsMissing; k++) {
					// int index = rand.nextInt(dataset.numInstances());
					// String instanceString = dataset.instance(index).toStringNoWeight();
					// outputStream.println(instanceString);
					for (int f = 0; f < subVectorLength - 1; f++) {
						out.write("1000,");
					}
					out.write("1000\n");
				}
			}
			out.flush();
		}
		out.close();

	}
174709
function () {
/*Line 30 - 'AtomSortableColumn.js' */                if (!this._value)
/*Line 31 - 'AtomSortableColumn.js' */                    return;
/*Line 32 - 'AtomSortableColumn.js' */                if (this._value.indexOf(this._sortField) == -1) {
/*Line 33 - 'AtomSortableColumn.js' */                    AtomBinder.setValue(this, "direction", "");
/*Line 34 - 'AtomSortableColumn.js' */                    return;
/*Line 35 - 'AtomSortableColumn.js' */                }

/*Line 37 - 'AtomSortableColumn.js' */                if (this._value.lastIndexOf("desc") != this._value.length - 4) {
/*Line 38 - 'AtomSortableColumn.js' */                    AtomBinder.setValue(this, "direction", "asc");
/*Line 39 - 'AtomSortableColumn.js' */                } else {
/*Line 40 - 'AtomSortableColumn.js' */                    AtomBinder.setValue(this, "direction", "desc");
/*Line 41 - 'AtomSortableColumn.js' */                }
/*Line 42 - 'AtomSortableColumn.js' */            }