Example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

List of usage examples for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Prototype

ToStringStyle MULTI_LINE_STYLE

To view the source code for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Click Source Link

Document

The multi line toString style.

Usage

From source file:org.jobjects.dao.annotation.Manager.java

/**
 * Retourne le bean  partir de la clef primaire. Si la ligne n'existe pas
 * dans la base alors une exception FinderException est leve.
 * @param beanPk Le bean d'un type quelconque comportant des annotations daoTable et
 *          DaoField. Il represente la clef primaire de la table.
 * @return Un bean de mme type que celui pass en paramtre. Les donnes du
 *         bean sont rafraichi  partir de la base au cas o celle-ci aurait
 *         modifi les donnes grace  des trigger ou autre.
 * @throws FinderException Returne un exception si le bean n'existe pas.
 *///w  ww.  jav a2s  . c  o  m
public final T load(final P beanPk) throws FinderException {
    T returnValue = null;
    try {

        String msg = "Load error  " + entityClass.getCanonicalName() + " : "
                + ToStringBuilder.reflectionToString(beanPk, ToStringStyle.MULTI_LINE_STYLE);

        try {
            Connection connection = getConnection();
            try {
                if (null == sql_load) {
                    sql_load = loadSqlLoad(usualTable, fields);
                }
                PreparedStatement pstmt = connection.prepareStatement(sql_load);
                try {
                    int i = 1;

                    for (Field field : fields) {
                        Annotation[] annotations = field.getAnnotations();
                        for (Annotation annotation : annotations) {
                            if (annotation instanceof DaoField) {
                                if (((DaoField) annotation).isPrimary()) {
                                    Object obj = BeanUtils.getProperty(beanPk, field.getName());
                                    if (obj == null) {
                                        pstmt.setNull(i++, ((DaoField) annotation).type());
                                    } else {
                                        setAll(pstmt, i++, obj);
                                    }
                                }
                                break;
                            }
                        }
                    }

                    ResultSet rs = pstmt.executeQuery();
                    try {
                        if (!rs.next()) {
                            throw new FinderException(msg);
                        }

                        returnValue = entityClass.newInstance();

                        int j = 1;
                        for (Field field : fields) {
                            Annotation[] annotations = field.getAnnotations();
                            for (Annotation annotation : annotations) {
                                if (annotation instanceof DaoField) {
                                    // field.set(returnValue,
                                    // rs.getObject(j++));
                                    BeanUtils.setProperty(returnValue, field.getName(), rs.getObject(j++));
                                    break;
                                }
                            }
                        }

                    } finally {
                        rs.close();
                    }
                    rs = null;
                } finally {
                    pstmt.close();
                }
                pstmt = null;
            } finally {
                connection.close();
            }
            connection = null;
        } catch (SQLException sqle) {
            log.error(msg, sqle);
            throw new FinderException(msg, sqle);
        }
    } catch (Exception e) {
        throw new FinderException(e);
    }
    return returnValue;
}

From source file:org.jobjects.dao.annotation.Manager.java

/**
 * @param bean le bean  sauvegarder//from  w ww .  ja v a2  s .  c om
 * @return le bean sauvegard
 * @throws SaveException Problme de persistance
 */
public final T save(final T bean) throws SaveException {
    T returnValue = null;
    String msg = "Cannot save " + entityClass.getCanonicalName() + " : "
            + ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE);

    try {
        if (isExist(bean)) {
            saveReal(bean);
        } else {
            create(bean);
        }
        returnValue = load(bean);
    } catch (Exception ce) {
        log.error(msg, ce);
        throw new SaveException(msg, ce);
    }
    return returnValue;
}

From source file:org.jobjects.dao.annotation.Manager.java

/**
 * Sauvegarde le bean dans la base. Une exception SaveException peut tre
 * leve si un problme survient./*from w ww  .  ja v  a 2 s.c  o  m*/
 * @param bean le bean  sauvegarder
 * @return Un boolean positif si la mise en jour s'est relement pass.
 * @throws SaveException Problme de persistance
 */
private boolean saveReal(final T bean) throws SaveException {
    boolean returnValue = true;

    String msg = "Cannot save " + entityClass.getCanonicalName() + " : "
            + ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE);
    try {
        Connection connection = getConnection();
        try {
            if (null == sql_save) {
                sql_save = loadSqlSave(usualTable, fields);
            }
            PreparedStatement pstmt = connection.prepareStatement(sql_save);
            try {
                int i = 1;

                for (Field field : fields) {
                    Annotation[] annotations = field.getAnnotations();
                    for (Annotation annotation : annotations) {
                        if (annotation instanceof DaoField) {
                            if (!((DaoField) annotation).isPrimary()) {
                                Object obj = BeanUtils.getProperty(bean, field.getName());
                                if (obj == null) {
                                    pstmt.setNull(i++, ((DaoField) annotation).type());
                                } else {
                                    setAll(pstmt, i++, obj);
                                }
                            }
                            break;
                        }
                    }
                }

                for (Field field : fields) {
                    Annotation[] annotations = field.getAnnotations();
                    for (Annotation annotation : annotations) {
                        if (annotation instanceof DaoField) {
                            if (((DaoField) annotation).isPrimary()) {
                                Object obj = BeanUtils.getProperty(bean, field.getName());
                                if (obj == null) {
                                    pstmt.setNull(i++, ((DaoField) annotation).type());
                                } else {
                                    setAll(pstmt, i++, obj);
                                }
                            }
                            break;
                        }
                    }
                }
                returnValue = pstmt.executeUpdate() == 1;
            } finally {
                pstmt.close();
            }
            pstmt = null;
        } finally {
            connection.close();
        }
        connection = null;
    } catch (Exception sqle) {
        log.error(msg, sqle);
        throw new SaveException(msg, sqle);
    }
    return returnValue;
}

From source file:org.jobjects.dao.annotation.Manager.java

/**
 * @param beanPk le bean  supprimer/*from   w  w  w  .j a  v a  2s . c o m*/
 * @throws RemoveException Problme de suppression
 */
public final void remove(final P beanPk) throws RemoveException {
    String msg = "Delete error " + entityClass.getCanonicalName() + " : "
            + ToStringBuilder.reflectionToString(beanPk, ToStringStyle.MULTI_LINE_STYLE);

    try {
        Connection connection = getConnection();
        try {
            if (null == sql_delete) {
                sql_delete = loadSqlDelete(usualTable, fields);
            }
            PreparedStatement pstmt = connection.prepareStatement(sql_delete);
            try {
                int i = 1;
                for (Field field : fields) {
                    Annotation[] annotations = field.getAnnotations();
                    for (Annotation annotation : annotations) {
                        if (annotation instanceof DaoField) {
                            if (((DaoField) annotation).isPrimary()) {
                                Object obj = BeanUtils.getProperty(beanPk, field.getName());
                                if (obj == null) {
                                    pstmt.setNull(i++, ((DaoField) annotation).type());
                                } else {
                                    setAll(pstmt, i++, obj);
                                }
                            }
                            break;
                        }
                    }
                }
                pstmt.executeUpdate();
            } finally {
                pstmt.close();
            }
            pstmt = null;
        } finally {
            connection.close();
        }
        connection = null;
    } catch (Exception sqle) {
        log.error(msg, sqle);
        throw new RemoveException(msg, sqle);
    }

}

From source file:org.kordamp.ezmorph.bean.MorphDynaBean.java

public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append(dynaValues).toString();
}

From source file:org.kuali.kfs.module.tem.batch.service.impl.ImportedExpensePendingEntryServiceImpl.java

/**
 * @see org.kuali.kfs.module.tem.batch.service.ImportedExpensePendingEntryService#buildDebitPendingEntry(org.kuali.kfs.module.tem.businessobject.AgencyStagingData, org.kuali.kfs.module.tem.businessobject.TripAccountingInformation, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.lang.String, org.kuali.rice.kns.util.KualiDecimal, boolean)
 *//*from w  w w . ja va 2  s.  c  o  m*/
@Override
public List<GeneralLedgerPendingEntry> buildDebitPendingEntry(AgencyStagingData agencyData,
        TripAccountingInformation info, GeneralLedgerPendingEntrySequenceHelper sequenceHelper,
        String objectCode, KualiDecimal amount, boolean generateOffset) {

    List<GeneralLedgerPendingEntry> entryList = new ArrayList<GeneralLedgerPendingEntry>();

    GeneralLedgerPendingEntry pendingEntry = buildGeneralLedgerPendingEntry(agencyData, info, sequenceHelper,
            info.getTripChartCode(), objectCode, amount, KFSConstants.GL_DEBIT_CODE);
    if (ObjectUtils.isNotNull(pendingEntry)) {
        pendingEntry.setAccountNumber(info.getTripAccountNumber());
        pendingEntry.setSubAccountNumber(StringUtils.defaultIfEmpty(info.getTripSubAccountNumber(),
                GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber()));

        LOG.info("Created DEBIT GLPE: " + pendingEntry.getDocumentNumber() + " for AGENCY Import Expense: "
                + agencyData.getId() + " TripId: " + agencyData.getTripId() + "\n\n"
                + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));

        //add to list if entry was created successfully
        entryList.add(pendingEntry);
        //handling offset
        if (generateOffset) {
            generateOffsetPendingEntry(entryList, sequenceHelper, pendingEntry);
        }
    }
    return entryList;
}

From source file:org.kuali.kfs.module.tem.batch.service.impl.ImportedExpensePendingEntryServiceImpl.java

/**
 * @see org.kuali.kfs.module.tem.batch.service.ImportedExpensePendingEntryService#buildCreditPendingEntry(org.kuali.kfs.module.tem.businessobject.AgencyStagingData, org.kuali.kfs.module.tem.businessobject.TripAccountingInformation, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.lang.String, org.kuali.rice.kns.util.KualiDecimal, boolean)
 *//*www . ja  va 2  s  . co  m*/
@Override
public List<GeneralLedgerPendingEntry> buildCreditPendingEntry(AgencyStagingData agencyData,
        TripAccountingInformation info, GeneralLedgerPendingEntrySequenceHelper sequenceHelper,
        String objectCode, KualiDecimal amount, boolean generateOffset) {
    List<GeneralLedgerPendingEntry> entryList = new ArrayList<GeneralLedgerPendingEntry>();

    //get chart code from parameter
    String chartCode = parameterService.getParameterValueAsString(TemParameterConstants.TEM_ALL.class,
            AgencyMatchProcessParameter.TRAVEL_CREDIT_CARD_CLEARING_CHART);

    GeneralLedgerPendingEntry pendingEntry = buildGeneralLedgerPendingEntry(agencyData, info, sequenceHelper,
            chartCode, objectCode, amount, KFSConstants.GL_CREDIT_CODE);
    if (ObjectUtils.isNotNull(pendingEntry)) {
        pendingEntry.setAccountNumber(
                parameterService.getParameterValueAsString(TemParameterConstants.TEM_ALL.class,
                        AgencyMatchProcessParameter.TRAVEL_CREDIT_CARD_CLEARING_ACCOUNT));
        pendingEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
    }

    LOG.info("Created CREDIT GLPE: " + pendingEntry.getDocumentNumber() + " for AGENCY Import Expense: "
            + agencyData.getId() + " TripId: " + agencyData.getTripId() + "\n\n"
            + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));

    //add to list if entry was created successfully
    if (ObjectUtils.isNotNull(pendingEntry)) {
        entryList.add(pendingEntry);
        //handling offset
        if (generateOffset) {
            generateOffsetPendingEntry(entryList, sequenceHelper, pendingEntry);
        }
    }
    return entryList;
}

From source file:org.kuali.kfs.module.tem.batch.service.impl.ImportedExpensePendingEntryServiceImpl.java

/**
 * @see org.kuali.kfs.module.tem.batch.service.ImportedExpensePendingEntryService#buildCreditPendingEntry(org.kuali.kfs.module.tem.businessobject.AgencyStagingData, org.kuali.kfs.module.tem.businessobject.TripAccountingInformation, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.lang.String, org.kuali.rice.kns.util.KualiDecimal, boolean)
 *//*  w w w .j a v a2 s  . c o  m*/
@Override
public List<GeneralLedgerPendingEntry> buildServiceFeeCreditPendingEntry(AgencyStagingData agencyData,
        TripAccountingInformation info, GeneralLedgerPendingEntrySequenceHelper sequenceHelper,
        AgencyServiceFee serviceFee, KualiDecimal amount, boolean generateOffset) {
    List<GeneralLedgerPendingEntry> entryList = new ArrayList<GeneralLedgerPendingEntry>();

    GeneralLedgerPendingEntry pendingEntry = buildGeneralLedgerPendingEntry(agencyData, info, sequenceHelper,
            serviceFee.getCreditChartCode(), serviceFee.getCreditObjectCode(), amount,
            KFSConstants.GL_CREDIT_CODE);
    if (ObjectUtils.isNotNull(pendingEntry)) {
        pendingEntry.setAccountNumber(serviceFee.getCreditAccountNumber());
        pendingEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
    }

    LOG.info("Created ServiceFee CREDIT GLPE: " + pendingEntry.getDocumentNumber()
            + " for AGENCY Import Expense: " + agencyData.getId() + " TripId: " + agencyData.getTripId()
            + "\n\n"
            + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));

    //add to list if entry was created successfully
    if (ObjectUtils.isNotNull(pendingEntry)) {
        entryList.add(pendingEntry);
        //handling offset
        if (generateOffset) {
            generateOffsetPendingEntry(entryList, sequenceHelper, pendingEntry);
        }
    }
    return entryList;
}

From source file:org.kuali.kfs.module.tem.batch.service.impl.ImportedExpensePendingEntryServiceImpl.java

/**
 * Generate the offset entry from the given pending entry.  If entry is created successfully, add to the entry list
 *
 * @param entryList// w w  w .jav a 2s .  co  m
 * @param sequenceHelper
 * @param pendingEntry
 */
private void generateOffsetPendingEntry(List<GeneralLedgerPendingEntry> entryList,
        GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry pendingEntry) {
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(pendingEntry);
    boolean success = generalLedgerPendingEntryService.populateOffsetGeneralLedgerPendingEntry(
            universityDateService.getCurrentFiscalYear(), pendingEntry, sequenceHelper, offsetEntry);
    sequenceHelper.increment();
    if (success) {
        LOG.info("Created OFFSET GLPE: " + pendingEntry.getDocumentNumber() + "\n"
                + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));
        entryList.add(offsetEntry);
    }
}

From source file:org.kuali.rice.kew.actionrequest.ActionRequestValue.java

public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("actionRequestId", actionRequestId)
            .append("actionRequested", actionRequested).append("documentId", documentId)
            .append("status", status).append("responsibilityId", responsibilityId).append("groupId", groupId)
            .append("recipientTypeCd", recipientTypeCd).append("priority", priority)
            .append("routeLevel", routeLevel).append("docVersion", docVersion).append("createDate", createDate)
            .append("responsibilityDesc", responsibilityDesc).append("annotation", annotation)
            .append("jrfVerNbr", jrfVerNbr).append("principalId", principalId)
            .append("forceAction", forceAction).append("qualifiedRoleName", qualifiedRoleName)
            .append("roleName", roleName).append("qualifiedRoleNameLabel", qualifiedRoleNameLabel)
            .append("displayStatus", displayStatus).append("ruleBaseValuesId", ruleBaseValuesId)
            .append("delegationType", delegationTypeCode).append("approvePolicy", approvePolicy)
            .append("actionTaken", actionTaken).append("currentIndicator", currentIndicator)
            .append("createDateString", createDateString).append("nodeInstance", nodeInstance).toString();
}