Example usage for java.lang Boolean toString

List of usage examples for java.lang Boolean toString

Introduction

In this page you can find the example usage for java.lang Boolean toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Boolean's value.

Usage

From source file:com.cloud.hypervisor.xenserver.resource.XenServerStorageProcessor.java

private String backupSnapshot(final Connection conn, final String primaryStorageSRUuid,
        final String localMountPoint, final String path, final String secondaryStorageMountPath,
        final String snapshotUuid, String prevBackupUuid, final Boolean isISCSI, final int wait) {
    String backupSnapshotUuid = null;

    if (prevBackupUuid == null) {
        prevBackupUuid = "";
    }/*w  w  w .j  a v  a 2 s.com*/

    // Each argument is put in a separate line for readability.
    // Using more lines does not harm the environment.
    final String backupUuid = UUID.randomUUID().toString();
    final String results = hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", wait,
            "primaryStorageSRUuid", primaryStorageSRUuid, "path", path, "secondaryStorageMountPath",
            secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevBackupUuid", prevBackupUuid,
            "backupUuid", backupUuid, "isISCSI", isISCSI.toString(), "localMountPoint", localMountPoint);
    String errMsg = null;
    if (results == null || results.isEmpty()) {
        errMsg = "Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage "
                + primaryStorageSRUuid + " to secondary storage " + secondaryStorageMountPath + " due to null";
    } else {

        final String[] tmp = results.split("#");
        final String status = tmp[0];
        backupSnapshotUuid = tmp[1];
        // status == "1" if and only if backupSnapshotUuid != null
        // So we don't rely on status value but return backupSnapshotUuid as an
        // indicator of success.
        if (status != null && status.equalsIgnoreCase("1") && backupSnapshotUuid != null) {
            s_logger.debug("Successfully copied backupUuid: " + backupSnapshotUuid + " to secondary storage");
            return results;
        } else {
            errMsg = "Could not copy backupUuid: " + backupSnapshotUuid + " from primary storage "
                    + primaryStorageSRUuid + " to secondary storage " + secondaryStorageMountPath + " due to "
                    + tmp[1];
        }
    }
    final String source = backupUuid + ".vhd";
    hypervisorResource.killCopyProcess(conn, source);
    s_logger.warn(errMsg);
    throw new CloudRuntimeException(errMsg);
}

From source file:org.ops4j.pax.web.service.tomcat.internal.TomcatServerWrapper.java

private void configureJspConfigDescriptor(Context context, ContextModel model) {

    Boolean elIgnored = model.getJspElIgnored();
    Boolean isXml = model.getJspIsXml();
    Boolean scriptingInvalid = model.getJspScriptingInvalid();

    Collection<JspPropertyGroupDescriptor> jspPropertyGroupDescriptors = null;
    Collection<TaglibDescriptor> taglibs = null;

    if (elIgnored != null || isXml != null || scriptingInvalid != null || model.getJspIncludeCodes() != null
            || model.getJspUrlPatterns() != null || model.getJspIncludePreludes() != null) {
        JspPropertyGroup jspPropertyGroup = new JspPropertyGroup();
        JspPropertyGroupDescriptorImpl jspPropertyGroupDescriptor = new JspPropertyGroupDescriptorImpl(
                jspPropertyGroup);// www.j  a  v a2 s.c  o m
        if (jspPropertyGroupDescriptors == null)
            jspPropertyGroupDescriptors = new ArrayList<>();
        jspPropertyGroupDescriptors.add(jspPropertyGroupDescriptor);

        if (model.getJspIncludeCodes() != null) {
            for (String includeCoda : model.getJspIncludeCodes()) {
                jspPropertyGroup.addIncludeCoda(includeCoda);
            }
        }

        if (model.getJspUrlPatterns() != null) {
            for (String urlPattern : model.getJspUrlPatterns()) {
                jspPropertyGroup.addUrlPattern(urlPattern);
            }
        }

        if (model.getJspIncludePreludes() != null) {
            for (String prelude : model.getJspIncludePreludes()) {
                jspPropertyGroup.addIncludePrelude(prelude);
            }
        }

        if (elIgnored != null)
            jspPropertyGroup.setElIgnored(elIgnored.toString());
        if (isXml != null)
            jspPropertyGroup.setIsXml(isXml.toString());
        if (scriptingInvalid != null)
            jspPropertyGroup.setScriptingInvalid(scriptingInvalid.toString());

    }

    if (model.getTagLibLocation() != null || model.getTagLibUri() != null) {
        TaglibDescriptorImpl tagLibDescriptor = new TaglibDescriptorImpl(model.getTagLibLocation(),
                model.getTagLibUri());
        if (taglibs == null)
            taglibs = new ArrayList<>();
        taglibs.add(tagLibDescriptor);
    }

    if (jspPropertyGroupDescriptors != null || taglibs != null) {
        JspConfigDescriptor jspConfig = new JspConfigDescriptorImpl(jspPropertyGroupDescriptors, taglibs);
        ((Context) context.getServletContext()).setJspConfigDescriptor(jspConfig);
    }
}

From source file:io.github.apfelcreme.MbPets.Commands.CreatePetCommand.java

/**
 * executes the command/*from   w  w w .ja  v  a  2  s . c  o m*/
 *
 * @param chatInput the input
 */
public void execute(ChatInput chatInput) {
    if (!chatInput.getSender().getPlayer().hasPermission("MbPets.buy")) {
        chatInput.getSender().getPlayer().sendMessage(MbPetsConfig.getTextNode("error.noPermission"));
        return;
    }
    Pet pet = null;
    Pet oldPet = null;
    Player owner = chatInput.getSender();
    DisguiseType type = MbPetsConfig.parseType(chatInput.getType());
    String name = "";
    String color = "";
    String style = "";
    Integer size = MbPetsConfig.parseSlimeSize(chatInput.getSize());
    Material material = MbPetsConfig.parseMaterial(chatInput.getType());
    Material block = MbPetsConfig.parseBlock(chatInput.getType());
    Boolean isBaby = false;
    Integer number = MbPets.getLatestPetNumber(owner) + 1;
    if (MbPets.getInstance().getConfigurations().get(chatInput.getSender()) != null) {
        // get the attributes the current pet object has stored
        oldPet = MbPets.getInstance().getConfigurations().get(chatInput.getSender());
        type = oldPet.getType();
        number = oldPet.getNumber();
        if (oldPet instanceof HorsePet) {
            color = ((HorsePet) oldPet).getColor() != null ? ((HorsePet) oldPet).getColor().name() : null;
            style = ((HorsePet) oldPet).getStyle() != null ? ((HorsePet) oldPet).getStyle().name() : null;
        } else if (oldPet instanceof SheepPet && ((SheepPet) oldPet).getColor() != null) {
            color = ((SheepPet) oldPet).getColor().name();
        } else if (oldPet instanceof WolfPet && ((WolfPet) oldPet).getColor() != null) {
            color = ((WolfPet) oldPet).getColor().name();
        } else if (oldPet instanceof OcelotPet && ((OcelotPet) oldPet).getStyle() != null) {
            style = ((OcelotPet) oldPet).getStyle().name();
        } else if (oldPet instanceof RabbitPet && ((RabbitPet) oldPet).getStyle() != null) {
            style = ((RabbitPet) oldPet).getStyle().name();
        } else if (oldPet instanceof Sizeable && ((Sizeable) oldPet).getSize() != null) {
            size = ((Sizeable) oldPet).getSize();
        }
        if (oldPet instanceof Ageable && ((Ageable) oldPet).isBaby() != null) {
            isBaby = ((Ageable) oldPet).isBaby();
        }
        if (oldPet instanceof DroppedItem) {
            material = ((DroppedItem) oldPet).getMaterial();
            type = DisguiseType.DROPPED_ITEM;
        }
        if (oldPet instanceof FallingBlock) {
            block = ((FallingBlock) oldPet).getBlock();
            type = DisguiseType.FALLING_BLOCK;
        }
        name = oldPet.getName();
    }
    name = chatInput.getName() != null ? chatInput.getName() : name;
    color = chatInput.getColor() != null ? chatInput.getColor() : color;
    style = chatInput.getStyle() != null ? chatInput.getStyle() : style;
    isBaby = Boolean.parseBoolean(chatInput.getBaby() != null ? chatInput.getBaby() : isBaby.toString());
    number = chatInput.getNumber() != null ? chatInput.getNumber() : number;
    size = chatInput.getSize() != null ? MbPetsConfig.parseSlimeSize(chatInput.getSize()) : size;
    // a type must be entered first to ensure, that the correct color and
    // style attributes are set!
    if (type == null) {
        if (MbPetsConfig.parseMaterial(chatInput.getType()) != null) {
            type = DisguiseType.DROPPED_ITEM;
        } else if (MbPetsConfig.parseBlock(chatInput.getType()) != null) {
            type = DisguiseType.FALLING_BLOCK;
        } else {
            chatInput.getSender().sendMessage(MbPetsConfig.getTextNode("error.missingType"));
            chatInput.getSender()
                    .sendMessage(MbPetsConfig.getTextNode("info.types") + ChatColor.GREEN
                            + StringUtils.join(MbPetsConfig.getAvailableTypes(), ", ") + ChatColor.GREEN + ", "
                            + StringUtils.join(MbPetsConfig.getAvailableDroppedItems(), ", ") + ChatColor.GREEN
                            + ", " + StringUtils.join(MbPetsConfig.getAvailableFallingBlocks(), ", "));
            return;
        }
    }

    switch (type) {
    case CHICKEN:
        pet = new ChickenPet(owner, name, number, isBaby);
        break;
    case COW:
        pet = new CowPet(owner, name, number, isBaby);
        break;
    case DROPPED_ITEM:
        if (material != null) {
            switch (material) {
            case OBSIDIAN:
                pet = new DevilPet(owner, name, number);
                break;
            case SNOW_BLOCK:
                pet = new AngelPet(owner, name, number);
                break;
            default:
                pet = new DroppedItemPet(owner, name, number, material);
                break;
            }
        } else {
            chatInput.getSender().sendMessage(MbPetsConfig.getTextNode("info.types") + ChatColor.GREEN
                    + MbPetsConfig.getAvailableDroppedItems());
        }
        break;
    case ENDERMAN:
        //endermen sind buggy <.<
        pet = new EndermanPet(owner, name, number);
        //         chatInput.getSender().sendMessage(ChatColor.RED+"Endermen sind derzeit noch nicht verfgbar! Warte ab ;)");
        //         return;
        break;
    case FALLING_BLOCK:
        if (block != null) {
            pet = new FallingBlockPet(owner, name, number, block);
        } else {
            chatInput.getSender().sendMessage(MbPetsConfig.getTextNode("info.types") + ChatColor.GREEN
                    + MbPetsConfig.getAvailableFallingBlocks());
        }
        break;
    case HORSE:
        pet = new HorsePet(owner, name, number, isBaby, MbPetsConfig.parseHorseColor(color),
                MbPetsConfig.parseHorseStyle(style));
        break;
    case IRON_GOLEM:
        pet = new IronGolemPet(owner, name, number);
        break;
    case MAGMA_CUBE:
        pet = new MagmaCubePet(owner, name, number, size);
        break;
    case MUSHROOM_COW:
        pet = new MooshroomPet(owner, name, number, isBaby);
        break;
    case OCELOT:
        pet = new OcelotPet(owner, name, number, isBaby, MbPetsConfig.parseOcelotType(style));
        break;
    case PIG:
        pet = new PigPet(owner, name, number, isBaby);
        break;
    case PRIMED_TNT:
        //pet = new PrimedTnTPet(owner, name, number);
        owner.sendMessage(ChatColor.RED + "Diese Pets sind derzeit noch nicht verfgbar!");
        return;
    case RABBIT:
        pet = new RabbitPet(owner, name, number, isBaby, MbPetsConfig.parseRabbitType(style));
        break;
    case SHEEP:
        pet = new SheepPet(owner, name, number, isBaby, MbPetsConfig.parseColor(color));
        break;
    case SLIME:
        pet = new SlimePet(owner, name, number, size);
        break;
    case SKELETON_HORSE:
        pet = new SkeletonHorsePet(owner, name, number, isBaby);
        break;
    case UNDEAD_HORSE:
        pet = new UndeadHorsePet(owner, name, number, isBaby);
        break;
    case WOLF:
        pet = new WolfPet(owner, name, number, isBaby, MbPetsConfig.parseColor(color));
        break;
    default:
        break;
    }
    if (oldPet != null) {
        // for uncommon prices e.g. modification price is 1000 benches
        pet.setPrice(oldPet.getPrice());
        if (oldPet.getEntity() != null) {
            //for converted pets as they store the old entity in this field
            pet.setEntity(oldPet.getEntity());
        }
    }
    MbPets.getInstance().getConfigurations().put(chatInput.getSender(), pet);
    owner.sendMessage(pet.toString());

}

From source file:de.bund.bfr.pmfml.sbml.PMFCoefficientImpl.java

/**
 * Creates a PMFCoefficientImpl fron an id, value, unit, P, error, t,
 * correlations and description.//  ww  w . j av  a 2 s.co m
 */
public PMFCoefficientImpl(final String id, final double value, final String unit, final Double P,
        final Double error, final Double t, final Correlation[] correlations, final String desc,
        final Boolean isStart) {
    param = new Parameter(id, LEVEL, VERSION);
    param.setValue(value);
    param.setUnits(unit);
    param.setConstant(true);

    if (P != null || error != null || t != null || correlations != null || desc != null) {

        // Builds metadata node
        final XMLNode metadataNode = new XMLNode(new XMLTriple(METADATA_TAG, null, METADATA_NS));

        // Creates P annotation
        if (P != null) {
            final XMLNode pNode = new XMLNode(new XMLTriple(P_TAG, null, P_NS));
            pNode.addChild(new XMLNode(P.toString()));
            metadataNode.addChild(pNode);
        }

        // Creates error annotation
        if (error != null) {
            final XMLNode errorNode = new XMLNode(new XMLTriple(ERROR_TAG, null, ERROR_NS));
            errorNode.addChild(new XMLNode(error.toString()));
            metadataNode.addChild(errorNode);
        }

        // Creates t annotation
        if (t != null) {
            final XMLNode tNode = new XMLNode(new XMLTriple(T_TAG, null, T_NS));
            tNode.addChild(new XMLNode(t.toString()));
            metadataNode.addChild(tNode);
        }

        // Creates correlation annotation
        if (correlations != null) {
            for (final Correlation correlation : correlations) {
                final XMLAttributes attrs = new XMLAttributes();
                attrs.add(ATTRIBUTE_NAME, correlation.getName());
                if (correlation.isSetValue()) {
                    attrs.add(ATTRIBUTE_VALUE, Double.toString(correlation.getValue()));
                }

                final XMLTriple triple = new XMLTriple(CORRELATION_TAG, null, CORRELATION_NS);
                metadataNode.addChild(new XMLNode(triple, attrs));
            }
        }

        // Creates annotation for description
        if (desc != null) {
            final XMLNode descNode = new XMLNode(new XMLTriple(DESC_TAG, null, DESC_NS));
            descNode.addChild(new XMLNode(desc));
            metadataNode.addChild(descNode);
        }

        // Creates annotation for isStart
        if (isStart != null) {
            final XMLNode isStartNode = new XMLNode(new XMLTriple(ISSTART_TAG, null, ISSTART_NS));
            isStartNode.addChild(new XMLNode(isStart.toString()));
            metadataNode.addChild(isStartNode);
        }

        param.getAnnotation().setNonRDFAnnotation(metadataNode);
    }
    this.P = P;
    this.error = error;
    this.t = t;
    this.correlations = correlations;
    this.desc = desc;
    this.isStart = isStart;
}

From source file:gov.nih.nci.nbia.basket.DynamicJNLPGenerator.java

public String generate(String userId, String password, String codebase, String downloadServerUrl,
        Boolean includeAnnotation, List<BasketSeriesItemBean> seriesItems, long currentTimeMillis,
        String noOfRetry) {//  w  w  w.  j  av  a2  s  . c o  m
    this.codebase = codebase;
    String jnlp = "";
    try {
        StringBuffer jnlpBuilder = this.getJnlp();
        int size = seriesItems.size();
        StringBuffer argsBuilder = new StringBuffer();
        List<String> seriesDownloadData = new ArrayList<String>();
        for (int i = 0; i < size; i++) {
            BasketSeriesItemBean seriesItem = seriesItems.get(i);

            String collection = seriesItem.getProject();
            String patientId = seriesItem.getPatientId();
            String studyInstanceUid = seriesItem.getStudyId();
            String seriesInstanceUid = seriesItem.getSeriesId();
            String annotation = seriesItem.getAnnotated();
            Integer numberImages = seriesItem.getTotalImagesInSeries();
            Long imagesSize = seriesItem.getTotalSizeForAllImagesInSeries();
            Long annoSize = seriesItem.getAnnotationsSize();
            String url = "url";
            String displayName = "displayName";
            String studyDate = seriesItem.getStudyDate();
            String studyDesc = cleanStr(seriesItem.getStudyDescription());
            String seriesDesc = cleanStr(seriesItem.getSeriesDescription());
            String study_id = cleanStr(seriesItem.getStudy_id());
            String seriesNumber = seriesItem.getSeriesNumber();

            String argument = "" + collection + "|" + patientId + "|" + studyInstanceUid + "|"
                    + seriesInstanceUid + "|" + annotation + "|" + numberImages + "|" + imagesSize + "|"
                    + annoSize + "|" + url + "|" + displayName + "|" + true + "|" + studyDate + "|" + study_id
                    + "|" + studyDesc + "|" + seriesNumber + "|" + seriesDesc;
            seriesDownloadData.add(argument);
        }
        File dataFile = new File(System.getProperty("java.io.tmpdir"),
                "jnlp-data" + currentTimeMillis + ".txt");
        OutputStream os = new FileOutputStream(dataFile);
        IOUtils.writeLines(seriesDownloadData, System.getProperty("line.separator"), os);
        os.close();
        argsBuilder.append("<argument>").append(dataFile.getAbsolutePath()).append("</argument>");
        //get user id and included annotation
        StringBuffer propXMLBuilder = new StringBuffer();
        propXMLBuilder.append(this.getPropertyXML("jnlp.includeAnnotation", includeAnnotation.toString()));
        propXMLBuilder.append(this.getPropertyXML("jnlp.userId", userId));
        //this should be over secure connection
        String encryptedPassword = this.encrypt(userId, password);
        propXMLBuilder.append(this.getPropertyXML("jnlp.password", encryptedPassword));
        propXMLBuilder.append(this.getPropertyXML("jnlp.codebase", this.codebase));
        propXMLBuilder.append(this.getPropertyXML("jnlp.downloadServerUrl", downloadServerUrl));
        propXMLBuilder.append(this.getPropertyXML("jnlp.noofretry", noOfRetry));
        this.replaceProperties(propXMLBuilder, jnlpBuilder);
        this.replaceArguments(argsBuilder.toString(), jnlpBuilder);

        jnlp = jnlpBuilder.toString();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    return jnlp;
}

From source file:com.perpetumobile.bit.orm.cassandra.CliMain.java

private void writeAttr(PrintStream output, boolean first, String name, Boolean value) {
    writeAttrRaw(output, first, name, value.toString());
}

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;//from   ww  w  .jav  a2s.  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:com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.java

@Override
public boolean saveSettings(Element element) {
    Boolean changed = false;//from   ww w  .  j  av a2s.co m
    Element e = element.element("defaultFilter");
    if (e == null)
        e = element.addElement("defaultFilter");

    UUID defaultId = null;
    Boolean applyDefault = false;

    for (FilterEntity filter : filterEntities) {
        if (BooleanUtils.isTrue(filter.getIsDefault())) {
            defaultId = filter.getId();
            applyDefault = filter.getApplyDefault();
            break;
        }
    }

    String newDef = defaultId != null ? defaultId.toString() : null;
    Attribute attr = e.attribute("id");
    String oldDef = attr != null ? attr.getValue() : null;
    if (!Objects.equals(oldDef, newDef)) {
        if (newDef == null && attr != null) {
            e.remove(attr);
        } else {
            if (attr == null)
                e.addAttribute("id", newDef);
            else
                attr.setValue(newDef);
        }
        changed = true;
    }
    Boolean newApplyDef = BooleanUtils.isTrue(applyDefault);
    Attribute applyDefaultAttr = e.attribute("applyDefault");
    Boolean oldApplyDef = applyDefaultAttr != null ? Boolean.valueOf(applyDefaultAttr.getValue()) : false;
    if (!Objects.equals(oldApplyDef, newApplyDef)) {
        if (applyDefaultAttr != null) {
            applyDefaultAttr.setValue(newApplyDef.toString());
        } else {
            e.addAttribute("applyDefault", newApplyDef.toString());
        }
        changed = true;
    }

    Element groupBoxExpandedEl = element.element("groupBoxExpanded");
    if (groupBoxExpandedEl == null)
        groupBoxExpandedEl = element.addElement("groupBoxExpanded");

    Boolean oldGroupBoxExpandedValue = Boolean.valueOf(groupBoxExpandedEl.getText());
    Boolean newGroupBoxExpandedValue = groupBoxLayout.isExpanded();
    if (!Objects.equals(oldGroupBoxExpandedValue, newGroupBoxExpandedValue)) {
        groupBoxExpandedEl.setText(newGroupBoxExpandedValue.toString());
        changed = true;
    }

    return changed;
}

From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java

@Override
public boolean saveSettings(Element element) {
    if (!isSettingsEnabled()) {
        return false;
    }/*from ww  w.j ava  2 s .c o  m*/

    if (isUsePresentations()) {
        element.addAttribute("textSelection", String.valueOf(component.isTextSelectionEnabled()));
    }

    Element columnsElem = element.element("columns");
    if (columnsElem != null) {
        element.remove(columnsElem);
    }
    columnsElem = element.addElement("columns");

    Object[] visibleColumns = component.getVisibleColumns();
    for (Object column : visibleColumns) {
        Element colElem = columnsElem.addElement("columns");
        colElem.addAttribute("id", column.toString());

        int width = component.getColumnWidth(column);
        if (width > -1)
            colElem.addAttribute("width", String.valueOf(width));

        Boolean visible = !component.isColumnCollapsed(column);
        colElem.addAttribute("visible", visible.toString());
    }

    MetaPropertyPath sortProperty = (MetaPropertyPath) component.getSortContainerPropertyId();
    if (sortProperty != null) {
        Boolean sortAscending = component.isSortAscending();

        columnsElem.addAttribute("sortProperty", sortProperty.toString());
        columnsElem.addAttribute("sortAscending", sortAscending.toString());
    }

    return true;
}