Example usage for java.math BigDecimal toString

List of usage examples for java.math BigDecimal toString

Introduction

In this page you can find the example usage for java.math BigDecimal toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.

Usage

From source file:com.tagaugmentedreality.NearByTagsList.java

public void prepareTagsList(String latitude, String longitude) {
    tagListView = (ListView) view.findViewById(R.id.tagListView);
    // tagListView.setVisibility(View.GONE);

    /*/*from w  ww . ja v a2  s .  c  o  m*/
     * I am building the tags list
     */

    for (int i = 0; i < TagListCache.getTagsList().size(); i++) {
        TagListCache.getTagsList().get(i).destroyTag();
        TagListCache.getTagsList().remove(i);
    } // end for

    TagListCache.getTagsList().clear();

    TagCache tag;
    OpenGLModelCache openGLModel;

    Location tagLocation = new Location(" ");
    Location deviceLocation = new Location(" ");
    deviceLocation.setLatitude(Utilities.LATITUDE);
    deviceLocation.setLongitude(Utilities.LONGITUDE);
    Float bearing = 0.0f;
    Float distance = 0.0f;
    BigDecimal bearingRounded;
    /*
     * TagCache(String id, OpenGLModelCache openGLModel, String title,
     * String comment, Double latitude, Double longitude, String
     * tagImageLink, String accuracy, String distance, Float direction,
     * String firstName, String lastName, String userFacebookId, String
     * city, String province, String country, boolean grouped )
     */

    // tag1

    tag = new TagCache("1", null, "Tag1", "Tag1 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.459379"));
    tagLocation.setLongitude(Double.parseDouble("74.368984"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag2

    tag = new TagCache("2", null, "Tag2", "Tag2 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.459379"));
    tagLocation.setLongitude(Double.parseDouble("74.368984"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag3

    tag = new TagCache("3", null, "Tag3", "Tag3 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.458804"));
    tagLocation.setLongitude(Double.parseDouble("74.368874"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    // tag4

    tag = new TagCache("4", null, "Tag4", "Tag4 is here.", Double.parseDouble(latitude),
            Double.parseDouble(longitude), "", "10", "10", 0.0f, "Lahore", "Punjab", "Pakistan", false);

    openGLModel = new OpenGLModelCache();
    openGLModel.resetVector();

    /**
     * I am getting the bearing of the tag with the device right here, by
     * using the latitude and longitude of both the tag and the device. Then
     * i am saving the value as the tag's heading.
     */
    tagLocation.setLatitude(Double.parseDouble("31.458651"));
    tagLocation.setLongitude(Double.parseDouble("74.369171"));
    distance = deviceLocation.distanceTo(tagLocation);
    bearing = deviceLocation.bearingTo(tagLocation);

    if (bearing < 0) {
        bearing = (-1) * bearing;
        bearing = 180 + (180 - bearing);
    } // end if

    bearingRounded = new BigDecimal(bearing).setScale(0, BigDecimal.ROUND_HALF_UP);
    bearing = Float.parseFloat(bearingRounded.toString());

    Log.e(Utilities.TAG, "bearing: " + bearing.toString());

    openGLModel.setHeading(bearing);// dataObject.getString("direction")));
    tag.setDirection(bearing);
    tag.setOpenGLModel(openGLModel);
    tag.setDistance(distance.toString());
    TagListCache.getTagsList().add(tag);

    /*
     * I am building the combined tags list to be used by the Browser
     */

    temporaryList.clear();
    CombinedTagListCache.getCombinedList().clear();
    CombinedTagCache combinedTag;
    int counter = 1;

    for (int i = 0; i < TagListCache.getTagsList().size(); ++i) {
        temporaryList.add(TagListCache.getTagsList().get(i).getTitle());

        /**
         * I am creating the combined tags list on the basis that each tag
         * in the group is separated (direction of each tag is away from
         * each other by the value given by
         * Utilities.combinedDirectionCriteria degrees) by
         * Utilities.combinedDirectionCriteria degrees. I am grouping
         * together tags because there is limited real estate in the
         * Augmented Reality View Screen.
         */
        combinedTag = new CombinedTagCache();

        if (!TagListCache.getTagsList().get(i).isGrouped()) {
            TagListCache.getTagsList().get(i).setGrouped(true);
            combinedTag.setId(((Integer) counter).toString());
            combinedTag.getTagList().add(TagListCache.getTagsList().get(i));
            combinedTag.setOpenGLModel(TagListCache.getTagsList().get(i).getOpenGLModel());
            combinedTag.setDirection(TagListCache.getTagsList().get(i).getDirection());
            combinedTag.setLatitude(TagListCache.getTagsList().get(i).getLatitude());
            combinedTag.setLongitude(TagListCache.getTagsList().get(i).getLongitude());

            CombinedTagListCache.getCombinedList().add(combinedTag);

            for (int j = 0; j < TagListCache.getTagsList().size(); j++) {
                if (!TagListCache.getTagsList().get(j).isGrouped()) {
                    if (Math.abs(TagListCache.getTagsList().get(i).getDirection() - TagListCache.getTagsList()
                            .get(j).getDirection()) < Utilities.COMBINED_DIRECTION_CRITERIA) {
                        combinedTag.getTagList().add(TagListCache.getTagsList().get(j));
                        TagListCache.getTagsList().get(j).setGrouped(true);
                    } // end if
                } // end if
            } // end for

            counter++;
        } // end if

    } // end for

    Log.e("combined tags size: ", "" + CombinedTagListCache.getCombinedList().size());

    for (int i = 0; i < CombinedTagListCache.getCombinedList().size(); i++) {
        Log.e("combined: ", "" + CombinedTagListCache.getCombinedList().get(i).getId());

        for (int j = 0; j < CombinedTagListCache.getCombinedList().get(i).getTagList().size(); j++) {

            Log.e("combined tag: ",
                    "" + CombinedTagListCache.getCombinedList().get(i).getTagList().get(j).getDirection());

        } // end for

    } // end for

    adapter.notifyDataSetChanged();

    // tagListView.setVisibility(View.VISIBLE);

    if (null != Lists.getActionProgressBar()) {
        Lists.getActionProgressBar().collapseActionView();
        Lists.getActionProgressBar().setActionView(null);

    } // end if

}

From source file:org.wso2.carbon.registry.jcr.RegistryNode.java

public Property setProperty(String s, BigDecimal bigDecimal) throws ValueFormatException, VersionException,
        LockException, ConstraintViolationException, RepositoryException {
    RegistryJCRItemOperationUtil.checkRetentionPolicy(registrySession, getPath());
    RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath());

    registrySession.sessionPending();/*w  w  w .  j av  a2  s.co m*/
    validatePropertyModifyPrivilege(s);

    if (bigDecimal != null) {

        Resource res = null;
        try {
            res = registrySession.getUserRegistry().newResource();
            res.setContent(bigDecimal.toString());
            res.setProperty("registry.jcr.property.type", "big_decimal");
            registrySession.getUserRegistry().put(nodePath + "/" + s, res);
            property = new RegistryProperty(nodePath + "/" + s, registrySession, s, bigDecimal);

        } catch (RegistryException e) {
            String msg = "failed to resolve the path of the given node or violation of repository syntax "
                    + this;
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }
        isModified = true;
        return property;

    } else {
        isModified = true;
        return null;
    }
}

From source file:com.gst.infrastructure.dataqueries.service.ReadWriteNonCoreDataServiceImpl.java

private String validateColumn(final ResultsetColumnHeaderData columnHeader, final String pValue,
        final String dateFormat, final Locale clientApplicationLocale) {

    String paramValue = pValue;/*  w ww. j a  va2s.  co  m*/
    if (columnHeader.isDateDisplayType() || columnHeader.isDateTimeDisplayType()
            || columnHeader.isIntegerDisplayType() || columnHeader.isDecimalDisplayType()
            || columnHeader.isBooleanDisplayType()) {
        // only trim if string is not empty and is not null.
        // throws a NULL pointer exception if the check below is not applied
        paramValue = StringUtils.isNotEmpty(paramValue) ? paramValue.trim() : paramValue;
    }

    if (StringUtils.isEmpty(paramValue) && columnHeader.isMandatory()) {

        final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
        final ApiParameterError error = ApiParameterError.parameterError("error.msg.column.mandatory",
                "Mandatory", columnHeader.getColumnName());
        dataValidationErrors.add(error);
        throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                "Validation errors exist.", dataValidationErrors);
    }

    if (StringUtils.isNotEmpty(paramValue)) {

        if (columnHeader.hasColumnValues()) {
            if (columnHeader.isCodeValueDisplayType()) {

                if (columnHeader.isColumnValueNotAllowed(paramValue)) {
                    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
                    final ApiParameterError error = ApiParameterError.parameterError(
                            "error.msg.invalid.columnValue", "Value not found in Allowed Value list",
                            columnHeader.getColumnName(), paramValue);
                    dataValidationErrors.add(error);
                    throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                            "Validation errors exist.", dataValidationErrors);
                }

                return paramValue;
            } else if (columnHeader.isCodeLookupDisplayType()) {

                final Integer codeLookup = Integer.valueOf(paramValue);
                if (columnHeader.isColumnCodeNotAllowed(codeLookup)) {
                    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
                    final ApiParameterError error = ApiParameterError.parameterError(
                            "error.msg.invalid.columnValue", "Value not found in Allowed Value list",
                            columnHeader.getColumnName(), paramValue);
                    dataValidationErrors.add(error);
                    throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                            "Validation errors exist.", dataValidationErrors);
                }

                return paramValue;
            } else {
                throw new PlatformDataIntegrityException("error.msg.invalid.columnType.",
                        "Code: " + columnHeader.getColumnName() + " - Invalid Type "
                                + columnHeader.getColumnType() + " (neither varchar nor int)");
            }
        }

        if (columnHeader.isDateDisplayType()) {
            final LocalDate tmpDate = JsonParserHelper.convertFrom(paramValue, columnHeader.getColumnName(),
                    dateFormat, clientApplicationLocale);
            if (tmpDate == null) {
                paramValue = null;
            } else {
                paramValue = tmpDate.toString();
            }
        } else if (columnHeader.isDateTimeDisplayType()) {
            final LocalDateTime tmpDateTime = JsonParserHelper.convertDateTimeFrom(paramValue,
                    columnHeader.getColumnName(), dateFormat, clientApplicationLocale);
            if (tmpDateTime == null) {
                paramValue = null;
            } else {
                paramValue = tmpDateTime.toString();
            }
        } else if (columnHeader.isIntegerDisplayType()) {
            final Integer tmpInt = this.helper.convertToInteger(paramValue, columnHeader.getColumnName(),
                    clientApplicationLocale);
            if (tmpInt == null) {
                paramValue = null;
            } else {
                paramValue = tmpInt.toString();
            }
        } else if (columnHeader.isDecimalDisplayType()) {
            final BigDecimal tmpDecimal = this.helper.convertFrom(paramValue, columnHeader.getColumnName(),
                    clientApplicationLocale);
            if (tmpDecimal == null) {
                paramValue = null;
            } else {
                paramValue = tmpDecimal.toString();
            }
        } else if (columnHeader.isBooleanDisplayType()) {

            final Boolean tmpBoolean = BooleanUtils.toBooleanObject(paramValue);
            if (tmpBoolean == null) {
                final ApiParameterError error = ApiParameterError.parameterError(
                        "validation.msg.invalid.boolean.format", "The parameter " + columnHeader.getColumnName()
                                + " has value: " + paramValue + " which is invalid boolean value.",
                        columnHeader.getColumnName(), paramValue);
                final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
                dataValidationErrors.add(error);
                throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                        "Validation errors exist.", dataValidationErrors);
            }
            paramValue = tmpBoolean.toString();
        } else if (columnHeader.isString()) {
            if (paramValue.length() > columnHeader.getColumnLength()) {
                final ApiParameterError error = ApiParameterError.parameterError(
                        "validation.msg.datatable.entry.column.exceeds.maxlength",
                        "The column `" + columnHeader.getColumnName() + "` exceeds its defined max-length ",
                        columnHeader.getColumnName(), paramValue);
                final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
                dataValidationErrors.add(error);
                throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
                        "Validation errors exist.", dataValidationErrors);
            }
        }
    }

    return paramValue;
}

From source file:org.egov.ptis.domain.service.property.VacancyRemissionService.java

public ReportRequest generateVRReportRequest(VacancyRemission vacancyRemission, String noticeNo,
        HttpServletRequest request, final String approvedUser) {
    ReportRequest reportInput = null;/*w  w w .  j  a v a2  s . c om*/
    CFinancialYear financialYear;
    if (vacancyRemission != null) {
        final BasicPropertyImpl basicProperty = vacancyRemission.getBasicProperty();
        final Map<String, Object> reportParams = new HashMap<>();
        final SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
        final String cityName = request.getSession().getAttribute("citymunicipalityname").toString();
        final String cityGrade = request.getSession().getAttribute("cityGrade") != null
                ? request.getSession().getAttribute("cityGrade").toString()
                : null;
        Boolean isCorporation;
        if (StringUtils.isNoneBlank(cityGrade) && CITY_GRADE_CORPORATION.equalsIgnoreCase(cityGrade))
            isCorporation = true;
        else
            isCorporation = false;
        final Address ownerAddress = basicProperty.getAddress();
        final PropertyID propertyId = basicProperty.getPropertyID();
        reportParams.put("isCorporation", isCorporation);
        reportParams.put("cityName", cityName);
        reportParams.put("userSignature",
                securityUtils.getCurrentUser().getSignature() != null
                        ? new ByteArrayInputStream(securityUtils.getCurrentUser().getSignature())
                        : "");
        reportParams.put("loggedInUsername", approvedUser);
        reportParams.put("approvedDate", formatter.format(vacancyRemission.getState().getCreatedDate()));
        reportParams.put("approverName",
                userService.getUserById(ApplicationThreadLocals.getUserId()).getName());
        reportParams.put("applicationDate", formatter.format(vacancyRemission.getCreatedDate()));
        reportParams.put("currentDate", formatter.format(new Date()));
        reportParams.put("noticeNo", noticeNo);
        reportParams.put("ownerName", basicProperty.getFullOwnerName());
        reportParams.put("houseNo", ownerAddress.getHouseNoBldgApt());
        reportParams.put("assessmentNo", basicProperty.getUpicNo());
        reportParams.put("locality", propertyId.getLocality().getName());
        reportParams.put("vrFromDate", formatter.format(vacancyRemission.getVacancyFromDate()));
        reportParams.put("vrToDate", formatter.format(vacancyRemission.getVacancyToDate()));
        final int noOfMonths = DateUtils.noOfMonthsBetween(vacancyRemission.getVacancyFromDate(),
                new DateTime(vacancyRemission.getVacancyToDate()).plusDays(1).toDate());
        reportParams.put("totalMonths", noOfMonths);
        final Map<String, BigDecimal> currentDemand = ptDemandDAO
                .getDemandCollMap(vacancyRemission.getBasicProperty().getProperty());
        BigDecimal halfYearTax = currentDemand.get(CURR_SECONDHALF_DMD_STR);
        BigDecimal newTax = BigDecimal.ZERO;
        financialYear = propertyTaxUtil.getFinancialYearforDate(new Date());
        final Map<String, Installment> installmentMap = propertyTaxUtil.getInstallmentsForCurrYear(
                vacancyRemission.getVacancyRemissionApproval().get(0).getApprovalDate());
        final Installment installmentFirstHalf = installmentMap.get(CURRENTYEAR_FIRST_HALF);
        final Installment installmentSecondHalf = installmentMap.get(CURRENTYEAR_SECOND_HALF);
        Ptdemand currPtDemand = getCurrentPTDemand(installmentFirstHalf,
                vacancyRemission.getBasicProperty().getActiveProperty().getPtDemandSet());
        if (isApprovedInFirstHalf(vacancyRemission, installmentFirstHalf)) {
            halfYearTax = currentDemand.get(CURR_FIRSTHALF_DMD_STR);
            newTax = getNewTax(currPtDemand, newTax, installmentFirstHalf);
        } else {
            newTax = getNewTax(currPtDemand, newTax, installmentSecondHalf);
        }
        reportParams.put("financialYear", financialYear.getFinYearRange());
        reportParams.put("halfYearTax", halfYearTax.toString());
        reportParams.put("newTax", newTax.toString());
        reportInput = new ReportRequest(VR_SPECIALNOTICE_TEMPLATE, vacancyRemission, reportParams);
    }
    if (reportInput != null) {
        reportInput.setPrintDialogOnOpenReport(true);
        reportInput.setReportFormat(ReportFormat.PDF);
    }
    return reportInput;
}

From source file:org.pentaho.metadata.util.XmiParser.java

@SuppressWarnings("unchecked")
protected void createDescriptions(Document doc, IConcept concept, String parentTag, String idstr,
        List<Element> allDescriptions, IdGen idGen) {
    for (String key : concept.getChildProperties().keySet()) {

        String body = null;// w w  w.  j  a v  a 2  s.  c  o  m
        String type = null;

        Object val = concept.getChildProperty(key);
        /*
         * <CWM:Description body="POSTALCODE" name="formula" type="String" xmi.id="a927"> <CWM:Description.modelElement>
         * <CWMRDB:Column xmi.idref="a922"/> </CWM:Description.modelElement> </CWM:Description>
         */
        if (val instanceof String) {
            if (key.equals(SqlPhysicalColumn.TARGET_COLUMN)) {
                key = "formula"; //$NON-NLS-1$
            }
            String str = (String) val;
            body = str;
            type = "String"; //$NON-NLS-1$
        } else if (val instanceof Boolean) {
            Boolean bool = (Boolean) val;
            type = "Boolean"; //$NON-NLS-1$
            body = bool.booleanValue() ? "Y" : "N"; //$NON-NLS-1$ //$NON-NLS-2$
        } else if (val instanceof Color) {
            Color c = (Color) val;
            ColorSettings cs = new ColorSettings(c.getRed(), c.getGreen(), c.getBlue());
            body = cs.toString();
            type = "Color"; //$NON-NLS-1$
        } else if (val instanceof URL) {
            body = val.toString();
            type = "URL"; //$NON-NLS-1$
        } else if (val instanceof org.pentaho.metadata.model.concept.types.ColumnWidth) {
            org.pentaho.metadata.model.concept.types.ColumnWidth ncw = (org.pentaho.metadata.model.concept.types.ColumnWidth) val;
            type = "ColumnWidth"; //$NON-NLS-1$
            ColumnWidth cw = new ColumnWidth(ncw.getType().ordinal(), ncw.getWidth());
            body = cw.toString();
        } else if (val instanceof Double) {
            type = "Number"; //$NON-NLS-1$
            BigDecimal bd = new BigDecimal((Double) val);
            body = bd.toString();
        } else if (val instanceof Alignment) {
            Alignment alignment = (Alignment) val;
            AlignmentSettings as = AlignmentSettings.types[alignment.ordinal()];
            body = as.toString();
            type = "Alignment"; //$NON-NLS-1$
        } else if (val instanceof org.pentaho.metadata.model.concept.security.Security) {
            org.pentaho.metadata.model.concept.security.Security security = (org.pentaho.metadata.model.concept.security.Security) val;
            Map<org.pentaho.pms.schema.security.SecurityOwner, Integer> map = new HashMap<org.pentaho.pms.schema.security.SecurityOwner, Integer>();
            for (SecurityOwner owner : security.getOwners()) {
                org.pentaho.pms.schema.security.SecurityOwner ownerObj = new org.pentaho.pms.schema.security.SecurityOwner(
                        owner.getOwnerType().ordinal(), owner.getOwnerName());
                map.put(ownerObj, security.getOwnerRights(owner));
            }
            Security legacySecurity = new Security(map);
            body = legacySecurity.toXML();
            type = "Security"; //$NON-NLS-1$
        } else if (val instanceof RowLevelSecurity) {
            RowLevelSecurity nrls = (RowLevelSecurity) val;
            org.pentaho.pms.schema.security.RowLevelSecurity rls = new org.pentaho.pms.schema.security.RowLevelSecurity();
            rls.setType(Type.values()[nrls.getType().ordinal()]);
            rls.setGlobalConstraint(nrls.getGlobalConstraint());
            Map<org.pentaho.pms.schema.security.SecurityOwner, String> roleBasedConstraintMap = new HashMap<org.pentaho.pms.schema.security.SecurityOwner, String>();
            for (SecurityOwner owner : nrls.getRoleBasedConstraintMap().keySet()) {
                org.pentaho.pms.schema.security.SecurityOwner ownerObj = new org.pentaho.pms.schema.security.SecurityOwner(
                        owner.getOwnerType().ordinal(), owner.getOwnerName());
                roleBasedConstraintMap.put(ownerObj, nrls.getRoleBasedConstraintMap().get(owner));
            }
            rls.setRoleBasedConstraintMap(roleBasedConstraintMap);

            body = rls.toXML();
            type = "RowLevelSecurity"; //$NON-NLS-1$
        } else if (val instanceof Font) {
            ConceptPropertyFont font = (ConceptPropertyFont) ThinModelConverter.convertPropertyToLegacy("font", //$NON-NLS-1$
                    val);
            body = ((FontSettings) font.getValue()).toString();
            type = "Font"; //$NON-NLS-1$
        } else if (val instanceof TargetTableType) {
            TargetTableType ttt = (TargetTableType) val;
            if (!(ttt == TargetTableType.TABLE)) {
                type = "TargetTableType"; //$NON-NLS-1$
                body = ttt.toString();
            }
        } else if (val instanceof TableType) {
            TableType tt = (TableType) val;
            body = TableTypeSettings.getTypeDescriptions()[tt.ordinal()];
            type = "TableType"; //$NON-NLS-1$
        } else if (val instanceof LocalizedString) {
            // need to add description for each locale
            LocalizedString lstr = (LocalizedString) val;
            for (String locale : lstr.getLocales()) {
                createDescription(doc, lstr.getLocalizedString(locale), key, "LocString", locale, idGen, //$NON-NLS-1$
                        parentTag, idstr, allDescriptions);
            }
        } else if (val instanceof TargetColumnType) {
            TargetColumnType tct = (TargetColumnType) val;
            body = tct == TargetColumnType.OPEN_FORMULA ? "Y" : "N"; //$NON-NLS-1$ //$NON-NLS-2$
            key = "exact"; //$NON-NLS-1$
            type = "Boolean"; //$NON-NLS-1$
        } else if (val instanceof FieldType) {
            FieldType ft = (FieldType) val;
            // concept.setProperty(name, FieldType.values()[FieldTypeSettings.getType(body).getType()]);
            body = FieldTypeSettings.getTypeDescriptions()[ft.ordinal()];
            type = "FieldType"; //$NON-NLS-1$
        } else if (val instanceof DataType) {
            body = DataTypeSettings.types[((DataType) val).ordinal()].getCode();
            type = "DataType"; //$NON-NLS-1$
        } else if (val instanceof AggregationType) {
            AggregationType at = (AggregationType) val;
            body = AggregationSettings.types[at.ordinal()].getCode();
            type = "Aggregation"; //$NON-NLS-1$
        } else if (val instanceof List) {
            List objs = (List) val;
            if (objs.size() == 0 && "aggregation_list".equals(key)) {
                // assume this is an agg list
                ConceptPropertyAggregationList list = new ConceptPropertyAggregationList(key,
                        new ArrayList<AggregationSettings>());
                type = "AggregationList"; //$NON-NLS-1$
                body = list.toXML();

            } else {
                if (objs.get(0) instanceof AggregationType) {
                    List<AggregationType> aggTypes = (List<AggregationType>) objs;
                    type = "AggregationList"; //$NON-NLS-1$
                    List<AggregationSettings> aggSettings = new ArrayList<AggregationSettings>();
                    for (AggregationType aggType : aggTypes) {
                        aggSettings.add(AggregationSettings.types[aggType.ordinal()]);
                    }
                    ConceptPropertyAggregationList list = new ConceptPropertyAggregationList(key, aggSettings);
                    type = "AggregationList"; //$NON-NLS-1$
                    body = list.toXML();
                } else if (objs.get(0) instanceof OlapRole) {
                    body = OlapUtil.toXmlRoles((List<OlapRole>) objs);
                    type = "String";
                } else if (!(objs.get(0) instanceof OlapCube || objs.get(0) instanceof OlapDimension)) {
                    logger.error(Messages.getErrorString(
                            "XmiParser.ERROR_0004_UNSUPPORTED_CONCEPT_PROPERTY_LIST", objs.get(0).getClass())); //$NON-NLS-1$
                }
            }
        } else {
            if (val == null) {
                logger.error(
                        Messages.getErrorString("XmiParser.ERROR_0005_UNSUPPORTED_CONCEPT_PROPERTY", "null")); //$NON-NLS-2$ //$NON-NLS-2$
            } else {
                logger.error(Messages.getErrorString("XmiParser.ERROR_0005_UNSUPPORTED_CONCEPT_PROPERTY", //$NON-NLS-1$
                        val.getClass()));
            }
        }
        if (type != null) {
            createDescription(doc, body, key, type, null, idGen, parentTag, idstr, allDescriptions);
        }
    }
}

From source file:org.opentaps.common.util.UtilCommon.java

/**
 * Given a set of values, calculates the correspondent % of total.
 *
 * @param values a <code>Map</code> of values, such as customer/vendor balance values
 * @param minPercentage the minimum percentage to consider for calculation purposes
 * @param locale the <code>Locale</code> used to build the label strings
 * @return returns the weight (percentage) of each balance
 *//*from w  w  w  .j  a  v a  2s .c  o  m*/
public static List<Map<String, Number>> getPercentageValues(Map<String, BigDecimal> values,
        BigDecimal minPercentage, Locale locale) {

    Collection<BigDecimal> inValues = values.values();
    Set<String> keys = values.keySet();
    List<Map<String, Number>> list = new LinkedList<Map<String, Number>>();
    BigDecimal total = BigDecimal.ZERO;
    BigDecimal othersTotal = BigDecimal.ZERO;
    final int decimals = 2; // precision for the percentage values

    // total up all the values
    for (BigDecimal value : inValues) {
        total = total.add(value);
    }

    if (total.signum() > 0) { //prevent division by zero
        for (String key : keys) {
            BigDecimal value = values.get(key);
            value = value.divide(total, 10, RoundingMode.HALF_UP);
            if (value.compareTo(minPercentage) == 1) { //greater than minPercentage?
                Map<String, Number> map = FastMap.newInstance();
                value = value.multiply(new BigDecimal(100)).setScale(decimals, RoundingMode.HALF_UP); //display only 2 decimal places
                map.put(key, value);
                list.add(map);
            } else {
                othersTotal = othersTotal.add(value).setScale(decimals + 3, RoundingMode.HALF_UP);
            }
        }

        // normalize to % - ie 0.577 to 57.7
        othersTotal = othersTotal.multiply(new BigDecimal(100)).setScale(decimals, RoundingMode.HALF_UP);
        if (othersTotal.signum() > 0) {
            list.add(UtilMisc.<String, Number>toMap(UtilMessage.expandLabel("CommonOther", locale)
                    + String.format(" (%1$s%%)", othersTotal.toString()), othersTotal));
        }
    }

    return list;
}

From source file:com.axelor.apps.account.service.MoveLineExportService.java

/**
 * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type avoir
 * @param mlr/*from   w  w  w.ja v a  2  s .  c o  m*/
 * @param replay
 * @throws AxelorException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public void exportMoveLineTypeSelect1007FILE1(MoveLineReport moveLineReport, boolean replay)
        throws AxelorException, IOException {

    log.info("In export service 1007 FILE 1:");

    Company company = moveLineReport.getCompany();

    String dateQueryStr = String.format(" WHERE self.company = %s", company.getId());
    JournalType journalType = moveLineReportService.getJournalType(moveLineReport);
    if (moveLineReport.getJournal() != null) {
        dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId());
    } else {
        dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId());
    }
    if (moveLineReport.getPeriod() != null) {
        dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (replay) {
        dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        dateQueryStr += " AND self.accountingOk = false ";
    }
    dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false ";
    dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);
    Query dateQuery = JPA.em().createQuery(
            "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date");

    List<LocalDate> allDates = new ArrayList<LocalDate>();
    allDates = dateQuery.getResultList();

    log.debug("allDates : {}", allDates);

    List<String[]> allMoveData = new ArrayList<String[]>();
    String companyCode = "";

    String reference = "";
    String moveQueryStr = "";
    String moveLineQueryStr = "";
    if (moveLineReport.getRef() != null) {
        reference = moveLineReport.getRef();
    }
    if (moveLineReport.getCompany() != null) {
        companyCode = moveLineReport.getCompany().getCode();
        moveQueryStr += String.format(" AND self.company = %s", moveLineReport.getCompany().getId());
    }
    if (moveLineReport.getPeriod() != null) {
        moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (moveLineReport.getDateFrom() != null) {
        moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString());
    }
    if (moveLineReport.getDateTo() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString());
    }
    if (moveLineReport.getDate() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString());
    }
    if (replay) {
        moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        moveQueryStr += " AND self.accountingOk = false ";
    }
    moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);

    LocalDate interfaceDate = moveLineReport.getDate();

    for (LocalDate dt : allDates) {

        List<Journal> journalList = journalRepo.all()
                .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch();

        if (moveLineReport.getJournal() != null) {
            journalList = new ArrayList<Journal>();
            journalList.add(moveLineReport.getJournal());
        }

        for (Journal journal : journalList) {

            List<Move> moveList = moveRepo.all().filter(
                    "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2"
                            + moveQueryStr,
                    dt, journal).fetch();

            String journalCode = journal.getExportCode();

            if (moveList.size() > 0) {

                BigDecimal sumCredit = this.getSumCredit(
                        "self.account.reconcileOk = true AND self.credit != 0.00 AND self.move in ?1 "
                                + moveLineQueryStr,
                        moveList);

                if (sumCredit.compareTo(BigDecimal.ZERO) == 1) {

                    String exportNumber = this.getSaleExportNumber(company);

                    Move firstMove = moveList.get(0);
                    String periodCode = firstMove.getPeriod().getFromDate().format(MONTH_FORMAT);

                    this.updateMoveList(moveList, moveLineReport, interfaceDate, exportNumber);

                    String items[] = new String[8];
                    items[0] = companyCode;
                    items[1] = journalCode;
                    items[2] = exportNumber;
                    items[3] = interfaceDate.format(DATE_FORMAT);
                    items[4] = sumCredit.toString();
                    items[5] = reference;
                    items[6] = dt.format(DATE_FORMAT);
                    items[7] = periodCode;
                    allMoveData.add(items);
                }
            }
        }
    }

    String fileName = "entete" + todayTime.format(DATE_TIME_FORMAT) + "avoirs.dat";
    String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
    new File(filePath).mkdirs();

    log.debug("Full path to export : {}{}", filePath, fileName);
    CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData);
    // Utilis pour le debuggage
    //         CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData);
}

From source file:com.axelor.apps.account.service.MoveLineExportService.java

/**
 * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type vente
 * @param mlr/*from  w  ww.jav a2s.c o m*/
 * @param replay
 * @throws AxelorException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public void exportMoveLineTypeSelect1006FILE1(MoveLineReport moveLineReport, boolean replay)
        throws AxelorException, IOException {

    log.info("In export service Type 1006 FILE 1 :");

    Company company = moveLineReport.getCompany();

    String dateQueryStr = String.format(" WHERE self.company = %s", company.getId());
    JournalType journalType = moveLineReportService.getJournalType(moveLineReport);
    if (moveLineReport.getJournal() != null) {
        dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId());
    } else {
        dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId());
    }
    if (moveLineReport.getPeriod() != null) {
        dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (replay) {
        dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        dateQueryStr += " AND self.accountingOk = false ";
    }
    dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false ";
    dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);
    Query dateQuery = JPA.em().createQuery(
            "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date");

    List<LocalDate> allDates = new ArrayList<LocalDate>();
    allDates = dateQuery.getResultList();

    log.debug("allDates : {}", allDates);

    List<String[]> allMoveData = new ArrayList<String[]>();
    String companyCode = "";

    String reference = "";
    String moveQueryStr = "";
    String moveLineQueryStr = "";
    if (moveLineReport.getRef() != null) {
        reference = moveLineReport.getRef();
    }
    if (company != null) {
        companyCode = company.getCode();
        moveQueryStr += String.format(" AND self.company = %s", company.getId());
    }
    if (moveLineReport.getPeriod() != null) {
        moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (moveLineReport.getDateFrom() != null) {
        moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString());
    }
    if (moveLineReport.getDateTo() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString());
    }
    if (moveLineReport.getDate() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString());
    }
    if (replay) {
        moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        moveQueryStr += " AND self.accountingOk = false ";
    }
    moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);

    LocalDate interfaceDate = moveLineReport.getDate();

    for (LocalDate dt : allDates) {

        List<Journal> journalList = journalRepo.all()
                .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch();

        if (moveLineReport.getJournal() != null) {
            journalList = new ArrayList<Journal>();
            journalList.add(moveLineReport.getJournal());
        }

        for (Journal journal : journalList) {

            List<? extends Move> moveList = moveRepo.all().filter(
                    "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2"
                            + moveQueryStr,
                    dt, journal).fetch();

            String journalCode = journal.getExportCode();

            if (moveList.size() > 0) {

                BigDecimal sumDebit = this.getSumDebit(
                        "self.account.reconcileOk = true AND self.debit != 0.00 AND self.move in ?1 "
                                + moveLineQueryStr,
                        moveList);

                if (sumDebit.compareTo(BigDecimal.ZERO) == 1) {

                    String exportNumber = this.getSaleExportNumber(company);

                    Move firstMove = moveList.get(0);
                    String periodCode = firstMove.getPeriod().getFromDate().format(MONTH_FORMAT);

                    this.updateMoveList((List<Move>) moveList, moveLineReport, interfaceDate, exportNumber);

                    String items[] = new String[8];
                    items[0] = companyCode;
                    items[1] = journalCode;
                    items[2] = exportNumber;
                    items[3] = interfaceDate.format(DATE_FORMAT);
                    items[4] = sumDebit.toString();
                    items[5] = reference;
                    items[6] = dt.format(DATE_FORMAT);
                    items[7] = periodCode;
                    allMoveData.add(items);
                }
            }
        }
    }

    String fileName = "entete" + todayTime.format(DATE_TIME_FORMAT) + "ventes.dat";
    String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
    new File(filePath).mkdirs();

    log.debug("Full path to export : {}{}", filePath, fileName);
    CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData);
    // Utilis pour le debuggage
    //         CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData);
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8NumberDefTable.java

public void createNumberDef(MSSBamAuthorization Authorization, MSSBamNumberDefBuff Buff) {
    final String S_ProcName = "createNumberDef ";
    try {/*from www  .  j  av  a 2s . c om*/
        Connection cnx = schema.getCnx();
        long Id = Buff.getRequiredId();
        short Digits = Buff.getRequiredDigits();
        short Precision = Buff.getRequiredPrecision();
        BigDecimal InitValue = Buff.getOptionalInitValue();
        BigDecimal DefaultValue = Buff.getOptionalDefaultValue();
        BigDecimal MinValue = Buff.getOptionalMinValue();
        BigDecimal MaxValue = Buff.getOptionalMaxValue();
        BigDecimal NullValue = Buff.getOptionalNullValue();
        BigDecimal UnknownValue = Buff.getOptionalUnknownValue();
        String sql = "INSERT INTO mssbam110.number_def( " + "id, " + "digits, " + "precision, " + "initval, "
                + "defval, " + "minval, " + "maxval, " + "nullval, " + "unknownval" + " )" + "VALUES ( " + Id
                + ", " + Digits + ", " + Precision + ", "
                + ((InitValue == null) ? "null" : InitValue.toString()) + ", "
                + ((DefaultValue == null) ? "null" : DefaultValue.toString()) + ", "
                + ((MinValue == null) ? "null" : MinValue.toString()) + ", "
                + ((MaxValue == null) ? "null" : MaxValue.toString()) + ", "
                + ((NullValue == null) ? "null" : NullValue.toString()) + ", "
                + ((UnknownValue == null) ? "null" : UnknownValue.toString()) + " )";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        int rowsAffected = stmt.executeUpdate(sql);
        if (rowsAffected != 1) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 row to be affected by insert, not " + rowsAffected);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:com.axelor.apps.account.service.MoveLineExportService.java

/**
 * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type achat
 * @param mlr//from ww  w  . j a  v  a2  s.com
 * @param replay
 * @throws AxelorException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public void exportMoveLineTypeSelect1009FILE1(MoveLineReport moveLineReport, boolean replay)
        throws AxelorException, IOException {

    log.info("In export service 1009 FILE 1:");

    Company company = moveLineReport.getCompany();
    String dateQueryStr = String.format(" WHERE self.company = %s", company.getId());
    JournalType journalType = moveLineReportService.getJournalType(moveLineReport);
    if (moveLineReport.getJournal() != null) {
        dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId());
    } else {
        dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId());
    }
    if (moveLineReport.getPeriod() != null) {
        dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (replay) {
        dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        dateQueryStr += " AND self.accountingOk = false ";
    }
    dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false ";
    dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);
    Query dateQuery = JPA.em().createQuery(
            "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date");

    List<LocalDate> allDates = new ArrayList<LocalDate>();
    allDates = dateQuery.getResultList();

    log.debug("allDates : {}", allDates);

    List<String[]> allMoveData = new ArrayList<String[]>();
    String companyCode = "";

    String reference = "";
    String moveQueryStr = "";
    String moveLineQueryStr = "";
    if (moveLineReport.getRef() != null) {
        reference = moveLineReport.getRef();
    }
    if (company != null) {
        companyCode = company.getCode();
        moveQueryStr += String.format(" AND self.company = %s", company.getId());
    }
    if (moveLineReport.getPeriod() != null) {
        moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId());
    }
    if (moveLineReport.getDateFrom() != null) {
        moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString());
    }
    if (moveLineReport.getDateTo() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString());
    }
    if (moveLineReport.getDate() != null) {
        moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString());
    }
    if (replay) {
        moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s",
                moveLineReport.getId());
    } else {
        moveQueryStr += " AND self.accountingOk = false ";
    }
    moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED);

    LocalDate interfaceDate = moveLineReport.getDate();

    for (LocalDate dt : allDates) {

        List<Journal> journalList = journalRepo.all()
                .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch();

        if (moveLineReport.getJournal() != null) {
            journalList = new ArrayList<Journal>();
            journalList.add(moveLineReport.getJournal());
        }

        for (Journal journal : journalList) {

            List<Move> moveList = moveRepo.all().filter(
                    "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2"
                            + moveQueryStr,
                    dt, journal).fetch();

            String journalCode = journal.getExportCode();

            int moveListSize = moveList.size();

            if (moveListSize > 0) {

                int i = 0;

                for (Move move : moveList) {

                    List<MoveLine> moveLineList = moveLineRepo.all().filter(
                            "self.account.reconcileOk = true AND self.credit != 0.00 AND self.move in ?1"
                                    + moveLineQueryStr,
                            moveList).fetch();

                    if (moveLineList.size() > 0) {

                        String exportNumber = this.getPurchaseExportNumber(company);

                        String periodCode = move.getPeriod().getFromDate().format(MONTH_FORMAT);

                        BigDecimal totalCredit = this.getSumCredit(moveLineList);
                        String invoiceId = "";
                        String dueDate = "";
                        if (move.getInvoice() != null) {
                            invoiceId = move.getInvoice().getInvoiceId();
                            dueDate = move.getInvoice().getDueDate().toString();
                        }

                        MoveLine firstMoveLine = moveLineList.get(0);
                        String items[] = new String[11];
                        items[0] = companyCode;
                        items[1] = journalCode;
                        items[2] = exportNumber;
                        items[3] = interfaceDate.format(DATE_FORMAT);
                        items[4] = invoiceId;
                        items[5] = dueDate;
                        items[6] = firstMoveLine.getAccount().getCode();
                        items[7] = totalCredit.toString();
                        items[8] = reference;
                        items[9] = dt.format(DATE_FORMAT);
                        items[10] = periodCode;
                        allMoveData.add(items);

                        this.updateMove(move, moveLineReport, interfaceDate, exportNumber);

                        if (i % 10 == 0) {
                            JPA.clear();
                        }
                        if (i++ % 100 == 0) {
                            log.debug("Process : {} / {}", i, moveListSize);
                        }
                    }
                }
            }
        }
    }

    String fileName = "entete" + todayTime.format(DATE_TIME_FORMAT) + "achats.dat";
    String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
    new File(filePath).mkdirs();

    log.debug("Full path to export : {}{}", filePath, fileName);
    CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData);
    // Utilis pour le debuggage
    //         CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData);
}