/* gibt für einen hbci-gv ("saldo3") die liste aller ll-job-parameter
zurück
322017
public List<String> getGVParameterNames(Document document, String gvname, String version) {
        ArrayList<String> ret = new ArrayList<>();
        Element gvdef = document.getElementById(gvname + version);
        NodeList gvcontent = gvdef.getChildNodes();
        int len = gvcontent.getLength();

        boolean first = true;
        for (int i = 0; i < len; i++) {
            Node contentref = gvcontent.item(i);

            if (contentref.getNodeType() == Node.ELEMENT_NODE) {
                // skip seghead
                if (first) {
                    first = false;
                } else {
                    addLowlevelProperties(document, ret, "", (Element) contentref);
                }
            }
        }

        return ret;
    }
1347834
public JobDetails getJobByJobID(String cluster, String jobId)
      throws IOException {
    return getJobByJobID(cluster, jobId, false);
  }
840193
public static int cusolverDnSsyevd_bufferSize(
        cusolverDnHandle handle, 
        int jobz, 
        int uplo, 
        int n, 
        Pointer A, 
        int lda, 
        Pointer W, 
        int[] lwork)
    {
        return checkResult(cusolverDnSsyevd_bufferSizeNative(handle, jobz, uplo, n, A, lda, W, lwork));
    }
985991
public function jsonDataAction()
    {
        $limit = null; $start = null; $order = 0;
        if ($this->_paging) {
            $limit = $this->getRequest()->getParam('limit');
            $start = $this->getRequest()->getParam('start');
            if (!$limit) {
                if (!is_array($this->_paging) && $this->_paging > 0) {
                    $limit = $this->_paging;
                } else if (is_array($this->_paging) && isset($this->_paging['pageSize'])) {
                    $limit = $this->_paging['pageSize'];
                } else {
                    $limit = $this->_paging;
                }
            }

// wird vermutlich nicht benötigt, da beim ersten laden 'sortInfo' in den metadaten drin ist
// falls es irgendwo benötigt wird wieder einkommentieren
//             $this->view->order = $order;
        }

        //TODO: dieser code sollte in _getOrder liegen
        $order = $this->_defaultOrder;
        if ($this->getRequest()->getParam('sort')) {
            $order['field'] = $this->getRequest()->getParam('sort');
        }
        if ($this->_getParam("direction") && $this->_getParam('direction') != 'undefined') {
            $order['direction'] = $this->_getParam('direction');
        }

        $primaryKey = $this->_primaryKey;

        $rowSet = $this->_fetchData($order, $limit, $start);
        if (!is_null($rowSet)) {
            if (isset($this->_paging['type']) && $this->_paging['type'] == 'Date') {
                //nothing to do, we don't know the total
            } else if ($this->_paging) {
                $this->view->total = $this->_fetchCount();
            } else {
                $this->view->total = sizeof($rowSet);
            }

            $number = 0;
            if ($start) $number = $start;
            $rows = array();
            foreach ($rowSet as $row) {
                $r = array();
                if (is_array($row)) {
                    $row = (object)$row;
                }
                if (!$this->_hasPermissions($row, 'load')) {
                    throw new Kwf_Exception("You don't have the permissions to load this row");
                }
                foreach ($this->_columns as $column) {
                    if ($column instanceof Kwf_Grid_Column_RowNumberer) continue;
                    if ($column->getShowIn() & Kwf_Grid_Column::SHOW_IN_GRID) {
                        $data = $column->load($row, Kwf_Grid_Column::ROLE_DISPLAY, array(
                                                    'number' => $number,
                                                    'total' => $this->view->total,
                                                ));
                        $r[$column->getDataIndex()] = $data;
                    }
                }
                if (!isset($r[$primaryKey]) && isset($row->$primaryKey)) {
                    $r[$primaryKey] = $row->$primaryKey;
                }
                $rows[] = $r;
                $number++;
            }

            $this->view->rows = $rows;
        } else {
            $this->view->total = 0;
            $this->view->rows = array();
        }

        if ($this->getRequest()->getParam('meta')) {
            $this->_appendMetaData();
        }
    }
413548
@Override
    public Collection<String> resumeJobs(GroupMatcher<JobKey> matcher, JedisCluster jedis) throws JobPersistenceException {
        Set<String> resumedJobGroups = new HashSet<>();
        if (matcher.getCompareWithOperator() == StringMatcher.StringOperatorName.EQUALS) {
            final String jobGroupSetKey = redisSchema.jobGroupSetKey(new JobKey("", matcher.getCompareToValue()));
            Long unpauseResponse = jedis.srem(redisSchema.pausedJobGroupsSet(), jobGroupSetKey);
            Set<String> jobsResponse = jedis.smembers(jobGroupSetKey);
            if (unpauseResponse > 0) {
                resumedJobGroups.add(redisSchema.jobGroup(jobGroupSetKey));
            }
            for (String job : jobsResponse) {
                resumeJob(redisSchema.jobKey(job), jedis);
            }
        } else {
            for (final String jobGroupSetKey : jedis.smembers(redisSchema.jobGroupsSet())) {
                if (matcher.getCompareWithOperator().evaluate(redisSchema.jobGroup(jobGroupSetKey), matcher.getCompareToValue())) {
                    resumedJobGroups.addAll(resumeJobs(GroupMatcher.jobGroupEquals(redisSchema.jobGroup(jobGroupSetKey)), jedis));
                }
            }
        }
        return resumedJobGroups;
    }
577780
public JobDetails getJobByJobID(String cluster, String jobId,
      boolean populateTasks) throws IOException {
    return getJobByJobID(new QualifiedJobId(cluster, jobId), populateTasks);
  }
468307
private BTag createDay(AccountReport9 report) {
        BTag tag = new BTag();
        tag.start = new Saldo();
        tag.end = new Saldo();
        tag.starttype = 'F';
        tag.endtype = 'F';

        ////////////////////////////////////////////////////////////////
        // Start- un End-Saldo ermitteln
        final long day = 24 * 60 * 60 * 1000L;
        for (CashBalance1 bal : report.getBal()) {
            BalanceType8Code code = bal.getTp().getCd();

            // Schluss-Saldo vom Vortag.
            if (code == BalanceType8Code.PRCD) {
                tag.start.value = new Value(this.checkDebit(bal.getAmt().getValue(), bal.getCdtDbtInd()));
                tag.start.value.setCurr(bal.getAmt().getCcy());

                //  Wir erhoehen noch das Datum um einen Tag, damit aus dem
                // Schlusssaldo des Vortages der Startsaldo des aktuellen Tages wird.
                tag.start.timestamp = new Date(SepaUtil.toDate(bal.getDt().getDt()).getTime() + day);
            }

            // End-Saldo
            else if (code == BalanceType8Code.CLBD) {
                tag.end.value = new Value(this.checkDebit(bal.getAmt().getValue(), bal.getCdtDbtInd()));
                tag.end.value.setCurr(bal.getAmt().getCcy());
                tag.end.timestamp = SepaUtil.toDate(bal.getDt().getDt());
            }
        }
        //
        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Das eigene Konto ermitteln
        CashAccount13 acc = report.getAcct();
        tag.my = new Konto();
        tag.my.iban = trim(acc.getId().getIBAN());
        tag.my.curr = trim(acc.getCcy());

        BranchAndFinancialInstitutionIdentification3 bank = acc.getSvcr();
        if (bank != null && bank.getFinInstnId() != null)
            tag.my.bic = trim(bank.getFinInstnId().getBIC());
        ////////////////////////////////////////////////////////////////

        return tag;
    }
627574
private void saveBasicValues(HashMap<String, String> result, int ref) {
        // wenn noch keine basic-daten gespeichert sind
        if (jobResult.getDialogId() == null) {
            // Pfad des originalen MsgHead-Segmentes holen und um "orig_" ergaenzen,
            // um den Key fuer die entsprechenden Daten in das result-Property zu erhalten
            String msgheadName = "orig_" + result.get("1");

            jobResult.storeResult("basic.dialogid", result.get(msgheadName + ".dialogid"));
            jobResult.storeResult("basic.msgnum", result.get(msgheadName + ".msgnum"));
            jobResult.storeResult("basic.segnum", Integer.toString(ref));

            log.debug("basic values for " + getName() + " set to "
                + jobResult.getDialogId() + "/"
                + jobResult.getMsgNum()
                + "/" + jobResult.getSegNum());
        }
    }
1132077
public boolean propagateValue(String destPath, String value, boolean tryToCreate, boolean allowOverwrite) {
        boolean ret = false;

        if (destPath.equals(getPath())) {
            if (value != null && value.equals("requested"))
                this.haveRequestTag = true;
            else
                throw new HBCI_Exception(HBCIUtils.getLocMsg("EXCMSG_INVVALUE", new Object[]{destPath, value}));
            ret = true;
        } else {
            // damit überspringen wir gleich elemente, bei denen es mit
            // sicherheit nicht funktionieren kann
            if (destPath.startsWith(getPath())) {
                for (MultipleSyntaxElements l : childContainers) {
                    if (l.propagateValue(destPath, value, tryToCreate, allowOverwrite)) {
                        ret = true;
                        break;
                    }
                }

                if (!ret && tryToCreate) {
                    // der Wert konnte nicht gesetzt werden -> möglicherweise
                    // existiert ja nur der entsprechende child-container noch
                    // nicht
                    log.trace(getPath() + ": could not set value for " + destPath);

                    // Namen des fehlenden Elementes ermitteln
                    String subPath = destPath.substring(getPath().length() + 1);
                    log.trace("  subpath is " + subPath);
                    int dotPos = subPath.indexOf('.');
                    if (dotPos == -1) {
                        dotPos = subPath.length();
                    }
                    String subType = subPath.substring(0, dotPos);
                    log.trace("  subname is " + subType);
                    int counterPos = subType.indexOf('_');
                    if (counterPos != -1) {
                        subType = subType.substring(0, counterPos);
                    }
                    log.trace("  subType is " + subType);

                    // hier überprüfen, ob es wirklich noch keinen child-container
                    // mit diesem Namen gibt. Wenn z.B. der pfad msg.gv.ueb.kik.blz
                    // gesucht wird und msg.gv schon existiert, wird diese methode
                    // hier in msg.gv ausgeführt. wenn sie fehlschlägt (z.b. weil
                    // tatsächlich kein .ueb.kik.blz angelegt werden kann), wird false
                    // ("can not propagate") zurückgegeben. im übergeordneten modul
                    // (msg) soll dann nicht versucht werden, das nächste sub-element
                    // (gv) anzulegen - dieser test merkt, dass es "gv" schon gibt
                    boolean found = false;
                    for (MultipleSyntaxElements c : childContainers) {
                        if (c.getName().equals(subType)) {
                            found = true;
                            break;
                        }
                    }

                    if (!found) {
                        // jetzt durch alle child-elemente des definierenden XML-Knotens
                        // loopen und den ref-Knoten suchen, der das fehlende Element
                        // beschreibt
                        int newChildIdx = 0;
                        Node ref;
                        found = false;
                        for (ref = def.getFirstChild(); ref != null; ref = ref.getNextSibling()) {
                            if (ref.getNodeType() == Node.ELEMENT_NODE) {
                                String type = ((Element) ref).getAttribute("type");
                                String name = ((Element) ref).getAttribute("name");
                                if (name.length() == 0) {
                                    name = type;
                                }
                                if (name.equals(subType)) {
                                    found = true;
                                    break;
                                }
                                newChildIdx++;
                            }
                        }

                        if (found) {
                            // entsprechenden child-container erzeugen
                            MultipleSyntaxElements child = createNewChildContainer(ref, document);
                            child.setParent(this);
                            child.setSyntaxIdx(newChildIdx);

                            if (getElementTypeName().equals("MSG"))
                                log.trace("child container " + child.getPath() + " has syntaxIdx=" + child.getSyntaxIdx());

                            // aktuelle child-container-liste durchlaufen und den neu
                            // erzeugten child-container dort richtig einsortieren
                            int newPosi = 0;
                            for (MultipleSyntaxElements c : childContainers) {
                                if (c.getSyntaxIdx() > newChildIdx) {
                                    // der gerade betrachtete child-container hat einen idx
                                    // gröÃer als den des einzufügenden elementes, also wird
                                    // sich diese position gemerkt und das element hier eingefügt
                                    break;
                                }
                                newPosi++;
                            }
                            log.trace("  inserting child container with syntaxIdx " + newChildIdx + " at position " + newPosi);
                            childContainers.add(newPosi, child);

                            // now try to propagate the value to the newly created child
                            ret = child.propagateValue(destPath, value, tryToCreate, allowOverwrite);
                        }
                    } else {
                        log.trace("  subtype " + subType + " already existing - will not try to create");
                    }
                }
            }
        }

        return ret;
    }
101123
private void findSpecNameForGV(String jobnameLL) {
        int maxVersion = 0;
        StringBuilder key = new StringBuilder();

        // alle param-segmente durchlaufen
        Map<String, String> bpd = passport.getBPD();
        for (String path : bpd.keySet()) {
            key.setLength(0);
            key.append(path);

            if (key.indexOf("Params") == 0) {
                key.delete(0, key.indexOf(".") + 1);

                // wenn segment mit namen des aktuellen jobs gefunden wurde
                if (key.indexOf(jobnameLL + "Par") == 0 &&
                    key.toString().endsWith(".SegHead.code")) {
                    key.delete(0, jobnameLL.length() + ("Par").length());

                    // extrahieren der versionsnummer aus dem spez-namen
                    String st = key.substring(0, key.indexOf("."));
                    int version = 0;

                    try {
                        version = Integer.parseInt(st);
                    } catch (Exception e) {
                        log.warn("found invalid job version: key=" + key + ", jobnameLL=" + jobnameLL + " (this is a " +
                            "known, but harmless bug)");
                    }

                    // merken der größten jemals aufgetretenen versionsnummer
                    if (version != 0) {
                        log.debug("task " + jobnameLL + " is supported with segment version " + st);
                        if (version > maxVersion) {
                            maxVersion = version;
                        }
                    }
                }
            }
        }

        if (maxVersion == 0 && !jobnameLL.equals(GVRawSEPA.getLowlevelName())) {
            maxVersion = 1;
            log.warn("Using segment version " + maxVersion + " for job " + jobnameLL + ", although not found in BPD. " +
                "This may fail");
            throw new JobNotSupportedException(jobnameLL);
        }

        // namen+versionsnummer speichern
        this.jobName = jobnameLL;
        this.segVersion = maxVersion;
        this.name = jobnameLL + this.segVersion;
    }
491726
@Override
	public HTCashbillJobState[] listActiveJob(String CorpNum, String UserID)
			throws PopbillException {
		return httpget("/HomeTax/Cashbill/JobList", CorpNum, UserID, HTCashbillJobState[].class);
	}
1096860
public String getWorkerGcParameter(LocalAssignment assignment,
                                       Map totalConf,
                                       String topologyId,
                                       Integer port) {

        StringBuilder commandSB = new StringBuilder();
        GcStrategy gcStrategy = GcStrategyManager.getGcStrategy(totalConf);
        return gcStrategy.toString();
    }
983745
function hslToRgb(h, s, l, a, out) {
		function hueToRgb(m1, m2, h) {
			h = h % 1;
			if (h < 0) {
				h += 1;
			}
			if (h < 1 / 6) {
				return m1 + (m2 - m1) * h * 6;
			}
			if (h < 1 / 2) {
				return m2;
			}
			if (h < 2 / 3) {
				return m1 + (m2 - m1) * (2/3 - h) * 6;
			}
			return m1;
		}

		var m1, m2;
		if (l < 0.5) {
			m2 = l * (s + 1);
		} else {
			m2 = l + s - l * s;
		}
		m1 = l * 2 - m2;

		if (!out) {
			out = [];
		}

		out[0] = hueToRgb(m1, m2, h + 1/3);
		out[1] = hueToRgb(m1, m2, h);
		out[2] = hueToRgb(m1, m2, h - 1/3);
		out[3] = a;

		return out;
	}
1145410
public static void validatePersistedJobInstanceIds(JobInstanceEntity instance) throws PersistenceException {
        if (instance.getInstanceId() <= 0) {

            long id = instance.getInstanceId();

            PersistenceException e = new PersistenceException(new BatchIllegalIDPersistedException(Long.toString(id)));
            logger.log(Level.SEVERE, "error.invalid.persisted.job.id",
                       new Object[] { Long.toString(id), e });

            throw e;
        }

    }
501856
@Override
  public List<? extends ProducerJob> partitionJobs() {
    UrlTrieNode root = _jobNode.getRight();
    if (isOperatorEquals() || root.getSize() == 1) {
      //Either at an Equals-Node or a Leaf-Node, both of which actually has actual size 1.
      return super.partitionJobs();
    } else {
      if (_groupSize <= 1) {
        throw new RuntimeException("This is impossible. When group size is 1, the operator must be equals");
      }

      UrlTrie trie = new UrlTrie(getPage(), root);
      int gs = Math.min(root.getSize(), _groupSize);

      UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, (int) Math.ceil(gs / 2.0));

      List<TrieBasedProducerJob> jobs = new ArrayList<>();
      while (grouper.hasNext()) {
        jobs.add(new TrieBasedProducerJob(_startDate, _endDate, grouper.next(), grouper.getGroupSize()));
      }
      return jobs;
    }
  }
1165056
@Override
    public String incomingClearText(String st, Document document, String msgName) {
        // empfangene Nachricht parsen, dabei die validvalues-Überprüfung weglassen
        String myMsgName = msgName + "Res";
        Message msg = new Message(myMsgName, st, document,
            Message.CHECK_SEQ, Message.DONT_CHECK_VALIDS);

        // in einer Schleife durch alle SuppSecMethods-Datensätze laufen
        for (int i = 0; ; i++) {
            String elemBaseName = HBCIUtils.withCounter(myMsgName + ".BPD.SecMethod.SuppSecMethods", i);
            SyntaxElement elem = msg.getElement(elemBaseName + ".method");

            if (elem == null) {
                break;
            }

            // Methodenbezeichner extrahieren
            String method = elem.toString();
            if (method.equals("TAN")) { // "TAN" ist ungültiger Bezeichner
                log.warn("there is an invalid sec type (TAN) in this BPD - removing it");

                // Elternelement finden (Segment "SecMethods")
                SyntaxElement parent = elem.getParent().getParent().getParent().getParent();
                String parentPath = parent.getPath();
                int number = 0;

                // durch alle Elemente dieses Segmentes laufen, bis die Multiple-DEG
                // mit den unterstützten SecMethods gefunden wurde
                for (Iterator<MultipleSyntaxElements> it = parent.getChildContainers().iterator(); it.hasNext(); ) {
                    MultipleSyntaxElements childContainer = it.next();
                    if (childContainer.getPath().equals(parentPath + ".SuppSecMethods")) {
                        // die Anzahl der eingestellten unterstützten SecMethods herausholen
                        number = childContainer.getElements().size();
                        break;
                    }
                }

                int startpos;
                int endpos;

                /* wenn mehr als eine SecMethod im Segment stand, dann braucht nur
                 * das eine der multiplen DEGs entfernt werden. Wenn aber nur die eine
                 * fehlerhafte Info enthalten war, dann muss das gesamte Segment
                 * entfernt werden, weil ein SecMethods-Segment ohne tatsächliche Daten
                 * über unterstützte SecMethods ungültig ist. */

                if (number > 1) { // nur das eine fehlerhafte TAN:1 löschen
                    startpos = elem.getPosInMsg();
                    endpos = startpos
                        + 1
                        + elem.toString(0).length()
                        + 1
                        + msg.getElement(elemBaseName + ".version").toString(0).length();
                } else { // komplettes segment "SecMethod" löschen
                    startpos = parent.getPosInMsg() + 1;
                    endpos = startpos + parent.toString(0).length();
                    /* der Fehler, der hier gemacht wird (nachfolgende Segment-
                     * Sequenznummern sind falsch), wird durch ein nachgeschaltetes
                     * Olly-Modul korrigiert */
                }

                st = new StringBuffer(st).delete(startpos, endpos).toString();
                log.debug("new message after removing: " + st);
                break;
            }
        }
        return st;
    }
676707
private List<BatchIdAndResultId> getQueryResultIds(String entity, List<Predicate> predicateList) throws Exception {
    if (!bulkApiLogin()) {
      throw new IllegalArgumentException("Invalid Login");
    }

    try {
      boolean usingPkChunking = false;

      // Set bulk job attributes
      this.bulkJob.setObject(entity);
      this.bulkJob.setOperation(this.bulkApiUseQueryAll ? OperationEnum.queryAll : OperationEnum.query);
      this.bulkJob.setConcurrencyMode(ConcurrencyMode.Parallel);

      // use pk chunking if pk chunking is configured and the expected record count is larger than the pk chunking size
      if (this.pkChunking && (this.pkChunkingSkipCountCheck || getExpectedRecordCount() > this.pkChunkingSize)) {
        log.info("Enabling pk chunking with size {}", this.pkChunkingSize);
        this.bulkConnection.addHeader("Sforce-Enable-PKChunking", "chunkSize=" + this.pkChunkingSize);
        usingPkChunking = true;
      }

      // Result type as CSV
      this.bulkJob.setContentType(ContentType.CSV);

      this.bulkJob = this.bulkConnection.createJob(this.bulkJob);
      this.bulkJob = this.bulkConnection.getJobStatus(this.bulkJob.getId());

      // Construct query with the predicates
      String query = this.updatedQuery;
      if (!isNullPredicate(predicateList)) {
        String limitString = getLimitFromInputQuery(query);
        query = query.replace(limitString, "");

        Iterator<Predicate> i = predicateList.listIterator();
        while (i.hasNext()) {
          Predicate predicate = i.next();
          query = SqlQueryUtils.addPredicate(query, predicate.getCondition());
        }

        query = query + limitString;
      }

      log.info("QUERY:" + query);
      ByteArrayInputStream bout = new ByteArrayInputStream(query.getBytes(ConfigurationKeys.DEFAULT_CHARSET_ENCODING));

      BatchInfo bulkBatchInfo = this.bulkConnection.createBatchFromStream(this.bulkJob, bout);

      long expectedSizePerBatch = usingPkChunking ? this.pkChunkingSize : this.getExpectedRecordCount();

      int retryInterval = Math.min(MAX_RETRY_INTERVAL_SECS,
          30 + (int) Math.ceil((float) expectedSizePerBatch / 10000) * 2);
      log.info("Salesforce bulk api retry interval in seconds:" + retryInterval);

      // Get batch info with complete resultset (info id - refers to the resultset id corresponding to entire resultset)
      bulkBatchInfo = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bulkBatchInfo.getId());

      // wait for completion, failure, or formation of PK chunking batches
      while ((bulkBatchInfo.getState() != BatchStateEnum.Completed)
          && (bulkBatchInfo.getState() != BatchStateEnum.Failed)
          && (!usingPkChunking || bulkBatchInfo.getState() != BatchStateEnum.NotProcessed)) {
        Thread.sleep(retryInterval * 1000);
        bulkBatchInfo = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bulkBatchInfo.getId());
        log.debug("Bulk Api Batch Info:" + bulkBatchInfo);
        log.info("Waiting for bulk resultSetIds");
      }

      // Wait for pk chunking batches
      BatchInfoList batchInfoList = this.bulkConnection.getBatchInfoList(this.bulkJob.getId());

      if (usingPkChunking && bulkBatchInfo.getState() == BatchStateEnum.NotProcessed) {
        bulkBatchInfo = waitForPkBatches(batchInfoList, retryInterval);
      }

      if (bulkBatchInfo.getState() == BatchStateEnum.Failed) {
        log.error("Bulk batch failed: " + bulkBatchInfo.toString());
        throw new RuntimeException("Failed to get bulk batch info for jobId " + bulkBatchInfo.getJobId()
            + " error - " + bulkBatchInfo.getStateMessage());
      }

      // Get resultset ids of all the batches from the batch info list
      List<BatchIdAndResultId> batchIdAndResultIdList = Lists.newArrayList();

      for (BatchInfo bi : batchInfoList.getBatchInfo()) {
        QueryResultList list = this.bulkConnection.getQueryResultList(this.bulkJob.getId(), bi.getId());

        for (String result : list.getResult()) {
          batchIdAndResultIdList.add(new BatchIdAndResultId(bi.getId(), result));
        }
      }

      log.info("QueryResultList: " + batchIdAndResultIdList);

      return batchIdAndResultIdList;

    } catch (RuntimeException | AsyncApiException | InterruptedException e) {
      throw new RuntimeException(
          "Failed to get query result ids from salesforce using bulk api; error - " + e.getMessage(), e);
    }
  }