List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:org.finra.herd.dao.impl.IndexSearchDaoImpl.java
@Override public IndexSearchResponse indexSearch(final IndexSearchRequest indexSearchRequest, final Set<String> fields, final Set<String> match, final String bdefActiveIndex, final String tagActiveIndex) { // Build a basic Boolean query upon which add all the necessary clauses as needed BoolQueryBuilder indexSearchQueryBuilder = QueryBuilders.boolQuery(); String searchPhrase = indexSearchRequest.getSearchTerm(); // If there is a search phrase, then process it if (StringUtils.isNotEmpty(searchPhrase)) { // Determine if negation terms are present boolean negationTermsExist = herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest); // Add the negation queries builder within a 'must-not' clause to the parent bool query if negation terms exist if (negationTermsExist) { // Build negation queries- each term is added to the query with a 'must-not' clause, List<String> negationTerms = herdSearchQueryHelper.extractNegationTerms(indexSearchRequest); if (CollectionUtils.isNotEmpty(negationTerms)) { negationTerms.forEach(term -> { indexSearchQueryBuilder .mustNot(buildMultiMatchQuery(term, PHRASE, 100f, FIELD_TYPE_STEMMED, match)); });//from ww w . java2 s . c o m } // Remove the negation terms from the search phrase searchPhrase = herdSearchQueryHelper.extractSearchPhrase(indexSearchRequest); } // Build a Dismax query with three primary components (multi-match queries) with boost values, these values can be configured in the // DB which provides a way to dynamically tune search behavior at runtime: // 1. Phrase match query on shingles fields. // 2. Phrase prefix query on stemmed fields. // 3. Best fields query on ngrams fields. final MultiMatchQueryBuilder phrasePrefixMultiMatchQueryBuilder = buildMultiMatchQuery(searchPhrase, PHRASE_PREFIX, configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_PHRASE_PREFIX_QUERY_BOOST, Float.class), FIELD_TYPE_STEMMED, match); final MultiMatchQueryBuilder bestFieldsMultiMatchQueryBuilder = buildMultiMatchQuery(searchPhrase, BEST_FIELDS, configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_BEST_FIELDS_QUERY_BOOST, Float.class), FIELD_TYPE_NGRAMS, match); final MultiMatchQueryBuilder phraseMultiMatchQueryBuilder = buildMultiMatchQuery( searchPhrase, PHRASE, configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_PHRASE_QUERY_BOOST, Float.class), FIELD_TYPE_SHINGLES, match); final MultiMatchQueryBuilder phraseStemmedMultiMatchQueryBuilder = buildMultiMatchQuery( searchPhrase, PHRASE, configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_PHRASE_QUERY_BOOST, Float.class), FIELD_TYPE_STEMMED, match); // Add the multi match queries to a dis max query and add to the parent bool query within a 'must' clause indexSearchQueryBuilder.must( disMaxQuery().add(phrasePrefixMultiMatchQueryBuilder).add(bestFieldsMultiMatchQueryBuilder) .add(phraseMultiMatchQueryBuilder).add(phraseStemmedMultiMatchQueryBuilder)); } // Add filter clauses if index search filters are specified in the request if (CollectionUtils.isNotEmpty(indexSearchRequest.getIndexSearchFilters())) { indexSearchQueryBuilder.filter(elasticsearchHelper.addIndexSearchFilterBooleanClause( indexSearchRequest.getIndexSearchFilters(), bdefActiveIndex, tagActiveIndex)); } // Get function score query builder FunctionScoreQueryBuilder functionScoreQueryBuilder = getFunctionScoreQueryBuilder(indexSearchQueryBuilder, bdefActiveIndex); // The fields in the search indexes to return final String[] searchSources = { NAME_SOURCE, NAMESPACE_CODE_SOURCE, TAG_CODE_SOURCE, TAG_TYPE_CODE_SOURCE, DISPLAY_NAME_SOURCE, DESCRIPTION_SOURCE, BDEF_TAGS_SOURCE, BDEF_TAGS_SEARCH_SCORE_MULTIPLIER }; // Create a new indexSearch source builder final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); // Fetch only the required fields searchSourceBuilder.fetchSource(searchSources, null); searchSourceBuilder.query(functionScoreQueryBuilder); // Create a indexSearch request builder SearchRequestBuilder searchRequestBuilder = new SearchRequestBuilder(new ElasticsearchClientImpl(), SearchAction.INSTANCE); searchRequestBuilder.setIndices(bdefActiveIndex, tagActiveIndex); searchRequestBuilder.setSource(searchSourceBuilder).setSize(SEARCH_RESULT_SIZE) .addSort(SortBuilders.scoreSort()); // Add highlighting if specified in the request if (BooleanUtils.isTrue(indexSearchRequest.isEnableHitHighlighting())) { // Fetch configured 'tag' values for highlighting String preTag = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_PRETAGS); String postTag = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_POSTTAGS); searchRequestBuilder.highlighter(buildHighlightQuery(preTag, postTag, match)); } // Add facet aggregations if specified in the request if (CollectionUtils.isNotEmpty(indexSearchRequest.getFacetFields())) { searchRequestBuilder = elasticsearchHelper.addFacetFieldAggregations( new HashSet<>(indexSearchRequest.getFacetFields()), searchRequestBuilder); } // Log the actual elasticsearch query when debug is enabled LOGGER.debug("indexSearchRequest={}", searchRequestBuilder.toString()); // Retrieve the indexSearch response final Search.Builder searchBuilder = new Search.Builder(searchRequestBuilder.toString()) .addIndices(Arrays.asList(bdefActiveIndex, tagActiveIndex)); final SearchResult searchResult = jestClientHelper.execute(searchBuilder.build()); final List<IndexSearchResult> indexSearchResults = buildIndexSearchResults(fields, tagActiveIndex, bdefActiveIndex, searchResult, indexSearchRequest.isEnableHitHighlighting()); List<Facet> facets = null; if (CollectionUtils.isNotEmpty(indexSearchRequest.getFacetFields())) { // Extract facets from the search response facets = new ArrayList<>( extractFacets(indexSearchRequest, searchResult, bdefActiveIndex, tagActiveIndex)); } return new IndexSearchResponse(searchResult.getTotal(), indexSearchResults, facets); }
From source file:org.finra.herd.dao.impl.IndexSearchDaoImpl.java
/** * Extracts and builds a list of {@link IndexSearchResult}s from a given {@link SearchResult} * * @param fields the specified fields to be included in the response * @param tagActiveIndex the name of the active tag index * @param bdefActiveIndex the name of the active business object definition index * @param searchResult the raw search result returned by the elasticsearch client * @param isHighlightingEnabled boolean which specifies if highlighting is requested or not * * @return A {@link List} of {@link IndexSearchResult} which represent the search response *///from ww w. jav a 2 s . c o m private List<IndexSearchResult> buildIndexSearchResults(Set<String> fields, String tagActiveIndex, String bdefActiveIndex, SearchResult searchResult, Boolean isHighlightingEnabled) { final Integer tagShortDescMaxLength = configurationHelper .getProperty(ConfigurationValue.TAG_SHORT_DESCRIPTION_LENGTH, Integer.class); final Integer businessObjectDefinitionShortDescMaxLength = configurationHelper .getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class); List<IndexSearchResult> indexSearchResults = new ArrayList<>(); try { final List<SearchResult.Hit<Map, Void>> searchHitList = searchResult.getHits(Map.class); // For each indexSearch hit for (final SearchResult.Hit<Map, Void> hit : searchHitList) { // Get the source map from the indexSearch hit @SuppressWarnings("unchecked") final Map<String, Object> sourceMap = hit.source; // Get the index from which this result is from final String index = hit.index; // Create a new document to populate with the indexSearch results final IndexSearchResult indexSearchResult = new IndexSearchResult(); // Populate the results indexSearchResult.setSearchIndexKey(new SearchIndexKey(index)); if (fields.contains(DISPLAY_NAME_FIELD)) { indexSearchResult.setDisplayName((String) sourceMap.get(DISPLAY_NAME_SOURCE)); } // Populate tag index specific key if (index.equals(tagActiveIndex)) { if (fields.contains(SHORT_DESCRIPTION_FIELD)) { indexSearchResult.setShortDescription(HerdStringUtils.getShortDescription( (String) sourceMap.get(DESCRIPTION_SOURCE), tagShortDescMaxLength)); } final TagKey tagKey = new TagKey(); tagKey.setTagCode((String) sourceMap.get(TAG_CODE_SOURCE)); tagKey.setTagTypeCode((String) ((Map) sourceMap.get(TAG_TYPE)).get(CODE)); indexSearchResult.setIndexSearchResultType(SearchIndexTypeEntity.SearchIndexTypes.TAG.name()); indexSearchResult.setIndexSearchResultKey(new IndexSearchResultKey(tagKey, null)); } // Populate business object definition key else if (index.equals(bdefActiveIndex)) { if (fields.contains(SHORT_DESCRIPTION_FIELD)) { indexSearchResult.setShortDescription( HerdStringUtils.getShortDescription((String) sourceMap.get(DESCRIPTION_SOURCE), businessObjectDefinitionShortDescMaxLength)); } final BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(); businessObjectDefinitionKey.setNamespace((String) ((Map) sourceMap.get(NAMESPACE)).get(CODE)); businessObjectDefinitionKey .setBusinessObjectDefinitionName((String) sourceMap.get(NAME_SOURCE)); indexSearchResult.setIndexSearchResultType( SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name()); indexSearchResult .setIndexSearchResultKey(new IndexSearchResultKey(null, businessObjectDefinitionKey)); } else { throw new IllegalStateException(String.format( "Search result index name \"%s\" does not match any of the active search indexes. tagActiveIndex=\"%s\" bdefActiveIndex=\"%s\"", index, tagActiveIndex, bdefActiveIndex)); } if (BooleanUtils.isTrue(isHighlightingEnabled)) { // Fetch configured 'tag' values for highlighting String preTag = configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_PRETAGS); String postTag = configurationHelper .getProperty(ConfigurationValue.ELASTICSEARCH_HIGHLIGHT_POSTTAGS); // Extract highlighted content from the search hit and clean html tags except the pre/post-tags as configured Highlight highlightedContent = extractHighlightedContent(hit, preTag, postTag); // Set highlighted content in the response element indexSearchResult.setHighlight(highlightedContent); } indexSearchResults.add(indexSearchResult); } } catch (RuntimeException e) { // Log the error along with the search response and throw the exception. LOGGER.error( "Failed to parse search results. tagActiveIndex=\"{}\" bdefActiveIndex=\"{}\" fields={} isHighlightingEnabled={} searchResult={}", tagActiveIndex, bdefActiveIndex, jsonHelper.objectToJson(fields), isHighlightingEnabled, jsonHelper.objectToJson(searchResult), e); // Throw an exception. throw new IllegalStateException( "Unexpected response received when attempting to retrieve search results."); } return indexSearchResults; }
From source file:org.finra.herd.service.helper.DefaultSqsMessageBuilder.java
@Override public String buildBusinessObjectDataStatusChangeMessage(BusinessObjectDataKey businessObjectDataKey, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus) { // Create a context map of values that can be used when building the message. Map<String, Object> velocityContextMap = new HashMap<>(); velocityContextMap.put("businessObjectDataKey", businessObjectDataKey); velocityContextMap.put("newBusinessObjectDataStatus", newBusinessObjectDataStatus); velocityContextMap.put("oldBusinessObjectDataStatus", oldBusinessObjectDataStatus); // Retrieve business object data entity and business object data id to the context. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper .getBusinessObjectDataEntity(businessObjectDataKey); velocityContextMap.put("businessObjectDataId", businessObjectDataEntity.getId()); // Load all attribute definitions for this business object data in a map for easy access. Map<String, BusinessObjectDataAttributeDefinitionEntity> attributeDefinitionEntityMap = businessObjectFormatHelper .getAttributeDefinitionEntities(businessObjectDataEntity.getBusinessObjectFormat()); // Build an ordered map of business object data attributes that are flagged to be published in notification messages. Map<String, String> businessObjectDataAttributes = new LinkedHashMap<>(); if (!attributeDefinitionEntityMap.isEmpty()) { for (BusinessObjectDataAttributeEntity attributeEntity : businessObjectDataEntity.getAttributes()) { if (attributeDefinitionEntityMap.containsKey(attributeEntity.getName().toUpperCase())) { BusinessObjectDataAttributeDefinitionEntity attributeDefinitionEntity = attributeDefinitionEntityMap .get(attributeEntity.getName().toUpperCase()); if (BooleanUtils.isTrue(attributeDefinitionEntity.getPublish())) { businessObjectDataAttributes.put(attributeEntity.getName(), attributeEntity.getValue()); }//from ww w . j ava 2s.com } } } // Add the map of business object data attributes to the context. velocityContextMap.put("businessObjectDataAttributes", businessObjectDataAttributes); // Evaluate the template and return the value. return evaluateVelocityTemplate( ConfigurationValue.HERD_NOTIFICATION_SQS_BUSINESS_OBJECT_DATA_STATUS_CHANGE_VELOCITY_TEMPLATE, velocityContextMap, "businessObjectDataStatusChangeEvent"); }
From source file:org.finra.herd.service.impl.EmrServiceImpl.java
/** * Gets details of an existing EMR Cluster. * * @param emrClusterAlternateKeyDto the EMR cluster alternate key * @param emrClusterId the cluster id of the cluster to get details * @param emrStepId the step id of the step to get details * @param verbose parameter for whether to return detailed information * @param accountId the optional AWS account that EMR cluster is running in * @param retrieveInstanceFleets parameter for whether to retrieve instance fleets * * @return the EMR Cluster object with details. *///from w ww.j a v a 2 s .co m protected EmrCluster getClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId, String emrStepId, boolean verbose, String accountId, Boolean retrieveInstanceFleets) { AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDtoByAccountId(accountId); // Perform the request validation. validateEmrClusterKey(emrClusterAlternateKeyDto); // Get the EMR cluster definition and ensure it exists. EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper .getEmrClusterDefinitionEntity(new EmrClusterDefinitionKey(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName())); EmrCluster emrCluster = createEmrClusterFromRequest(null, emrClusterDefinitionEntity.getNamespace().getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, null, null, null, null); String clusterName = emrHelper.buildEmrClusterName(emrClusterDefinitionEntity.getNamespace().getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName()); try { // Get Cluster status if clusterId is specified if (StringUtils.isNotBlank(emrClusterId)) { Cluster cluster = emrDao.getEmrClusterById(emrClusterId.trim(), awsParamsDto); // Validate that, Cluster exists Assert.notNull(cluster, "An EMR cluster must exists with the cluster ID \"" + emrClusterId + "\"."); // Validate that, Cluster name match as specified Assert.isTrue(clusterName.equalsIgnoreCase(cluster.getName()), "Cluster name of specified cluster id \"" + emrClusterId + "\" must match the name specified."); emrCluster.setId(cluster.getId()); setEmrClusterStatus(emrCluster, cluster.getStatus()); } else { ClusterSummary clusterSummary = emrDao.getActiveEmrClusterByName(clusterName, awsParamsDto); // Validate that, Cluster exists with the name Assert.notNull(clusterSummary, "An EMR cluster must exists with the name \"" + clusterName + "\"."); emrCluster.setId(clusterSummary.getId()); setEmrClusterStatus(emrCluster, clusterSummary.getStatus()); } // Get active step details if (emrHelper.isActiveEmrState(emrCluster.getStatus())) { StepSummary stepSummary = emrDao.getClusterActiveStep(emrCluster.getId(), awsParamsDto); if (stepSummary != null) { EmrStep activeStep; // If verbose get active step details if (verbose) { activeStep = buildEmrStepFromAwsStep(stepSummary, true); } else { activeStep = buildEmrStepFromAwsStepSummary(stepSummary); } emrCluster.setActiveStep(activeStep); } } // Get requested step details if (StringUtils.isNotBlank(emrStepId)) { Step step = emrDao.getClusterStep(emrCluster.getId(), emrStepId.trim(), awsParamsDto); emrCluster.setStep(buildEmrStepFromAwsStep(step, verbose)); } // Get instance fleet if true if (BooleanUtils.isTrue(retrieveInstanceFleets)) { ListInstanceFleetsResult listInstanceFleetsResult = emrDao .getListInstanceFleetsResult(emrCluster.getId(), awsParamsDto); emrCluster.setInstanceFleets( emrHelper.buildEmrClusterInstanceFleetFromAwsResult(listInstanceFleetsResult)); } } catch (AmazonServiceException ex) { awsServiceHelper.handleAmazonException(ex, "An Amazon exception occurred while getting EMR cluster details with name \"" + clusterName + "\"."); } return emrCluster; }
From source file:org.finra.herd.service.impl.EmrServiceImpl.java
/** * <p> Creates a new EMR cluster based on the given request if the cluster with the given name does not already exist. If the cluster already exist, returns * the information about the existing cluster. </p> <p> The request must contain: </p> <ul> <li>A namespace and definition name which refer to an existing * EMR cluster definition.</li> <li>A valid cluster name to create.</li> </ul> <p> The request may optionally contain: </p> <ul> <li>A "dry run" flag, which * when set to {@code true}, no calls to AWS will occur, but validations and override will. Defaults to {@code false}.</li> <li>An override parameter, which * when set, overrides the given parameters in the cluster definition before creating the cluster. Defaults to no override. </li> </ul> <p> A successful * response will contain: </p> <ul> <li>The ID of the cluster that was created, or if the cluster already exists, the ID of the cluster that exists. This * field will be {@code null} when dry run flag is {@code true}.</li> <li>The status of the cluster that was created or already exists. The status will * normally be "Starting" on successful creations. This field will be {@code null} when dry run flag is {@code true}</li> <li>The namespace, definition * name, and cluster name of the cluster.</li> <li>The dry run flag, if given in the request.</li> <li>An indicator whether the cluster was created or not. * If the cluster already exists, the cluster will not be created and this flag will be set to {@code false}.</li> <li>The definition which was used to * create the cluster. If any overrides were given, this definition's values will be the values after the override. This field will be {@code null} if the * cluster was not created.</li> </ul> <p> Notes: </p> <ul> <li>At any point of the execution, if there are validation errors, the method will immediately * throw an exception.</li> <li>Even if the validations pass, AWS may still reject the request, which will cause this method to throw an exception.</li> * <li>Dry runs do not make any calls to AWS, therefore AWS may still reject the creation request even when a dry run succeeds.</li> </ul> * * @param request - {@link EmrClusterCreateRequest} The EMR cluster create request * * @return {@link EmrCluster} the created EMR cluster object * @throws Exception when the original EMR cluster definition XML is malformed *//*from www . ja v a 2s.c o m*/ protected EmrCluster createClusterImpl(EmrClusterCreateRequest request) throws Exception { // Extract EMR cluster alternate key from the create request. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = getEmrClusterAlternateKey(request); // Perform the request validation. validateEmrClusterKey(emrClusterAlternateKeyDto); EmrClusterDefinition emrClusterDefinition = emrHelperServiceImpl .emrPreCreateClusterSteps(emrClusterAlternateKeyDto, request); String accountId = emrClusterDefinition.getAccountId(); EmrClusterCreateDto emrClusterCreateDto = emrHelperServiceImpl.emrCreateClusterAwsSpecificSteps(request, emrClusterDefinition, emrClusterAlternateKeyDto); if (emrClusterCreateDto.isEmrClusterCreated()) { emrHelperServiceImpl.logEmrClusterCreation(emrClusterAlternateKeyDto, emrClusterDefinition, emrClusterCreateDto.getClusterId()); } if (BooleanUtils.isTrue(emrClusterCreateDto.isEmrClusterAlreadyExists())) { // Do not include cluster definition in response emrClusterDefinition = null; } return createEmrClusterFromRequest(emrClusterCreateDto.getClusterId(), emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, emrClusterCreateDto.getEmrClusterStatus(), emrClusterCreateDto.isEmrClusterCreated(), request.isDryRun(), emrClusterDefinition); }
From source file:org.finra.herd.service.impl.SearchIndexValidationServiceImpl.java
@Override public SearchIndexValidation createSearchIndexValidation(SearchIndexValidationCreateRequest request) { //validate the request validateSearchIndexValidationRequest(request); // Ensure that search index for the specified search index key exists. Fetch the type SearchIndexEntity searchIndexEntity = searchIndexDaoHelper .getSearchIndexEntity(request.getSearchIndexKey()); String searchIndexType = searchIndexEntity.getType().getCode(); String indexName = request.getSearchIndexKey().getSearchIndexName(); boolean sizeCheck = false; boolean spotCheckPercentage = false; boolean spotCheckMostRecent = false; // Currently, only search index for business object definitions and tag are supported. if (SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name().equalsIgnoreCase(searchIndexType)) { // only perform full validation if specified in the request if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) { businessObjectDefinitionService.indexValidateAllBusinessObjectDefinitions(indexName); }//from www . java2s.c o m sizeCheck = businessObjectDefinitionService .indexSizeCheckValidationBusinessObjectDefinitions(indexName); spotCheckPercentage = businessObjectDefinitionService .indexSpotCheckPercentageValidationBusinessObjectDefinitions(indexName); spotCheckMostRecent = businessObjectDefinitionService .indexSpotCheckMostRecentValidationBusinessObjectDefinitions(indexName); } else if (SearchIndexTypeEntity.SearchIndexTypes.TAG.name().equalsIgnoreCase(searchIndexType)) { // only perform full validation if specified in the request if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) { tagService.indexValidateAllTags(indexName); } sizeCheck = tagService.indexSizeCheckValidationTags(indexName); spotCheckPercentage = tagService.indexSpotCheckPercentageValidationTags(indexName); spotCheckMostRecent = tagService.indexSpotCheckMostRecentValidationTags(indexName); } return new SearchIndexValidation(request.getSearchIndexKey(), getXMLGregorianCalendarValue(new Date()), sizeCheck, spotCheckPercentage, spotCheckMostRecent); }
From source file:org.jahia.services.render.filter.AggregateFilter.java
/** * Utility method to check if the aggregation is skipped. * @param request is the current request * @return//from www.j av a2s. c om */ public static boolean skipAggregation(ServletRequest request) { return BooleanUtils.isTrue((Boolean) request.getAttribute(SKIP_AGGREGATION)); }
From source file:org.jiemamy.eclipse.core.ui.editor.diagram.node.table.TypeParameterManager.java
/** * ????widget??/*from www . j a va 2 s. c o m*/ * * @param dataType * @throws IllegalArgumentException ?{@code null}??? */ public void setParametersToControl(DataType dataType) { Validate.notNull(dataType); if (dataType.getRawTypeDescriptor() instanceof DomainType) { return; } for (Entry<String, String> entry : dataType.getParams()) { if (entry.getKey().equals(TypeParameterKey.SIZE.getKeyString())) { Integer size = dataType.getParam(TypeParameterKey.SIZE); txtSize.setText(StringUtils.defaultString(ObjectUtils.toString(size))); } if (entry.getKey().equals(TypeParameterKey.PRECISION.getKeyString())) { Integer precision = dataType.getParam(TypeParameterKey.PRECISION); txtPrecision.setText(StringUtils.defaultString(ObjectUtils.toString(precision))); } if (entry.getKey().equals(TypeParameterKey.SCALE.getKeyString())) { Integer scale = dataType.getParam(TypeParameterKey.SCALE); txtScale.setText(StringUtils.defaultString(ObjectUtils.toString(scale))); } if (entry.getKey().equals(TypeParameterKey.WITH_TIMEZONE.getKeyString())) { Boolean withTimeZone = dataType.getParam(TypeParameterKey.WITH_TIMEZONE); chkWithTimezone.setSelection(BooleanUtils.isTrue(withTimeZone)); } if (entry.getKey().equals(TypeParameterKey.SERIAL.getKeyString())) { Boolean serial = dataType.getParam(TypeParameterKey.SERIAL); chkSerial.setSelection(BooleanUtils.isTrue(serial)); } if (handler != null) { handler.setParametersToControl(); } } }
From source file:org.jumpmind.symmetric.load.DynamicDatabaseWriterFilter.java
protected void executeScripts(DataContext context, String key) { @SuppressWarnings("unchecked") Set<String> scripts = (Set<String>) context.get(key); executeScripts(context, key, scripts, BooleanUtils.isTrue((Boolean) context.get(FAIL_ON_ERROR_KEY))); }
From source file:org.kuali.rice.kew.xml.RuleTemplateXmlParser.java
/** * //from w w w .j ava2 s . c om * Updates the default/template rule options with those in the defaults element * @param defaultsElement the ruleDefaults element * @param updatedRuleTemplate the Rule Template being updated * @return whether this is a delegation rule template */ protected boolean updateRuleDefaults(Element defaultsElement, RuleTemplateBo updatedRuleTemplate) throws XmlException { // NOTE: implementation detail: in contrast with the other options, the delegate template, and the rule attributes, // we unconditionally blow away the default rule and re-create it (we don't update the existing one, if there is one) if (updatedRuleTemplate.getId() != null) { RuleBaseValues ruleDefaults = KEWServiceLocator.getRuleService() .findDefaultRuleByRuleTemplateId(updatedRuleTemplate.getId()); if (ruleDefaults != null) { List ruleDelegationDefaults = KEWServiceLocator.getRuleDelegationService() .findByDelegateRuleId(ruleDefaults.getId()); // delete the rule KEWServiceLocator.getRuleService().delete(ruleDefaults.getId()); // delete the associated rule delegation defaults for (Iterator iterator = ruleDelegationDefaults.iterator(); iterator.hasNext();) { RuleDelegationBo ruleDelegation = (RuleDelegationBo) iterator.next(); KEWServiceLocator.getRuleDelegationService().delete(ruleDelegation.getRuleDelegationId()); } } } boolean isDelegation = false; if (defaultsElement != null) { String delegationTypeCode = defaultsElement.getChildText(DELEGATION_TYPE, RULE_TEMPLATE_NAMESPACE); DelegationType delegationType = null; isDelegation = !org.apache.commons.lang.StringUtils.isEmpty(delegationTypeCode); String description = defaultsElement.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE); // would normally be validated via schema but might not be present if invoking RuleXmlParser directly if (description == null) { throw new XmlException("Description must be specified in rule defaults"); } String fromDate = defaultsElement.getChildText(FROM_DATE, RULE_TEMPLATE_NAMESPACE); String toDate = defaultsElement.getChildText(TO_DATE, RULE_TEMPLATE_NAMESPACE); // toBooleanObject ensures that if the value is null (not set) that the Boolean object will likewise be null (will not default to a value) Boolean forceAction = BooleanUtils .toBooleanObject(defaultsElement.getChildText(FORCE_ACTION, RULE_TEMPLATE_NAMESPACE)); Boolean active = BooleanUtils .toBooleanObject(defaultsElement.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE)); if (isDelegation) { delegationType = DelegationType.parseCode(delegationTypeCode); if (delegationType == null) { throw new XmlException( "Invalid delegation type '" + delegationType + "'." + " Expected one of: " + DelegationType.PRIMARY.getCode() + "," + DelegationType.SECONDARY.getCode()); } } // create our "default rule" which encapsulates the defaults for the rule RuleBaseValues ruleDefaults = new RuleBaseValues(); // set simple values ruleDefaults.setRuleTemplate(updatedRuleTemplate); ruleDefaults.setRuleTemplateId(updatedRuleTemplate.getId()); ruleDefaults.setDocTypeName(DUMMY_DOCUMENT_TYPE); ruleDefaults.setTemplateRuleInd(Boolean.TRUE); ruleDefaults.setCurrentInd(Boolean.TRUE); ruleDefaults.setVersionNbr(new Integer(0)); ruleDefaults.setDescription(description); // these are non-nullable fields, so default them if they were not set in the defaults section ruleDefaults.setForceAction(Boolean.valueOf(BooleanUtils.isTrue(forceAction))); ruleDefaults.setActive(Boolean.valueOf(BooleanUtils.isTrue(active))); if (ruleDefaults.getActivationDate() == null) { ruleDefaults.setActivationDate(new Timestamp(System.currentTimeMillis())); } ruleDefaults.setFromDateValue(formatDate("fromDate", fromDate)); ruleDefaults.setToDateValue(formatDate("toDate", toDate)); // ok, if this is a "Delegate Template", then we need to set this other RuleDelegation object which contains // some delegation-related info RuleDelegationBo ruleDelegationDefaults = null; if (isDelegation) { ruleDelegationDefaults = new RuleDelegationBo(); ruleDelegationDefaults.setDelegationRule(ruleDefaults); ruleDelegationDefaults.setDelegationType(delegationType); ruleDelegationDefaults.setResponsibilityId(KewApiConstants.ADHOC_REQUEST_RESPONSIBILITY_ID); } // explicitly save the new rule delegation defaults and default rule KEWServiceLocator.getRuleTemplateService().saveRuleDefaults(ruleDelegationDefaults, ruleDefaults); } else { // do nothing, rule defaults will be deleted if ruleDefaults element is omitted } return isDelegation; }