Example usage for org.apache.commons.lang StringUtils trimToNull

List of usage examples for org.apache.commons.lang StringUtils trimToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils trimToNull.

Prototype

public static String trimToNull(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null.

Usage

From source file:com.bluexml.side.Integration.alfresco.xforms.webscript.XFormsWork.java

/**
 * Provides information about one or several nodes. Modes:
 * <ol>//ww w  . j a v  a  2 s . c  o m
 * <li>node content information: returns info about the node content.
 * Parameter: "nodeId"
 * <li>objects information: returns information about node(s). Parameters:
 * "ids", "format"
 * <li>find object and retrieve information: finds the object that has a
 * specific value in a specific property and returns information about the
 * node. Parameters: "datatype", "identifier", "id". Optional parameters:
 * "format", "labelLength".
 * </ol>
 * <p>
 * See the individual handler functions for the format of the parameters.
 * 
 * @return an empty string if any problem or the comma-separated string
 *         containing the
 *         information built. Currently, {full node id}, {content size in
 *         bytes}.
 */
protected String nodeInfo() {
    String nodeId = parameters.get("nodeId");
    if (nodeId != null) {
        return contentInfo(nodeId);
    }

    String ids = parameters.get("ids");
    if (ids != null) {
        String sharedFormat = parameters.get("format");
        return nodeObjectsInfo(ids, sharedFormat);
    }
    String datatype = parameters.get("datatype");
    String identifier = parameters.get("identifier");

    // configure the filtering/limiting
    QName identifierQName = null;
    boolean includeSystemProperties = FORCE_SYSTEM_PROPERTIES_RESOLUTION;
    if (StringUtils.trimToNull(identifier) != null) {
        identifierQName = resolveIdentifierQName(identifier, datatype);
        includeSystemProperties = (identifierQName != null);
    }

    if (datatype != null) {
        String format = parameters.get("format");
        String labelLength = parameters.get("labelLength");
        String idValue = parameters.get("id");
        return resolveObjectInfo(datatype, identifier, format, labelLength, idValue, includeSystemProperties);
    }

    return "";
}

From source file:net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.java

/**
 * OK button was selected.//  w w  w  .ja  va2s.c  o  m
 */
protected void okPressed() {
    //
    // Get the selected severity level.
    //
    Severity severity = mRule.getSeverity();
    try {
        severity = (Severity) ((IStructuredSelection) mSeverityCombo.getSelection()).getFirstElement();
    } catch (IllegalArgumentException e) {
        CheckstyleLog.log(e);
    }

    // Get the comment.
    String comment = StringUtils.trimToNull(mCommentText.getText());

    // Get the id
    String id = StringUtils.trimToNull(mIdText.getText());

    // Get the custom message
    for (Map.Entry<String, Text> entry : mCustomMessages.entrySet()) {

        String msgKey = entry.getKey();

        String standardMessage = MetadataFactory.getStandardMessage(msgKey,
                mRule.getMetaData().getInternalName());
        if (standardMessage == null) {
            standardMessage = ""; //$NON-NLS-1$
        }

        String message = StringUtils.trimToNull(entry.getValue().getText());
        if (message != null && !message.equals(standardMessage)) {
            mRule.getCustomMessages().put(msgKey, message);
        } else {
            mRule.getCustomMessages().remove(msgKey);
        }
    }

    //
    // Build a new collection of configuration properties.
    //
    // Note: if the rule does not have any configuration properties then
    // skip over the populating of the config property hash map.
    //
    if (mConfigPropertyWidgets != null) {
        for (int i = 0; i < mConfigPropertyWidgets.length; i++) {
            IConfigPropertyWidget widget = mConfigPropertyWidgets[i];
            ConfigProperty property = widget.getConfigProperty();

            try {
                widget.validate();
            } catch (CheckstylePluginException e) {
                String message = NLS.bind(Messages.RuleConfigurationEditDialog_msgInvalidPropertyValue,
                        property.getMetaData().getName());
                this.setErrorMessage(message);
                return;
            }
            property.setValue(widget.getValue());
        }
    }

    //
    // If we made it this far then all of the user input validated and we
    // can
    // update the final rule with the values the user entered.
    //
    mRule.setSeverity(severity);
    mRule.setComment(comment);
    mRule.setId(id);

    super.okPressed();

}

From source file:mitm.application.djigzo.james.mailets.Notify.java

private void addEmails(Object input, Collection<MailAddress> target) {
    if (input == null) {
        return;/* w  ww  .  j  a va  2s.com*/
    }

    if (input instanceof String) {
        String addresses = StringUtils.trimToNull((String) input);

        if (addresses != null) {
            try {
                InternetAddress[] emails = InternetAddress.parse(addresses, false);

                if (emails != null) {
                    for (InternetAddress email : emails) {
                        if (email == null) {
                            continue;
                        }

                        /*
                         * We never want the invalid@invalid.tld address
                         */
                        if (EmailAddressUtils.isInvalidDummyAddress(email)) {
                            continue;
                        }

                        try {
                            target.add(new MailAddress(email));
                        } catch (ParseException e) {
                            getLogger().warn("Email address is invalid. Skipping address: " + email);
                        }
                    }
                }
            } catch (AddressException e) {
                getLogger().warn("Email address(s) are invalid " + addresses);
            }
        }
    } else if (input instanceof MailAddress) {
        MailAddress mailAddress = (MailAddress) input;
        /*
         * We never want the invalid@invalid.tld address
         */
        if (!EmailAddressUtils.isInvalidDummyAddress(mailAddress.toInternetAddress())) {
            target.add(mailAddress);
        }
    } else if (input instanceof InternetAddress) {
        InternetAddress inetAddress = (InternetAddress) input;
        /*
         * We never want the invalid@invalid.tld address
         */
        if (!EmailAddressUtils.isInvalidDummyAddress(inetAddress)) {
            try {
                target.add(new MailAddress(inetAddress));
            } catch (ParseException e) {
                getLogger().warn("Email address is invalid. Skipping address: " + input);
            }
        }
    } else if (input instanceof Collection) {
        for (Object o : (Collection<?>) input) {
            addEmails(o, target);
        }
    } else if (input instanceof Object[]) {
        for (Object o : (Object[]) input) {
            addEmails(o, target);
        }
    } else {
        /*
         * Fallback to #toString
         */
        addEmails(input.toString(), target);
    }
}

From source file:ips1ap101.web.fragments.FragmentoFiltro1.java

protected void setConsultaPendiente(Long filtro, String codigo, String nombre) {
    PaginaConsultaConFiltro pagina = getPaginaConsultaConFiltro();
    pagina.getContextoPeticion().setFiltroFuncionSelect(filtro);
    pagina.getContextoPeticion().setCodigoFuncionSelect(StringUtils.trimToNull(codigo));
    pagina.getContextoPeticion().setNombreFuncionSelect(StringUtils.trimToNull(nombre));
    pagina.setConsultaPendiente(true);//  w  ww. ja  v a  2s.  co m
}

From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java

/**
 * Returns the string property for {@link #SELENIUM_REMOTE_URL}
 * @return the url in string form, or null if it does not exist.
 */// ww w.ja  v  a  2  s .  c o  m
protected String getRemoteSeleniumUrlString() {
    return StringUtils.trimToNull(System.getProperty(SELENIUM_REMOTE_URL));
}

From source file:fsl.ta.toms.roms.dao.impl.RoadCompliancyDAOImpl.java

/*****************************************************************************************************************/

public List<ComplianceBO> lookupRoadComplianceActivities(RoadCompliancyCriteriaBO criteria) {

    StringBuffer queryString = new StringBuffer(
            "select new fsl.ta.toms.roms.bo.ComplianceBO(c) from ComplianceDO c where 1=1");

    //TRN/*w  w  w  .j  av  a2 s  .c  o m*/
    if (StringUtils.trimToNull(criteria.getTrn()) != null) {
        queryString.append(" and c.person.trnNbr = '").append(criteria.getTrn()).append("'");
    }

    //FirstName
    if (StringUtils.trimToNull(criteria.getFirstName()) != null) {
        queryString.append(" and upper(c.person.firstName) LIKE '")
                .append(criteria.getFirstName().trim().toUpperCase()).append("%'");
    }

    //MioddleName
    if (StringUtils.trimToNull(criteria.getMiddleName()) != null) {
        queryString.append(" and upper(c.person.middleName) LIKE '")
                .append(criteria.getMiddleName().trim().toUpperCase()).append("%'");
    }

    //LastName
    if (StringUtils.trimToNull(criteria.getLastName()) != null) {
        queryString.append(" and upper(c.person.lastName) LIKE '")
                .append(criteria.getLastName().trim().toUpperCase()).append("%'");
    }

    //Operation Name
    if (StringUtils.trimToNull(criteria.getOperationName()) != null) {
        queryString.append(" and upper(c.roadOperation.operationName) like '%")
                .append(criteria.getOperationName().trim().toUpperCase()).append("%'");
    }

    //TA Staff
    if (StringUtils.trimToNull(criteria.getStaffID()) != null) {
        queryString.append(" and c.taStaff.staffId = '").append(criteria.getStaffID().trim()).append("'");
    }

    //Region
    if (StringUtils.trimToNull(criteria.getRegion()) != null) {
        queryString.append(" and upper(c.compliancyArtery.location.parish.officeLocationCode) = '")
                .append(criteria.getRegion().trim().toUpperCase()).append("'");
    }

    //Compliance Id
    if (criteria.getComplianceId() != null && criteria.getComplianceId() > 1) {
        queryString.append(" and c.complianceId = ").append(criteria.getComplianceId());
    }

    //Road Operation ID
    if (criteria.getOperationID() != null && criteria.getOperationID() > 0)
        queryString.append(" and c.roadOperation.roadOperationId = '").append(criteria.getOperationID())
                .append("'");

    //Status
    if (StringUtils.trimToNull(criteria.getStatus()) != null) {
        queryString.append(" and c.status.statusId = '").append(criteria.getStatus()).append("'");

    }

    //Operation Start Date
    // Road Check Date
    try {
        /**SCHEDULED**/
        if (criteria.getScheduledStartDateRange() != null && criteria.getScheduledEndDateRange() != null) {

            queryString.append(" and (date(c.roadOperation.scheduledStartDtime) between '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getScheduledStartDateRange()))
                    .append("' and '").append(DateUtils.utilDateToSqlDate(criteria.getScheduledEndDateRange()))

                    .append("'  or  ");

            queryString.append(" date(c.roadOperation.scheduledEndDtime) between '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getScheduledStartDateRange()))
                    .append("' and '").append(DateUtils.utilDateToSqlDate(criteria.getScheduledEndDateRange()))
                    .append("')");
        }

        if (criteria.getActualStartDateRange() != null && criteria.getActualEndDateRange() != null) {
            queryString.append(" and (date(c.roadOperation.actualStartDtime) between '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getActualStartDateRange())).append("' and '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getActualEndDateRange()))

                    .append("'  or  ");

            queryString.append(" date(c.roadOperation.actualEndDtime) between '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getActualStartDateRange())).append("' and '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getActualEndDateRange())).append("')");

        }

        if (criteria.getRoadCheckStartDateRange() != null && criteria.getRoadCheckEndDateRange() != null) {

            queryString.append(" and (date(c.offenceDateTime) between '")
                    .append(DateUtils.utilDateToSqlDate(criteria.getRoadCheckStartDateRange()))
                    .append("' and '").append(DateUtils.utilDateToSqlDate(criteria.getRoadCheckEndDateRange()))
                    .append("') ");

        }

        queryString.append(" order by c.auditEntry.createDTime DESC");

    } catch (ParseException e) {

        e.printStackTrace();
    }
    //System.out.println("This is the query string " + queryString.toString());
    return hibernateTemplate.find(queryString.toString());
}

From source file:com.prowidesoftware.swift.io.parser.MxParser.java

/**
 * Gets the namespace, if any, from current position in the parameter reader
 * @since 7.8.4//from   ww  w  .jav  a2s.  c o m
 */
private String readNamespace(final javax.xml.stream.XMLStreamReader reader) {
    if (reader.getNamespaceCount() > 0) {
        //log.finest("ELEMENT START: " + reader.getLocalName() + " , namespace count is: " + reader.getNamespaceCount());
        for (int nsIndex = 0; nsIndex < reader.getNamespaceCount(); nsIndex++) {
            final String nsPrefix = StringUtils.trimToNull(reader.getNamespacePrefix(nsIndex));
            final String elementPrefix = StringUtils.trimToNull(reader.getPrefix());
            if (StringUtils.equals(nsPrefix, elementPrefix)) {
                //log.finest("\tNamepsace prefix: " + nsPrefix + " associated with URI " + nsId);
                return reader.getNamespaceURI(nsIndex);
            }
        }
    }
    return null;
}

From source file:ch.entwine.weblounge.common.impl.request.RequestUtils.java

/**
 * Checks if the parameter <code>parameter</code> is present in the request
 * and is not equal to the empty string. In this case, the parameter itself is
 * returned, <code>null</code> otherwise.
 * <p>/*from www  .j a  v a2 s.  co m*/
 * The parameter is decoded using the specified <code>encoding</code>.
 * 
 * @param request
 *          the weblounge request
 * @param parameter
 *          the parameter name
 * @param decoding
 *          the encoding parameter, e. g. <code>utf-8</code>
 * @return the decoded parameter value or <code>null</code> if the parameter
 *         is not available
 */
public static String getParameterWithDecoding(WebloungeRequest request, String parameter, String decoding) {
    String p = request.getParameter(parameter);
    if (p != null) {
        p = p.trim();
        if ("application/x-www-form-urlencoded".equalsIgnoreCase(request.getContentType())) {
            try {
                p = decode(p, decoding);
            } catch (UnsupportedEncodingException e) {
                throw new IllegalArgumentException("Encoding " + decoding + " is unsupported");
            } catch (IllegalArgumentException e) {
                // Tried decoding a string with a % inside, so obviously the
                // parameter
                // was decoded already
            }
        }
    }
    return StringUtils.trimToNull(p);
}

From source file:eionet.meta.imp.VocabularyRDFImportHandler.java

@Override
public void handleStatement(Statement st) throws RDFHandlerException {
    this.totalNumberOfTriples++;
    Resource subject = st.getSubject();
    URI predicate = st.getPredicate();
    Value object = st.getObject();/*from   w  ww . j  a v  a  2s  .  c o m*/

    if (!(subject instanceof URI)) {
        // this.logMessages.add(st.toString() + " NOT imported, subject is not a URI");
        return;
    }

    // object should a resource or a literal (value)
    if (!(object instanceof URI) && !(object instanceof Literal)) {
        // this.logMessages.add(st.toString() + " NOT imported, object is not instance of URI or Literal");
        return;
    }

    String conceptUri = subject.stringValue();
    if (!StringUtils.startsWith(conceptUri, this.folderContextRoot)) {
        // this.logMessages.add(st.toString() + " NOT imported, does not have base URI");
        return;
    }

    this.messageDigestInstance.reset();
    byte[] digested;
    try {
        digested = this.messageDigestInstance.digest(st.toString().getBytes(DEFAULT_ENCODING_OF_STRINGS));
    } catch (UnsupportedEncodingException e) {
        throw new RDFHandlerException(e);
    }
    BigInteger statementHashCode = new BigInteger(1, digested);
    if (this.seenStatementsHashCodes.contains(statementHashCode)) {
        // this.logMessages.add(st.toString() + " NOT imported, duplicates a previous triple");
        this.numberOfDuplicatedTriples++;
        return;
    }
    this.seenStatementsHashCodes.add(statementHashCode);

    // if it does not a have conceptIdentifier than it may be an attribute for vocabulary or a wrong record, so just ignore it
    String conceptIdentifier = conceptUri.replace(this.folderContextRoot, "");
    if (StringUtils.contains(conceptIdentifier, "/") || !Util.isValidIdentifier(conceptIdentifier)) {
        // this.logMessages.add(st.toString() + " NOT imported, contains a / in concept identifier or empty");
        return;
    }

    String predicateUri = predicate.stringValue();

    Pair<Class, String> ignoranceRule = PREDICATE_IGNORANCE_RULES.get(predicateUri);
    if (ignoranceRule != null) {
        if (ignoranceRule.getLeft().isInstance(object)
                && object.stringValue().matches(ignoranceRule.getRight())) {
            // ignore value
            return;
        }
    }

    String attributeIdentifier = null;
    String predicateNS = null;

    boolean candidateForConceptAttribute = false;
    if (StringUtils.startsWith(predicateUri, VocabularyOutputHelper.LinkedDataNamespaces.SKOS_NS)) {
        attributeIdentifier = predicateUri.replace(VocabularyOutputHelper.LinkedDataNamespaces.SKOS_NS, "");
        candidateForConceptAttribute = SKOS_CONCEPT_ATTRIBUTES.contains(attributeIdentifier);
        if (candidateForConceptAttribute) {
            predicateNS = SKOS_CONCEPT_ATTRIBUTE_NS;
        }
    }

    if (candidateForConceptAttribute && !(object instanceof Literal)) {
        // this.logMessages.add(st.toString() + " NOT imported, object is not a Literal for concept attribute");
        return;
    }

    if (!candidateForConceptAttribute) {
        for (String key : this.boundURIs.keySet()) {
            if (StringUtils.startsWith(predicateUri, key)) {
                attributeIdentifier = predicateUri.replace(key, "");
                predicateNS = this.boundURIs.get(key);
                if (!this.boundElements.get(predicateNS).contains(attributeIdentifier)) {
                    predicateNS = null;
                }
                break;
            }
        }
    }

    if (StringUtils.isEmpty(predicateNS)) {
        // this.logMessages.add(st.toString() + " NOT imported, predicate is not a bound URI nor a concept attribute");
        this.notBoundPredicates.add(predicateUri);
        return;
    }

    // if execution comes here so we have a valid triple to import
    // first find the concept
    if (!StringUtils.equals(conceptIdentifier, this.prevConceptIdentifier)) {
        this.prevDataElemIdentifier = null;
        this.prevLang = null;
        this.lastFoundConcept = null;
    }
    this.prevConceptIdentifier = conceptIdentifier;

    if (this.lastFoundConcept == null) {
        Pair<VocabularyConcept, Boolean> foundConceptWithFlag = findOrCreateConcept(conceptIdentifier);
        // if vocabulary concept couldnt find or couldnt be created
        if (foundConceptWithFlag == null) {
            return;
        }

        this.lastFoundConcept = foundConceptWithFlag.getLeft();
        if (!foundConceptWithFlag.getRight()) {
            // vocabulary concept found or created, add it to list
            this.toBeUpdatedConcepts.add(this.lastFoundConcept);
        }
    }

    String dataElemIdentifier = predicateNS + ":" + attributeIdentifier;
    if (StringUtils.equals(this.ddNamespace, predicateNS)) {
        dataElemIdentifier = attributeIdentifier;
    }

    // TODO code below can be refactored
    if (candidateForConceptAttribute && !this.conceptsUpdatedForAttributes.get(dataElemIdentifier)
            .contains(this.lastFoundConcept.getId())) {
        this.conceptsUpdatedForAttributes.get(dataElemIdentifier).add(this.lastFoundConcept.getId());
        // update concept value here
        String val = StringUtils.trimToNull(object.stringValue());
        if (StringUtils.equals(attributeIdentifier, NOTATION)) {
            this.lastFoundConcept.setNotation(val);
        } else {
            if (StringUtils.equals(attributeIdentifier, DEFINITION)) {
                this.lastFoundConcept.setDefinition(val);
            } else if (StringUtils.equals(attributeIdentifier, PREF_LABEL)) {
                this.lastFoundConcept.setLabel(val);
            }
            String elemLang = StringUtils.substring(((Literal) object).getLanguage(), 0, 2);
            if (StringUtils.isNotBlank(elemLang)) {
                this.lastCandidateForConceptAttribute.put(this.lastFoundConcept.getId() + dataElemIdentifier,
                        (Literal) object);
                candidateForConceptAttribute = false;
            }
        }
    } else if (candidateForConceptAttribute && this.lastCandidateForConceptAttribute
            .containsKey(this.lastFoundConcept.getId() + dataElemIdentifier)) {
        // check if more prior value received
        Literal previousCandidate = this.lastCandidateForConceptAttribute
                .remove(this.lastFoundConcept.getId() + dataElemIdentifier);

        String elemLang = StringUtils.substring(((Literal) object).getLanguage(), 0, 2);
        boolean updateValue = false;
        if (StringUtils.isEmpty(elemLang)) {
            updateValue = true;
        } else if (StringUtils.equals(elemLang, this.workingLanguage) && !StringUtils
                .equals(StringUtils.substring(previousCandidate.getLanguage(), 0, 2), this.workingLanguage)) {
            updateValue = true;
            candidateForConceptAttribute = false;
            this.lastCandidateForConceptAttribute.put(this.lastFoundConcept.getId() + dataElemIdentifier,
                    (Literal) object);
        } else {
            this.lastCandidateForConceptAttribute.put(this.lastFoundConcept.getId() + dataElemIdentifier,
                    previousCandidate);
            candidateForConceptAttribute = false;
        }

        if (updateValue) {
            String val = StringUtils.trimToNull(object.stringValue());
            if (StringUtils.equals(attributeIdentifier, DEFINITION)) {
                this.lastFoundConcept.setDefinition(val);
            } else if (StringUtils.equals(attributeIdentifier, PREF_LABEL)) {
                this.lastFoundConcept.setLabel(val);
            }
        }
    } else {
        candidateForConceptAttribute = false;
    }

    if (!candidateForConceptAttribute) {
        if (!this.boundElementsIds.containsKey(dataElemIdentifier)) {
            this.notBoundPredicates.add(predicateUri);
            return;
        }

        Set<Integer> conceptIdsUpdatedWithPredicate = this.predicateUpdatesAtConcepts.get(predicateUri);
        if (conceptIdsUpdatedWithPredicate == null) {
            conceptIdsUpdatedWithPredicate = new HashSet<Integer>();
            this.predicateUpdatesAtConcepts.put(predicateUri, conceptIdsUpdatedWithPredicate);
        }
        // find the data element
        if (!this.identifierOfPredicate.containsKey(predicateUri)) {
            this.identifierOfPredicate.put(predicateUri, dataElemIdentifier);
        }
        if (!StringUtils.equals(dataElemIdentifier, this.prevDataElemIdentifier)) {
            elementsOfConcept = getDataElementValuesByName(dataElemIdentifier,
                    lastFoundConcept.getElementAttributes());
            if (createNewDataElementsForPredicates
                    && !conceptIdsUpdatedWithPredicate.contains(lastFoundConcept.getId())) {
                if (this.elementsOfConcept != null) {
                    this.lastFoundConcept.getElementAttributes().remove(this.elementsOfConcept);
                }
                this.elementsOfConcept = null;
            }

            if (this.elementsOfConcept == null) {
                this.elementsOfConcept = new ArrayList<DataElement>();
                this.lastFoundConcept.getElementAttributes().add(this.elementsOfConcept);
            }
        }

        String elementValue = object.stringValue();
        if (StringUtils.isEmpty(elementValue)) {
            // value is empty, no need to continue
            return;
        }
        String elemLang = null;
        VocabularyConcept foundRelatedConcept = null;
        // if object is a resource (i.e. URI), it can be a related concept
        if (object instanceof URI) {
            foundRelatedConcept = findRelatedConcept(elementValue);
        } else if (object instanceof Literal) {
            // it is literal
            elemLang = StringUtils.substring(((Literal) object).getLanguage(), 0, 2);
        }

        if (!StringUtils.equals(dataElemIdentifier, prevDataElemIdentifier)
                || !StringUtils.equals(elemLang, prevLang)) {
            elementsOfConceptByLang = getDataElementValuesByNameAndLang(dataElemIdentifier, elemLang,
                    lastFoundConcept.getElementAttributes());
        }
        this.prevLang = elemLang;
        this.prevDataElemIdentifier = dataElemIdentifier;

        // check for pre-existence of the VCE by attribute value or related concept id
        Integer relatedId = null;
        if (foundRelatedConcept != null) {
            relatedId = foundRelatedConcept.getId();
        }
        for (DataElement elemByLang : elementsOfConceptByLang) {
            String elementValueByLang = elemByLang.getAttributeValue();
            if (StringUtils.equals(elementValue, elementValueByLang)) {
                // vocabulary concept element already in database, no need to continue, return
                return;
            }
            if (relatedId != null) {
                Integer relatedConceptId = elemByLang.getRelatedConceptId();
                if (relatedConceptId != null && relatedConceptId.intValue() == relatedId.intValue()) {
                    // vocabulary concept element already in database, no need to continue, return
                    return;
                }
            }
        }

        // create VCE
        DataElement elem = new DataElement();
        this.elementsOfConcept.add(elem);
        elem.setAttributeLanguage(elemLang);
        elem.setIdentifier(dataElemIdentifier);
        elem.setId(this.boundElementsIds.get(dataElemIdentifier));
        // check if there is a found related concept
        if (foundRelatedConcept != null) {
            elem.setRelatedConceptIdentifier(foundRelatedConcept.getIdentifier());
            int id = foundRelatedConcept.getId();
            elem.setRelatedConceptId(id);
            elem.setAttributeValue(null);
            if (id < 0) {
                addToElementsReferringNotCreatedConcepts(id, elem);
            }
        } else {
            elem.setAttributeValue(elementValue);
            elem.setRelatedConceptId(null);
        }

        conceptIdsUpdatedWithPredicate.add(this.lastFoundConcept.getId());
    }
    this.numberOfValidTriples++;
}

From source file:ch.entwine.weblounge.common.impl.request.RequestUtils.java

/**
 * Checks if the parameter <code>parameter</code> is present in the request
 * and is not equal to the empty string.
 * /*from   w w  w. j av  a 2s .  c  o m*/
 * @param request
 *          the weblounge request
 * @param parameter
 *          the parameter name
 * @return <code>true</code> if the parameter is available
 */
public static boolean parameterExists(WebloungeRequest request, String parameter) {
    String p = getParameter(request, parameter);
    return StringUtils.trimToNull(p) != null;
}