////////////////////////////////////////////////////////////
421365
private static void gameplay(Random r, GraphicalModel model, ConcatVector weights, ConcatVector[] humanFeatureVectors) {
        List<Integer> variablesList = new ArrayList<>();
        List<Integer> variableSizesList = new ArrayList<>();
        for (GraphicalModel.Factor f : model.factors) {
            for (int i = 0; i < f.neigborIndices.length; i++) {
                int j = f.neigborIndices[i];
                if (!variablesList.contains(j)) {
                    variablesList.add(j);
                    variableSizesList.add(f.featuresTable.getDimensions()[i]);
                }
            }
        }

        int[] variables = variablesList.stream().mapToInt(i->i).toArray();
        int[] variableSizes = variableSizesList.stream().mapToInt(i->i).toArray();

        List<SampleState> childrenOfRoot = new ArrayList<>();

        CliqueTree tree = new CliqueTree(model, weights);

        int initialFactors = model.factors.size();

        // Run some "samples"
        long start = System.currentTimeMillis();
        long marginalsTime = 0;
        for (int i = 0; i < 1000; i++) {
            System.err.println("\tTaking sample "+i);
            Stack<SampleState> stack = new Stack<>();
            SampleState state = selectOrCreateChildAtRandom(r, model, variables, variableSizes, childrenOfRoot, humanFeatureVectors);
            long localMarginalsTime = 0;
            // Each "sample" is 10 moves deep
            for (int j = 0; j < 10; j++) {
                // System.err.println("\t\tFrame "+j);
                state.push(model);
                assert(model.factors.size() == initialFactors+j+1);

                ///////////////////////////////////////////////////////////
                // This is the thing we're really benchmarking
                ///////////////////////////////////////////////////////////
                if (state.cachedMarginal == null) {
                    long s = System.currentTimeMillis();
                    state.cachedMarginal = tree.calculateMarginalsJustSingletons();
                    localMarginalsTime += System.currentTimeMillis() - s;
                }

                stack.push(state);
                state = selectOrCreateChildAtRandom(r, model, variables, variableSizes, state.children, humanFeatureVectors);
            }
            System.err.println("\t\t"+localMarginalsTime+" ms");
            marginalsTime += localMarginalsTime;

            while (!stack.empty()) {
                stack.pop().pop(model);
            }
            assert(model.factors.size() == initialFactors);
        }

        System.err.println("Marginals time: "+marginalsTime+" ms");
        System.err.println("Avg time per marginal: "+(marginalsTime / 200)+" ms");
        System.err.println("Total time: "+(System.currentTimeMillis() - start));
    }
609083
private void createProject() {

        CmsObject cms = A_CmsUI.getCmsObject();
        try {
            String name = "/";
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_fieldOU.getValue())) {
                name = CmsStringUtil.joinPaths(name, m_fieldOU.getValue());
            }
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_fieldName.getValue())) {
                name = CmsStringUtil.joinPaths(name, m_fieldName.getValue());
            } else {
                name = CmsStringUtil.joinPaths(name, "/");
            }

            m_project = cms.createProject(
                name,
                m_fieldDescription.getValue(),
                m_fieldUser.getValue(),
                m_fieldManager.getValue(),
                m_fieldDeleteAfterPublish.getValue().booleanValue()
                ? CmsProject.PROJECT_TYPE_TEMPORARY
                : CmsProject.PROJECT_TYPE_NORMAL);
            updateProjectResources();

        } catch (Throwable t) {
            CmsErrorDialog.showErrorDialog(t);
        }
    }
786923
void onCategorySelected(String columnId, int row) {
        Integer maxSelections = displayerSettings.isFilterSelfApplyEnabled() ? null : dataSet.getRowCount();
        filterUpdate(columnId, row, maxSelections);

        // Update the displayer in order to reflect the current selection
        // (only if not has already been redrawn in the previous filterUpdate() call)
        if (!displayerSettings.isFilterSelfApplyEnabled()) {
            updateVisualization();
        }
    }
785443
@Override
    public void actionCommit() {

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

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_msgInfo.getTo())) {
            setCommitErrors(
                Collections.singletonList((Throwable)new CmsIllegalStateException(
                    Messages.get().container(Messages.ERR_NO_SELECTED_USER_WITH_EMAIL_0))));
            return;
        }
        try {
            m_msgInfo.setTo(getEmailAddresses());
            m_msgInfo.sendEmail(getCms());
        } catch (Throwable t) {
            errors.add(t);
        } finally {
            m_msgInfo.setTo(getToNames());
        }
        // set the list of errors to display when saving failed
        setCommitErrors(errors);
    }
1364422
private void init(final Window window, final CmsAccountsApp app, final CmsUserSettings settings, boolean enabled) {

        m_userdata.initFields(m_user, enabled ? EditLevel.all : EditLevel.none);
        if (m_user != null) {
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_user.getFirstname())
                | CmsStringUtil.isEmptyOrWhitespaceOnly(m_user.getLastname())
                | CmsStringUtil.isEmptyOrWhitespaceOnly(m_user.getEmail())) {
                m_name_was_empty = true;
            }
        }
        iniLanguage(settings);
        iniProject(settings);
        iniSite(settings);
        iniStartView(settings);

        m_site.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 5111762655156037899L;

            public void valueChange(ValueChangeEvent event) {

                setupStartFolder(null);

            }

        });

        m_ok.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -2579639520410382246L;

            public void buttonClick(ClickEvent event) {

                setupValidators();
                if (isValid()) {
                    save();
                    window.close();
                    app.reload();
                }
            }
        });

        m_next.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -8584899970290349959L;

            public void buttonClick(ClickEvent event) {

                setupValidators();
                switchTab();

            }
        });

        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 5803825104722705175L;

            public void buttonClick(ClickEvent event) {

                window.close();
            }
        });

        if (m_user == null) {
            m_role.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 5697126133686172725L;

                public void valueChange(ValueChangeEvent event) {

                    iniSite(settings);
                    iniStartView(settings);
                }
            });
            m_group.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1512940002751242094L;

                public void valueChange(ValueChangeEvent event) {

                    iniStartView(settings);
                    iniSite(settings);
                }

            });
        }

        m_site.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = -169973382455098800L;

            public void valueChange(ValueChangeEvent event) {

                m_startfolder.setCmsObject(getCmsObjectWithSite((String)m_site.getValue()));

            }

        });

        m_generateButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = 4128513094772586752L;

            public void buttonClick(ClickEvent event) {

                final Window windowDialog = CmsBasicDialog.prepareWindow(CmsBasicDialog.DialogWidth.content);
                windowDialog.setCaption(
                    CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_GEN_PASSWORD_CAPTION_0));
                CmsGeneratePasswordDialog dialog = new CmsGeneratePasswordDialog(
                    CmsUserEditDialog.this,
                    new Runnable() {

                        public void run() {

                            windowDialog.close();

                        }
                    });
                windowDialog.setContent(dialog);
                A_CmsUI.get().addWindow(windowDialog);
            }
        });
    }
1233206
public function init()
    {
        /* @var $options MailOptions */
        $options = $this->getServiceLocator()
            ->getServiceLocator()
            ->get(MailOptions::class);

        $emailAddresses = $options->getAddressList();

        $addressList = [];

        foreach ($emailAddresses as $transport => $address) {

            $addressList[] = [
                'label' => $address['name'] . ' <' . $address['address'] . '>',
                'value' => $transport,
            ];
        }

        $this->setValueOptions($addressList);
    }
1086042
public static void main(String[] args) {
    SparkSession spark = SparkSession
      .builder()
      .appName("Java Spark SQL user-defined Datasets aggregation example")
      .getOrCreate();

    // $example on:typed_custom_aggregation$
    Encoder<Employee> employeeEncoder = Encoders.bean(Employee.class);
    String path = "examples/src/main/resources/employees.json";
    Dataset<Employee> ds = spark.read().json(path).as(employeeEncoder);
    ds.show();
    // +-------+------+
    // |   name|salary|
    // +-------+------+
    // |Michael|  3000|
    // |   Andy|  4500|
    // | Justin|  3500|
    // |  Berta|  4000|
    // +-------+------+

    MyAverage myAverage = new MyAverage();
    // Convert the function to a `TypedColumn` and give it a name
    TypedColumn<Employee, Double> averageSalary = myAverage.toColumn().name("average_salary");
    Dataset<Double> result = ds.select(averageSalary);
    result.show();
    // +--------------+
    // |average_salary|
    // +--------------+
    // |        3750.0|
    // +--------------+
    // 
    spark.stop();
  }
184044
function() {
      this.tableOptions = inputEx.cn('a', {href: '#'}, null, msgs.tableOptions);
      this.options.parentEl.appendChild(this.tableOptions);
      
      this.tableOptionsDlg = new YAHOO.widget.SimpleDialog( Dom.generateId(), {
              width: "30em",
		        visible: false,
		        modal: true,
		        buttons: [ 
				      { text:msgs.columnDialogCloseButton,  handler: function(e) { this.hide(); } }
              ],
              fixedcenter: true,
              constrainToViewport: true
	   });
	
		Dom.addClass(this.tableOptionsDlg.element.firstChild, "inputex-datatable-columnsDlg");
		
	   this.tableOptionsDlg.bodyId = Dom.generateId();
	   this.tableOptionsDlg.setHeader(msgs.columnDialogTitle);
	   this.tableOptionsDlg.setBody("<div id='"+this.tableOptionsDlg.bodyId+"'></div>");
	   this.tableOptionsDlg.render(document.body);
   }
1126843
@Override
    public void onInteractionEvent(final InteractionEvent event) {
        QName id = event.getId();
        QName source = (QName)event.getSource();

        final Set<Procedure> collection = procedures.get(id);
        Procedure execution = null;

        if(collection!=null)
        {
            for(Procedure consumer : collection) {

                // TODO: This isn't optimal (creation of new resource with every comparison)
                Resource<ResourceType> resource = new Resource<ResourceType>(id, ResourceType.Interaction);
                resource.setSource(source);

                boolean justified = consumer.getJustification() == null
                        || source.equals(consumer.getJustification());

                if(consumer.doesConsume(resource) && justified)
                {
                    execution = consumer;
                    break;
                }
            }
        }

        if(null==execution)
        {
            Window.alert("No procedure for " + event);
            Log.warn("No procedure for " + event);
        }
        else if(execution.getPrecondition().isMet(getStatementContext(source)))   // guarded
        {
            try {
                execution.getCommand().execute(InteractionCoordinator.this.dialog, event.getPayload());
            } catch (Throwable e) {
                Log.error("Failed to execute procedure "+execution, e);
            }
        }

    }
819036
void submit() {

        CmsObject cms = A_CmsUI.getCmsObject();
        try {
            List<CmsUUID> changedIds = Lists.newArrayList();
            CmsResourceDeleteMode mode = (CmsResourceDeleteMode)m_deleteSiblings.getValue();
            for (CmsResource resource : m_context.getResources()) {
                changedIds.add(resource.getStructureId());
                CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(cms, resource);
                try {
                    cms.deleteResource(cms.getSitePath(resource), mode);
                } finally {
                    if (lockRecord.getChange().equals(LockChange.locked)) {
                        if (!resource.getState().isNew()) {
                            try {
                                cms.unlockResource(resource);
                            } catch (CmsVfsResourceNotFoundException e) {
                                LOG.warn(e.getLocalizedMessage(), e);
                            } catch (CmsLockException e) {
                                LOG.warn(e.getLocalizedMessage(), e);
                            }
                        }
                    }
                }
            }
            m_context.finish(changedIds);
        } catch (Exception e) {
            m_context.error(e);
        }
    }
340663
static void forEachColumnInContentValue(MethodSpec.Builder methodBuilder, final SQLiteModelMethod method, String columnSetString, boolean generateColumnNameCheck, OnColumnListener listener) {
		methodBuilder.beginControlFlow("for (String columnName:$L)", columnSetString);
		if (generateColumnNameCheck) {
			methodBuilder.beginControlFlow("if (!$L.contains(columnName))", method.contentProviderMethodName + "ColumnSet");
			methodBuilder.addStatement("throw new $T(String.format(\"For URI '$L', column '%s' does not exists in table '%s' or can not be defined in this $L operation\", columnName, $S ))",
					KriptonRuntimeException.class, method.contentProviderUriTemplate, method.jql.operationType, method.getEntity().getTableName());
			methodBuilder.endControlFlow();
		}
		if (listener != null)
			listener.onColumnCheck(methodBuilder, "columnName");
		methodBuilder.endControlFlow();
	}
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);
    }
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));
                                  }
                              });
            }
        }
    }
32076
function (config, cb) {

        var o = {}, k;

        for (k in this.baseConfig) {
            if (this.baseConfig.hasOwnProperty(k)) {
                o[k] = this.baseConfig[k];
            }
        }

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        if (!o.workflowId) {
            o.workflowId = String(Math.random()).substr(2);
        }

        this.workflowId = o.workflowId;

        this.swfClient.startWorkflowExecution(o, function (err, result) {
            cb(err, result ? result.runId : null);
        });
    }
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);
        }
    }
1234050
@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        lblMessage = new javax.swing.JLabel();
        barProgressActivity = new javax.swing.JProgressBar();
        cmdCancelOperation = new javax.swing.JButton();

        setLayout(new java.awt.GridBagLayout());

        lblMessage.setText("Executing Query");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        add(lblMessage, gridBagConstraints);

        barProgressActivity.setIndeterminate(true);
        barProgressActivity.setMinimumSize(new java.awt.Dimension(200, 15));
        barProgressActivity.setPreferredSize(new java.awt.Dimension(300, 18));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
        add(barProgressActivity, gridBagConstraints);

        cmdCancelOperation.setText("Cancel Operation");
        cmdCancelOperation.setEnabled(false);
        cmdCancelOperation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	cmdCancelOperationActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
        add(cmdCancelOperation, gridBagConstraints);
    }
295230
public static List<UserCustomColumn> createRequiredColumns(
			int startingIndex, String idColumnName) {

		if (idColumnName == null) {
			idColumnName = COLUMN_ID;
		}

		List<UserCustomColumn> columns = new ArrayList<>();
		columns.add(createIdColumn(startingIndex++, idColumnName));
		columns.add(createDataColumn(startingIndex++));
		columns.add(createContentTypeColumn(startingIndex++));

		return columns;
	}