Get the generalID etc. from the eFasp DataBase.
@param _complStmt Statement to be executed
@throws EFapsException on error
334887
private void getGeneralID(final String _complStmt)
        throws EFapsException
    {
        ConnectionResource con = null;
        try {
            con = Context.getThreadContext().getConnectionResource();

            final Statement stmt = con.createStatement();

            final ResultSet rs = stmt.executeQuery(_complStmt.toString());

            while (rs.next()) {
                this.generalID = rs.getLong(1);
                this.fileName = rs.getString(2);
                if (this.fileName != null && !this.fileName.isEmpty()) {
                    this.fileName = this.fileName.trim();
                }
                this.fileLength = rs.getLong(3);
                for (int i = 0; i < this.exist.length; i++) {
                    this.exist[i] = rs.getLong(4 + i) > 0;
                }
                getAdditionalInfo(rs);
            }
            rs.close();
            stmt.close();
        } catch (final SQLException e) {
            throw new EFapsException(InstanceQuery.class, "executeOneCompleteStmt", e);
        }
    }
1349595
public static Person get(final long _id)
        throws EFapsException
    {
        final Cache<Long, Person> cache = InfinispanCache.get().<Long, Person>getCache(Person.IDCACHE);
        if (!cache.containsKey(_id)) {
            Person.getPersonFromDB(Person.SQL_ID, _id);
        }
        return cache.get(_id);
    }
1247466
protected void extractEF_ID(final Application pApplication) throws CommunicationException {
		// 00B201BC00
		byte[] data = template.get().getProvider().transceive(new CommandApdu(CommandEnum.READ_RECORD, 0x01, 0xBC, 0).toBytes());
		if (ResponseUtils.isSucceed(data)) {
			pApplication.setReadingStep(ApplicationStepEnum.READ);
			// Date
			SimpleDateFormat format = new SimpleDateFormat("MM/yy",Locale.getDefault());

			// Track 2
			EmvTrack2 track2 = new EmvTrack2();
			track2.setCardNumber(BytesUtils.bytesToStringNoSpace(Arrays.copyOfRange(data, 4, 9)));
			try {
				track2.setExpireDate(format.parse(String.format("%02x/%02x", data[11], data[10])));
			} catch (ParseException e) {
				LOGGER.error(e.getMessage(),e);
			}
			template.get().getCard().setTrack2(track2);
		}
	}
1033398
@Override
    public void executeWithoutTrigger()
        throws EFapsException
    {
        final Context context = Context.getThreadContext();
        ConnectionResource con = null;
        try {

            con = context.getConnectionResource();

            final SQLTable mainTable = getType().getMainTable();

            final long id = executeOneStatement(con, mainTable, getTable2values().get(mainTable), 0);

            setInstance(Instance.get(getInstance().getType(), id));

            getInstance().setExchangeId(this.exchangeId);
            getInstance().setExchangeSystemId(this.exchangeSystemId);

            GeneralInstance.insert(getInstance(), con);

            for (final Entry<SQLTable, List<Value>> entry :  getTable2values().entrySet()) {
                final SQLTable table = entry.getKey();
                if (!table.equals(mainTable) && !table.isReadOnly()) {
                    executeOneStatement(con, table, entry.getValue(), id);
                }
            }
            Queue.registerUpdate(getInstance());
        } finally {

        }
    }
816953
public Long getNextValAsLong()
        throws EFapsException
    {
        long ret = 0;
        try {
            ret = Context.getDbType().nextSequence(Context.getThreadContext().getConnectionResource(),
                            getDBName());
        } catch (final SQLException e) {
            throw new EFapsException(NumberGenerator.class, " getNextValAsLong()", e);
        }
        return ret;
    }
686445
static QuerySpecification getCheckSelect(Session session, Table t,
            Expression e) {

        CompileContext     compileContext = new CompileContext(session);
        QuerySpecification s = new QuerySpecification(compileContext);

        s.exprColumns    = new Expression[1];
        s.exprColumns[0] = EXPR_TRUE;

        RangeVariable range = new RangeVariable(t, null, null, null,
            compileContext);

        s.rangeVariables = new RangeVariable[]{ range };

        HsqlList unresolved = e.resolveColumnReferences(s.rangeVariables,
            null);

        ExpressionColumn.checkColumnsResolved(unresolved);
        e.resolveTypes(session, null);

        if (Type.SQL_BOOLEAN != e.getDataType()) {
            throw Error.error(ErrorCode.X_42568);
        }

        Expression condition = new ExpressionLogical(OpTypes.NOT, e);

        s.queryCondition = condition;

        s.resolveReferences(session);
        s.resolveTypes(session);

        return s;
    }
918024
def _output_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        self.get_child("output")._handle_substatements(stmt, sctx)
710512
protected List<Instance> getSuper(final Instance _instance)
        throws EFapsException
    {
        final List<Instance> ret = new ArrayList<>();
        final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type2Type());
        queryBldr.addWhereAttrEqValue(CIAdminProgram.Program2Program.From, _instance.getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminProgram.Program2Program.To);
        multi.execute();
        if (multi.next()) {
            final Instance instance = Instance.get(getClassName4Type().getType(),
                                             multi.<Long>getAttribute(CIAdminProgram.Program2Program.To));
            ret.add(instance);
            ret.addAll(getSuper(instance));
        }
        return ret;
    }
1047576
private Set getPrivateGenericCredentials(final Subject subj) throws ResourceException {

        Set privateGenericCredentials = null;

        if (System.getSecurityManager() != null) {
            try {
                privateGenericCredentials = (Set) AccessController.doPrivileged(
                                                                                new PrivilegedExceptionAction() {
                                                                                    @Override
                                                                                    public Object run() throws Exception {
                                                                                        return subj.getPrivateCredentials(GenericCredential.class);
                                                                                    }
                                                                                });
            } catch (PrivilegedActionException pae) {
                FFDCFilter.processException(pae, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "18", this);
                Tr.error(tc, "FAILED_DOPRIVILEGED_J2CA0060", pae);
                Exception e = pae.getException();
                ResourceException re = new ResourceException("ThreadIdentitySecurityHelper failed attempting to access Subject's credentials");
                re.initCause(e);
                throw re;
            }

        } else {
            privateGenericCredentials = subj.getPrivateCredentials(GenericCredential.class);
        }

        return privateGenericCredentials;
    }
549049
@Override
    public Object get(final Attribute _attribute,
                      final Object _object)
        throws EFapsException
    {
        Object ret = null;
        if (_object != null && _attribute.getAttributeType().getDbAttrType() instanceof IFormattableType) {
            final IFormattableType attrType = (IFormattableType) _attribute.getAttributeType().getDbAttrType();
            if (_object instanceof List<?>) {
                final List<?> objectList = (List<?>) _object;
                final List<Object> temp = new ArrayList<>();
                for (final Object object : objectList) {
                    temp.add(attrType.format(object, this.pattern));
                }
                ret = temp;
            } else {
                ret = attrType.format(_object, this.pattern);
            }
        }
        return ret;
    }
149653
public <T> T getAttribute(final CIAttribute _attribute)
        throws EFapsException
    {
        return this.<T>getAttribute(_attribute.name);
    }
129583
protected AttributeQuery getAttributeQuery()
        throws EFapsException
    {
        AttributeQuery ret = this.getAttributeQuery(getSelectAttributeName());
        // check if in the linkto chain is one before this one
        if (!this.attrQueryBldrs.isEmpty()) {
            final QueryBuilder queryBldr = this.attrQueryBldrs.values().iterator().next();
            queryBldr.addWhereAttrInQuery(queryBldr.getLinkAttributeName(), ret);
            ret = queryBldr.getAttributeQuery();
        }
        return ret;
    }
941927
private static void loadDefinition(final UUID _typeUUID)
        throws EFapsException
    {
        final Type type = Type.get(_typeUUID);
        final QueryBuilder queryBldr = new QueryBuilder(CIAdminIndex.IndexDefinition);
        queryBldr.addWhereAttrEqValue(CIAdminIndex.IndexDefinition.Active, true);
        queryBldr.addWhereAttrEqValue(CIAdminIndex.IndexDefinition.TypeLink, type.getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminIndex.IndexDefinition.MsgPhraseLink);
        multi.executeWithoutAccessCheck();

        IndexDefinition def;
        if (multi.next()) {
            def = new IndexDefinition(_typeUUID,
                            multi.<Long>getAttribute(CIAdminIndex.IndexDefinition.MsgPhraseLink));

            final QueryBuilder fieldQueryBldr = new QueryBuilder(CIAdminIndex.IndexField);
            fieldQueryBldr.addWhereAttrEqValue(CIAdminIndex.IndexField.DefinitionLink, multi.getCurrentInstance());
            final MultiPrintQuery fieldMulti = fieldQueryBldr.getPrint();
            fieldMulti.addAttribute(CIAdminIndex.IndexField.Key, CIAdminIndex.IndexField.Select,
                            CIAdminIndex.IndexField.FieldType, CIAdminIndex.IndexField.Identifier);
            final SelectBuilder selTransName = SelectBuilder.get().linkto(CIAdminIndex.IndexField.TransformerLink)
                            .attribute(CIAdminProgram.Java.Name);
            fieldMulti.addSelect(selTransName);
            fieldMulti.executeWithoutAccessCheck();
            while (fieldMulti.next()) {
                final IndexField field = new IndexField(fieldMulti.<String>getAttribute(
                                    CIAdminIndex.IndexField.Identifier),
                                fieldMulti.<String>getAttribute(CIAdminIndex.IndexField.Key),
                                fieldMulti.<String>getAttribute(CIAdminIndex.IndexField.Select),
                                fieldMulti.<FieldType>getAttribute(CIAdminIndex.IndexField.FieldType),
                                fieldMulti.<String>getSelect(selTransName));
                def.fields.add(field);
            }
        } else {
            def = NULLINDEXDEF;
        }
        final Cache<UUID, IndexDefinition> cache = InfinispanCache.get().<UUID, IndexDefinition>getCache(
                        IndexDefinition.UUIDCACHE);
        cache.put(_typeUUID, def);

        // only if it is not a null index check if it must be joined with parent index definitions
        final List<IndexDefinition> defs = new ArrayList<>();
        Type current = type;
        while (current.getParentType() != null) {
            current = current.getParentType();
            final IndexDefinition parentDef = get(current.getUUID());
            if (parentDef != null) {
                defs.add(parentDef);
            }
        }
        boolean dirty = false;
        for (final IndexDefinition parentDef : defs) {
            for (final IndexField parentField : parentDef.fields) {
                boolean found = false;
                if (def.equals(NULLINDEXDEF)) {
                    def = new IndexDefinition(_typeUUID, parentDef.msgPhraseId);
                }
                for (final IndexField currentField : def.fields) {
                    if (currentField.getIdentifier().equals(parentField.getIdentifier())) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    def.fields.add(new IndexField(parentField.getIdentifier(), parentField.getKey(),
                                    parentField.getSelect(), parentField.getFieldType(), parentField.getTransform()));
                    dirty = true;
                }
            }
        }
        if (dirty) {
            cache.put(_typeUUID, def);
        }
    }
1051880
protected CmsDbSqlException wrapException(PreparedStatement stmt, SQLException e) {

        return new CmsDbSqlException(
            Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
            e);
    }
465432
public static SearchResult search(final String _query)
        throws EFapsException
    {
        final ISearch searchDef = Index.getSearch();
        searchDef.setQuery(_query);
        return search(searchDef);
    }
112865
private AbstractQValue getValue(final Object _value)
        throws EFapsException
    {
        AbstractQValue ret = null;
        if (_value == null) {
            ret = new QNullValue();
        } else if (_value instanceof Number) {
            ret = new QNumberValue((Number) _value);
        } else if (_value instanceof String) {
            ret = new QStringValue((String) _value);
        } else if (_value instanceof DateTime) {
            ret = new QDateTimeValue((DateTime) _value);
        } else if (_value instanceof Boolean) {
            ret = new QBooleanValue((Boolean) _value);
        } else if (_value instanceof Status) {
            ret = new QNumberValue(((Status) _value).getId());
        } else if (_value instanceof CIStatus) {
            ret = new QNumberValue(Status.find((CIStatus) _value).getId());
        } else if (_value instanceof Instance) {
            if (!((Instance) _value).isValid()) {
                QueryBuilder.LOG.error("the given Instance was not valid and cannot be used as filter criteria",
                                _value);
                throw new EFapsException(QueryBuilder.class, "invalid Instance given");
            }
            ret = new QNumberValue(((Instance) _value).getId());
        } else if (_value instanceof UoM) {
            ret = new QNumberValue(((UoM) _value).getId());
        } else if (_value instanceof IBitEnum) {
            ret = new QBitValue((IBitEnum) _value);
        } else if (_value instanceof IEnum) {
            ret = new QNumberValue(((IEnum) _value).getInt());
        } else if (_value instanceof AbstractQValue) {
            ret = (AbstractQValue) _value;
        } else {
            throw new EFapsException(QueryBuilder.class, "notsuported");
        }
        return ret;
    }
1206600
private Selection analyze(final IStmtProvider _stmtProvider)
        throws EFapsException
    {
        final Type type = evalMainType(_stmtProvider.getTypes());
        final IStatement<?> stmt = _stmtProvider.getStmt();
        for (final ISelect sel : ((IPrintStatement<?>) stmt).getSelection().getSelects()) {
            final Select select = Select.get(sel.getAlias());
            if (this.selects.isEmpty()) {
                this.instSelects.put(BASEPATH, Select.get().addElement(new InstanceElement(type)));
            }
            this.selects.add(select);
            Type currentType = type;
            for (final ISelectElement ele : sel.getElements()) {
                if (ele instanceof IAttributeSelectElement) {
                    final String attrName = ((IAttributeSelectElement) ele).getName();
                    final Attribute attr = currentType.getAttribute(attrName);
                    if (attr == null) {
                        LOG.error("Could not find Attribute '{}' on Type '{}'", attrName, currentType.getName());
                    }
                    final AttributeElement element = new AttributeElement().setAttribute(attr);
                    select.addElement(element);
                } else if (ele instanceof ILinktoSelectElement) {
                    final String attrName = ((ILinktoSelectElement) ele).getName();
                    final Attribute attr = currentType.getAttribute(attrName);
                    final LinktoElement element = new LinktoElement().setAttribute(attr);
                    select.addElement(element);
                    currentType = attr.getLink();
                    addInstSelect(select, element, attr, currentType);
                } else if (ele instanceof ILinkfromSelectElement) {
                    final String typeName = ((ILinkfromSelectElement) ele).getTypeName();
                    final String attrName = ((ILinkfromSelectElement) ele).getAttribute();
                    final Type linkFromType = Type.get(typeName);
                    final Attribute attr = linkFromType.getAttribute(attrName);
                    final LinkfromElement element = new LinkfromElement().setAttribute(attr).setStartType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, attr, currentType);
                    currentType = linkFromType;
                } else if (ele instanceof IClassSelectElement) {
                    final String typeName = ((IClassSelectElement) ele).getName();
                    final Classification classification = Classification.get(typeName);
                    final ClassElement element = new ClassElement().setClassification(classification)
                                    .setType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, classification, currentType);
                    currentType = classification;
                } else if (ele instanceof IAttributeSetSelectElement) {
                    final String attrSetName = ((IAttributeSetSelectElement) ele).getName();
                    final AttributeSet attributeSet = AttributeSet.find(currentType.getName(), attrSetName);
                    final AttributeSetElement element = new AttributeSetElement().setAttributeSet(attributeSet)
                                    .setType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, attributeSet, currentType);
                    currentType = attributeSet;
                } else if (ele instanceof IBaseSelectElement) {
                    switch (((IBaseSelectElement) ele).getElement()) {
                        case INSTANCE:
                            select.addElement(new InstanceElement(currentType));
                            break;
                        case OID:
                            select.addElement(new OIDElement(currentType));
                            break;
                        case STATUS:
                            select.addElement(new StatusElement(currentType));
                            break;
                        case TYPE:
                            select.addElement(new TypeElement(currentType));
                            break;
                        case KEY:
                            select.addElement(new KeyElement());
                            break;
                        case LABEL:
                            select.addElement(new LabelElement());
                            break;
                        case NAME:
                            select.addElement(new NameElement());
                            break;
                        case ID:
                            select.addElement(new IDElement());
                            break;
                        case UUID:
                            select.addElement(new UUIDElement());
                            break;
                        case FIRST:
                            select.addElement(new FirstElement());
                            break;
                        case LAST:
                            select.addElement(new LastElement());
                            break;
                        default:
                            break;
                    }
                } else if (ele instanceof IFormatSelectElement) {
                    final String pattern = ((IFormatSelectElement) ele).getPattern();
                    select.addElement(new FormatElement().setPattern(pattern));
                } else if (ele instanceof IExecSelectElement) {
                    select.addElement(new ExecElement(currentType)
                                    .setEsjp(((IExecSelectElement) ele).getClassName())
                                    .setParameters(((IExecSelectElement) ele).getParameters()));
                }
            }
        }
        return this;
    }