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

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

Introduction

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

Prototype

public static String substring(String str, int start, int end) 

Source Link

Document

Gets a substring from the specified String avoiding exceptions.

Usage

From source file:com.haulmont.cuba.gui.xml.layout.loaders.DataGridLoader.java

@Nullable
protected Integer loadWidth(Element element, String propertyName) {
    String width = loadThemeString(element.attributeValue(propertyName));
    if (!StringUtils.isBlank(width)) {
        if (StringUtils.endsWith(width, "px")) {
            width = StringUtils.substring(width, 0, width.length() - 2);
        }//from   ww  w  . j  av  a 2  s  . co  m
        try {
            // Only integer allowed in XML
            return Integer.parseInt(width);
        } catch (NumberFormatException e) {
            throw new GuiDevelopmentException("Property '" + propertyName + "' must contain only numeric value",
                    context.getCurrentFrameId(), propertyName, element.attributeValue("width"));
        }
    }
    return null;
}

From source file:hydrograph.ui.graph.figure.ComponentFigure.java

@Override
protected void paintFigure(Graphics graphics) {

    Rectangle r = getBounds().getCopy();
    graphics.translate(r.getLocation());

    Rectangle q = new Rectangle(4, 4 + componentLabelMargin, r.width - 8, r.height - 8 - componentLabelMargin);
    graphics.fillRoundRectangle(q, 5, 5);

    graphics.drawImage(canvasIcon, new Point(q.width / 2 - 16, q.height / 2 + componentLabelMargin - 11));
    drawPropertyStatus(graphics);/*from   w w w  .jav  a2 s  .  c o m*/
    if ((StringUtils.equalsIgnoreCase(component.getCategory(), Constants.TRANSFORM)
            && !StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.FILTER)
            && !StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.UNIQUE_SEQUENCE))) {
        PropertyToolTipInformation propertyToolTipInformation;
        if (component.isContinuousSchemaPropogationAllow()) {
            drawSchemaPropogationInfoImageIfSchemaPropogationBreaks(graphics);
            propertyToolTipInformation = createPropertyToolTipInformation(
                    Messages.CONTINUOUS_SCHEMA_PROPAGATION_STOPPED, Constants.SHOW_TOOLTIP);
        } else {
            propertyToolTipInformation = createPropertyToolTipInformation("", Constants.HIDE_TOOLTIP);
        }
        component.getTooltipInformation().put(Constants.ISSUE_PROPERTY_NAME, propertyToolTipInformation);
    } else if (StringUtils.equalsIgnoreCase(Constants.UNION_ALL, component.getComponentName())) {
        PropertyToolTipInformation propertyToolTipInformation;
        if (component.getProperties().get(Constants.IS_UNION_ALL_COMPONENT_SYNC) != null
                && StringUtils.equalsIgnoreCase(
                        ((String) component.getProperties().get(Constants.IS_UNION_ALL_COMPONENT_SYNC)),
                        Constants.FALSE)) {
            drawSchemaPropogationInfoImageIfSchemaPropogationBreaks(graphics);
            propertyToolTipInformation = createPropertyToolTipInformation(
                    Messages.INPUTS_SCHEMA_ARE_NOT_IN_SYNC, Constants.SHOW_TOOLTIP);
        } else {
            propertyToolTipInformation = createPropertyToolTipInformation("", Constants.HIDE_TOOLTIP);
        }
        component.getTooltipInformation().put(Constants.ISSUE_PROPERTY_NAME, propertyToolTipInformation);
    } else if (component instanceof SubjobComponent) {
        boolean isTransformComponentPresent = SubjobUtility.INSTANCE
                .checkIfSubJobHasTransformOrUnionAllComponent(component);
        PropertyToolTipInformation propertyToolTipInformation;
        if (isTransformComponentPresent) {
            drawSchemaPropogationInfoImageIfSchemaPropogationBreaks(graphics);
            propertyToolTipInformation = createPropertyToolTipInformation(
                    Messages.CONTINUOUS_SCHEMA_PROPAGATION_STOPPED_IN_SUBJOB, Constants.SHOW_TOOLTIP);
        } else {
            propertyToolTipInformation = createPropertyToolTipInformation("", Constants.HIDE_TOOLTIP);
        }
        component.getTooltipInformation().put(Constants.ISSUE_PROPERTY_NAME, propertyToolTipInformation);
    }
    graphics.drawText(acronym,
            new Point((q.width - (acronym.length() * 5)) / 2, q.height / 2 + componentLabelMargin - 23));

    if (componentProperties != null
            && componentProperties.get(StringUtils.lowerCase(Constants.BATCH)) != null) {
        if (String.valueOf(componentProperties.get(StringUtils.lowerCase(Constants.BATCH))).length() > 2) {
            graphics.drawText(StringUtils.substring(
                    String.valueOf(componentProperties.get(StringUtils.lowerCase(Constants.BATCH))), 0, 2)
                    + "..", new Point(q.width - 16, q.height + getComponentLabelMargin() - 20));
        } else {
            graphics.drawText(String.valueOf(componentProperties.get(StringUtils.lowerCase(Constants.BATCH))),
                    new Point(q.width - 14, q.height + getComponentLabelMargin() - 20));
        }
    }

    trackExecution(graphics);
}

From source file:com.hangum.tadpole.commons.admin.core.editors.sqlaudit.AdminSQLAuditEditor.java

/**
 * show query editor//ww w.  ja v a 2 s. c  o m
 */
private void showQueryEditor() {
    GridItem[] gridItems = gridHistory.getSelection();
    if (gridItems.length != 0) {
        try {
            RequestResultDAO reqResultDao = mapSQLHistory.get(gridItems[0].getText(0));

            if (null != reqResultDao) {
                String strApiOrSQL = gridItems[0].getText(4);

                if (reqResultDao.getEXECUSTE_SQL_TYPE() == PublicTadpoleDefine.EXECUTE_SQL_TYPE.API) {
                    int intFindAnd = StringUtils.indexOf(strApiOrSQL, "&"); //$NON-NLS-1$
                    String strApi = StringUtils.substring(strApiOrSQL, 0, intFindAnd);

                    UserDBResourceDAO userDBResourceDao = TadpoleSystem_UserDBResource.findAPIKey(strApi);
                    String strSQL = TadpoleSystem_UserDBResource.getResourceData(userDBResourceDao);
                    if (logger.isDebugEnabled())
                        logger.debug(userDBResourceDao.getName() + ", " + strSQL); //$NON-NLS-1$

                    strApiOrSQL = strSQL;
                }

                UserDBDAO dbDao = TadpoleSystem_UserDBQuery.getUserDBInstance(reqResultDao.getDbSeq());
                FindEditorAndWriteQueryUtil.run(dbDao,
                        Utils.convHtmlToLine(strApiOrSQL) + PublicTadpoleDefine.SQL_DELIMITER,
                        PublicTadpoleDefine.OBJECT_TYPE.TABLES);
            }
        } catch (Exception e) {
            logger.error("find editor and write query", e); //$NON-NLS-1$
        }
    }
}

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();//w  ww.  j  a  va  2  s.c om

    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:feup.pfaria.jenkins.plugins.filtereddashboardview.FilteredDashboardView.java

/**
 * Gets all child values defined in the Metadata Plugin
 * and creates Tags according their values
 *
 * @param jobName name of the Job to search for
 * @param buildNr number of the Build of the Job
 * @return tags the list of Tags associated to this Build
 */// w w  w .j  a  va 2s .c o m
public ArrayList<Tag> getBuildTags(String jobName, int buildNr) {
    ArrayList<Tag> tags = new ArrayList<Tag>();
    Job job = Jenkins.getInstance().getItemByFullName(jobName, Job.class);
    Run build = job.getBuildByNumber(buildNr);

    /**
     * Since the Metadata-Plugin doesn't support WorkflowJob (From the Pipeline-Plugin)
     * one can add metadata to this type of jobs by creating Parameterized Builds
     * (checking 'This project is parameterized')
     * and creating its tags by adding parameters in the following sctructure:
     *
     * String Parameter
     * Name:   metadata:NameOfTag
     * Value:  anyValue
     */
    if (job.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
        ParametersAction parameterActions = build.getAction(ParametersAction.class);
        if (parameterActions != null) {
            for (ParameterValue parameter : parameterActions.getAllParameters()) {
                if (parameter.getClass().equals(StringParameterValue.class)) {
                    if (StringUtils.substring(parameter.getName(), 0, "metadata:".length()).equals("metadata:")
                            && !parameter.getValue().equals("")) {
                        String name = parameter.getName().replace("metadata:", "");
                        tags.add(new Tag(name.toUpperCase(), parameter.getValue().toString().toLowerCase()));
                    }
                }
            }
        }
    } else {
        try {
            //Get all the metadata in this build
            MetadataBuildAction metadataBuild = new MetadataBuildAction();

            //By unknonw reason, Inheritance-Plugin makes conflict with the Metadata-Plugin
            if (!build.getParent().getClass().getName()
                    .equals("hudson.plugins.project_inheritance.projects.InheritanceProject"))
                metadataBuild = build.getAction(MetadataBuildAction.class);

            if (metadataBuild != null) {
                Collection<String> metadataNames = metadataBuild.getChildNames();
                for (String name : metadataNames) {
                    switch (name) {
                    //Hide metadata-plugin predefined tags
                    case "job-info":
                        break;
                    case "build":
                        break;
                    default:
                        MetadataValue value = metadataBuild.getChild(name);
                        tags.add(new Tag(name.toUpperCase(), value.getValue().toString().toLowerCase()));
                        break;
                    }
                }
            }
            return tags;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return tags;
}

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

/**
 * @deprecated use the {@link Icons#get(com.haulmont.cuba.gui.icons.Icons.Icon)} bean
 * and {@link com.haulmont.cuba.gui.icons.CubaIcon} icon set instead
 *///ww  w. j a va 2 s .c om
@Deprecated
@Nullable
public static Resource getFontIconResource(String fontIcon)
        throws NoSuchFieldException, IllegalAccessException {
    if (StringUtils.isNotEmpty(fontIcon)) {
        String fontIconName = "font-awesome-icon";
        String fontIconField;
        if (fontIcon.contains(":")) {
            fontIconName = StringUtils.substring(fontIcon, 0, fontIcon.indexOf(":"));
            fontIconField = StringUtils.substring(fontIcon, fontIcon.indexOf(":") + 1);
        } else {
            fontIconField = fontIcon;
        }
        return getFontIconResource(fontIconName, fontIconField);
    }
    return null;
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.AbstractTableLoader.java

protected Table.Column loadColumn(Element element, Datasource ds) {
    String id = element.attributeValue("id");

    MetaPropertyPath metaPropertyPath = AppBeans.get(MetadataTools.NAME, MetadataTools.class)
            .resolveMetaPropertyPath(ds.getMetaClass(), id);

    Table.Column column = new Table.Column(metaPropertyPath != null ? metaPropertyPath : id);

    String editable = element.attributeValue("editable");
    if (StringUtils.isNotEmpty(editable)) {
        column.setEditable(Boolean.parseBoolean(editable));
    }/*from w  w w. j  a va 2s .com*/

    String collapsed = element.attributeValue("collapsed");
    if (StringUtils.isNotEmpty(collapsed)) {
        column.setCollapsed(Boolean.parseBoolean(collapsed));
    }

    String groupAllowed = element.attributeValue("groupAllowed");
    if (StringUtils.isNotEmpty(groupAllowed)) {
        column.setGroupAllowed(Boolean.parseBoolean(groupAllowed));
    }

    String sortable = element.attributeValue("sortable");
    if (StringUtils.isNotEmpty(sortable)) {
        column.setSortable(Boolean.parseBoolean(sortable));
    }

    loadCaption(column, element);
    loadDescription(column, element);

    if (column.getCaption() == null) {
        String columnCaption;
        if (column.getId() instanceof MetaPropertyPath) {
            MetaPropertyPath mpp = (MetaPropertyPath) column.getId();
            MetaProperty metaProperty = mpp.getMetaProperty();
            String propertyName = metaProperty.getName();

            if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
                CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty);

                columnCaption = LocaleHelper.isLocalizedValueDefined(categoryAttribute.getLocaleNames())
                        ? categoryAttribute.getLocaleName()
                        : StringUtils.capitalize(categoryAttribute.getName());
            } else {
                MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(mpp);
                columnCaption = messageTools.getPropertyCaption(propertyMetaClass, propertyName);
            }
        } else {
            Class<?> declaringClass = ds.getMetaClass().getJavaClass();
            String className = declaringClass.getName();
            int i = className.lastIndexOf('.');
            if (i > -1)
                className = className.substring(i + 1);
            columnCaption = messages.getMessage(declaringClass, className + "." + id);
        }
        column.setCaption(columnCaption);
    }

    column.setXmlDescriptor(element);
    if (metaPropertyPath != null)
        column.setType(metaPropertyPath.getRangeJavaClass());

    String width = loadThemeString(element.attributeValue("width"));
    if (!StringUtils.isBlank(width)) {
        if (StringUtils.endsWith(width, "px")) {
            width = StringUtils.substring(width, 0, width.length() - 2);
        }
        try {
            column.setWidth(Integer.parseInt(width));
        } catch (NumberFormatException e) {
            throw new GuiDevelopmentException("Property 'width' must contain only numeric value",
                    context.getCurrentFrameId(), "width", element.attributeValue("width"));
        }
    }
    String align = element.attributeValue("align");
    if (StringUtils.isNotBlank(align)) {
        column.setAlignment(Table.ColumnAlignment.valueOf(align));
    }

    column.setFormatter(loadFormatter(element));

    loadAggregation(column, element);
    loadCalculatable(column, element);
    loadMaxTextLength(column, element);

    return column;
}

From source file:de.iai.ilcd.model.process.Process.java

/**
 * Apply cache fields for process, those are cached values for:
 * <ul>//from   ww  w.  j av a 2  s  .c o  m
 * <li>{@link #getLCIMethodInformation()}</li>
 * </ul>
 */
@Override
@PrePersist
protected void applyDataSetCache() {
    super.applyDataSetCache();
    if (this.lCIMethodInformation != null && this.lCIMethodInformation.getMethodPrinciple() != null) {
        this.lciMethodInformationCache = StringUtils
                .substring(this.lCIMethodInformation.getMethodPrinciple().value(), 0, 20);
    } else {
        this.lciMethodInformationCache = null;
    }
    // TODO: use dependency injection later
    ComplianceUtilHandler compHandler = new ComplianceUtilHandler();
    this.complianceSystemCache = StringUtils
            .substring(compHandler.getComplianceCodeAsString(this.complianceSystems), 0, 1);
}

From source file:com.hangum.tadpole.manager.core.editor.executedsql.SQLAuditEditor.java

/**
 * show query editor//www. j a va  2 s  .co  m
 */
private void showQueryEditor() {
    GridItem[] gridItems = gridHistory.getSelection();
    if (gridItems.length != 0) {
        try {
            RequestResultDAO reqResultDao = mapSQLHistory.get(gridItems[0].getText(0));

            if (null != reqResultDao) {
                String strApiOrSQL = gridItems[0].getText(4);

                if (reqResultDao.getEXECUSTE_SQL_TYPE() == PublicTadpoleDefine.EXECUTE_SQL_TYPE.API) {
                    int intFindAnd = StringUtils.indexOf(strApiOrSQL, "&"); //$NON-NLS-1$
                    String strApi = StringUtils.substring(strApiOrSQL, 0, intFindAnd);

                    UserDBResourceDAO userDBResourceDao = TadpoleSystem_UserDBResource.findAPIKey(strApi);
                    String strSQL = TadpoleSystem_UserDBResource.getResourceData(userDBResourceDao);
                    if (logger.isDebugEnabled())
                        logger.debug(userDBResourceDao.getName() + ", " + strSQL); //$NON-NLS-1$

                    strApiOrSQL = strSQL;
                }

                UserDBDAO dbDao = TadpoleSystem_UserDBQuery.getUserDBInstance(reqResultDao.getDbSeq());
                FindEditorAndWriteQueryUtil.run(dbDao,
                        Utils.convHtmlToLine(strApiOrSQL) + PublicTadpoleDefine.SQL_DELIMITER,
                        PublicTadpoleDefine.OBJECT_TYPE.TABLES);

            }
        } catch (Exception e) {
            logger.error("find editor and write query", e); //$NON-NLS-1$
        }
    }
}

From source file:gnete.card.web.merch.MerchAction.java

public String add() throws Exception {
    String type = merchInfoReg.getMerchType();
    Assert.notEmpty(type, "?");
    this.merchInfoReg.setMerchType(StringUtils.substring(type, 0, StringUtils.indexOf(type, "|")));
    //      /*from  w  ww  . j av  a  2  s  .  c o m*/
    //      // service?;??
    //      UserInfo admin = new UserInfo();
    //      admin.setUserId(this.merchAdmin);
    //      this.merchService.addMerch(this.merchInfo, admin, branchCode, this.getSessionUserCode());
    //      
    //      if (addAdmin == 1) {
    //         this.merchService.addMerch(this.merchInfo, admin, branchCode, this.getSessionUserCode());
    //      } else {
    //         this.merchService.addMerch(this.merchInfo, null, branchCode, this.getSessionUserCode());
    //      }

    this.merchInfoReg.setAdminId(this.merchAdmin);

    this.merchService.addMerch(this.merchInfoReg, this.getSessionUser());

    String msg = LogUtils.r("id[{0}]??", this.merchInfoReg.getId());
    this.addActionMessage("/pages/merch/regList.do?goBack=goBack", msg);
    this.log(msg, UserLogType.ADD);
    return SUCCESS;
}