public SonarResource apply(org.sonar.wsclient.services.Resource input) { io.gmind7.devops.ldap.sonar.resource.SonarResource output = new io.gmind7.devops.ldap.sonar.resource.SonarResource(); output.setId(String.valueOf(input.getId())); output.setKey(StringUtils.defaultIfBlank(input.getKey(), "")); output.setName(StringUtils.defaultIfBlank(input.getName(), "")); output.setLongName(StringUtils.defaultIfBlank(input.getLongName(), "")); output.setScope(StringUtils.defaultIfBlank(input.getScope(), "")); output.setQualifier(StringUtils.defaultIfBlank(input.getQualifier(), "")); output.setLanguage(StringUtils.defaultIfBlank(input.getLanguage(), "")); output.setVersion(StringUtils.defaultIfBlank(input.getVersion(), "")); output.setCopy(StringUtils.defaultIfBlank(String.valueOf(input.getCopy()), "")); output.setDescription(StringUtils.defaultIfBlank(input.getDescription(), "")); output.setDate(input.getDate()); List<org.sonar.wsclient.services.Measure> sonarMeasures = input.getMeasures(); if (sonarMeasures != null) { List<io.gmind7.devops.ldap.sonar.measure.SonarMeasure> measures = Lists.newArrayList(); for (org.sonar.wsclient.services.Measure sonarMeasure : sonarMeasures) { measures.add(sonarMeasureMapper.apply(input, sonarMeasure)); } output.setMeasures(measures); } else { output.setMeasures( Lists.newArrayList(new io.gmind7.devops.ldap.sonar.measure.SonarMeasure())); } return output; }
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.key())) { definitions.put(definition.key(), definition); String category = StringUtils.defaultIfBlank(definition.category(), defaultCategory); categories.put(definition.key(), new Category(category)); String subcategory = StringUtils.defaultIfBlank(definition.subCategory(), category); subcategories.put(definition.key(), new SubCategory(subcategory)); if (!Strings.isNullOrEmpty(definition.deprecatedKey()) && !definition.deprecatedKey().equals(definition.key())) { deprecatedKeys.put(definition.deprecatedKey(), definition.key()); } } return this; }
/* (non-Javadoc) * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { StandardFieldColumn column = (StandardFieldColumn) element; IARESProject project = com.hundsun.ares.studio.core.util.ResourcesUtil.getARESProject(bundle); IMetadataService service = DataServiceManager.getInstance().getService(project, IMetadataService.class); if (service != null) { IStandardField filed = service.getStandardField(column.getStandardField()); if (filed != null) { switch (type) { case ChineseName: return StringUtils.defaultString(filed.getChineseName()); case Desciption: StringBuffer text = new StringBuffer(); IDictionaryType dictType = filed.getDictionaryType(); if (dictType instanceof DeDictionaryType) { for (DeDictionaryItem item : ((DeDictionaryType) dictType).getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(value); text.append(":"); text.append(chineseName); text.append(" "); } } return StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), filed.getDescription())); case Type: return StringUtils.defaultString(filed.getDataTypeId()); } } } return StringUtils.EMPTY; }
public static String fullName(String packagePart, String className) { String pck = StringUtils.defaultIfBlank(packagePart, ""); if (StringUtils.isNotEmpty(pck)) { pck += "."; } return pck + className; }
public DefaultModuleCfg(YMP owner) throws Exception { Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ICaches.MODULE_NAME); // String _providerClassStr = StringUtils.defaultIfBlank(_moduleCfgs.get("provider_class"), "default"); __cacheProvider = ClassUtils.impl( StringUtils.defaultIfBlank(Caches.PROVIDERS.get(_providerClassStr), _providerClassStr), ICacheProvider.class, this.getClass()); if (__cacheProvider == null) { __cacheProvider = new DefaultCacheProvider(); } // __cacheEventListener = ClassUtils.impl( _moduleCfgs.get("event_listener_class"), ICacheEventListener.class, this.getClass()); // __cacheScopeProcessor = ClassUtils.impl( _moduleCfgs.get("scope_processor_class"), ICacheScopeProcessor.class, this.getClass()); // __serializer = ClassUtils.impl(_moduleCfgs.get("serializer_class"), ISerializer.class, this.getClass()); if (__serializer == null) { __serializer = new DefaultSerializer(); } // __keyGenerator = ClassUtils.impl( _moduleCfgs.get("key_generator_class"), IKeyGenerator.class, this.getClass()); if (__keyGenerator == null) { __keyGenerator = new DefaultKeyGenerator(); } __keyGenerator.init(__serializer); // __defaultCacheName = StringUtils.defaultIfBlank(_moduleCfgs.get("default_cache_name"), "default"); __defaultCacheTimeout = BlurObject.bind(StringUtils.defaultIfBlank(_moduleCfgs.get("default_cache_timeout"), "0")) .toIntValue(); if (__defaultCacheTimeout <= 0) { __defaultCacheTimeout = 300; } }
@SuppressWarnings("unchecked") @Override public void inform(SolrCore core) { if (initParams != null) { log.info("Initializing Clustering Engines"); // Our target list of engines, split into search-results and document clustering. SolrResourceLoader loader = core.getResourceLoader(); for (Map.Entry<String, Object> entry : initParams) { if ("engine".equals(entry.getKey())) { NamedList<Object> engineInitParams = (NamedList<Object>) entry.getValue(); String engineClassName = StringUtils.defaultIfBlank( (String) engineInitParams.get("classname"), CarrotClusteringEngine.class.getName()); // Instantiate the clustering engine and split to appropriate map. final ClusteringEngine engine = loader.newInstance(engineClassName, ClusteringEngine.class); final String name = StringUtils.defaultIfBlank(engine.init(engineInitParams, core), ""); final ClusteringEngine previousEntry; if (engine instanceof SearchClusteringEngine) { previousEntry = searchClusteringEngines.put(name, (SearchClusteringEngine) engine); } else if (engine instanceof DocumentClusteringEngine) { previousEntry = documentClusteringEngines.put(name, (DocumentClusteringEngine) engine); } else { log.warn("Unknown type of a clustering engine for class: " + engineClassName); continue; } if (previousEntry != null) { log.warn("Duplicate clustering engine component named '" + name + "'."); } } } // Set up the default engine key for both types of engines. setupDefaultEngine("search results clustering", searchClusteringEngines); setupDefaultEngine("document clustering", documentClusteringEngines); log.info("Finished Initializing Clustering Engines"); } }
/** Visibility has been relaxed for tests. */ String getUserFullName(String login) { if (login == null) { return null; } User user = userFinder.findByLogin(login); if (user == null) { // most probably user was deleted return login; } return StringUtils.defaultIfBlank(user.getName(), login); }
public Result<Issue> assign(String issueKey, @Nullable String assignee) { Result<Issue> result = Result.of(); try { result.set( issueService.assign( issueKey, StringUtils.defaultIfBlank(assignee, null), UserSession.get())); } catch (Exception e) { result.addError(e.getMessage()); } return result; }
/** * Constructor called from Jelly with parameters. * * @param name name * @param description description * @param script script * @param choiceType choice type * @param referencedParameters referenced parameters * @param filterable filter flag */ @DataBoundConstructor public CascadeChoiceParameter( String name, String description, Script script, String choiceType, String referencedParameters, Boolean filterable) { super(name, description, script, referencedParameters); this.choiceType = StringUtils.defaultIfBlank(choiceType, PARAMETER_TYPE_SINGLE_SELECT); this.filterable = filterable; }
/** * Constructor called from Jelly with parameters. * * @param name name * @param description description * @param script script * @param choiceType choice type * @param referencedParameters referenced parameters * @param omitValueField used in the UI to decide whether to include a hidden empty <input * name=value>. <code>false</code> by default. */ @DataBoundConstructor public DynamicReferenceParameter( String name, String description, Script script, String choiceType, String referencedParameters, Boolean omitValueField) { super(name, description, script, referencedParameters); this.choiceType = StringUtils.defaultIfBlank(choiceType, PARAMETER_TYPE_SINGLE_SELECT); this.omitValueField = BooleanUtils.toBooleanDefaultIfNull(omitValueField, Boolean.FALSE); }
private String select( boolean distinct, List<String> columns, String from, String where, List<String> groupBy, List<String> orderBy) throws ExcepcionAplicacion { return "SELECT " + (distinct ? "DISTINCT " : "") + StringUtils.join(columns, ", ") + from + StringUtils.defaultIfBlank(where, "") + group(groupBy) + order(orderBy); }
public boolean plan(DefaultIssue issue, @Nullable ActionPlan actionPlan, IssueChangeContext context) { String sanitizedActionPlanKey = null; if (actionPlan != null) { sanitizedActionPlanKey = StringUtils.defaultIfBlank(actionPlan.key(), null); } if (!Objects.equal(sanitizedActionPlanKey, issue.actionPlanKey())) { String newActionPlanName = actionPlan != null ? actionPlan.name() : null; issue.setFieldChange(context, ACTION_PLAN, UNUSED, newActionPlanName); issue.setActionPlanKey(sanitizedActionPlanKey); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean assign(DefaultIssue issue, @Nullable User user, IssueChangeContext context) { String sanitizedAssignee = null; if (user != null) { sanitizedAssignee = StringUtils.defaultIfBlank(user.login(), null); } if (!Objects.equal(sanitizedAssignee, issue.assignee())) { String newAssignee = user != null ? user.name() : null; issue.setFieldChange(context, ASSIGNEE, UNUSED, newAssignee); issue.setAssignee(sanitizedAssignee); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
private void createResourceInterface(final Resource resource) throws Exception { final String resourceInterfaceName = Names.buildResourceInterfaceName(resource); final JDefinedClass resourceInterface = context.createResourceInterface(resourceInterfaceName); context.setCurrentResourceInterface(resourceInterface); final String path = strip(resource.getRelativeUri(), "/"); resourceInterface .annotate(Path.class) .param(DEFAULT_ANNOTATION_PARAMETER, StringUtils.defaultIfBlank(path, "/")); if (isNotBlank(resource.getDescription())) { resourceInterface.javadoc().add(resource.getDescription()); } addResourceMethods(resource, resourceInterface, path); }
@Override public void addBuildTrigger(IBuildTrigger trigger) { ModelNode triggers = get(BUILDCONFIG_TRIGGERS); ModelNode triggerNode = triggers.add(); switch (trigger.getType()) { case BuildTriggerType.generic: case BuildTriggerType.GENERIC: if (!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException( "IBuildTrigger of type generic does not implement IWebhookTrigger"); } IWebhookTrigger generic = (IWebhookTrigger) trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GENERIC_SECRET)).set(generic.getSecret()); break; case BuildTriggerType.github: case BuildTriggerType.GITHUB: if (!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException( "IBuildTrigger of type github does not implement IWebhookTrigger"); } IWebhookTrigger github = (IWebhookTrigger) trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GITHUB_SECRET)).set(github.getSecret()); break; case BuildTriggerType.imageChange: case BuildTriggerType.IMAGE_CHANGE: { if (!(trigger instanceof IImageChangeTrigger)) { throw new IllegalArgumentException( "IBuildTrigger of type imageChange does not implement IImageChangeTrigger"); } IImageChangeTrigger image = (IImageChangeTrigger) trigger; if (image.getImage() != null) triggerNode .get(getPath(BUILD_CONFIG_IMAGECHANGE_IMAGE)) .set(image.getImage().toString()); if (image.getFrom() != null) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_NAME)).set(image.getFrom().toString()); if (StringUtils.isNotEmpty(image.getTag())) triggerNode .get(getPath(BUILD_CONFIG_IMAGECHANGE_TAG)) .set(StringUtils.defaultIfBlank(image.getTag(), "")); break; } } triggerNode.get(TYPE).set(trigger.getType()); }
/** * Appends the getValue() String values of the matching "pieces" to the indicated buffer, * performing truncation, right-padding or separator-character-delimiting as needed. Blank values * will be treated as "" for not-exact-length processing, or " " for exact-length processing. * Values that are too long will be truncated to the piece's length. If doing exact-length * processing, values that are too short will be right-padded to the piece's length. If adding * separator characters and at least one piece is added, then a trailing separator character will * also be appended. * * @param bufferIndex * @throws SQLException */ final void appendPieces(int bufferIndex) throws SQLException { OutputHelper helper = outputHelpers[bufferIndex]; String tempValue; int tempLen; final String defaultStringIfBlank = helper.useExactLengths ? KRADConstants.BLANK_SPACE : KRADConstants.EMPTY_STRING; // Append the String values of the pieces in order, right-padding or truncating as needed. for (RecordPiece piece : helper.outputPieces) { if (piece.alwaysBlank) { // If the value is unconditionally blank, then just fill with spaces as necessary. if (helper.useExactLengths) { Arrays.fill(helper.outputBuffer, helper.position, helper.position + piece.len, ' '); helper.position += piece.len; } } else { // Otherwise, prepare to append the value. tempValue = StringUtils.defaultIfBlank(piece.getValue(), defaultStringIfBlank); tempLen = tempValue.length(); if (tempLen <= piece.len) { // If not too long, use the whole value and right-pad with spaces as needed. tempValue.getChars(0, tempLen, helper.outputBuffer, helper.position); if (helper.useExactLengths && tempLen < piece.len) { Arrays.fill( helper.outputBuffer, helper.position + tempLen, helper.position + piece.len, ' '); helper.position += piece.len; } else { helper.position += tempLen; } } else { // If the value is too long, then truncate it and notify the piece. tempValue.getChars(0, piece.len, helper.outputBuffer, helper.position); piece.notifyOfTruncatedValue(); helper.position += piece.len; } } // If necessary, add a separator character. if (helper.addSeparatorChar) { helper.outputBuffer[helper.position] = helper.separator; helper.position++; } } }
private String getDescription(MetadataItem mdItem) { // 标准字段提示具体的说明信息 TASK #8602 输入输出中标准字段参数,能显示具体的说明信息 if (mdItem instanceof StandardField) { StandardField field = (StandardField) mdItem; StringBuffer text = new StringBuffer(); String dictTypeStr = field.getDictionaryType(); if (StringUtils.isNotBlank(dictTypeStr)) { ReferenceInfo dictReferenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true); if (dictReferenceInfo != null) { DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject(); if (objDictionaryType != null) { for (DictionaryItem item : objDictionaryType.getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(objDictionaryType.getName()); text.append(":"); text.append(objDictionaryType.getChineseName()); text.append("-"); text.append(value); text.append(":"); text.append(chineseName); text.append("\r\n"); } } } } if (StringUtils.isNotBlank(text.toString()) && StringUtils.isNotBlank(field.getDescription())) { text.append("\r\n"); text.append(field.getDescription()); } String desc = StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), field.getDescription())); if (StringUtils.isNotBlank(desc)) { return desc; } } return null; }
protected void loadPatternsFromNewProperties() { // Patterns Multicriteria multicriteriaPatterns = Lists.newArrayList(); String patternConf = StringUtils.defaultIfBlank(settings.getString(getMulticriteriaConfigurationKey()), ""); for (String id : StringUtils.split(patternConf, ',')) { String propPrefix = getMulticriteriaConfigurationKey() + "." + id + "."; String resourceKeyPattern = settings.getString(propPrefix + IgnoreIssuesConfiguration.RESOURCE_KEY); String ruleKeyPattern = settings.getString(propPrefix + IgnoreIssuesConfiguration.RULE_KEY); String lineRange = settings.getString(propPrefix + IgnoreIssuesConfiguration.LINE_RANGE_KEY); String[] fields = new String[] {resourceKeyPattern, ruleKeyPattern, lineRange}; PatternDecoder.checkRegularLineConstraints(StringUtils.join(fields, ","), fields); IssuePattern pattern = new IssuePattern( firstNonNull(resourceKeyPattern, "*"), firstNonNull(ruleKeyPattern, "*")); PatternDecoder.decodeRangeOfLines(pattern, firstNonNull(lineRange, "*")); multicriteriaPatterns.add(pattern); } }
@VisibleForTesting protected static void checkMandatoryProperties( Map<String, String> props, String[] mandatoryProps) { StringBuilder missing = new StringBuilder(); for (String mandatoryProperty : mandatoryProps) { if (!props.containsKey(mandatoryProperty)) { if (missing.length() > 0) { missing.append(", "); } missing.append(mandatoryProperty); } } String moduleKey = StringUtils.defaultIfBlank( props.get(MODULE_KEY_PROPERTY), props.get(CoreProperties.PROJECT_KEY_PROPERTY)); if (missing.length() != 0) { throw new IllegalStateException( "You must define the following mandatory properties for '" + (moduleKey == null ? "Unknown" : moduleKey) + "': " + missing); } }
public NewRule setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, DEFAULT_SEVERITY); return this; }
protected void doLoad(BlockVirtualPoolRestRep virtualPool) { loadCommon(virtualPool); minPaths = virtualPool.getMinPaths(); maxPaths = virtualPool.getMaxPaths(); initiatorPaths = virtualPool.getPathsPerInitiator(); driveType = virtualPool.getDriveType(); autoTierPolicy = virtualPool.getAutoTieringPolicyName(); expandable = virtualPool.getExpandable(); fastExpansion = virtualPool.getFastExpansion(); multiVolumeConsistency = virtualPool.getMultiVolumeConsistent(); thinPreAllocationPercent = virtualPool.getThinVolumePreAllocationPercentage(); uniqueAutoTierPolicyNames = virtualPool.getUniquePolicyNames(); raidLevels = defaultSet(virtualPool.getRaidLevels()); hostIOLimitBandwidth = virtualPool.getHostIOLimitBandwidth(); hostIOLimitIOPs = virtualPool.getHostIOLimitIOPs(); VirtualPoolHighAvailabilityParam highAvailabilityType = virtualPool.getHighAvailability(); if (highAvailabilityType != null && HighAvailability.isHighAvailability(highAvailabilityType.getType())) { highAvailability = highAvailabilityType.getType(); if (highAvailability.equals(HighAvailability.VPLEX_LOCAL)) { protectSourceSite = true; } enableAutoCrossConnExport = highAvailabilityType.getAutoCrossConnectExport(); if (highAvailabilityType.getHaVirtualArrayVirtualPool() != null) { haVirtualArray = asString(highAvailabilityType.getHaVirtualArrayVirtualPool().getVirtualArray()); haVirtualPool = asString(highAvailabilityType.getHaVirtualArrayVirtualPool().getVirtualPool()); Boolean activeProtectionAtHASite = Boolean.TRUE.equals( highAvailabilityType.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()); Boolean metroPoint = Boolean.TRUE.equals(highAvailabilityType.getMetroPoint()); if (metroPoint) { protectSourceSite = true; protectHASite = true; if (activeProtectionAtHASite) { activeSite = HighAvailability.VPLEX_HA.toString(); } else { activeSite = HighAvailability.VPLEX_SOURCE.toString(); protectSourceSite = true; } } else { protectHASite = activeProtectionAtHASite; protectSourceSite = !protectHASite; } } else { protectSourceSite = true; } } else { protectSourceSite = true; } BlockVirtualPoolProtectionParam protection = virtualPool.getProtection(); if (protection != null) { if (protection.getSnapshots() != null) { maxSnapshots = protection.getSnapshots().getMaxSnapshots(); } if (protection.getContinuousCopies() != null) { maxContinuousCopies = protection.getContinuousCopies().getMaxMirrors(); continuousCopyVirtualPool = asString(protection.getContinuousCopies().getVpool()); } VirtualPoolProtectionRPParam recoverPoint = protection.getRecoverPoint(); if (recoverPoint != null) { remoteProtection = ProtectionSystemTypes.RECOVERPOINT; ProtectionSourcePolicy sourcePolicy = recoverPoint.getSourcePolicy(); if (sourcePolicy != null) { String journalSize = sourcePolicy.getJournalSize(); rpJournalSizeUnit = RPCopyForm.parseJournalSizeUnit(journalSize); rpJournalSize = StringUtils.defaultIfBlank( RPCopyForm.parseJournalSize(journalSize, rpJournalSizeUnit), RPCopyForm.JOURNAL_SIZE_MIN); rpRemoteCopyMode = sourcePolicy.getRemoteCopyMode(); rpRpoValue = sourcePolicy.getRpoValue(); rpRpoType = sourcePolicy.getRpoType(); if (protectHASite != null && protectSourceSite != null && protectHASite && protectSourceSite) { // Backend will take care of swapping // if(activeSite.equalsIgnoreCase(HighAvailability.VPLEX_SOURCE)){ sourceJournalVArray = asString(sourcePolicy.getJournalVarray()); sourceJournalVPool = asString(sourcePolicy.getJournalVpool()); haJournalVArray = asString(sourcePolicy.getStandbyJournalVarray()); haJournalVPool = asString(sourcePolicy.getStandbyJournalVpool()); } else { if (protectHASite != null && protectHASite) { haJournalVArray = asString(sourcePolicy.getJournalVarray()); haJournalVPool = asString(sourcePolicy.getJournalVpool()); } else if (protectSourceSite != null && protectSourceSite) { sourceJournalVArray = asString(sourcePolicy.getJournalVarray()); sourceJournalVPool = asString(sourcePolicy.getJournalVpool()); } } } List<RPCopyForm> rpCopyForms = Lists.newArrayList(); for (VirtualPoolProtectionVirtualArraySettingsParam copy : recoverPoint.getCopies()) { RPCopyForm rpCopy = new RPCopyForm(); rpCopy.load(copy); rpCopyForms.add(rpCopy); } rpCopies = rpCopyForms.toArray(new RPCopyForm[0]); rpCopiesJson = new Gson().toJson(rpCopies); } VirtualPoolRemoteMirrorProtectionParam srdf = protection.getRemoteCopies(); if (srdf != null) { remoteProtection = ProtectionSystemTypes.SRDF; List<SrdfCopyForm> copyForms = Lists.newArrayList(); for (VirtualPoolRemoteProtectionVirtualArraySettingsParam copy : srdf.getRemoteCopySettings()) { srdfCopyMode = copy.getRemoteCopyMode(); SrdfCopyForm srdfCopyForm = new SrdfCopyForm(); srdfCopyForm.load(copy); copyForms.add(srdfCopyForm); } srdfCopies = copyForms.toArray(new SrdfCopyForm[0]); Gson gson = new Gson(); srdfCopiesJson = gson.toJson(srdfCopies); } else { srdfCopiesJson = "[]"; } } }
public LoggingConfiguration setFormat(String format) { return addSubstitutionVariable( PROPERTY_FORMAT, StringUtils.defaultIfBlank(format, FORMAT_DEFAULT)); }
public Builder memberSearch(@Nullable String s) { this.memberSearch = StringUtils.defaultIfBlank(s, null); return this; }
/* * (non-Javadoc) * * @see * org.ngrinder.script.service.IScriptValidationService#validateScript(org * .ngrinder.model.User, org.ngrinder.model.IFileEntry, boolean, * java.lang.String) */ @Override public String validateScript( User user, IFileEntry scriptIEntry, boolean useScriptInSVN, String hostString) { FileEntry scriptEntry = cast(scriptIEntry); try { checkNotNull(scriptEntry, "scriptEntity should be not null"); checkNotEmpty(scriptEntry.getPath(), "scriptEntity path should be provided"); if (!useScriptInSVN) { checkNotEmpty(scriptEntry.getContent(), "scriptEntity content should be provided"); } checkNotNull(user, "user should be provided"); // String result = checkSyntaxErrors(scriptEntry.getContent()); ScriptHandler handler = scriptHandlerFactory.getHandler(scriptEntry); String result = handler.checkSyntaxErrors(scriptEntry.getPath(), scriptEntry.getContent()); if (result != null) { return result; } File scriptDirectory = config.getHome().getScriptDirectory(user); FileUtils.deleteDirectory(scriptDirectory); scriptDirectory.mkdirs(); ProcessingResultPrintStream processingResult = new ProcessingResultPrintStream(new ByteArrayOutputStream()); handler.prepareDist( 0L, user, scriptEntry, scriptDirectory, config.getSystemProperties(), processingResult); if (!processingResult.isSuccess()) { return new String(processingResult.getLogByteArray()); } File scriptFile = new File(scriptDirectory, FilenameUtils.getName(scriptEntry.getPath())); if (useScriptInSVN) { fileEntryService.writeContentTo(user, scriptEntry.getPath(), scriptDirectory); } else { FileUtils.writeStringToFile( scriptFile, scriptEntry.getContent(), StringUtils.defaultIfBlank(scriptEntry.getEncoding(), "UTF-8")); } int timeout = Math.max( config .getSystemProperties() .getPropertyInt( NGrinderConstants.NGRINDER_VALIDATION_TIMEOUT, LocalScriptTestDriveService.DEFAULT_TIMEOUT), 10); File doValidate = localScriptTestDriveService.doValidate( scriptDirectory, scriptFile, new Condition(), config.isSecurityEnabled(), hostString, timeout); List<String> readLines = FileUtils.readLines(doValidate); StringBuffer output = new StringBuffer(); String path = config.getHome().getDirectory().getAbsolutePath(); for (String each : readLines) { if (!each.startsWith("*sys-package-mgr")) { each = each.replace(path, "${NGRINDER_HOME}"); output.append(each).append("\n"); } } return output.toString(); } catch (IOException e) { LOG.error("Error while distributing files on {} for {}", user, scriptEntry.getPath()); LOG.error("Error details ", e); } return StringUtils.EMPTY; }
public NewActiveRule setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, Severity.defaultSeverity()); return this; }
@Override public boolean handle(Row row, SqlStatement update) throws SQLException { String projectUuid = row.getNullableString(1); String fileUuid = row.getNullableString(2); String source = StringUtils.defaultIfBlank(row.getNullableString(3), ""); Date updatedAt = row.getNullableDate(4); byte[] shortRevisions = row.getNullableBytes(5); byte[] longRevisions = row.getNullableBytes(6); byte[] shortAuthors = row.getNullableBytes(7); byte[] longAuthors = row.getNullableBytes(8); byte[] shortDates = row.getNullableBytes(9); byte[] longDates = row.getNullableBytes(10); byte[] shortUtHits = row.getNullableBytes(11); byte[] longUtHits = row.getNullableBytes(12); byte[] shortUtCond = row.getNullableBytes(13); byte[] longUtCond = row.getNullableBytes(14); byte[] shortUtCovCond = row.getNullableBytes(15); byte[] longUtCovCond = row.getNullableBytes(16); byte[] shortItHits = row.getNullableBytes(17); byte[] longItHits = row.getNullableBytes(18); byte[] shortItCond = row.getNullableBytes(19); byte[] longItCond = row.getNullableBytes(20); byte[] shortItCovCond = row.getNullableBytes(21); byte[] longItCovCond = row.getNullableBytes(22); byte[] shortOverallHits = row.getNullableBytes(23); byte[] longOverallHits = row.getNullableBytes(24); byte[] shortOverallCond = row.getNullableBytes(25); byte[] longOverallCond = row.getNullableBytes(26); byte[] shortOverallCovCond = row.getNullableBytes(27); byte[] longOverallCovCond = row.getNullableBytes(28); byte[] shortDuplicationData = row.getNullableBytes(29); byte[] longDuplicationData = row.getNullableBytes(30); long snapshotId = row.getLong(31); if (snapshotId == previousSnapshotId) { return false; } this.previousSnapshotId = snapshotId; String[] sourceData = new FileSourceDto( source, ofNullableBytes(shortRevisions, longRevisions), ofNullableBytes(shortAuthors, longAuthors), ofNullableBytes(shortDates, longDates), ofNullableBytes(shortUtHits, longUtHits), ofNullableBytes(shortUtCond, longUtCond), ofNullableBytes(shortUtCovCond, longUtCovCond), ofNullableBytes(shortItHits, longItHits), ofNullableBytes(shortItCond, longItCond), ofNullableBytes(shortItCovCond, longItCovCond), ofNullableBytes(shortOverallHits, longOverallHits), ofNullableBytes(shortOverallCond, longOverallCond), ofNullableBytes(shortOverallCovCond, longOverallCovCond), ofNullableBytes(shortDuplicationData, longDuplicationData)) .getSourceData(); update .setString(1, projectUuid) .setString(2, fileUuid) .setLong(3, now) .setLong(4, updatedAt == null ? now : updatedAt.getTime()) .setString(5, sourceData[0]) .setString(6, sourceData[1]) .setString(7, ""); return true; }
/** * 标准字段列表读取 * * @param is 需要读取的文件流 */ public List<PDMStandardField> standardFieldReader(HSSFWorkbook wb) { List<PDMStandardField> stdList = new ArrayList<PDMStandardField>(); HSSFSheet sheet = wb.getSheet(STD_SHEET); if (sheet == null) { return stdList; } HSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); for (int i = 2; i <= sheet.getLastRowNum(); i++) { HSSFRow row = sheet.getRow(i); PDMStandardField std = new PDMStandardField(); stdList.add(std); // 1 HSSFCell cell = row.getCell(1); std.setOldName(POIUtils.getCellStringValue(cell, evaluator)); // 2 cell = row.getCell(2); std.setOldChineseName(POIUtils.getCellStringValue(cell, evaluator)); // 3 cell = row.getCell(3); std.setOldBusType(POIUtils.getCellStringValue(cell, evaluator)); // 4 cell = row.getCell(4); String[] tableNameArray = StringUtils.split( StringUtils.defaultIfBlank(POIUtils.getCellStringValue(cell, evaluator), ""), ",,"); for (String tableName : tableNameArray) { std.getBelongTableList().add(tableName); } // 5 cell = row.getCell(5); std.getBolongSubSystemList().add((POIUtils.getCellStringValue(cell, evaluator))); // 6 cell = row.getCell(6); std.setGenName(POIUtils.getCellStringValue(cell, evaluator)); // 7 cell = row.getCell(7); std.setNewName(POIUtils.getCellStringValue(cell, evaluator)); // 8 cell = row.getCell(8); std.setNewChineseName(POIUtils.getCellStringValue(cell, evaluator)); // 9 cell = row.getCell(9); std.setGenBusType(POIUtils.getCellStringValue(cell, evaluator)); // 10 cell = row.getCell(10); std.setNewBusType(POIUtils.getCellStringValue(cell, evaluator)); // 11 cell = row.getCell(11); std.setOldComment(POIUtils.getCellStringValue(cell, evaluator)); // 12 cell = row.getCell(12); std.setNewComment(POIUtils.getCellStringValue(cell, evaluator)); // 13 cell = row.getCell(13); std.setDictId(POIUtils.getCellStringValue(cell, evaluator)); // 14 cell = row.getCell(14); std.setModefyDesc(POIUtils.getCellStringValue(cell, evaluator)); // 15 cell = row.getCell(15); std.setImportPath(POIUtils.getCellStringValue(cell, evaluator)); } return stdList; }
@Override public String getText(Object element) { Parameter p = (Parameter) getOwner(element); EStructuralFeature feature = getEStructuralFeature(element); if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN) || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT)) { return StringUtils.EMPTY; } // 不同参数类型分开处理 switch (p.getParamType()) { case NON_STD_FIELD: // 非标准字段参数的真实类型也不可编辑,显示对应的业务数据类型的设置的语言的值(在项目属性中设置) if (feature.equals(BizPackage.Literals.PARAMETER__REAL_TYPE)) { String bizType = p.getType(); if (StringUtils.isEmpty(bizType)) break; ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.BizType, bizType, true); if (ref != null) { BusinessDataType bizDataType = (BusinessDataType) ref.getObject(); if (bizDataType == null) break; String stdType = bizDataType.getStdType(); if (StringUtils.isEmpty(stdType)) break; ReferenceInfo stdTypeRef = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdType, stdType, true); if (stdTypeRef == null) break; StandardDataType stdDataType = (StandardDataType) stdTypeRef.getObject(); return stdDataType.getData().get(dataType); } } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getNonStdParameterDefaultValue(p.getDefaultValue(), p); } break; case STD_FIELD: if (BizPackage.Literals.PARAMETER__NAME.equals(feature) || BizPackage.Literals.PARAMETER__REAL_TYPE.equals(feature) || BizPackage.Literals.PARAMETER__TYPE.equals(feature) || BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature) || BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { ReferenceInfo referenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.StdField, p.getId(), true); if (referenceInfo != null) { StandardField field = (StandardField) referenceInfo.getObject(); if (field == null) { return StringUtils.EMPTY; } if (BizPackage.Literals.PARAMETER__NAME.equals(feature)) { return field.getChineseName(); } else if (BizPackage.Literals.PARAMETER__REAL_TYPE.equals( feature)) { // 一般不存在此情况,如果要取真实类型可以继承此类重新实现 try { StandardDataType sdt = MetadataServiceProvider.getStandardDataTypeOfStdFieldByName( project, field.getName()); if (sdt != null) { return sdt.getData().get(dataType); } } catch (Exception e) { // e.printStackTrace(); } } else if (BizPackage.Literals.PARAMETER__TYPE.equals(feature)) { return field.getDataType(); } else if (BizPackage.Literals.PARAMETER__DESCRIPTION.equals(feature)) { StringBuffer text = new StringBuffer(); String dictTypeStr = field.getDictionaryType(); if (StringUtils.isNotBlank(dictTypeStr)) { ReferenceInfo dictReferenceInfo = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true); if (dictReferenceInfo != null) { DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject(); if (objDictionaryType != null) { for (DictionaryItem item : objDictionaryType.getItems()) { String value = StringUtils.defaultString(item.getValue()); String chineseName = StringUtils.defaultString(item.getChineseName()); text.append(value); text.append(":"); text.append(chineseName); text.append(" "); } } } } if (StringUtils.isNotBlank(text.toString()) && StringUtils.isNotBlank(field.getDescription())) { text.append("\r\n"); text.append(field.getDescription()); } return StringUtils.defaultString( StringUtils.defaultIfBlank(text.toString(), field.getDescription())); } else if (BizPackage.Literals.PARAMETER__DEFAULT_VALUE.equals(feature)) { return getParameterDefaultValue(p.getDefaultValue(), field); } } } break; case OBJECT: // 如果有对象标准字段列表资源 if (BizUtil.hasStdObjList(project)) { String refId = p.getId(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Std_Obj, refId, true); if (ref == null) break; StandardObjField field = (StandardObjField) ref.getObject(); String objId = field.getType(); ARESObject obj = BizUtil.getObject(objId, project); if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { if (StringUtils.contains(objId, '.')) return StringUtils.substringAfterLast(objId, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { return obj == null ? StringUtils.EMPTY : obj.getChineseName(); } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { return obj == null ? StringUtils.EMPTY : obj.getDescription(); } } else { String objId = p.getType(); ReferenceInfo ref = null; // ReferenceManager.getInstance().getFirstReferenceInfo(project, // IBizRefType.Object, objId, true); List<String> refTypes = ObjectRefTypes.getRefTypes(); for (String refType : refTypes) { ref = ReferenceManager.getInstance().getFirstReferenceInfo(project, refType, objId, true); if (ref != null) { break; } } // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } } break; case PARAM_GROUP: String objId = p.getType(); ReferenceInfo ref = ReferenceManager.getInstance() .getFirstReferenceInfo(project, IBizRefType.Object, objId, true); // 2012-10-18 sundl 对象类型参数显示的时候,只显示最后一个点后面的部分 if (feature.equals(BizPackage.Literals.PARAMETER__TYPE)) { String type = super.getText(element); if (StringUtils.indexOf(type, '.') != -1) return StringUtils.substringAfterLast(type, "."); } else if (feature.equals(BizPackage.Literals.PARAMETER__NAME)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getChineseName(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__DESCRIPTION)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getDescription(); } } else if (feature.equals(BizPackage.Literals.PARAMETER__ID)) { if (ref != null) { ARESObject obj = (ARESObject) ref.getObject(); return obj.getName(); } } default: break; } return super.getText(element); }