Example usage for org.apache.commons.lang3 StringUtils abbreviate

List of usage examples for org.apache.commons.lang3 StringUtils abbreviate

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils abbreviate.

Prototype

public static String abbreviate(final String str, final int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:org.openestate.is24.restapi.utils.RandomRealEstateFactory.java

/**
 * Initialize a {@link SeniorCare} object with random values.
 *
 * @param realEstate//  w w  w.  ja  va  2  s.c  o m
 * object to initialize
 */
protected void initRealEstate(SeniorCare realEstate) {
    realEstate.setBalconyAvailable(getRandomBalconyAvailableType());
    realEstate.setBarrierFree(getRandomYesNotApplicableType());
    realEstate.setBranchEntry(getRandomBoolean());
    realEstate.setCareLevel(getRandomCareLevel());
    realEstate.setCareOfAlzheimer(getRandomYesNotApplicableType());
    realEstate.setCareOfArtificialRespiration(getRandomYesNotApplicableType());
    realEstate.setCareOfComaVigil(getRandomYesNotApplicableType());
    realEstate.setCareOfDementia(getRandomYesNotApplicableType());
    realEstate.setCareOfMultipleSclerosis(getRandomYesNotApplicableType());
    realEstate.setCareOfParkinson(getRandomYesNotApplicableType());
    realEstate.setCareOfStroke(getRandomYesNotApplicableType());
    realEstate.setCleaningServiceAvailable(getRandomYesNotApplicableType());
    realEstate.setCookingFacilitiesAvailable(getRandomYesNotApplicableType());
    realEstate.setCulturalProgramAvailable(getRandomYesNotApplicableType());
    realEstate.setGuestApartmentsAvailable(getRandomYesNotApplicableType());
    realEstate.setHandicappedAccessible(getRandomYesNotApplicableType());
    realEstate.setKitchenAvailable(getRandomYesNotApplicableType());
    realEstate.setLeisureActivitiesAvailable(getRandomYesNotApplicableType());
    realEstate.setLivingSpaceFrom(getRandomDecimal(20, 50));
    realEstate.setLivingSpaceTo(getRandomDecimal(50, 150));
    realEstate.setNumberOfBeds(getRandomLong(1, 10));
    realEstate.setNumberOfLookedAfterApartments(getRandomLong(1, 10));
    realEstate.setNumberOfNursingPlaces(getRandomLong(1, 10));
    realEstate.setOpening(getRandomCalendar());
    realEstate.setOwnFurniturePossible(getRandomYesNotApplicableType());
    realEstate.setPetsAllowed(getRandomPetsAllowedType());
    realEstate.setReligiousOfferingsAvailable(getRandomYesNotApplicableType());
    realEstate.setRestaurantAvailable(getRandomYesNotApplicableType());
    realEstate.setRoomType(getRandomRoomType());
    realEstate.setSecurity24Hours(getRandomYesNotApplicableType());
    realEstate.setShoppingFacilitiesAvailable(getRandomYesNotApplicableType());
    realEstate.setShortDescription(StringUtils.abbreviate(LOREM.getWords(3, 15), 200));
    realEstate.setTherapyOfferingsAvailable(getRandomYesNotApplicableType());
    realEstate.setTrialLivingPossible(getRandomYesNotApplicableType());

    // care types
    realEstate.setCareTypes(commonFactory.createCareTypes());
    realEstate.getCareTypes().getCareType().addAll(Arrays.asList(CareType.values()));

    // pricing
    realEstate.setPrice(getDefaultPrice());
    realEstate.getPrice().setMarketingType(MarketingType.RENT);
    realEstate.getPrice().setPriceIntervalType(PriceIntervalType.MONTH);
    realEstate.getPrice().setValue(getRandomDecimal(500, 9999));
}

From source file:org.openestate.is24.restapi.utils.RandomRealEstateFactory.java

/**
 * Initialize a {@link ShortTermAccommodation} object with random values.
 *
 * @param realEstate/*from  w ww . j  av a 2  s  .co m*/
 * object to initialize
 */
protected void initRealEstate(ShortTermAccommodation realEstate) {
    realEstate.setBalcony(getRandomBoolean());
    realEstate.setBaseRent(getRandomDecimal(200, 1500));
    realEstate.setCellar(getRandomBoolean());
    realEstate.setCondition(getRandomRealEstateCondition());
    realEstate.setDeposit(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setEndRentalDate(getRandomCalendar());
    realEstate.setEnergySourcesEnev2014(createRandomEnergySourcesEnev2014());
    realEstate.setFloor(String.valueOf(getRandomLong(5)));
    realEstate.setGarden(getRandomBoolean());
    realEstate.setGender(getRandomFlatMateGenderType());
    realEstate.setGuestToilet(getRandomBoolean());
    realEstate.setHandicappedAccessible(getRandomBoolean());
    realEstate.setHasFurniture(getRandomYesNoNotApplicableType());
    realEstate.setHeatingTypeEnev2014(getRandomHeatingTypeEnev2014());
    realEstate.setLift(getRandomBoolean());
    realEstate.setLivingSpace(getRandomDecimal(20, 300));
    realEstate.setMaxNumberOfPersons(getRandomLong(4, 10));
    realEstate.setMaxRentalTime(getRandomDecimal(12, 24));
    realEstate.setMinRentalTime(getRandomDecimal(3, 12));
    realEstate.setNonSmoker(getRandomBoolean());
    realEstate.setNumberOfFloors(getRandomLong(1, 10));
    realEstate.setNumberOfParkingSpaces(getRandomLong(1, 10));
    realEstate.setNumberOfRooms(getRandomDecimal(1, 10));
    realEstate.setParkingSpacePrice(getRandomDecimal(30, 300));
    realEstate.setParkingSpaceType(getRandomParkingSpaceType());
    realEstate.setPetsAllowed(getRandomPetsAllowedType());
    realEstate.setServiceCharge(getRandomDecimal(50, 500));
    realEstate.setShortTermAccomodationType(getRandomShortTermAccommodationType());
    realEstate.setStartRentalDate(getRandomCalendar());

    // construction year
    if (getRandomBoolean()) {
        realEstate.setConstructionYear(null);
        realEstate.setConstructionYearUnknown(true);
    } else {
        realEstate.setConstructionYear(getRandomLong(1900, 1980));
    }

    // courtage
    realEstate.setCourtage(commonFactory.createCourtageInfo());
    realEstate.getCourtage().setCourtage(StringUtils.abbreviate(LOREM.getWords(1, 5), 100));
    realEstate.getCourtage().setCourtageNote(StringUtils.abbreviate(LOREM.getParagraphs(2, 10), 1000));
    realEstate.getCourtage().setHasCourtage(YesNoNotApplicableType.YES);

    // energy certificate for habitation
    realEstate.setEnergyCertificate(commonFactory.createEnergyPerformanceCertificate());

    // energy certificate for habitation by consumption
    if (getRandomBoolean()) {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_CONSUMPTION);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.setEnergyConsumptionContainsWarmWater(getRandomYesNotApplicableType());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // energy certificate for habitation by demand
    else {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_REQUIRED);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // pricing
    realEstate.setPrice(getDefaultPrice());
    realEstate.getPrice().setMarketingType(MarketingType.RENT);
    realEstate.getPrice().setPriceIntervalType(PriceIntervalType.MONTH);
    realEstate.getPrice().setValue(getRandomDecimal(200, 9999));
}

From source file:org.openestate.is24.restapi.utils.RandomRealEstateFactory.java

/**
 * Initialize a {@link SpecialPurpose} object with random values.
 *
 * @param realEstate//from w ww . j a  v  a 2 s .c  om
 * object to initialize
 */
protected void initRealEstate(SpecialPurpose realEstate) {
    realEstate.setAdditionalArea(getRandomDecimal(250, 5000));
    realEstate.setBasement(getRandomYesNotApplicableType());
    realEstate.setCondition(getRandomRealEstateCondition());
    realEstate.setDeposit(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setDistanceToAirport(getRandomLong(5, 50));
    realEstate.setDistanceToFM(getRandomLong(5, 50));
    realEstate.setDistanceToMRS(getRandomLong(5, 50));
    realEstate.setDistanceToPT(getRandomLong(5, 50));
    realEstate.setEnergySourcesEnev2014(createRandomEnergySourcesEnev2014());
    realEstate.setFlooringType(getRandomFlooringType());
    realEstate.setFreeFrom(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setHeatingTypeEnev2014(getRandomHeatingTypeEnev2014());
    realEstate.setInteriorQuality(getRandomInteriorQuality());
    realEstate.setLastRefurbishment(getRandomLong(1990, 2014));
    realEstate.setLift(getRandomYesNotApplicableType());
    realEstate.setListed(getRandomYesNotApplicableType());
    realEstate.setMinDivisible(getRandomDecimal(500, 2500));
    realEstate.setNetFloorSpace(getRandomDecimal(50, 5000));
    realEstate.setNumberOfFloors(String.valueOf(getRandomInt(1, 10)));
    realEstate.setNumberOfParkingSpaces(getRandomLong(1, 10));
    realEstate.setParkingSpacePrice(getRandomDecimal(30, 300));
    realEstate.setPlotArea(getRandomDecimal(100, 5000));
    realEstate.setSpecialPurposePropertyType(getRandomSpecialPurposeType());
    realEstate.setTotalFloorSpace(getRandomDecimal(50, 500));

    // construction year
    if (getRandomBoolean()) {
        realEstate.setConstructionYear(null);
        realEstate.setConstructionYearUnknown(true);
    } else {
        realEstate.setConstructionYear(getRandomLong(1900, 1980));
    }

    // courtage
    realEstate.setCourtage(commonFactory.createCourtageInfo());
    realEstate.getCourtage().setCourtage(StringUtils.abbreviate(LOREM.getWords(1, 5), 100));
    realEstate.getCourtage().setCourtageNote(StringUtils.abbreviate(LOREM.getParagraphs(2, 10), 1000));
    realEstate.getCourtage().setHasCourtage(YesNoNotApplicableType.YES);

    // energy certificate for business
    realEstate.setEnergyCertificate(commonFactory.createEnergyPerformanceCertificate());

    // energy certificate for business by consumption
    if (getRandomBoolean()) {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_CONSUMPTION);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.getEnergyCertificate().setElectricityConsumption(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setHeatingConsumption(getRandomDecimal(10, 250));
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
            realEstate.setEnergyConsumptionContainsWarmWater(getRandomYesNotApplicableType());
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setEnergyConsumptionElectricity(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setEnergyConsumptionHeating(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // energy certificate for business by demand
    else {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_REQUIRED);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setThermalCharacteristicElectricity(getRandomDecimal(500, 2500));
            realEstate.getEnergyCertificate().setThermalCharacteristicHeating(getRandomDecimal(500, 2500));
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // pricing for rent
    if (getRandomBoolean()) {
        realEstate.setCommercializationType(CommercializationType.RENT);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.RENT);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.MONTH);
        realEstate.getPrice().setValue(getRandomDecimal(500, 5000));
    }

    // pricing for purchase
    else {
        realEstate.setCommercializationType(CommercializationType.BUY);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.PURCHASE);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.ONE_TIME_CHARGE);
        realEstate.getPrice().setValue(getRandomDecimal(50000, 999999));
    }

    // pricing / additional costs
    realEstate.setAdditionalCosts(getDefaultPrice());
    realEstate.getAdditionalCosts().setPriceIntervalType(PriceIntervalType.MONTH);
    realEstate.getAdditionalCosts().setValue(getRandomDecimal(500, 5000));

    // pricing / calculated price
    //realEstate.setCalculatedPrice( getDefaultPrice() );
    //realEstate.getCalculatedPrice().setValue( value );
}

From source file:org.openestate.is24.restapi.utils.RandomRealEstateFactory.java

/**
 * Initialize a {@link Store} object with random values.
 *
 * @param realEstate/*from  w ww  .  jav  a  2s  .co m*/
 * object to initialize
 */
protected void initRealEstate(Store realEstate) {
    realEstate.setAdditionalArea(getRandomDecimal(250, 5000));
    realEstate.setCellar(getRandomYesNotApplicableType());
    realEstate.setCondition(getRandomRealEstateCondition());
    realEstate.setDeposit(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setDistanceToAirport(getRandomLong(5, 50));
    realEstate.setDistanceToFM(getRandomLong(5, 50));
    realEstate.setDistanceToMRS(getRandomLong(5, 50));
    realEstate.setDistanceToPT(getRandomLong(5, 50));
    realEstate.setEnergySourcesEnev2014(createRandomEnergySourcesEnev2014());
    realEstate.setFloorLoad(getRandomDecimal(500, 50000));
    realEstate.setFlooringType(getRandomFlooringType());
    realEstate.setFreeFrom(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setGoodsLift(getRandomYesNotApplicableType());
    realEstate.setGoodsLiftLoad(getRandomDecimal(500, 50000));
    realEstate.setHeatingTypeEnev2014(getRandomHeatingTypeEnev2014());
    realEstate.setInteriorQuality(getRandomInteriorQuality());
    realEstate.setLastRefurbishment(getRandomLong(1990, 2014));
    realEstate.setLift(getRandomYesNotApplicableType());
    realEstate.setListed(getRandomYesNotApplicableType());
    realEstate.setLocationClassificationType(getRandomLocationClassificationType());
    realEstate.setMinDivisible(getRandomDecimal(500, 2500));
    realEstate.setNetFloorSpace(getRandomDecimal(50, 5000));
    realEstate.setNumberOfFloors(String.valueOf(getRandomInt(1, 10)));
    realEstate.setNumberOfParkingSpaces(getRandomLong(1, 10));
    realEstate.setParkingSpacePrice(getRandomDecimal(30, 300));
    realEstate.setRamp(getRandomYesNotApplicableType());
    realEstate.setShopWindowLength(getRandomDecimal(2, 15));
    realEstate.setStoreType(getRandomStoreType());
    realEstate.setSupplyType(getRandomSupplyType());
    realEstate.setTotalFloorSpace(getRandomDecimal(50, 500));

    // construction year
    if (getRandomBoolean()) {
        realEstate.setConstructionYear(null);
        realEstate.setConstructionYearUnknown(true);
    } else {
        realEstate.setConstructionYear(getRandomLong(1900, 1980));
    }

    // courtage
    realEstate.setCourtage(commonFactory.createCourtageInfo());
    realEstate.getCourtage().setCourtage(StringUtils.abbreviate(LOREM.getWords(1, 5), 100));
    realEstate.getCourtage().setCourtageNote(StringUtils.abbreviate(LOREM.getParagraphs(2, 10), 1000));
    realEstate.getCourtage().setHasCourtage(YesNoNotApplicableType.YES);

    // energy certificate for business
    realEstate.setEnergyCertificate(commonFactory.createEnergyPerformanceCertificate());

    // energy certificate for business by consumption
    if (getRandomBoolean()) {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_CONSUMPTION);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.getEnergyCertificate().setElectricityConsumption(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setHeatingConsumption(getRandomDecimal(10, 250));
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
            realEstate.setEnergyConsumptionContainsWarmWater(getRandomYesNotApplicableType());
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setEnergyConsumptionElectricity(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setEnergyConsumptionHeating(getRandomDecimal(10, 250));
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // energy certificate for business by demand
    else {
        realEstate.setBuildingEnergyRatingType(BuildingEnergyRatingType.ENERGY_REQUIRED);
        if (getRandomBoolean()) {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.BEFORE_01_MAY_2014);
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        } else {
            realEstate.getEnergyCertificate()
                    .setEnergyCertificateCreationDate(EnergyCertificateCreationDate.FROM_01_MAY_2014);
            realEstate.getEnergyCertificate().setThermalCharacteristicElectricity(getRandomDecimal(500, 2500));
            realEstate.getEnergyCertificate().setThermalCharacteristicHeating(getRandomDecimal(500, 2500));
            realEstate.getEnergyCertificate().setEnergyEfficiencyClass(getRandomEnergyEfficiencyClass());
            realEstate.setThermalCharacteristic(getRandomDecimal(20, 500));
        }
    }

    // pricing for rent
    if (getRandomBoolean()) {
        realEstate.setCommercializationType(CommercializationType.RENT);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.RENT);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.MONTH);
        realEstate.getPrice().setValue(getRandomDecimal(500, 5000));
    }

    // pricing for purchase
    else {
        realEstate.setCommercializationType(CommercializationType.BUY);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.PURCHASE);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.ONE_TIME_CHARGE);
        realEstate.getPrice().setValue(getRandomDecimal(50000, 999999));
    }

    // pricing / additional costs
    realEstate.setAdditionalCosts(getDefaultPrice());
    realEstate.getAdditionalCosts().setPriceIntervalType(PriceIntervalType.MONTH);
    realEstate.getAdditionalCosts().setValue(getRandomDecimal(500, 5000));

    // pricing / calculated price
    //realEstate.setCalculatedPrice( getDefaultPrice() );
    //realEstate.getCalculatedPrice().setValue( value );
}

From source file:org.openestate.is24.restapi.utils.RandomRealEstateFactory.java

/**
 * Initialize a {@link TradeSite} object with random values.
 *
 * @param realEstate/*from  w  w  w.j a v  a 2 s .  co  m*/
 * object to initialize
 */
protected void initRealEstate(TradeSite realEstate) {
    realEstate.setBuildingPermission(getRandomBoolean());
    realEstate.setDemolition(getRandomBoolean());
    realEstate.setFreeFrom(StringUtils.abbreviate(LOREM.getWords(1, 10), 50));
    realEstate.setGfz(getRandomDecimal(1, 10));
    realEstate.setGrz(getRandomDecimal(1, 10));
    realEstate.setMinDivisible(getRandomDecimal(500, 2500));
    realEstate.setPlotArea(getRandomDecimal(100, 5000));
    realEstate.setRecommendedUseTypes(createRandomSiteRecommendedUseForTradeTypes());
    realEstate.setShortTermConstructible(getRandomBoolean());
    realEstate.setSiteConstructibleType(getRandomSiteConstructibleType());
    realEstate.setSiteDevelopmentType(getRandomSiteDevelopmentType());
    realEstate.setTenancy(getRandomLong(100));
    realEstate.setUtilizationTradeSite(getRandomUtilizationTradeSite());

    // courtage
    realEstate.setCourtage(commonFactory.createCourtageInfo());
    realEstate.getCourtage().setCourtage(StringUtils.abbreviate(LOREM.getWords(1, 5), 100));
    realEstate.getCourtage().setCourtageNote(StringUtils.abbreviate(LOREM.getParagraphs(2, 10), 1000));
    realEstate.getCourtage().setHasCourtage(YesNoNotApplicableType.YES);

    // pricing for leasing
    if (getRandomBoolean()) {
        realEstate.setCommercializationType(CommercializationType.LEASE);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.LEASE);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.YEAR);
        realEstate.getPrice().setValue(getRandomDecimal(50000, 999999));
    }

    // pricing for purchase
    else {
        realEstate.setCommercializationType(CommercializationType.BUY);
        realEstate.setPrice(getDefaultPrice());
        realEstate.getPrice().setMarketingType(MarketingType.PURCHASE);
        realEstate.getPrice().setPriceIntervalType(PriceIntervalType.ONE_TIME_CHARGE);
        realEstate.getPrice().setValue(getRandomDecimal(50000, 999999));
    }
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link String} value into XML output.
 *
 * @param value/*from ww  w.j  a  v a 2 s.c  o m*/
 * XML string
 *
 * @param minLength
 * minimal length
 *
 * @param maxLength
 * maximal length
 *
 * @return
 * XML string
 *
 * @throws IllegalArgumentException
 * if a validation error occured
 */
private static String printText(String value, Integer minLength, Integer maxLength) {
    String val = StringUtils.trimToNull(value);
    if (val == null) {
        throw new IllegalArgumentException("The provided text '" + value + "' is invalid!");
    }
    if (minLength != null && val.length() < minLength) {
        throw new IllegalArgumentException(
                "The provided text " + value + " is too short (minimum is " + minLength + ")!");
    }
    val = StringEscapeUtils.unescapeHtml4(value);

    // replace <br> with line breaks
    Matcher m = BR_TAG_PATTERN.matcher(val);
    val = StringUtils.trimToEmpty(m.replaceAll(SystemUtils.LINE_SEPARATOR));

    // strip any other html code
    m = ANY_TAG_PATTERN.matcher(val);
    val = StringUtils.trimToEmpty(m.replaceAll(""));
    val = StringUtils.replace(val, "<", "");
    val = StringUtils.replace(val, ">", "");

    return (maxLength != null) ? StringUtils.abbreviate(val, maxLength) : val;
}

From source file:org.openestate.tool.helloworld.db.hsql.HSqlDbHelloWorldHandler.java

@Override
public void saveObject(Connection c, DbHelloWorldObject object) throws SQLException {
    final boolean oldAutoCommit = c.getAutoCommit();
    NamedCallableStatement saveStatement = null;
    try {/*  w w  w  .  j  a v a  2  s.  c om*/
        c.setAutoCommit(false);
        saveStatement = new NamedCallableStatement(c,
                "CALL " + PROC_SAVE_HELLOWORLD + "(" + ":" + FIELD_HELLOWORLD_ID + ", " + ":"
                        + FIELD_HELLOWORLD_NAME + ", " + ":" + FIELD_HELLOWORLD_NOTES + ", " + ":"
                        + FIELD_ACCESS_OWNER_ID + ", " + ":" + FIELD_ACCESS_GROUP_ID + ", " + ":"
                        + FIELD_ACCESS_PERMISSIONS + ");");
        saveStatement.setLong(FIELD_HELLOWORLD_ID, object.id);
        saveStatement.setString(FIELD_HELLOWORLD_NOTES, object.notes);
        saveStatement.setString(FIELD_HELLOWORLD_NAME, StringUtils.abbreviate(object.name, 100));
        saveStatement.setLong(FIELD_ACCESS_OWNER_ID, object.ownerUserId);
        saveStatement.setLong(FIELD_ACCESS_GROUP_ID, object.ownerGroupId);
        saveStatement.setInt(FIELD_ACCESS_PERMISSIONS,
                (object.permission != null) ? object.permission.getValue() : -1);
        saveStatement.execute();

        // remember ID of the created / update row
        final long referencedId = (object.id < 1) ? saveStatement.getLong(FIELD_HELLOWORLD_ID) : object.id;
        if (referencedId < 1)
            throw new SQLException("Can't determine ID of the saved object!");

        c.commit();

        // store ID of into object
        if (object.id <= 0) {
            object.id = referencedId;
        }
    } catch (SQLException ex) {
        c.rollback();
        throw ex;
    } finally {
        JdbcUtils.closeQuietly(saveStatement);
        c.setAutoCommit(oldAutoCommit);
    }
}

From source file:org.openestate.tool.helloworld.HelloWorldFrameSidebarExtension.java

private JPopupMenu createActionMenu(final DbHelloWorldObject object) {
    // create a popup menu for the Hello World sidebar
    final JPopupMenu popup = new JPopupMenu();

    // add action into the popup menu for sidebar refresh
    popup.add(new JMenuItem(new HelloWorldPlugin.SidebarRefreshAction()));

    // add action into the popup menu for a new object
    popup.add(new JMenuItem(new HelloWorldPlugin.ObjectFormAction()));

    // no object is selected in the sidebar
    //noinspection StatementWithEmptyBody
    if (object == null) {
    }/*  w  w  w .  j ava  2s .co m*/

    // add further actions for the selected sidebar entry
    else {
        String title = StringUtils.abbreviate(StringUtils.trimToEmpty(object.name), 30);
        popup.add(
                ImmoToolUtils.createMenuSeparator("<html>" + StringEscapeUtils.escapeHtml4(title) + "</html>"));

        // add action into the popup menu for editing the selected object
        popup.add(new HelloWorldPlugin.ObjectFormAction(object.id));

        // add action into the popup menu for removing the selected object
        popup.add(new HelloWorldPlugin.ObjectRemoveAction(object.id));
    }

    // return the created popup menu
    return popup;
}

From source file:org.optaplanner.examples.coachshuttlegathering.swingui.CoachShuttleGatheringWorldPanel.java

public void resetPanel(CoachShuttleGatheringSolution solution) {
    translator = new LatitudeLongitudeTranslator();
    for (RoadLocation location : solution.getLocationList()) {
        translator.addCoordinates(location.getLatitude(), location.getLongitude());
    }/*from  w  ww. j  a v a 2 s . c  om*/

    Dimension size = getSize();
    double width = size.getWidth();
    double height = size.getHeight();
    translator.prepareFor(width, height);

    Graphics2D g = createCanvas(width, height);
    g.setColor(TangoColorFactory.ORANGE_3);
    RoadLocation hubLocation = solution.getHub().getLocation();
    translator.drawSquare(g, hubLocation.getLongitude(), hubLocation.getLatitude(), 5);
    for (BusStop stop : solution.getStopList()) {
        RoadLocation location = stop.getLocation();
        g.setColor((stop.getPassengerQuantity() <= 0) ? TangoColorFactory.ALUMINIUM_4
                : (stop.getTransportTimeToHub() == null) ? TangoColorFactory.ORANGE_2
                        : (stop.getTransportTimeRemainder() < 0) ? TangoColorFactory.SCARLET_2
                                : TangoColorFactory.ORANGE_2);
        translator.drawSquare(g, location.getLongitude(), location.getLatitude(), 3, stop.getTransportLabel());
    }
    List<Bus> busList = solution.getBusList();
    g.setColor(TangoColorFactory.ALUMINIUM_2);
    g.setFont(g.getFont().deriveFont((float) LOCATION_NAME_TEXT_SIZE));
    for (Bus bus : busList) {
        RoadLocation location = bus.getLocation();
        g.setColor(bus instanceof Coach ? TangoColorFactory.ORANGE_1 : TangoColorFactory.ALUMINIUM_2);
        translator.drawSquare(g, location.getLongitude(), location.getLatitude(), 3,
                StringUtils.abbreviate(bus.getName(), 20));
    }
    int colorIndex = 0;
    for (Bus bus : busList) {
        g.setColor(TangoColorFactory.SEQUENCE_2[colorIndex]);
        BusStop lastStop = null;
        for (BusStop stop = bus.getNextStop(); stop != null; stop = stop.getNextStop()) {
            RoadLocation previousLocation = stop.getPreviousBusOrStop().getLocation();
            RoadLocation location = stop.getLocation();
            translator.drawRoute(g, previousLocation.getLongitude(), previousLocation.getLatitude(),
                    location.getLongitude(), location.getLatitude(), false, false);
            lastStop = stop;
        }
        if (lastStop != null || bus instanceof Coach) {
            RoadLocation lastStopLocation = lastStop == null ? bus.getLocation() : lastStop.getLocation();
            StopOrHub destination = bus.getDestination();
            if (destination != null) {
                RoadLocation destinationLocation = destination.getLocation();
                translator.drawRoute(g, lastStopLocation.getLongitude(), lastStopLocation.getLatitude(),
                        destinationLocation.getLongitude(), destinationLocation.getLatitude(), false, true);
            }
        }
        colorIndex = (colorIndex + 1) % TangoColorFactory.SEQUENCE_2.length;
    }
    repaint();
}

From source file:org.optaplanner.examples.flightcrewscheduling.swingui.FlightCrewSchedulingWorldPanel.java

public void resetPanel(FlightCrewSolution solution) {
    translator = new LatitudeLongitudeTranslator();
    for (Airport airport : solution.getAirportList()) {
        translator.addCoordinates(airport.getLatitude(), airport.getLongitude());
    }//from   w  ww .j a v a  2s .c  o m

    Dimension size = getSize();
    double width = size.getWidth();
    double height = size.getHeight();
    translator.prepareFor(width, height);

    Graphics2D g = createCanvas(width, height);
    g.setFont(g.getFont().deriveFont((float) LOCATION_NAME_TEXT_SIZE));
    g.setColor(TangoColorFactory.PLUM_2);
    for (Airport airport : solution.getAirportList()) {
        int x = translator.translateLongitudeToX(airport.getLongitude());
        int y = translator.translateLatitudeToY(airport.getLatitude());
        g.fillRect(x - 1, y - 1, 3, 3);
        g.drawString(StringUtils.abbreviate(airport.getCode(), 20), x + 3, y - 3);
    }
    g.setColor(TangoColorFactory.CHOCOLATE_1);
    for (Flight flight : solution.getFlightList()) {
        Airport departureAirport = flight.getDepartureAirport();
        Airport arrivalAirport = flight.getArrivalAirport();
        translator.drawRoute(g, departureAirport.getLongitude(), departureAirport.getLatitude(),
                arrivalAirport.getLongitude(), arrivalAirport.getLatitude(), true, false);
    }
    g.setFont(g.getFont().deriveFont((float) TEXT_SIZE));
    // Legend
    g.setColor(TangoColorFactory.PLUM_2);
    g.fillRect(6, (int) height - 11, 3, 3);
    g.drawString("Airport", 15, (int) height - 5);
    repaint();
}