Get the object returned by the given select statement.

@param <T> class the return value will be casted to
@param _selectStmt select statement the object is wanted for
@return object for the select statement
@throws EFapsException on error
2914
@SuppressWarnings("unchecked")
    public <T> T getSelect(final String _selectStmt)
        throws EFapsException
    {
        final OneSelect oneselect = this.selectStmt2OneSelect.get(_selectStmt);
        return oneselect == null ? null : (T) oneselect.getObject();
    }
1266045
@Override
  public Selection<E> value() {
    return value == null ? null : new Selection<E>() {
      @Override
      public E result() {
        return value;
      }

      @Override
      public Object target() {
        return target;
      }
    };
  }
518353
@SuppressWarnings("unchecked")
    protected boolean executeSQLStmt(final ISelectionProvider _sqlProvider, final String _complStmt)
        throws EFapsException
    {
        SQLRunner.LOG.debug("SQL-Statement: {}", _complStmt);

        boolean ret = false;
        List<Object[]> rows = new ArrayList<>();

        boolean cached = false;
        if (runnable.has(StmtFlag.REQCACHED)) {
            final QueryKey querykey = QueryKey.get(Context.getThreadContext().getRequestId(), _complStmt);
            final Cache<QueryKey, Object> cache = QueryCache.getSqlCache();
            if (cache.containsKey(querykey)) {
                final Object object = cache.get(querykey);
                if (object instanceof List) {
                    rows = (List<Object[]>) object;
                }
                cached = true;
            }
        }
        if (!cached) {
            ConnectionResource con = null;
            try {
                con = Context.getThreadContext().getConnectionResource();
                final Statement stmt = con.createStatement();
                final ResultSet rs = stmt.executeQuery(_complStmt);
                final ArrayListHandler handler = new ArrayListHandler(Context.getDbType().getRowProcessor());
                rows = handler.handle(rs);
                rs.close();
                stmt.close();
            } catch (final SQLException e) {
                throw new EFapsException(SQLRunner.class, "executeOneCompleteStmt", e);
            }
            if (runnable.has(StmtFlag.REQCACHED)) {
                final ICacheDefinition cacheDefinition = new ICacheDefinition() {

                    @Override
                    public long getLifespan()
                    {
                        return 5;
                    }

                    @Override
                    public TimeUnit getLifespanUnit()
                    {
                        return TimeUnit.MINUTES;
                    }
                };
                QueryCache.put(cacheDefinition, QueryKey.get(Context.getThreadContext().getRequestId(), _complStmt), rows);
            }
        }
        for (final Object[] row : rows) {
            for (final Select select : _sqlProvider.getSelection().getAllSelects()) {
                select.addObject(row);
            }
            ret = true;
        }
        return ret;
    }
766604
public void append2SQLFrom(final SQLSelect _select)
        throws EFapsException
    {
        // for attributes it must be evaluated if the attribute is inside a child table
        if (this.valueSelect != null && "attribute".equals(this.valueSelect.getValueType())) {
            final Type type;
            if (this.selectParts.size() > 0) {
                type = this.selectParts.get(this.selectParts.size() - 1).getType();
            } else {
                type = this.query.getMainType();
            }
            Attribute attr = this.valueSelect.getAttribute();
            if (attr == null) {
                attr = type.getAttribute(((AttributeValueSelect) this.valueSelect).getAttrName());
            }
            // if the attr is still null that means that the type does not have this attribute, so last
            // chance to find the attribute is to search in the child types
            if (attr == null) {
                for (final Type childType : type.getChildTypes()) {
                    attr = childType.getAttribute(((AttributeValueSelect) this.valueSelect).getAttrName());
                    if (attr != null) {
                        ((AttributeValueSelect) this.valueSelect).setAttribute(attr);
                        break;
                    }
                }
            }
            if (attr != null && attr.getTable() != null && !attr.getTable().equals(type.getMainTable())) {
                final ChildTableSelectPart childtable = new ChildTableSelectPart(type, attr.getTable());
                this.selectParts.add(childtable);
            }
        }
        for (final ISelectPart sel : this.selectParts) {
            this.tableIndex = sel.join(this, _select, this.tableIndex);
        }
    }
823479
public void bindSelect(PreparedStatement stmt, Identity oid, ClassDescriptor cld, boolean callableStmt) throws SQLException
    {
        ValueContainer[] values = null;
        int i = 0;
        int j = 0;

        if (cld == null)
        {
            cld = m_broker.getClassDescriptor(oid.getObjectsRealClass());
        }
        try
        {
            if(callableStmt)
            {
                // First argument is the result set
                m_platform.registerOutResultSet((CallableStatement) stmt, 1);
                j++;
            }

            values = getKeyValues(m_broker, cld, oid);
            for (/*void*/; i < values.length; i++, j++)
            {
                setObjectForStatement(stmt, j + 1, values[i].getValue(), values[i].getJdbcType().getType());
            }
        }
        catch (SQLException e)
        {
            m_log.error("bindSelect failed for: " + oid.toString() + ", PK: " + i + ", value: " + values[i]);
            throw e;
        }
    }
479787
public <T> List<T> selectList(String sql, Class<T> resultType) {
        String msId;
        if (resultType == null) {
            msId = msUtils.select(sql);
        } else {
            msId = msUtils.select(sql, resultType);
        }
        return sqlSession.selectList(msId);
    }
901419
T getObjectAt(final int rowIndex) {
		// getSelectedRow peut renvoyer une ligne qui n'est plus dans la table
		// si c'est la dernière sélectionnée
		if (rowIndex < 0 || rowIndex >= getRowCount()) {
			return null;
		}

		final int row = convertRowIndexToModel(rowIndex);

		return getListTableModel().getObjectAt(row);
	}
3469
public Object getValue(final List<Object> _objectList)
        throws EFapsException
    {
        final List<Object> ret = new ArrayList<Object>();
        for (final Object object : _objectList) {
            ret.add(getValue(object));
        }
        return _objectList.size() > 0 ? (ret.size() > 1 ? ret : ret.get(0)) : null;
    }
210174
public static Object selectObject(Node node, String xpathQuery) {
        Object result = node.selectObject(xpathQuery);
        if (result != null && result instanceof Collection && ((Collection) result).isEmpty()) {
            return null;
        } else {
            return result;
        }
    }
465432
public static SearchResult search(final String _query)
        throws EFapsException
    {
        final ISearch searchDef = Index.getSearch();
        searchDef.setQuery(_query);
        return search(searchDef);
    }
67245
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
	return (T) QueryUtil.getObject(this, columnIndex, type);
    }
1346225
@Override
  public final String getFor(final Class<?> pClass, final String pThingName) {
    if ("entityEdit".equals(pThingName)) {
      if (IPersistableBase.class.isAssignableFrom(pClass)) {
        return PrcEntityPbEditDelete.class.getSimpleName();
      } else {
        return PrcEntityRetrieve.class.getSimpleName();
      }
    } else if ("entityPrint".equals(pThingName)) {
      return PrcEntityRetrieve.class.getSimpleName();
    } else if ("entityCopy".equals(pThingName)) {
      if (IPersistableBase.class.isAssignableFrom(pClass)) {
        return PrcEntityPbCopy.class.getSimpleName();
      } else {
        return PrcEntityCopy.class.getSimpleName();
      }
    } else if ("entitySave".equals(pThingName)) {
      if (IPersistableBase.class.isAssignableFrom(pClass)) {
        return PrcEntityPbSave.class.getSimpleName();
      } else if (EmailMsg.class == pClass) {
        return PrcEmailMsgSave.class.getSimpleName();
      } else {
        return PrcEntitySave.class.getSimpleName();
      }
    } else if ("entityFolDelete".equals(pThingName)) {
      if (Eattachment.class == pClass) {
        return PrcEntityFfolDelete.class.getSimpleName();
      }
      return PrcEntityFolDelete.class.getSimpleName();
    } else if ("entityFolSave".equals(pThingName)) {
      if (Eattachment.class == pClass) {
        return PrcEntityFfolSave.class.getSimpleName();
      }
      return PrcEntityFolSave.class.getSimpleName();
    } else if ("entityDelete".equals(pThingName)) {
      if (IPersistableBase.class.isAssignableFrom(pClass)) {
        return PrcEntityPbDelete.class.getSimpleName();
      } else {
        return PrcEntityDelete.class.getSimpleName();
      }
    } else if ("entityCreate".equals(pThingName)) {
      if (CsvColumn.class == pClass) {
        return PrcCsvColumnCreate.class.getSimpleName();
      } else if (MatchForeignLine.class == pClass) {
        return PrcMatchForeignLineCreate.class.getSimpleName();
      } else {
        return PrcEntityCreate.class.getSimpleName();
      }
    } else if ("entityConfirmDelete".equals(pThingName)) {
      if (IPersistableBase.class.isAssignableFrom(pClass)) {
        return PrcEntityPbEditDelete.class.getSimpleName();
      } else {
        return PrcEntityRetrieve.class.getSimpleName();
      }
    }
    return null;
  }
452026
@Override
  public final String getFor(final Class<?> pClass, final String pThingName) {
    if ("entityEdit".equals(pThingName) && pClass == Cart.class) {
      return null;
    } else if (pClass == CustOrder.class) {
      if ("entitySave".equals(pThingName)) {
        return PrCuOrSv.class.getSimpleName();
      } else if ("entityEdit".equals(pThingName)
        || "entityPrint".equals(pThingName)) {
        return PrcEntityRetrieve.class.getSimpleName();
      }
      return null;
    } else if ("entityEdit".equals(pThingName)
      || "entityConfirmDelete".equals(pThingName)) {
      return getForRetrieveForEditDelete(pClass);
    } else if ("entityCopy".equals(pThingName)) {
      return getForCopy(pClass);
    } else if ("entityPrint".equals(pThingName)) {
      return getForPrint(pClass);
    } else if ("entitySave".equals(pThingName)) {
      return getForSave(pClass);
    } else if ("entityFDelete".equals(pThingName)) {
      return getForFDelete(pClass);
    } else if ("entityEFDelete".equals(pThingName)) {
      return getForEFDelete(pClass);
    } else if ("entityFSave".equals(pThingName)) {
      return getForFSave(pClass);
    } else if ("entityEFSave".equals(pThingName)) {
      return getForEFSave(pClass);
    } else if ("entityFolDelete".equals(pThingName)) {
      return getForFolDelete(pClass);
    } else if ("entityFolSave".equals(pThingName)) {
      return getForFolSave(pClass);
    } else if ("entityDelete".equals(pThingName)) {
      return getForDelete(pClass);
    } else if ("entityCreate".equals(pThingName)) {
      return getForCreate(pClass);
    }
    return null;
  }
900865
@SuppressWarnings("unchecked")
    public <T> T getAttributeSet(final String _setName)
        throws EFapsException
    {
        final OneSelect oneselect = this.attr2OneSelect.get(_setName);
        Map<String, Object> ret = null;
        if (oneselect == null || oneselect.getFromSelect() == null) {
            AbstractPrintQuery.LOG.error("Could not get an AttributeSet for the name: '{}' in PrintQuery '{]'",
                            _setName, this);
        } else if (oneselect.getFromSelect().hasResult()) {
            ret = new HashMap<>();
            // in an attributset the first one is fake
            boolean first = true;
            for (final OneSelect onsel : oneselect.getFromSelect().getAllSelects()) {
                if (first) {
                    first = false;
                } else {
                    final ArrayList<Object> list = new ArrayList<>();
                    final Object object = onsel.getObject();
                    if (object instanceof List<?>) {
                        list.addAll((List<?>) object);
                    } else {
                        list.add(object);
                    }
                    ret.put(onsel.getAttribute().getName(), list);
                }
            }
        }
        return (T) ret;
    }
1215295
@SuppressWarnings("unchecked")
    protected <T> T get(final Select _select)
        throws EFapsException
    {
        Object ret = null;
        final List<Boolean> accessList = access(_select);
        final Object obj = _select.getCurrent();
        if (obj instanceof List) {
            final Iterator<Boolean> iter = accessList.iterator();
            ret = ((List<?>) obj).stream()
                .map(ele -> iter.hasNext() && iter.next() ? ele : null)
                .collect(Collectors.toList());
            ret = agregate(_select, (List<Object>) ret);
        } else if (accessList.size() == 1 && accessList.get(0)) {
            ret = obj;
        }
        return (T) ret;
    }
1032449
public static Object getObject(final ResultSet rs,
                                   final String name,
                                   final ColumnType type) throws SQLException {
        
        switch (type) {
        case BigDecimal: return rs.getBigDecimal(name);
        case Boolean: return rs.getBoolean(name);
        case Byte: return rs.getByte(name);
        case Short: return rs.getShort(name);
        case Date: return rs.getDate(name);
        case Double: return rs.getDouble(name);
        case Float: return rs.getFloat(name);
        case Int: return rs.getInt(name);
        case Long: return rs.getLong(name);
        case Time: return rs.getTime(name);
        case Timestamp: return rs.getTimestamp(name);
        default: return rs.getString(name);
        }
    }
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;
    }