⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 integratorgetrecords.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 4 页
字号:

                        SearchGridRecordsResponseObject result
                                = IntegratorHelper
                                .getNotEmptyResult(0, requestBuilder,
                                        entityName,
                                        EntityViewHelper.FieldsModificator.CUSTOMIZED_GRID,
                                        ls, ctx);
                        rows = new ArrayList<RowData>(Arrays.asList(
                            result.getGridData().getRows()));
                    } else {
                        RowData row = EntityOperationsHelper
                                .retrieveGridRowsDataFromResult(entityName,
                                        filter.getFiltersList(),
                                        EntityViewHelper.FieldsModificator.CUSTOMIZED_GRID,
                                        ls, ctx);
                        rows = new ArrayList<RowData>();
                        rows.add(row);
                    }
                    data = new GetRecordsInformOnDemandData(req.getElementID(),
                            rows, req.getFilter().getFiltersList());//for now we just resend the filters,
                    // but it can be a case, when we need to verify or process them.  
                    break;
                }
                default: {
                    throw new IllegalArgumentException(
                            "Couldn't create in-form grid "
                                    + "data of type [" + type + "].");
                }
            }
        } catch (UserQueryParseException ex) {
            IntegratorHelper.throwException("Incorrect value: " + ex.getValue() + ". Entity: " + ex.getEntityName() + ". Field: " +
                    ex.getFieldCaption(), ex);
        } catch (EQLSystemException ex) {
            IntegratorHelper.throwException("EQL System Exception. " + ex.getMessage(), ex);
        } catch (EQLException ex) {
            IntegratorHelper.throwException("EQL Exception. " + ex.getMessage(), ex);
        } catch (RuntimeException th) {
            IntegratorHelper.reThrowException(th);
        }
        return data;
    }

    /**
     * Builds available choises list
     * @param entityName
     * @param fieldFilters
     * @param eqlFilters
     * @param ls
     * @param ctx
     * @return
     * @throws EQLException
     */
    private static SubsetMeta getAvailableChoises(String entityName,
                                                  List<FieldData> fieldFilters,
                                                  String eqlFilters,
                                                  LogonSession ls,
                                                  ActionContext ctx
    )
            throws EQLException {
        //build options
        LinkedList<SubsetItemMeta> optionsList = EntityViewHelper
                .getOptionsForSubsetMeta(entityName, fieldFilters, eqlFilters, ls,
                        ctx);
        //build response
        return new SubsetMeta(optionsList.toArray(new SubsetItemMeta[optionsList.size()]));
    }

    private static FieldOnDemandData getMoreDataForEntityReference(EntityReferenceDataRequest elementRequest,
                                                                   LogonSession ls, ActionContext actx)
            throws EQLException {
        String entityName = elementRequest.getEntityName();

        //build filters for direct linked entity (see xml description)
        ArrayList<EntityData> filters = new ArrayList<EntityData>();
        FieldData mainEntityFilter = null;
        //if entity selected, choose it by pkey, otherwise try to add name filter to listfield.
        if(elementRequest.getId() != null) {
            String pkeyName = EntityViewHelper.getPkeyID(entityName, actx);
            mainEntityFilter = new TextboxFieldData(pkeyName, Long.toString(elementRequest.getId()));
        } else if(!StringHelper.isEmpty(elementRequest.getFilter())) {
            String listfieldName = EntityViewHelper.getListFieldNameForEntity(entityName, actx);
            mainEntityFilter = new TextboxFieldData(listfieldName, elementRequest.getFilter());
        }
        if(mainEntityFilter != null) {
            filters.add(new EntityData(entityName, -1L, new FieldData[]{mainEntityFilter}));
        }
        //add all additional filters
        filters.addAll(elementRequest.getAdditionalFilters());

        RequestProperties properties = new RequestProperties();
        properties.setDoCount(elementRequest.isCounterToggledOn());
        properties.setPage((int) elementRequest.getPage());
        properties.setPagesize(elementRequest.getPageSize());
        properties.setSortField(elementRequest.getSortOrder());

        Reqs castorRequest = EntityFacade.buildReqsFromEntities(filters,
                elementRequest.getEqlFilter(), entityName, properties, ls, actx);

        RowData[] responseRecords;
        HashMap<Long, String> listfieldValues;
        int totalRecordsCount = 0;
        int currentPage = 0;
        try {
            IntegratedRecordSet integratedRecordSet = EntityFacade.performRequest(castorRequest, entityName, ls, actx,
                    EntityViewHelper.FieldsModificator.GRID);

            Ress ress = integratedRecordSet.getInitialResultSet().getRess();
            totalRecordsCount = ress.getCount();
            currentPage = ress.getPage();
            responseRecords = EntityOperationsHelper.retrieveGridRowsDataFromResult(integratedRecordSet, ls, actx);

            //build listfield values array
            String key = integratedRecordSet.getListRefFieldName();
            FieldMeta listfieldMeta = integratedRecordSet.getRecordMeta().get(key);
            listfieldValues = new HashMap<Long, String>(integratedRecordSet.getRowsCount());
            for (IntegratedRecord record : integratedRecordSet.getRecordSet()) {
                FieldData listfield = record.getFieldSet().get(key);
                String fieldData = EntitySerializeHelper.getStringRepresentationForGrid(listfield, listfieldMeta, ls, actx);
                String pkeyFieldName = integratedRecordSet.getPkeyFieldName();
                Long rowID = Long.parseLong(EntitySerializeHelper.getValueStringRepresentation(record.getFieldSet().get(pkeyFieldName),
                        integratedRecordSet.getRecordMeta().get(pkeyFieldName)));
                listfieldValues.put(rowID, fieldData);
            }
        } catch (UserQueryParseException ex) {//in case of some incorrect entered data
            responseRecords = new RowData[0];
            listfieldValues = new HashMap<Long, String>();
        }

        return new EntityReferenceOnDemandData(elementRequest.getElementID(), new GridData(responseRecords, entityName), listfieldValues,
                totalRecordsCount, currentPage);
    }

    public static void printForm(PrintFormRequestObject printRequest, HttpServletRequest req) throws DisplayableException {
        ServletContext ctx = req.getSession().getServletContext();
        LogonSession ls = WebLoginManager.getLogonSession(req);
        long processId = printRequest.getProcessId();

        RequestProperties prop = new RequestProperties();
        prop.setDoCount(printRequest.isDoCount());
        prop.setPage(printRequest.getPage());
        prop.setPagesize(printRequest.getPageSize());
        Report report = new Report();
        report.setProcessId(processId);
        report.setPrintPage(printRequest.isPrintPage());
        report.setIgnoreIncludeToReport(true);

        Reqs r = null;
        try {
            r = EntityFacade.buildRequestByID(EntityOperationsHelper.getEntityNameFromFormID(printRequest.getFormID()),
                    printRequest.getRowID(), prop, ls, IntegratorHelper.getActionContext(ctx));
        } catch (EQLException ex) {
            IntegratorHelper.throwException("Eql exception occured. ", ex);
        }

        report.setReqs(new Reqs[]{r});

        // Construct ReportBuilder object.
        ReportBuilder reportBuilder = new ReportBuilder(ls, processId, report);

        // Put it in cache.
        IntegratorHelper.getReportBuilderCache(req.getSession()).putReportBuilder(reportBuilder);
    }

    public static void printGrid(PrintGridRequestObject printRequest, HttpServletRequest req)
            throws DisplayableException {
        ServletContext ctx = req.getSession().getServletContext();
        LogonSession ls = WebLoginManager.getLogonSession(req);
        long processId = printRequest.getProcessId();

        RequestProperties prop = new RequestProperties();
        prop.setDoCount(printRequest.isDoCount());
        prop.setPage(printRequest.getPage());
        prop.setPagesize(printRequest.getPageSize());
        prop.setDoHeader(true);
        Report report = new Report();
        report.setProcessId(processId);
        report.setPrintPage(printRequest.isPrintPage());
        report.setIgnoreIncludeToReport(true);
        try {
            ActionContext actx = IntegratorHelper.getActionContext(ctx);
            report.setReqs(new Reqs[]{
                    EntityFacade.buildReqsFromThisEntityFields((List<FieldData>) printRequest.getFieldsFilterData(),
                            EntityOperationsHelper.getEntityNameFromFormID(printRequest.getFormID()),
                            null, prop,
                            ls, actx)});
        } catch (EQLException ex) {
            IntegratorHelper.throwException("Eql exception occured. ", ex);
        }

        // Construct ReportBuilder object.
        ReportBuilder reportBuilder = new ReportBuilder(ls, processId, report);

        // Put it in cache.
        IntegratorHelper.getReportBuilderCache(req.getSession()).putReportBuilder(reportBuilder);
    }


    public static void saveSearch(SavedSearchObject search, HttpServletRequest request) throws DisplayableException {
        final String searchEntity = SEARCH_SAVING_ENTITY;
        LogonSession ls = WebLoginManager.getLogonSession(request);
        ServletContext ctx = request.getSession().getServletContext();

        String formId = search.getFormId();
        String entity = EntityOperationsHelper.getEntityNameFromFormID(formId);
        ActionContext actx = IntegratorHelper.getActionContext(ctx);
        Map<String, FieldMeta> meta = EntityViewHelper.getMetaForEntity(entity,
                EntityViewHelper.FieldsModificator.FORM, false, ls,
                actx);
        try {
            ArrayList<FieldData> l = new ArrayList<FieldData>();
            l.add(new TextboxFieldData("name", search.getSearchName()));
            l.add(new TextboxFieldData("focus_id", EntityOperationsHelper.getFocusNameFromFormID(formId)));
            l.add(new TextboxFieldData("tab_id", EntityOperationsHelper.getTabNameFromFormID(formId)));
            l.add(new TextboxFieldData("form_id", formId));
            l.add(new EntityReferenceData("owner_id", "", ls.getUser().getUserID()));
            l.add(new DateFieldData("timestamp", DateHelper.getNowDate(), DateHelper.getNowDate(), DateHelper.formatDate(
                    DateHelper.getNowDate())));
            if(search.isRowIDSet()) {
                IntegratedRecordSet resultset = EntityFacade.getEntityByIDRequest(searchEntity, search.getRowID(), ls, actx);
                LockManagerLocal locker = actx.getRecordsLockManager();
                EQLERes eqleRes = (EQLERes) resultset.getInitialResultSet().getEQLRes();
                locker.lock(eqleRes, "", 0L, ls);
                l.add(new TextboxFieldData("search_id", search.getRowID().toString()));
                l.add(new MemoFieldData("body", EntitySerializeHelper.serialize(search.getFieldsData(), meta), search.getRowID()));
                EntityData entityData = new EntityData(searchEntity, search.getRowID(), l.toArray(new FieldData[l.size()]));
                EntityFacade.updateRecord(entityData, actx, ls);
            } else {
                EntityData d = EntityFacade.createEntityPrototype(searchEntity, new LinkedList<FieldData>(), ls, actx);
                l.add(new TextboxFieldData("search_id", d.getRowID().toString()));
                l.add(new MemoFieldData("body", EntitySerializeHelper.serialize(search.getFieldsData(), meta), d.getRowID()));
                EntityData entityData = new EntityData(searchEntity, (long) -1, l.toArray(new FieldData[l.size()]));
                EntityFacade.insertRecord(entityData, actx, ls);
            }
        } catch (EQLException ex) {
            IntegratorHelper.throwException("Eql exception occured. ", ex);
        } catch (RecordDoesntExistsException ex) {
            IntegratorHelper.throwException("Record doesn't exist exception occured. ", ex);
        }
    }

    public static SavedSearchObject[] loadSavedSearches(HttpServletRequest request)
        throws EQLException {
        LogonSession ls = WebLoginManager.getLogonSession(request);
        RequestProperties props = new RequestProperties();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -