Example usage for java.lang IllegalAccessException getMessage

List of usage examples for java.lang IllegalAccessException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalAccessException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.cruk.genologics.api.impl.GenologicsAPIImpl.java

/**
 * Update entities in Clarity with the entity objects given here. The objects are
 * updated in-situ, so any changes made in the server will be pushed into the
 * objects in the collection./*from   w ww  .  ja  v  a 2 s . c o m*/
 *
 * <p>Uses the bulk create mechanism where it is available for the entity.</p>
 *
 * @param entities The collection of entities to update.
 *
 * @param <E> The type of the entity.
 * @param <BH> The type of the object that is sent to perform the bulk update.
 *
 * @throws IllegalArgumentException if {@code entities} contains a null value or
 * an entity that already exists in the API (i.e. has a URI).
 *
 * @throws GenologicsUpdateException if the entities cannot be updated via the API
 * (as determined by the {@link GenologicsEntity#updateable()} flag).
 */
private <E extends Locatable, BH extends BatchUpdate<E>> void doUpdateAll(Collection<E> entities) {
    if (entities != null && !entities.isEmpty()) {
        Class<E> entityClass = checkCollectionHomogeneousAndUnique(entities, true);

        GenologicsEntity entityAnno = checkEntityAnnotated(entityClass);

        if (!entityAnno.updateable()) {
            throw new GenologicsUpdateException(getShortClassName(entityClass) + " cannot be updated.");
        }

        assert entityAnno.primaryEntity() == void.class : entityClass.getName()
                + " has a primary entity set, but such things cannot be updated through the API.";

        Class<BH> batchUpdateClass = getBatchRetrieveClassForEntity(entityClass);

        boolean doBatchUpdates = false;

        if (batchUpdateClass != null) {
            GenologicsBatchRetrieveResult batchAnnotation = batchUpdateClass
                    .getAnnotation(GenologicsBatchRetrieveResult.class);
            assert batchAnnotation != null : "No GenologicsBatchRetrieveResult annotation on result class "
                    + entityClass.getName();

            doBatchUpdates = batchAnnotation.batchUpdate() && entities.size() > 1;
        }

        checkServerSet();

        if (doBatchUpdates) {
            try {
                List<E> updatedEntities = new ArrayList<E>(entities.size());

                final int batchCapacity = Math.min(bulkOperationBatchSize, entities.size());
                List<E> batch = new ArrayList<E>(batchCapacity);

                Iterator<E> entityIter = entities.iterator();

                while (entityIter.hasNext()) {
                    batch.clear();

                    while (entityIter.hasNext() && batch.size() < batchCapacity) {
                        batch.add(entityIter.next());
                    }

                    BH details = batchUpdateClass.newInstance();
                    details.addForUpdate(batch);

                    String url = apiRoot + entityAnno.uriSection() + "/batch/update";

                    ResponseEntity<Links> updateReply = restClient.exchange(url, HttpMethod.POST,
                            new HttpEntity<BH>(details), Links.class);
                    Links replyLinks = updateReply.getBody();

                    assert replyLinks.getSize() == batch.size() : "Have " + replyLinks.getSize()
                            + " links returned for " + batch.size() + " submitted entities.";

                    // Fetch the updated objects to make sure all the properties are correct.
                    // Some may be disallowed or just not updated in the LIMS.

                    url = apiRoot + entityAnno.uriSection() + "/batch/retrieve";

                    ResponseEntity<BH> reloadReply = restClient.exchange(url, HttpMethod.POST,
                            new HttpEntity<Links>(replyLinks), batchUpdateClass);

                    updatedEntities.addAll(reloadReply.getBody().getList());
                }

                // The fetch of the entities using the Links object may not bring them back in
                // the order originally requested, so sort based on the order of the original
                // entities. As these entities already existed, they will all have URIs to
                // compare. We can then update the originals.

                reorderBatchFetchList(entities, updatedEntities);

                reflectiveCollectionUpdate(entities, updatedEntities);
            } catch (IllegalAccessException e) {
                logger.error("Cannot access the default constructor on {}", batchUpdateClass.getName());
            } catch (InstantiationException e) {
                logger.error("Cannot create a new {}: {}", batchUpdateClass.getName(), e.getMessage());
            }
        } else {
            for (E entity : entities) {
                if (entity != null) {
                    ResponseEntity<? extends Locatable> response = restClient.exchange(entity.getUri(),
                            HttpMethod.PUT, new HttpEntity<E>(entity), entity.getClass());

                    reflectiveUpdate(entity, response.getBody());
                }
            }
        }
    }
}

From source file:org.cruk.genologics.api.impl.GenologicsAPIImpl.java

/**
 * Create entities in the API for the entity objects given here.
 *
 * <p>//from ww  w  .ja  v a  2  s.c om
 * This method will use the batch create mechanism if there is a batch
 * retrieve class for the type of entity and that class is annotated
 * to say batch creates are allowed.
 * </p>
 *
 * @param entities The collection of entities to create.
 *
 * @throws IllegalArgumentException if {@code entities} contains a null value or
 * an entity that already exists in the API (i.e. has a URI).
 *
 * @throws GenologicsUpdateException if the entities cannot be created via the API
 * (as determined by the {@link GenologicsEntity#creatable()} flag).
 *
 * @param <E> The type of the entity.
 * @param <BH> The type of the object that holds the list of links to these entities.
 *
 * @see GenologicsEntity#creatable()
 * @see GenologicsBatchRetrieveResult#batchCreate()
 */
private <E extends Locatable, BH extends BatchUpdate<E>> void doCreateAll(Collection<E> entities) {
    if (entities != null && !entities.isEmpty()) {
        Class<E> entityClass = checkCollectionHomogeneousAndUnique(entities, false);

        GenologicsEntity entityAnno = checkEntityAnnotated(entityClass);

        if (!entityAnno.creatable()) {
            throw new GenologicsUpdateException(getShortClassName(entityClass) + " cannot be created.");
        }

        assert entityAnno.primaryEntity() == void.class : entityClass.getName()
                + " has a primary entity set, but such things cannot be created through the API.";

        Class<BH> batchRetrieveClass = getBatchRetrieveClassForEntity(entityClass);

        checkServerSet();

        boolean doBatchCreates = false;

        if (batchRetrieveClass != null) {
            GenologicsBatchRetrieveResult batchAnnotation = batchRetrieveClass
                    .getAnnotation(GenologicsBatchRetrieveResult.class);
            assert batchAnnotation != null : "No GenologicsBatchRetrieveResult annotation on result class "
                    + entityClass.getName();

            doBatchCreates = batchAnnotation.batchCreate() && entities.size() > 1;
        }

        if (doBatchCreates) {
            try {
                List<E> createdEntities = new ArrayList<E>(entities.size());
                Links createdLinks = new Links(entities.size());

                final int batchCapacity = Math.min(bulkOperationBatchSize, entities.size());
                List<E> batch = new ArrayList<E>(batchCapacity);

                Iterator<E> entityIter = entities.iterator();

                while (entityIter.hasNext()) {
                    batch.clear();

                    while (entityIter.hasNext() && batch.size() < batchCapacity) {
                        batch.add(entityIter.next());
                    }

                    BH details = batchRetrieveClass.newInstance();

                    details.addForCreate(batch);

                    String url = apiRoot + entityAnno.uriSection() + "/batch/create";

                    ResponseEntity<Links> createReply = restClient.exchange(url, HttpMethod.POST,
                            new HttpEntity<BH>(details), Links.class);
                    Links replyLinks = createReply.getBody();

                    assert replyLinks.getSize() == batch.size() : "Have " + replyLinks.getSize()
                            + " links returned for " + batch.size() + " submitted entities.";

                    // Need to record the links as they are returned from the create call
                    // in the order they are returned (see below).

                    createdLinks.addAll(replyLinks);

                    // Fetch the new objects to make sure all the properties are correct.

                    url = apiRoot + entityAnno.uriSection() + "/batch/retrieve";

                    ResponseEntity<BH> reloadReply = restClient.exchange(url, HttpMethod.POST,
                            new HttpEntity<Links>(replyLinks), batchRetrieveClass);

                    createdEntities.addAll(reloadReply.getBody().getList());
                }

                if (Sample.class.equals(entityClass)) {
                    // Special case for samples because we've found in tests that these do
                    // not have their URIs returned in the correct order from the batch
                    // create call. We can though use their location to match up the originals
                    // to the new copies.

                    updateFromNewSamples(entities, createdEntities);
                } else {
                    // The fetch of the entities using the Links may not bring them back in
                    // the order originally requested, so sort based on the order defined in
                    // the createdLinks object (now a collection of the links from all the
                    // batch call replies).

                    reorderBatchFetchList(createdLinks.getLinks(), createdEntities);

                    // We must assume that the order of the URIs returned in the Links object
                    // received after the creation POST is the same order as the original
                    // objects were submitted. The entities returned after the load of those
                    // objects may not be. So use the order of the Links URIs to update the
                    // original entities.
                    // This seems to hold true for containers, where every test (so far) sees
                    // them coming back in the right order.

                    reflectiveCollectionUpdate(entities, createdEntities);
                }
            } catch (IllegalAccessException e) {
                logger.error("Cannot access the default constructor on {}", batchRetrieveClass.getName());
            } catch (InstantiationException e) {
                logger.error("Cannot create a new {}: {}", batchRetrieveClass.getName(), e.getMessage());
            }
        } else {
            String uri = apiRoot + entityAnno.uriSection();

            for (E entity : entities) {
                doCreateSingle(entity, uri);
            }
        }
    }
}

From source file:com.espertech.esper.util.PopulateUtil.java

public static void populateObject(String operatorName, int operatorNum, String dataFlowName,
        Map<String, Object> objectProperties, Object top, EngineImportService engineImportService,
        EPDataFlowOperatorParameterProvider optionalParameterProvider,
        Map<String, Object> optionalParameterURIs) throws ExprValidationException {
    Class applicableClass = top.getClass();
    Set<WriteablePropertyDescriptor> writables = PropertyHelper.getWritableProperties(applicableClass);
    Set<Field> annotatedFields = JavaClassHelper.findAnnotatedFields(top.getClass(), DataFlowOpParameter.class);
    Set<Method> annotatedMethods = JavaClassHelper.findAnnotatedMethods(top.getClass(),
            DataFlowOpParameter.class);

    // find catch-all methods
    Set<Method> catchAllMethods = new LinkedHashSet<Method>();
    if (annotatedMethods != null) {
        for (Method method : annotatedMethods) {
            DataFlowOpParameter anno = (DataFlowOpParameter) JavaClassHelper
                    .getAnnotations(DataFlowOpParameter.class, method.getDeclaredAnnotations()).get(0);
            if (anno.all()) {
                if (method.getParameterTypes().length == 2 && method.getParameterTypes()[0] == String.class
                        && method.getParameterTypes()[1] == Object.class) {
                    catchAllMethods.add(method);
                    continue;
                }/* ww  w .ja v a 2  s . com*/
                throw new ExprValidationException("Invalid annotation for catch-call");
            }
        }
    }

    // map provided values
    for (Map.Entry<String, Object> property : objectProperties.entrySet()) {
        boolean found = false;
        String propertyName = property.getKey();

        // invoke catch-all setters
        for (Method method : catchAllMethods) {
            try {
                method.invoke(top, new Object[] { propertyName, property.getValue() });
            } catch (IllegalAccessException e) {
                throw new ExprValidationException("Illegal access invoking method for property '" + propertyName
                        + "' for class " + applicableClass.getName() + " method " + method.getName(), e);
            } catch (InvocationTargetException e) {
                throw new ExprValidationException("Exception invoking method for property '" + propertyName
                        + "' for class " + applicableClass.getName() + " method " + method.getName() + ": "
                        + e.getTargetException().getMessage(), e);
            }
            found = true;
        }

        if (propertyName.toLowerCase().equals(CLASS_PROPERTY_NAME)) {
            continue;
        }

        // use the writeable property descriptor (appropriate setter method) from writing the property
        WriteablePropertyDescriptor descriptor = findDescriptor(applicableClass, propertyName, writables);
        if (descriptor != null) {
            Object coerceProperty = coerceProperty(propertyName, applicableClass, property.getValue(),
                    descriptor.getType(), engineImportService, false);

            try {
                descriptor.getWriteMethod().invoke(top, new Object[] { coerceProperty });
            } catch (IllegalArgumentException e) {
                throw new ExprValidationException("Illegal argument invoking setter method for property '"
                        + propertyName + "' for class " + applicableClass.getName() + " method "
                        + descriptor.getWriteMethod().getName() + " provided value " + coerceProperty, e);
            } catch (IllegalAccessException e) {
                throw new ExprValidationException("Illegal access invoking setter method for property '"
                        + propertyName + "' for class " + applicableClass.getName() + " method "
                        + descriptor.getWriteMethod().getName(), e);
            } catch (InvocationTargetException e) {
                throw new ExprValidationException("Exception invoking setter method for property '"
                        + propertyName + "' for class " + applicableClass.getName() + " method "
                        + descriptor.getWriteMethod().getName() + ": " + e.getTargetException().getMessage(),
                        e);
            }
            continue;
        }

        // find the field annotated with {@link @GraphOpProperty}
        for (Field annotatedField : annotatedFields) {
            DataFlowOpParameter anno = (DataFlowOpParameter) JavaClassHelper
                    .getAnnotations(DataFlowOpParameter.class, annotatedField.getDeclaredAnnotations()).get(0);
            if (anno.name().equals(propertyName) || annotatedField.getName().equals(propertyName)) {
                Object coerceProperty = coerceProperty(propertyName, applicableClass, property.getValue(),
                        annotatedField.getType(), engineImportService, true);
                try {
                    annotatedField.setAccessible(true);
                    annotatedField.set(top, coerceProperty);
                } catch (Exception e) {
                    throw new ExprValidationException(
                            "Failed to set field '" + annotatedField.getName() + "': " + e.getMessage(), e);
                }
                found = true;
                break;
            }
        }
        if (found) {
            continue;
        }

        throw new ExprValidationException("Failed to find writable property '" + propertyName + "' for class "
                + applicableClass.getName());
    }

    // second pass: if a parameter URI - value pairs were provided, check that
    if (optionalParameterURIs != null) {
        for (Field annotatedField : annotatedFields) {
            try {
                annotatedField.setAccessible(true);
                String uri = operatorName + "/" + annotatedField.getName();
                if (optionalParameterURIs.containsKey(uri)) {
                    Object value = optionalParameterURIs.get(uri);
                    annotatedField.set(top, value);
                    if (log.isDebugEnabled()) {
                        log.debug("Found parameter '" + uri + "' for data flow " + dataFlowName + " setting "
                                + value);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Not found parameter '" + uri + "' for data flow " + dataFlowName);
                    }
                }
            } catch (Exception e) {
                throw new ExprValidationException(
                        "Failed to set field '" + annotatedField.getName() + "': " + e.getMessage(), e);
            }
        }

        for (Method method : annotatedMethods) {
            DataFlowOpParameter anno = (DataFlowOpParameter) JavaClassHelper
                    .getAnnotations(DataFlowOpParameter.class, method.getDeclaredAnnotations()).get(0);
            if (anno.all()) {
                if (method.getParameterTypes().length == 2 && method.getParameterTypes()[0] == String.class
                        && method.getParameterTypes()[1] == Object.class) {
                    for (Map.Entry<String, Object> entry : optionalParameterURIs.entrySet()) {
                        String[] elements = URIUtil.parsePathElements(URI.create(entry.getKey()));
                        if (elements.length < 2) {
                            throw new ExprValidationException("Failed to parse URI '" + entry.getKey()
                                    + "', expected " + "'operator_name/property_name' format");
                        }
                        if (elements[0].equals(operatorName)) {
                            try {
                                method.invoke(top, new Object[] { elements[1], entry.getValue() });
                            } catch (IllegalAccessException e) {
                                throw new ExprValidationException(
                                        "Illegal access invoking method for property '" + entry.getKey()
                                                + "' for class " + applicableClass.getName() + " method "
                                                + method.getName(),
                                        e);
                            } catch (InvocationTargetException e) {
                                throw new ExprValidationException(
                                        "Exception invoking method for property '" + entry.getKey()
                                                + "' for class " + applicableClass.getName() + " method "
                                                + method.getName() + ": " + e.getTargetException().getMessage(),
                                        e);
                            }
                        }
                    }
                }
            }
        }
    }

    // third pass: if a parameter provider is provided, use that
    if (optionalParameterProvider != null) {

        for (Field annotatedField : annotatedFields) {
            try {
                annotatedField.setAccessible(true);
                Object provided = annotatedField.get(top);
                Object value = optionalParameterProvider.provide(new EPDataFlowOperatorParameterProviderContext(
                        operatorName, annotatedField.getName(), top, operatorNum, provided, dataFlowName));
                if (value != null) {
                    annotatedField.set(top, value);
                }
            } catch (Exception e) {
                throw new ExprValidationException(
                        "Failed to set field '" + annotatedField.getName() + "': " + e.getMessage(), e);
            }
        }
    }
}

From source file:com.amalto.workbench.editors.DataModelMainPage.java

public void validateSchema() throws IllegalAccessException {

    final String msg_shouldRefresh[] = { Messages.XsdRefresh };

    // do not force to refresh every time just when an error throws.
    String error = validateDiagnoses(XSDEditor.MSG_OMIT);
    for (String msg : msg_shouldRefresh) {
        if (error.indexOf(msg) != -1) {
            refreshModelPageSchema();/*from   w  w w  .  j  a  v  a 2 s  . c  o m*/
        }
    }
    // refreshModelPageSchema and validate again
    error = validateDiagnoses(XSDEditor.MSG_OMIT);

    if (!error.equals("")) {//$NON-NLS-1$
        IllegalAccessException illegalAccessException = new IllegalAccessException(error);
        log.error(illegalAccessException.getMessage(), illegalAccessException);
        ErrorExceptionDialog.openError(this.getSite().getShell(), Messages.ErrorCommittingPage,
                CommonUtil.getErrMsgFromException(illegalAccessException));
    }

    validateType();
    validateElementation();
}

From source file:org.cruk.genologics.api.impl.GenologicsAPIImpl.java

/**
 * Reflectively set all the attributes in {@code original} to the values given
 * by {@code updated}. This has the effect of making {@code original} the
 * same as {@code updated} but without requiring the client code to change the
 * object reference to {@code original}, which may be referenced in many places.
 *
 * <p>//from ww w  .  ja  v  a  2 s  . c o  m
 * Where a field is a Collection, the existing collection is emptied and all the
 * objects from that field in {@code updated} are added in the same order to the
 * collection in {@code original}. Whether this order is maintained depends on
 * the type of collection in {@code original} (a list will maintain order, a set
 * typically won't).
 * </p>
 *
 * <p>
 * Fields that are static, transient or final are ignored, as are any fields annotated
 * with the {@code @XmlTransient} annotation.
 * </p>
 *
 * <p>
 * Note that fields within the original object that are objects themselves (as opposed to
 * primitives) are replaced with the new versions. References to sub objects are therefore
 * no longer valid.
 * </p>
 *
 * @param original The original object that was provided in the call and needs updating.
 * @param updated The version of the object returned from the LIMS with the current state.
 *
 * @throws IllegalArgumentException if either {@code original} or {@code updated}
 * are null, or are of different classes.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void reflectiveUpdate(Object original, Object updated) {
    if (original == null) {
        throw new IllegalArgumentException("original cannot be null");
    }
    if (updated == null) {
        throw new IllegalArgumentException("updated cannot be null");
    }

    if (!original.getClass().equals(updated.getClass())) {
        throw new IllegalArgumentException("original and updated are of different classes");
    }

    Class<?> clazz = original.getClass();

    do {
        Map<String, java.lang.reflect.Field> fieldMap = updaterFields.get(clazz);
        if (fieldMap == null) {
            fieldMap = Collections.synchronizedMap(new HashMap<String, java.lang.reflect.Field>());
            updaterFields.put(clazz, fieldMap);

            Class<?> currentClass = clazz;
            while (!Object.class.equals(currentClass)) {
                for (java.lang.reflect.Field field : currentClass.getDeclaredFields()) {
                    // Skip transient and XmlTransient fields.
                    if ((field.getModifiers() & REFLECTIVE_UPDATE_MODIFIER_MASK) == 0
                            && field.getAnnotation(XmlTransient.class) == null) {
                        field.setAccessible(true);
                        java.lang.reflect.Field clash = fieldMap.put(field.getName(), field);
                        if (clash != null) {
                            throw new AssertionError("There is more than one field with the name '"
                                    + field.getName() + " in the class hierarchy of " + clazz.getName() + " ("
                                    + getShortClassName(field.getDeclaringClass()) + " and "
                                    + getShortClassName(clash.getDeclaringClass()) + ")");
                        }
                    }
                }
                currentClass = currentClass.getSuperclass();
            }
        }

        for (java.lang.reflect.Field field : fieldMap.values()) {
            try {
                Object originalValue = field.get(original);
                Object updatedValue = field.get(updated);

                if (Collection.class.isAssignableFrom(field.getDeclaringClass())) {
                    Collection originalCollection = (Collection) originalValue;
                    Collection updatedCollection = (Collection) updatedValue;

                    if (originalCollection != null) {
                        originalCollection.clear();
                        if (updatedCollection != null) {
                            originalCollection.addAll(updatedCollection);
                        }
                    } else {
                        if (updatedCollection != null) {
                            // Getting as a property should create the collection object.
                            originalCollection = (Collection) PropertyUtils.getProperty(original,
                                    field.getName());
                            originalCollection.addAll(updatedCollection);
                        }
                    }
                } else if (Map.class.isAssignableFrom(field.getDeclaringClass())) {
                    throw new AssertionError("I didn't think we'd be dealing with maps: field "
                            + field.getName() + " on class " + field.getDeclaringClass().getName());
                } else {
                    field.set(original, updatedValue);
                }
            } catch (IllegalAccessException e) {
                logger.error("Cannot access the property {} on the class {}", field.getName(),
                        field.getDeclaringClass().getName());
                fieldMap.remove(field.getName());
            } catch (NoSuchMethodException e) {
                logger.error("There is no getter method for the property {} on the class {}", field.getName(),
                        field.getDeclaringClass().getName());
                fieldMap.remove(field.getName());
            } catch (InvocationTargetException e) {
                logger.error("Error while getting collection property {}", field.getName(),
                        e.getTargetException());
            } catch (ClassCastException e) {
                logger.error("Cannot cast a {} to a Collection.", e.getMessage());
            }
        }

        clazz = clazz.getSuperclass();
    } while (!Object.class.equals(clazz));
}

From source file:com.krawler.workflow.module.dao.ModuleBuilderDaoImpl.java

public String getColumndata(Object value, Hashtable<String, String> ht, String tableName,
        mb_reportlist basemodule, JSONObject jtemp, pm_taskmaster taskObj) throws ServiceException {
    String result = value.toString();
    if (ht.get("configtype").equals("combo")) {
        String columnName = ht.get("name").substring(0, ht.get("name").length() - 2);
        if (ht.get("refflag").equals("-1")) { // not combogridconfig
            try {
                Class clrefTable = value.getClass();
                Class[] arguments = new Class[] {};

                //check for delete flag
                java.lang.reflect.Method objMethod = clrefTable.getMethod("getDeleteflag", arguments);
                Object result1 = objMethod.invoke(value, new Object[] {});
                if (Double.parseDouble(result1.toString()) == 0) {
                    boolean conditionFlag = true;//ModuleBuilderController.checkFilterRules(session, taskObj, basemodule, value, 2);
                    if (conditionFlag) {
                        String methodName = "get"
                                + TextFormatter.format(getPrimaryColName(ht.get("reftable")), TextFormatter.G);
                        objMethod = clrefTable.getMethod(
                                "get" + TextFormatter.format(columnName, TextFormatter.G), arguments);
                        result1 = objMethod.invoke(value, new Object[] {});
                        result = result1.toString();
                        if (result.startsWith("com.krawler")) {
                            mb_configmasterdata mb_configmasterdata = (mb_configmasterdata) result1;
                            result = mb_configmasterdata.getMasterdata();
                        }/*from   w ww  . j a va  2s . co  m*/
                        objMethod = clrefTable.getMethod(methodName, arguments);
                        result1 = objMethod.invoke(value, new Object[] {});
                        result = result1.toString() + PropsValues.REPORT_HARDCODE_STR + result;

                        //fetch read only fields data
                        String SELECT_QUERY = "select mb_gridconfig.name,mb_gridconfig.displayfield,mb_gridconfig.reftable, "
                                + "mb_gridconfig.combogridconfig from com.krawler.esp.hibernate.impl.mb_gridconfig as mb_gridconfig where reportid = ? and mb_gridconfig.xtype = ? and mb_gridconfig.name like ? order by columnindex ";
                        List list = find(SELECT_QUERY, new Object[] { basemodule, "readOnlyCmp",
                                "%" + PropsValues.REPORT_HARDCODE_STR + ht.get("name") });
                        Iterator ite = list.iterator();
                        while (ite.hasNext()) {
                            Object[] row = (Object[]) ite.next();
                            String[] parentFieldName = row[0].toString().split(PropsValues.REPORT_HARDCODE_STR);

                            objMethod = clrefTable.getMethod(
                                    "get" + TextFormatter.format(parentFieldName[1], TextFormatter.G),
                                    arguments);
                            result1 = objMethod.invoke(value, new Object[] {});
                            jtemp.put(parentFieldName[0], result1.toString());
                        }
                    } else {
                        result = "conditionnotmatch";
                    }
                } else {
                    result = "deleted";
                }

            } catch (IllegalAccessException ex) {
                logger.warn(ex.getMessage(), ex);
            } catch (IllegalArgumentException ex) {
                logger.warn(ex.getMessage(), ex);
            } catch (InvocationTargetException ex) {
                logger.warn(ex.getMessage(), ex);
            } catch (NoSuchMethodException e) {
                logger.warn(e.getMessage(), e);
                throw ServiceException.FAILURE("FormServlet.getColumndata", e);
            } catch (Exception e) {
                logger.warn(e.getMessage(), e);
                throw ServiceException.FAILURE("FormServlet.getColumndata", e);
            }

        } else {
            mb_configmasterdata obj = (mb_configmasterdata) value;
            result = obj.getMasterid() + PropsValues.REPORT_HARDCODE_STR + obj.getMasterdata();
        }
    } else if (ht.get("configtype").equals("select")) {
        if (result.length() > 0) {
            String[] valueArray = result.split(",");
            String str = "(";
            for (int j = 0; j < valueArray.length; j++) {
                str += "'" + valueArray[j] + "',";
            }
            str = str.substring(0, str.length() - 1);
            str += ")";

            String sql = "";
            List li = null;
            Iterator ite = null;
            if (ht.get("refflag").equals("-1")) {// now combogridconfig
                String columnName = ht.get("name").substring(0, ht.get("name").length() - 2);
                sql = "select t1." + columnName + " from " + PropsValues.PACKAGE_PATH + "." + ht.get("reftable")
                        + " as t1  where t1.id in " + str;
                li = executeQuery(sql);
                ite = li.iterator();
                //                    rs = DbUtil.executeQuery(conn,sql,new Object[]{value});
            } else {
                sql = "select t1.masterdata as name from " + PropsValues.PACKAGE_PATH
                        + ".mb_configmasterdata as t1 where t1.configid = ? and t1.masterid in " + str
                        + " order by t1.masterdata";
                li = find(sql, new Object[] { ht.get("refflag") });
                ite = li.iterator();
                //                    rs = DbUtil.executeQuery(conn,sql, new Object[]{ht.get("reftable"),value});
            }
            str = "";
            while (ite.hasNext()) {
                str += ite.next() + ",";
            }
            str = str.length() > 0 ? str.substring(0, str.length() - 1) : "";
            result += PropsValues.REPORT_HARDCODE_STR + str;
        }
    } else if (ht.get("configtype").equals("file")) {
        if (!result.equals("")) {
            mb_docs docObj = (mb_docs) get(mb_docs.class, result);

            String Url = "fileDownload.jsp?url=" + tableName + "/" + docObj.getStorename() + "&docid=" + result
                    + "&attachment=true";
            //               String Url = "fileDownload.jsp?url="+tableName+"/"+result+"&attachment=true";
            result = "<img src='images/download.png' style='cursor: pointer;' onclick='setDldUrl(\"" + Url
                    + "\")'  title='Click to download'>";

        } else {
            result = "File not exists";
        }
    } else if (ht.get("configtype").equals("datefield")) {
        result = result.split(" ")[0];
    }
    return result;
}

From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java

/**
 * ??????????????/* ww w  .  j ava2s .c om*/
 * 
 * @param pvpSerno
 *            ??
 * @throws EMPException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws Exception
 * @since 2009-09-17
 * @author modified by zhangwei
 */
public String addPvpTfCvrgExtAuthorize(String pvpSerno)
        throws EMPException, IllegalAccessException, InvocationTargetException {

    String strReturnMessage = CMISMessage.ADDDEFEAT;
    PvpTfIface pvpTfIface = (PvpTfIface) this.getComponentInterface("PvpTfImpl");
    PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
    PvpTfCvrgExt pvpTfCvrgExt = new PvpTfCvrgExt();

    //??
    pvpTfCvrgExt = pvpTfIface.queryPvpTfCvrgExtBySerNo(pvpSerno);
    if (pvpTfCvrgExt == null || pvpTfCvrgExt.getContNo() == null) {
        System.out.println("???");
        return strReturnMessage;
    }

    // ??
    CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
    CusBase cusBase = customIface.getCusBase(pvpTfCvrgExt.getCusId());
    String transCusId = cusBase.getTransCusId();

    //????
    CtrTfCvrgExt ctrTfCvrgExt = null;
    CtrTfCvrgExtComponent ctrTfCvrgExtComponent = (CtrTfCvrgExtComponent) this.getComponent("CtrTfCvrgExt");
    ctrTfCvrgExt = ctrTfCvrgExtComponent.queryCtrTfCvrgExtDetail(pvpTfCvrgExt.getContNo());

    //???
    AccTfCvrg accTfCvrg = null;
    AccTfCvrgComponent accTfCvrgComponent = (AccTfCvrgComponent) this.getComponent("AccTfCvrg");
    accTfCvrg = accTfCvrgComponent.queryAccTfCvrgByContNoAndCondition(ctrTfCvrgExt.getOldContNo());

    AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
    AccTfComm accTfCommIns = new AccTfComm();
    accTfCommIns = accTfCommComponent.findAccTfCommByBillNo(ctrTfCvrgExt.getOldBillNo());
    //?
    accTfCommComponent.checkConditionBeforeAuthorize("PvpTfCvrgExt", pvpSerno, ctrTfCvrgExt.getContNo());

    Context context = this.getContext();
    Connection connection = this.getConnection();
    CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

    //???
    String[] billZero = { "", "00", "0", "" };
    int billSeqCtr = ctrTfCvrgExt.getBillSeq();
    String billSeq = String.valueOf(billSeqCtr);
    billSeq = billZero[billSeq.length()] + billSeq;
    String billNo = pvpTfCvrgExt.getContNo() + billSeq; // ??? ??????
    billSeqCtr++;
    ctrTfCvrgExt.setBillSeq(billSeqCtr);

    PvpAuthorize pvpAuthorize = new PvpAuthorize();
    pvpAuthorize.setSerno(pvpSerno);
    pvpAuthorize.setLoanNo(loanNo);
    pvpAuthorize.setCusManager(pvpTfCvrgExt.getCusManager());
    pvpAuthorize.setInputBrId(pvpTfCvrgExt.getInputBrId());
    pvpAuthorize.setFinaBrId(pvpTfCvrgExt.getFinaBrId());
    pvpAuthorize.setCusId(pvpTfCvrgExt.getCusId());
    pvpAuthorize.setCusName(pvpTfCvrgExt.getCusName());
    pvpAuthorize.setContNo(pvpTfCvrgExt.getContNo());
    pvpAuthorize.setBillNo(billNo);
    pvpAuthorize.setTradeAmount(pvpTfCvrgExt.getApplyAmount());
    pvpAuthorize.setTradeDate(this.getOpenDay());
    pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
    pvpAuthorize.setTradeCode("0034");
    pvpAuthorize.setFieldNum(26);

    //
    pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
    pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
    pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfCvrgExt.getContNo()); //???
    pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfCvrgExt.getCusId()); //?
    pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfCvrgExt.getCusName()); //??
    pvpAuthorize.setFldvalue06("c@bizType@" + "0034"); //??
    pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfCvrgExt.getApplyCurType()); //???
    pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfCvrgExt.getNewApplyAmount()); //?
    pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
    pvpAuthorize.setFldvalue10("c@dueDate@" + pvpTfCvrgExt.getNewDueDate()); //?
    pvpAuthorize.setFldvalue11("c@note@" + ""); //
    pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfCvrgExt.getFinaBrId()); //
    pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

    //?
    pvpAuthorize.setFldvalue14("c@iocNo@" + accTfCommIns.getSernoInternation()); //?
    pvpAuthorize.setFldvalue15("c@applyTerm@" + " ");
    //pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + pvpTfCvrgExt.getSecurityMoneyRt());
    DecimalFormat df = new DecimalFormat("#0.00");//??
    pvpAuthorize.setFldvalue16("c@securityMoneyRt@" + 100 * pvpTfCvrgExt.getSecurityMoneyRt()); //??
    List<TfSecurityMsg> securitylist = ctrTfCvrgExtComponent.querySecurityByCont(pvpTfCvrgExt.getContNo()); //?????

    if (securitylist.size() == 0) {
        pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + " "); //???1
        pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + " "); //???1
        pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + " ");
        pvpAuthorize.setFldvalue20("c@securityMoneyType@" + " "); //???1
        pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + " ");

        pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " "); //???2
        pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " "); //???2
        pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " "); //????2
        pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " "); //???1
        pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
    } else if (securitylist.size() == 1) {
        TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
        pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
        pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
        pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
        pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
        pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

        pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + " ");
        pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + " ");
        pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + " ");
        pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + " ");
        pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + " "); //????2
    } else if (securitylist.size() == 2) {
        TfSecurityMsg tfmsg = (TfSecurityMsg) securitylist.get(0);
        pvpAuthorize.setFldvalue17("c@securityMoneyAcNo@" + tfmsg.getSecurityMoneyAcNo());
        pvpAuthorize.setFldvalue18("c@securityMoneyAmt@" + df.format(tfmsg.getSecurityMoneyAmt()));
        pvpAuthorize.setFldvalue19("c@securityMoneyCur@" + tfmsg.getSecurityMoneyCur());
        pvpAuthorize.setFldvalue20("c@securityMoneyType@" + tfmsg.getSecurityMoneyType());
        pvpAuthorize.setFldvalue21("c@securityMoneyDueDate@" + tfmsg.getSecurityMoneyDueDate());

        TfSecurityMsg tfmsg2 = (TfSecurityMsg) securitylist.get(1);
        pvpAuthorize.setFldvalue22("c@securityMoneyAcNo1@" + tfmsg2.getSecurityMoneyAcNo());
        pvpAuthorize.setFldvalue23("c@securityMoneyAmt1@" + df.format(tfmsg2.getSecurityMoneyAmt()));
        pvpAuthorize.setFldvalue24("c@securityMoneyCur1@" + tfmsg2.getSecurityMoneyCur());
        pvpAuthorize.setFldvalue25("c@securityMoneyType1@" + tfmsg2.getSecurityMoneyType());
        pvpAuthorize.setFldvalue26("c@securityMoneyDueDate1@" + tfmsg2.getSecurityMoneyDueDate());
    }

    strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
    if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
        System.out.println("???");
        return strReturnMessage;
    }

    //????
    AccTfCvrgExt accTfCvrgExt = new AccTfCvrgExt();
    AccTfCvrgExtAgent accTfCvrgExtAgent = (AccTfCvrgExtAgent) this.getAgentInstance(PUBConstant.ACCTFCVRGEXT);
    BeanUtilsBean bub = new BeanUtilsBean();
    try {
        bub.copyProperties(accTfCvrgExt, pvpTfCvrgExt);
    } catch (IllegalAccessException e) {
        new ComponentException("?????");
    } catch (InvocationTargetException e) {
        new ComponentException("?????");
    }
    accTfCvrgExt.setLoanForm4("10");
    accTfCvrgExt.setCla("10");
    accTfCvrgExt.setBillNo(billNo);
    accTfCvrgExt.setAccountStatus("0");
    accTfCvrgExt.setLoanAmount(pvpTfCvrgExt.getApplyAmount());
    accTfCvrgExt.setLoanBalance(pvpTfCvrgExt.getApplyAmount());
    accTfCvrgExtAgent.insertAccTfCvrgExt(accTfCvrgExt);

    //????

    AccTfComm accTfComm = new AccTfComm();
    try {
        bub.copyProperties(accTfComm, accTfCvrgExt);
    } catch (IllegalAccessException e) {
        new ComponentException("?????");
    } catch (InvocationTargetException e) {
        new ComponentException("?????");
    }
    accTfComm.setLimitAccNo(accTfCvrgExt.getLimitAccNo());
    accTfComm.setApplyAmount(accTfCvrgExt.getNewApplyAmount());
    accTfComm.setLoanAmount(accTfCvrgExt.getNewApplyAmount());
    try {
        accTfCommComponent.addAccTfComm(accTfComm);
    } catch (Exception e) {
        accTfCommComponent.updateDomain(accTfComm);
    }

    //
    pvpTfCvrgExt.setChargeoffStatus(Constant.PVPSTATUS3);
    pvpTfCvrgExt.setBillNo(billNo);
    pvpTfIface.updatePvpTfCvrgExt(pvpTfCvrgExt);

    //?????
    ctrTfCvrgExtComponent.modifyCtrTfCvrgExt(ctrTfCvrgExt);

    //
    try {
        //???
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
        cbqService.queryAccreditNotice(connection, context);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ComponentException("??" + e.getMessage());
    }

    return strReturnMessage;
}

From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java

/**
 * ??????????????//  ww w  . j a  v  a 2  s  .  c  om
 * 
 * @param pvpSerno
 *            ??
 * @throws EMPException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws Exception
 * @since 2009-09-17
 * @author modified by zhangwei
 */
public String addPvpTfFftAuthorize(String pvpSerno)
        throws EMPException, IllegalAccessException, InvocationTargetException {

    String strReturnMessage = CMISMessage.ADDDEFEAT;

    //?
    PvpTfFftComponent pvpTfFftComponent = (PvpTfFftComponent) this.getComponent("PvpTfFft");
    PvpTfFft pvpTfFft = new PvpTfFft();
    pvpTfFft = pvpTfFftComponent.queryPvpTfFftBySerNo(pvpSerno);
    if (pvpTfFft == null || pvpTfFft.getContNo() == null) {
        return strReturnMessage;
    }

    //??
    //      CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
    //      CusBase cusBase = customIface.getCusBase(pvpTfFft.getCusId());
    //      String transCusId = cusBase.getTransCusId();

    //????
    CtrTfFft ctrTfFft = new CtrTfFft();
    CtrTfLocImpl ctrTfLocImpl = (CtrTfLocImpl) this.getComponentInterface("CtrTfLoc");
    ctrTfFft = ctrTfLocImpl.getCtrTfFft(pvpTfFft.getContNo());
    if (ctrTfFft == null) {
        System.out.println("????????");
        return strReturnMessage;
    }

    //?
    AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
    accTfCommComponent.checkConditionBeforeAuthorize("PvpTfFft", pvpSerno, ctrTfFft.getContNo());
    // ???
    //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    //String orgId = pvpTfOinvf.getInputBrId();
    //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
    //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
    //loanNo = loanNo.substring(2);

    Context context = this.getContext();
    Connection connection = this.getConnection();
    CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

    //???
    String[] billZero = { "", "00", "0", "" };
    int billSeqCtr = ctrTfFft.getBillSeq();
    String billSeq = String.valueOf(billSeqCtr);
    billSeq = billZero[billSeq.length()] + billSeq;
    String billNo = pvpTfFft.getContNo() + billSeq; // ??? ??????
    billSeqCtr++;
    ctrTfFft.setBillSeq(billSeqCtr);

    //???
    PvpAuthorize pvpAuthorize = new PvpAuthorize();

    pvpAuthorize.setSerno(pvpSerno);
    pvpAuthorize.setLoanNo(loanNo);
    pvpAuthorize.setCusManager(pvpTfFft.getCusManager());
    pvpAuthorize.setInputBrId(pvpTfFft.getInputBrId());
    pvpAuthorize.setFinaBrId(pvpTfFft.getFinaBrId());
    pvpAuthorize.setCusId(pvpTfFft.getCusId());
    pvpAuthorize.setCusName(pvpTfFft.getCusName());
    pvpAuthorize.setContNo(pvpTfFft.getContNo());
    pvpAuthorize.setBillNo(billNo);
    pvpAuthorize.setTradeAmount(pvpTfFft.getApplyAmount());
    pvpAuthorize.setTradeDate(this.getOpenDay());
    pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
    pvpAuthorize.setTradeCode("0014");
    pvpAuthorize.setFieldNum(25);

    //
    pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
    pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
    pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfFft.getContNo()); //???
    pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfFft.getCusId()); //?
    pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfFft.getCusName()); //??
    pvpAuthorize.setFldvalue06("c@bizType@" + "0014"); //??
    pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfFft.getApplyCurType()); //???
    pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfFft.getApplyAmount()); //?
    pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
    pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfFft.getDueDate())); //?
    pvpAuthorize.setFldvalue11("c@note@" + ""); //
    pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfFft.getFinaBrId()); //
    pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

    //?
    //1  2?  3
    String no = "";
    String fftType = "";
    String bizTypeSub = pvpTfFft.getBizTypeSub();
    if (bizTypeSub.equals("BMTH")) {
        no = pvpTfFft.getPriceNo();
        fftType = "3";
    } else if (bizTypeSub.equals("ZMTH")) {
        no = pvpTfFft.getPriceNo();
        fftType = "2";
    } else if (bizTypeSub.equals("ZXMR")) {
        no = pvpTfFft.getBpNo();
        fftType = "1";
    } else
        throw new ComponentException("?[" + bizTypeSub + "]");

    DecimalFormat sf = new DecimalFormat("#");
    pvpAuthorize.setFldvalue14("c@bpNo@" + checkNull(no));
    pvpAuthorize.setFldvalue15("c@fftType@" + checkNull(fftType));
    pvpAuthorize.setFldvalue16("c@enterAccount@" + checkNull(pvpTfFft.getEntAccNo()));
    pvpAuthorize.setFldvalue17("c@billCurType@" + checkNull(pvpTfFft.getApplyCurType()));
    pvpAuthorize.setFldvalue18("c@billAmt@" + pvpTfFft.getApplyAmount());
    pvpAuthorize.setFldvalue19("c@applyTerm@" + String.valueOf(sf.format(pvpTfFft.getApplyTerm())));
    pvpAuthorize.setFldvalue20("c@graceTerm@" + String.valueOf(sf.format(pvpTfFft.getDaysOfGrace())));
    DecimalFormat df = new DecimalFormat("#.000000");
    pvpAuthorize.setFldvalue21("c@discRate@" + df.format(pvpTfFft.getRealityIrY() * 100));
    pvpAuthorize.setFldvalue22("c@bearTerm@" + String.valueOf(sf.format(pvpTfFft.getBearDays())));
    pvpAuthorize.setFldvalue23("c@bearRate@" + df.format(pvpTfFft.getBearRate() * 100));
    pvpAuthorize.setFldvalue24("c@withholdingFee@" + pvpTfFft.getPreAmount());
    pvpAuthorize.setFldvalue25("c@chargeFee@" + pvpTfFft.getFeeAmt());

    //?????,? modified by wxy 20110108
    int appterm = 0;
    String dueDate;
    if (!this.getOpenDay().equals(pvpTfFft.getStartDate())) {

        appterm = (int) pvpTfFft.getApplyTerm();
        dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

        pvpTfFft.setStartDate(this.getOpenDay());
        pvpTfFft.setDueDate(dueDate);

        ctrTfFft.setStartDate(this.getOpenDay());
        ctrTfFft.setDueDate(dueDate);

        pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

    }

    //??
    PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
    strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
    if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
        System.out.println("???");
        return strReturnMessage;
    }

    AccTfFft accTfFft = new AccTfFft();
    AccTfFftAgent AccTfFftAgent = (AccTfFftAgent) this.getAgentInstance("AccTfFft");
    BeanUtilsBean bub = new BeanUtilsBean();
    try {
        bub.copyProperties(accTfFft, pvpTfFft);
    } catch (IllegalAccessException e) {
        new ComponentException("??????");
    } catch (InvocationTargetException e) {
        new ComponentException("??????");
    }
    accTfFft.setLoanForm4("10");
    accTfFft.setCla("10");
    accTfFft.setBillNo(billNo);
    accTfFft.setAccountStatus("0");
    accTfFft.setMainBrId(pvpTfFft.getInvestigatorBrId());
    accTfFft.setLoanAmount(pvpTfFft.getApplyAmount());
    accTfFft.setLoanBalance(pvpTfFft.getApplyAmount());
    AccTfFftAgent.insertAccTfFft(accTfFft);

    //???

    AccTfComm accTfComm = new AccTfComm();
    try {
        bub.copyProperties(accTfComm, accTfFft);
    } catch (IllegalAccessException e) {
        new ComponentException("????");
    } catch (InvocationTargetException e) {
        new ComponentException("????");
    }
    accTfComm.setSendDate(this.getOpenDay());
    try {
        accTfCommComponent.addAccTfComm(accTfComm);
    } catch (Exception e) {
        accTfCommComponent.updateDomain(accTfComm);
    }

    //
    pvpTfFft.setChargeoffStatus(Constant.PVPSTATUS3);
    pvpTfFftComponent.updatePvpTfFft(pvpTfFft);

    //???
    ctrTfLocImpl.modifyCtrTfFft(ctrTfFft);

    //
    try {
        /*??
        IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
              loanNo, connection, connection, context);
        KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
        String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
              .trim();
        pvpAuthorize.setHostSerno(hostSerNo);
        pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
        pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
           */

        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
        cbqService.queryAccreditNotice(connection, context);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ComponentException("??" + e.getMessage());
    }

    return strReturnMessage;
}

From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java

/**
 * ????????????????/*from  www  . j  ava 2  s  .c  o  m*/
 * 
 * @param pvpSerno
 *            ??
 * @throws EMPException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws Exception
 * @since 2009-09-17
 * @author modified by zhangwei
 */
public String addPvpTfOiffAuthorize(String pvpSerno)
        throws EMPException, IllegalAccessException, InvocationTargetException {

    String strReturnMessage = CMISMessage.ADDDEFEAT;

    //??
    PvpTfOiffComponent pvpTfOiffComponent = (PvpTfOiffComponent) this.getComponent("PvpTfOiff");
    PvpTfOiff pvpTfOiff = new PvpTfOiff();
    pvpTfOiff = pvpTfOiffComponent.queryPvpTfOiff(pvpSerno);
    if (pvpTfOiff == null || pvpTfOiff.getContNo() == null) {
        return strReturnMessage;
    }

    //??
    CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
    CusBase cusBase = customIface.getCusBase(pvpTfOiff.getCusId());
    String transCusId = cusBase.getTransCusId();

    //????
    CtrTfOiff ctrTfOiff = null;
    CtrTfOiffComponent ctrTfOiffComponent = (CtrTfOiffComponent) this.getComponent("CtrTfOiff");
    ctrTfOiff = ctrTfOiffComponent.queryCtrTfOiff(pvpTfOiff.getContNo());

    //?
    AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
    accTfCommComponent.checkConditionBeforeAuthorize("PvpTfOiff", pvpSerno, ctrTfOiff.getContNo());

    // ?????
    //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    //String orgId = pvpTfOiff.getInputBrId();
    //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
    //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
    //loanNo = loanNo.substring(2);

    //???
    Context context = this.getContext();
    Connection connection = this.getConnection();
    CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

    //???
    String[] billZero = { "", "00", "0", "" };
    int billSeqCtr = ctrTfOiff.getBillSeq();
    String billSeq = String.valueOf(billSeqCtr);
    billSeq = billZero[billSeq.length()] + billSeq;
    String billNo = pvpTfOiff.getContNo() + billSeq; // ??? ??????
    billSeqCtr++;
    ctrTfOiff.setBillSeq(billSeqCtr);

    PvpAuthorize pvpAuthorize = new PvpAuthorize();
    pvpAuthorize.setSerno(pvpSerno);
    pvpAuthorize.setLoanNo(loanNo);
    pvpAuthorize.setCusManager(pvpTfOiff.getCusManager());
    pvpAuthorize.setInputBrId(pvpTfOiff.getInputBrId());
    pvpAuthorize.setFinaBrId(pvpTfOiff.getFinaBrId());
    pvpAuthorize.setCusId(pvpTfOiff.getCusId());
    pvpAuthorize.setCusName(pvpTfOiff.getCusName());
    pvpAuthorize.setContNo(pvpTfOiff.getContNo());
    pvpAuthorize.setBillNo(billNo);
    pvpAuthorize.setTradeAmount(pvpTfOiff.getApplyAmount());
    pvpAuthorize.setTradeDate(this.getOpenDay());
    pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
    pvpAuthorize.setTradeCode("0019");
    pvpAuthorize.setFieldNum(17);

    //
    pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
    pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
    pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfOiff.getContNo()); //???
    pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfOiff.getCusId()); //?
    pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfOiff.getCusName()); //??
    pvpAuthorize.setFldvalue06("c@bizType@" + "0019"); //??
    pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfOiff.getApplyCurType()); //???
    pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfOiff.getApplyAmount()); //?
    pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)
    pvpAuthorize.setFldvalue10("c@dueDate@" + checkNull(pvpTfOiff.getDueDate())); //?
    pvpAuthorize.setFldvalue11("c@note@" + ""); //
    pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfOiff.getFinaBrId()); //
    pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

    //?
    pvpAuthorize.setFldvalue14("c@ifNo@" + checkNull(pvpTfOiff.getIfNo())); //???          
    DecimalFormat df = new DecimalFormat("#.000000");
    pvpAuthorize.setFldvalue15("c@realityIrY@" + df.format(pvpTfOiff.getRealityIrY() * 100)); //  
    pvpAuthorize.setFldvalue16("c@enterAccount@" + checkNull(pvpTfOiff.getEnterAccount())); //?          
    pvpAuthorize.setFldvalue17("c@intCalType@" + pvpTfOiff.getIntCalType()); //?          

    //?????,? modified by wxy 20110108
    int appterm = 0;
    String dueDate;
    if (!this.getOpenDay().equals(pvpTfOiff.getStartDate())) {
        System.out.println("------------openday----" + this.getOpenDay());
        appterm = (int) pvpTfOiff.getApplyTerm();
        dueDate = TimeUtil.ADD_DAY(this.getOpenDay(), appterm);

        pvpTfOiff.setStartDate(this.getOpenDay());
        pvpTfOiff.setDueDate(dueDate);
        //pvpTfOiffComponent.updatePvpTfOiff(pvpTfOiff);

        ctrTfOiff.setStartDate(this.getOpenDay());
        ctrTfOiff.setDueDate(dueDate);
        // ctrTfOiffComponent.modifyCtrTfOiff(ctrTfOiff);
        pvpAuthorize.setFldvalue10("c@dueDate@" + dueDate);

    }

    //??
    PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
    strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
    if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
        return strReturnMessage;
    }

    //??????
    AccTfOiff accTfOiff = new AccTfOiff();
    AccTfOiffAgent accTfOiffAgent = (AccTfOiffAgent) this.getAgentInstance("AccTfOiff");
    BeanUtilsBean bub = new BeanUtilsBean();
    try {
        bub.copyProperties(accTfOiff, pvpTfOiff);
    } catch (IllegalAccessException e) {
        new ComponentException("???????");
    } catch (InvocationTargetException e) {
        new ComponentException("???????");
    }

    accTfOiff.setBillNo(billNo);
    accTfOiff.setAccountStatus("0");
    accTfOiff.setMainBrId(pvpTfOiff.getInvestigatorBrId());
    accTfOiff.setLoanAmount(pvpTfOiff.getApplyAmount());
    accTfOiff.setLoanBalance(pvpTfOiff.getApplyAmount());
    accTfOiffAgent.insertAccTfOiff(accTfOiff);

    //????

    AccTfComm accTfComm = new AccTfComm();
    try {
        bub.copyProperties(accTfComm, accTfOiff);

    } catch (IllegalAccessException e) {
        new ComponentException("??????");
    } catch (InvocationTargetException e) {
        new ComponentException("??????");
    }

    accTfComm.setLimitAccNo(accTfOiff.getLimitAccNo());
    accTfComm.setSendDate(this.getOpenDay());
    try {
        accTfCommComponent.addAccTfComm(accTfComm);
    } catch (Exception e) {
        accTfCommComponent.updateDomain(accTfComm);
    }

    //
    pvpTfOiff.setChargeoffStatus(Constant.PVPSTATUS3);
    pvpTfOiff.setBillNo(billNo);
    pvpTfOiffComponent.updatePvpTfOiff(pvpTfOiff);

    //?????
    ctrTfOiffComponent.modifyCtrTfOiff(ctrTfOiff);

    try {
        /*??
        IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(loanNo, connection, connection, context);
        KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
        String hostSerNo = (String) reqPkg.get("hostSerNo").toString().trim();
        pvpAuthorize.setHostSerno(hostSerNo);
        pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
        pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
         */
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
        cbqService.queryAccreditNotice(connection, context);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ComponentException("?????" + e.getMessage());
    }

    return strReturnMessage;
}

From source file:com.yucheng.cmis.pvp.app.component.PvpAuthorizeComponent.java

/**
 * ???????????????/*from  w ww.j a  va 2s .  c  o  m*/
 * 
 * @param pvpSerno
 *            ??
 * @throws EMPException
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws Exception
 * @since 2009-09-17
 * @author modified by zhangwei
 * @throws ParseException 
 */
public String addPvpTfIbcAuthorize(String pvpSerno)
        throws EMPException, IllegalAccessException, InvocationTargetException, ParseException {

    String strReturnMessage = CMISMessage.ADDDEFEAT;
    PvpTfIface pvpTfIface = (PvpTfIface) this.getComponentInterface("PvpTfImpl");
    PvpAuthorizeAgent pvpAuthorizeAgent = (PvpAuthorizeAgent) this.getAgentInstance(PUBConstant.PVPAUTHORIZE);
    PvpTfIbc pvpTfIbc = new PvpTfIbc();

    //??
    pvpTfIbc = pvpTfIface.queryPvpTfIbcBySerNo(pvpSerno);
    if (pvpTfIbc == null || pvpTfIbc.getContNo() == null) {
        System.out.println("???");
        return strReturnMessage;
    }

    // ??
    CustomIface customIface = (CustomIface) this.getComponentInterface(CusPubConstant.CUS_IFACE);
    CusBase cusBase = customIface.getCusBase(pvpTfIbc.getCusId());
    String transCusId = cusBase.getTransCusId();

    //????
    CtrTfIbc ctrTfIbc = null;
    CtrTfIbcComponent ctrTfIbcComponent = (CtrTfIbcComponent) this.getComponent("CtrTfIbc");
    ctrTfIbc = ctrTfIbcComponent.queryCtrTfIbcDetail(pvpTfIbc.getContNo());

    //?
    AccTfCommComponent accTfCommComponent = (AccTfCommComponent) this.getComponent(PUBConstant.ACCTFCOMM);
    accTfCommComponent.checkConditionBeforeAuthorize("PvpTfIbc", pvpSerno, ctrTfIbc.getContNo());

    // ?????
    //CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    //String orgId = pvpTfIbc.getInputBrId();
    //billNo = sequenceService.getSequence(orgId, "fromOrg", 15, context);
    //String loanNo = sequenceService.getSequence("CZ", "fromDate", 15, context);
    //loanNo = loanNo.substring(2);

    Context context = this.getContext();
    Connection connection = this.getConnection();
    CMISSequenceService sequenceService = (CMISSequenceService) context.getService("sequenceService");
    String loanNo = sequenceService.getSequence(TradeCodeConstant.SERNONC, "44", context, connection);

    //???
    String[] billZero = { "", "00", "0", "" };
    int billSeqCtr = ctrTfIbc.getBillSeq();
    String billSeq = String.valueOf(billSeqCtr);
    billSeq = billZero[billSeq.length()] + billSeq;
    String billNo = pvpTfIbc.getContNo() + billSeq; // ??? ??????
    billSeqCtr++;
    ctrTfIbc.setBillSeq(billSeqCtr);

    PvpAuthorize pvpAuthorize = new PvpAuthorize();
    pvpAuthorize.setSerno(pvpSerno);
    pvpAuthorize.setLoanNo(loanNo);
    pvpAuthorize.setCusManager(pvpTfIbc.getCusManager());
    pvpAuthorize.setInputBrId(pvpTfIbc.getInputBrId());
    pvpAuthorize.setFinaBrId(pvpTfIbc.getFinaBrId());
    pvpAuthorize.setCusId(pvpTfIbc.getCusId());
    pvpAuthorize.setCusName(pvpTfIbc.getCusName());
    pvpAuthorize.setContNo(pvpTfIbc.getContNo());
    pvpAuthorize.setBillNo(billNo);
    pvpAuthorize.setTradeAmount(pvpTfIbc.getApplyAmount());
    pvpAuthorize.setTradeDate(this.getOpenDay());
    pvpAuthorize.setTradeStatus(TradeCodeConstant.WTZ);
    pvpAuthorize.setTradeCode("0012");
    pvpAuthorize.setFieldNum(18);

    //
    pvpAuthorize.setFldvalue01("c@loanNo@" + loanNo); //?
    pvpAuthorize.setFldvalue02("c@contSerno@" + billNo); //????
    pvpAuthorize.setFldvalue03("c@contNo@" + pvpTfIbc.getContNo()); //???
    pvpAuthorize.setFldvalue04("c@cusId@" + pvpTfIbc.getCusId()); //?
    pvpAuthorize.setFldvalue05("c@cusName@" + pvpTfIbc.getCusName()); //??
    pvpAuthorize.setFldvalue06("c@bizType@" + "0012"); //??
    pvpAuthorize.setFldvalue07("c@CurType@" + pvpTfIbc.getApplyCurType()); //???
    pvpAuthorize.setFldvalue08("c@Amount@" + pvpTfIbc.getApplyAmount()); //?
    pvpAuthorize.setFldvalue09("c@startDate@" + (String) context.getDataValue("OPENDAY")); //(?)

    //???
    /*
     *                 Calendar cal = Calendar.getInstance();
        cal.setTime(ft.parse(billDueDay_Holiday));
        cal.add(Calendar.DATE,3);
        billDueDay_Holiday_billIssue_Date = cal.getTime();
     */
    SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
    Date openday = ft.parse((String) context.getDataValue("OPENDAY"));

    Calendar cal = Calendar.getInstance();
    cal.setTime(openday);
    cal.add(Calendar.DATE, pvpTfIbc.getApplyTerm());
    Date dueDate = cal.getTime();
    String dueDateStr = ft.format(dueDate);

    pvpAuthorize.setFldvalue10("c@dueDate@" + dueDateStr); //??
    pvpAuthorize.setFldvalue11("c@note@" + ""); //
    pvpAuthorize.setFldvalue12("c@applyOrg@" + pvpTfIbc.getFinaBrId()); //
    pvpAuthorize.setFldvalue13("c@inputDate@" + (String) context.getDataValue("OPENDAY")); //

    //?
    DecimalFormat df = new DecimalFormat("#.000000");
    pvpAuthorize.setFldvalue14("c@realityIrY@" + df.format(pvpTfIbc.getRealityIrY() * 100)); //
    pvpAuthorize.setFldvalue15("c@iocNo@" + pvpTfIbc.getIocNo()); //???
    pvpAuthorize.setFldvalue16("c@tfBillNo@" + pvpTfIbc.getTfBillNo()); //????
    pvpAuthorize.setFldvalue17("c@enterAccount@" + pvpTfIbc.getEnterAccount()); //?
    pvpAuthorize.setFldvalue18("c@intCalType@" + pvpTfIbc.getIntCalType()); //??

    //pvpAuthorize.setFldvalue18("c@businessrate@" + BigDecimalUtil.mul(pvpTfIbc.getRulingIr(), 100, 6, BigDecimal.ROUND_HALF_UP));
    //pvpAuthorize.setFldvalue20("c@BillNo@" + checkNull(pvpTfIbc.getTfBillNo()));

    strReturnMessage = pvpAuthorizeAgent.insertPvpAuthorize(pvpAuthorize);
    if (!strReturnMessage.equals(CMISMessage.ADDSUCCEESS)) {
        System.out.println("???");
        return strReturnMessage;
    }

    //?????,? modified by wxy 20110108
    int appterm = 0;
    if (!this.getOpenDay().equals(pvpTfIbc.getStartDate())) {
        System.out.println("------------openday----" + this.getOpenDay());
        appterm = pvpTfIbc.getApplyTerm();
        pvpTfIbc.setStartDate(this.getOpenDay());
        pvpTfIbc.setApplyTerm(appterm);
        pvpTfIbc.setDueDate(dueDateStr);

        ctrTfIbc.setStartDate(this.getOpenDay());
        ctrTfIbc.setApplyTerm(appterm);
        ctrTfIbc.setDueDate(dueDateStr);

    }

    //????
    AccTfIbc accTfIbc = new AccTfIbc();
    AccTfIbcAgent accTfIbcAgent = (AccTfIbcAgent) this.getAgentInstance(PUBConstant.ACCTFIBC);
    BeanUtilsBean bub = new BeanUtilsBean();
    try {
        bub.copyProperties(accTfIbc, pvpTfIbc);
    } catch (IllegalAccessException e) {
        new ComponentException("?????");
    } catch (InvocationTargetException e) {
        new ComponentException("?????");
    }
    accTfIbc.setLoanForm4("10");
    accTfIbc.setCla("10");
    accTfIbc.setBillNo(billNo);
    accTfIbc.setAccountStatus("0");
    accTfIbc.setMainBrId(pvpTfIbc.getInvestigatorBrId());
    accTfIbc.setLoanAmount(pvpTfIbc.getApplyAmount());
    accTfIbc.setLoanBalance(pvpTfIbc.getApplyAmount());
    accTfIbcAgent.insertAccTfIbc(accTfIbc);

    //????

    AccTfComm accTfComm = new AccTfComm();
    try {
        bub.copyProperties(accTfComm, accTfIbc);
    } catch (IllegalAccessException e) {
        new ComponentException("?????");
    } catch (InvocationTargetException e) {
        new ComponentException("?????");
    }
    accTfComm.setLimitAccNo(accTfIbc.getLimitAccNo());
    accTfComm.setSendDate(this.getOpenDay());
    try {
        accTfCommComponent.addAccTfComm(accTfComm);
    } catch (Exception e) {
        accTfCommComponent.updateDomain(accTfComm);
    }

    //?
    pvpTfIbc.setChargeoffStatus(Constant.PVPSTATUS3);
    pvpTfIbc.setBillNo(billNo);
    pvpTfIface.updatePvpTfIbc(pvpTfIbc);

    //?????
    ctrTfIbcComponent.modifyCtrTfIbc(ctrTfIbc);

    //
    try {
        /*
        IndexedCollection icoll = cbqService.queryAccreditNotice4Trade(
              loanNo, connection, connection, context);
        KeyedCollection reqPkg = (KeyedCollection) icoll.get(0);
                
        String hostSerNo = (String) reqPkg.get("hostSerNo").toString()
              .trim();
        pvpAuthorize.setHostSerno(hostSerNo);
        pvpAuthorize.setTradeStatus(TradeCodeConstant.YTZ);
        pvpAuthorizeAgent.modifyCMISDomain(pvpAuthorize, "PvpAuthorize");
        */
        //???
        CreditBusinessQuartzService cbqService = new CreditBusinessQuartzService();
        cbqService.queryAccreditNotice(connection, context);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ComponentException("??" + e.getMessage());
    }

    return strReturnMessage;
}