List of usage examples for org.apache.commons.lang BooleanUtils toBoolean
public static boolean toBoolean(String str)
Converts a String to a boolean (optimised for performance).
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:org.pentaho.di.job.entries.build.JobEntryBuildModel.java
public void loadXML(Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep, IMetaStore metaStore) throws KettleXMLException { super.loadXML(entrynode, databases, slaveServers); setOutputStep(XMLHandler.getTagValue(entrynode, Fields.OUTPUT_STEP)); setModelName(XMLHandler.getTagValue(entrynode, Fields.MODEL_NAME)); setUseExistingModel("Y".equals(XMLHandler.getTagValue(entrynode, Fields.USE_EXISTING_MODEL))); setExistingModel(XMLHandler.getTagValue(entrynode, Fields.EXISTING_MODEL)); BiServerConnection biServer = new BiServerConnection(); biServer.setUrl(nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_URL))); biServer.setUserId(nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_USERID))); // Decrypt/*w w w . j a va 2 s. c o m*/ String password = Encr .decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(entrynode, Fields.BASERVER_PASSWORD)); biServer.setPassword(nullToEmpty(password)); setBiServerConnection(biServer); setSelectedModel(XMLHandler.getTagValue(entrynode, Fields.SELECTED_MODEL)); setCreateOnPublish(BooleanUtils.toBoolean(XMLHandler.getTagValue(entrynode, Fields.CREATE_ON_PUBLISH))); }
From source file:org.pentaho.di.job.entries.build.JobEntryBuildModel.java
@Override public void loadRep(Repository rep, IMetaStore metaStore, ObjectId id_jobentry, List<DatabaseMeta> databases, List<SlaveServer> slaveServers) throws KettleException { super.loadRep(rep, metaStore, id_jobentry, databases, slaveServers); setOutputStep(rep.getJobEntryAttributeString(id_jobentry, Fields.OUTPUT_STEP)); setModelName(rep.getJobEntryAttributeString(id_jobentry, Fields.MODEL_NAME)); setUseExistingModel(rep.getJobEntryAttributeBoolean(id_jobentry, Fields.USE_EXISTING_MODEL)); setExistingModel(rep.getJobEntryAttributeString(id_jobentry, Fields.EXISTING_MODEL)); BiServerConnection biServerModel = new BiServerConnection(); // Decrypt/*from www . j a v a2s .c o m*/ String password = Encr.decryptPasswordOptionallyEncrypted( rep.getJobEntryAttributeString(id_jobentry, Fields.BASERVER_PASSWORD)); biServerModel.setPassword(nullToEmpty(password)); biServerModel.setUrl(nullToEmpty(rep.getJobEntryAttributeString(id_jobentry, Fields.BASERVER_URL))); biServerModel.setUserId(nullToEmpty(rep.getJobEntryAttributeString(id_jobentry, Fields.BASERVER_USERID))); setBiServerConnection(biServerModel); setSelectedModel(rep.getJobEntryAttributeString(id_jobentry, Fields.SELECTED_MODEL)); setCreateOnPublish( BooleanUtils.toBoolean(rep.getJobEntryAttributeString(id_jobentry, Fields.CREATE_ON_PUBLISH))); }
From source file:org.pentaho.di.job.entries.publish.JobEntryDatasourcePublish.java
@Override public void loadXML(Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep, IMetaStore metaStore) throws KettleXMLException { super.loadXML(entrynode, databases, slaveServers); DataSourcePublishModel model = new DataSourcePublishModel(); BiServerConnection biServerModel = new BiServerConnection(); biServerModel.setName(nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_NAME))); biServerModel.setUrl(nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_URL))); biServerModel.setUserId(nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_USERID))); // Decrypt/*from w ww .j a v a 2s. c om*/ String password = Encr.decryptPasswordOptionallyEncrypted( nullToEmpty(XMLHandler.getTagValue(entrynode, Fields.BASERVER_PASSWORD))); biServerModel.setPassword(password); model.setBiServerConnection(biServerModel); model.setOverride(BooleanUtils.toBoolean(XMLHandler.getTagValue(entrynode, Fields.OVERRIDE))); model.setAccessType(XMLHandler.getTagValue(entrynode, Fields.ACL_ACCESS_TYPE)); model.setUserOrRole(XMLHandler.getTagValue(entrynode, Fields.ACL_USER_OR_ROLE)); model.setModelName(XMLHandler.getTagValue(entrynode, Fields.LOGICAL_MODEL)); setDataSourcePublishModel(model); }
From source file:org.pentaho.di.repository.pur.PurRepositoryConnector.java
public static boolean inProcess() { boolean inProcess = false; boolean remoteDiServer = BooleanUtils .toBoolean(PentahoSystem.getSystemSetting(REMOTE_DI_SERVER_INSTANCE, "false")); //$NON-NLS-1$ if ("true".equals(PentahoSystem.getSystemSetting(SINGLE_DI_SERVER_INSTANCE, "true"))) { //$NON-NLS-1$ //$NON-NLS-2$ inProcess = true;/* www . j a v a 2 s .c o m*/ } else if (!remoteDiServer && PentahoSystem.getApplicationContext().getFullyQualifiedServerURL() != null) { inProcess = true; } return inProcess; }
From source file:org.pentaho.di.trans.step.jms.JmsProducer.java
private void setOptions(JMSProducer producer) { String optionValue = meta.getDisableMessageId(); getLogChannel().logDebug("Disable Message ID is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setDisableMessageID(BooleanUtils.toBoolean(optionValue)); }/*from www . ja va2 s . com*/ optionValue = meta.getDisableMessageTimestamp(); getLogChannel().logDebug("Disable Message Timestamp is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setDisableMessageTimestamp(BooleanUtils.toBoolean(optionValue)); } optionValue = meta.getDeliveryMode(); getLogChannel().logDebug("Delivery Mode is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setDeliveryMode(Integer.parseInt(optionValue)); } optionValue = meta.getPriority(); getLogChannel().logDebug("Priority is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setPriority(Integer.parseInt(optionValue)); } optionValue = meta.getTimeToLive(); getLogChannel().logDebug("Time to Live is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setTimeToLive(Long.parseLong(optionValue)); } optionValue = meta.getDeliveryDelay(); getLogChannel().logDebug("Delivery Delay is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setDeliveryDelay(Long.parseLong(optionValue)); } optionValue = meta.getJmsCorrelationId(); getLogChannel().logDebug("JMS Correlation ID is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setJMSCorrelationID(optionValue); } optionValue = meta.getJmsType(); getLogChannel().logDebug("JMS Type is set to " + optionValue); if (!StringUtil.isEmpty(optionValue)) { producer.setJMSType(optionValue); } }
From source file:org.pentaho.di.trans.step.mqtt.MQTTClientBuilder.java
private MqttConnectOptions getOptions() { MqttConnectOptions options = new MqttConnectOptions(); if (isSecure) { setSSLProps(options);/*from w w w . j ava 2s . c om*/ } if (!StringUtil.isEmpty(username)) { options.setUserName(username); } if (!StringUtil.isEmpty(password)) { options.setPassword(password.toCharArray()); } if (!StringUtil.isEmpty(keepAliveInterval)) { options.setKeepAliveInterval(Integer.parseInt(keepAliveInterval)); } if (!StringUtil.isEmpty(maxInflight)) { options.setMaxInflight(Integer.parseInt(maxInflight)); } if (!StringUtil.isEmpty(connectionTimeout)) { options.setConnectionTimeout(Integer.parseInt(connectionTimeout)); } if (!StringUtil.isEmpty(cleanSession)) { options.setCleanSession(BooleanUtils.toBoolean(cleanSession)); } if (!StringUtil.isEmpty(serverUris)) { options.setServerURIs( Arrays.stream(serverUris.split(";")).map(uri -> getProtocol() + uri).toArray(String[]::new)); } if (!StringUtil.isEmpty(mqttVersion)) { options.setMqttVersion(Integer.parseInt(mqttVersion)); } if (!StringUtil.isEmpty(automaticReconnect)) { options.setAutomaticReconnect(BooleanUtils.toBoolean(automaticReconnect)); } return options; }
From source file:org.pentaho.di.trans.steps.annotation.BaseAnnotationMeta.java
@Override public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException { ModelAnnotationGroup modelAnnotationGroup = new ModelAnnotationGroup(); try {//from w ww . ja va2 s .c o m setModelAnnotationCategory(rep.getStepAttributeString(id_step, "CATEGORY_NAME")); setTargetOutputStep(rep.getStepAttributeString(id_step, "TARGET_OUTPUT_STEP")); int nrAnnotations = rep.countNrStepAttributes(id_step, "ANNOTATION_NAME"); // Read annotations for (int i = 0; i < nrAnnotations; i++) { String annotationName = rep.getStepAttributeString(id_step, i, "ANNOTATION_NAME"); String annotationFieldName = rep.getStepAttributeString(id_step, i, "ANNOTATION_FIELD_NAME"); String annotationType = rep.getStepAttributeString(id_step, i, "ANNOTATION_TYPE"); // Create model annotation ModelAnnotation<?> modelAnnotation = ModelAnnotationGroupXmlReader.create(annotationType, annotationFieldName); if (StringUtils.isNotBlank(annotationName)) { modelAnnotation.setName(annotationName); } if (StringUtils.isNotBlank(annotationType)) { // Populate annotation properties Map<String, Serializable> map = new HashMap<String, Serializable>(); for (String key : modelAnnotation.getAnnotation().getModelPropertyIds()) { try { String value = rep.getStepAttributeString(id_step, i, "PROPERTY_VALUE_" + key); if (StringUtils.isNotBlank(value)) { map.put(key, value); } } catch (KettleException ke) { // Ignore - not found } } modelAnnotation.populateAnnotation(map); } // Add to group modelAnnotationGroup.add(modelAnnotation); } modelAnnotationGroup.setSharedDimension( BooleanUtils.toBoolean(rep.getStepAttributeString(id_step, "SHARED_DIMENSION"))); sharedDimension = modelAnnotationGroup.isSharedDimension(); modelAnnotationGroup.setDescription(rep.getStepAttributeString(id_step, "DESCRIPTION")); List<DataProvider> dataProviders = new ArrayList<DataProvider>(); int nrDataProviders = rep.countNrStepAttributes(id_step, "DP_NAME"); for (int i = 0; i < nrDataProviders; i++) { DataProvider dataProvider = new DataProvider(); dataProvider.setName(rep.getStepAttributeString(id_step, i, "DP_NAME")); dataProvider.setSchemaName(rep.getStepAttributeString(id_step, i, "DP_SCHEMA_NAME")); dataProvider.setTableName(rep.getStepAttributeString(id_step, i, "DP_TABLE_NAME")); dataProvider.setDatabaseMetaNameRef( rep.getStepAttributeString(id_step, i, "DP_DATABASE_META_NAME_REF")); List<ColumnMapping> columnMappings = new ArrayList<ColumnMapping>(); long nrColumnMappings = rep.getStepAttributeString(id_step, "CM_COUNT_" + i) != null ? Long.valueOf(rep.getStepAttributeString(id_step, "CM_COUNT_" + i)) : 0; for (int j = 0; j < nrColumnMappings; j++) { ColumnMapping columnMapping = new ColumnMapping(); columnMapping.setName(rep.getStepAttributeString(id_step, i, "CM_NAME_" + j)); columnMapping.setColumnName(rep.getStepAttributeString(id_step, i, "CM_COLUMN_NAME_" + j)); String dataType = rep.getStepAttributeString(id_step, i, "CM_DATA_TYPE_" + j); if (StringUtils.isNotBlank(dataType)) { columnMapping.setColumnDataType(DataType.valueOf(dataType)); } columnMappings.add(columnMapping); } dataProvider.setColumnMappings(columnMappings); dataProviders.add(dataProvider); } modelAnnotationGroup.setDataProviders(dataProviders); } catch (Exception e) { throw new KettleException(BaseMessages.getString(PKG, "ModelAnnotationMeta.Exception.UnexpectedErrorReadingStepInfoFromRepository"), e); } setModelAnnotations(modelAnnotationGroup); // This may override the loaded model annotation group if (StringUtils.isNotBlank(getModelAnnotationCategory())) { readDataFromMetaStore(metaStore); } }
From source file:org.pentaho.di.trans.steps.annotation.ModelAnnotationMeta.java
@Override public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException { ModelAnnotationGroup modelAnnotationGroup = new ModelAnnotationGroup(); try {/*from w w w . j a va 2 s .c om*/ setModelAnnotationCategory(rep.getStepAttributeString(id_step, "CATEGORY_NAME")); setTargetOutputStep(rep.getStepAttributeString(id_step, "TARGET_OUTPUT_STEP")); int nrAnnotations = rep.countNrStepAttributes(id_step, "ANNOTATION_FIELD_NAME"); // Read annotations for (int i = 0; i < nrAnnotations; i++) { String annotationName = rep.getStepAttributeString(id_step, i, "ANNOTATION_NAME"); String annotationFieldName = rep.getStepAttributeString(id_step, i, "ANNOTATION_FIELD_NAME"); String annotationType = rep.getStepAttributeString(id_step, i, "ANNOTATION_TYPE"); // Create model annotation ModelAnnotation<?> modelAnnotation = ModelAnnotationGroupXmlReader.create(annotationType, annotationFieldName); if (StringUtils.isNotBlank(annotationName)) { modelAnnotation.setName(annotationName); } if (StringUtils.isNotBlank(annotationType)) { // Populate annotation properties Map<String, Serializable> map = new HashMap<String, Serializable>(); for (String key : modelAnnotation.getAnnotation().getModelPropertyIds()) { try { String value = rep.getStepAttributeString(id_step, i, "PROPERTY_VALUE_" + key); if (StringUtils.isNotBlank(value)) { map.put(key, value); } } catch (KettleException ke) { // Ignore - not found } } modelAnnotation.populateAnnotation(map); } // Add to group modelAnnotationGroup.add(modelAnnotation); } modelAnnotationGroup.setSharedDimension( BooleanUtils.toBoolean(rep.getStepAttributeString(id_step, "SHARED_DIMENSION"))); sharedDimension = modelAnnotationGroup.isSharedDimension(); modelAnnotationGroup.setDescription(rep.getStepAttributeString(id_step, "DESCRIPTION")); List<DataProvider> dataProviders = new ArrayList<DataProvider>(); int nrDataProviders = rep.countNrStepAttributes(id_step, "DP_NAME"); for (int i = 0; i < nrDataProviders; i++) { DataProvider dataProvider = new DataProvider(); dataProvider.setName(rep.getStepAttributeString(id_step, i, "DP_NAME")); dataProvider.setSchemaName(rep.getStepAttributeString(id_step, i, "DP_SCHEMA_NAME")); dataProvider.setTableName(rep.getStepAttributeString(id_step, i, "DP_TABLE_NAME")); dataProvider.setDatabaseMetaNameRef( rep.getStepAttributeString(id_step, i, "DP_DATABASE_META_NAME_REF")); List<ColumnMapping> columnMappings = new ArrayList<ColumnMapping>(); long nrColumnMappings = rep.getStepAttributeString(id_step, "CM_COUNT_" + i) != null ? Long.valueOf(rep.getStepAttributeString(id_step, "CM_COUNT_" + i)) : 0; for (int j = 0; j < nrColumnMappings; j++) { ColumnMapping columnMapping = new ColumnMapping(); columnMapping.setName(rep.getStepAttributeString(id_step, i, "CM_NAME_" + j)); columnMapping.setColumnName(rep.getStepAttributeString(id_step, i, "CM_COLUMN_NAME_" + j)); String dataType = rep.getStepAttributeString(id_step, i, "CM_DATA_TYPE_" + j); if (StringUtils.isNotBlank(dataType)) { columnMapping.setColumnDataType(DataType.valueOf(dataType)); } columnMappings.add(columnMapping); } dataProvider.setColumnMappings(columnMappings); dataProviders.add(dataProvider); } modelAnnotationGroup.setDataProviders(dataProviders); } catch (Exception e) { throw new KettleException(BaseMessages.getString(PKG, "ModelAnnotationMeta.Exception.UnexpectedErrorReadingStepInfoFromRepository"), e); } setModelAnnotations(modelAnnotationGroup); // This may override the loaded model annotation group if (StringUtils.isNotBlank(getModelAnnotationCategory())) { readDataFromMetaStore(metaStore); } }
From source file:org.sinekartads.dto.BaseDTO.java
protected void formatValues(Map<DTOPropertyType, String> dtoPropertyFormats) throws IllegalArgumentException { // Mapping annotation -> dtoPropertyType restricted on the managed annotations Map<Class<? extends Annotation>, DTOPropertyType> annotationTypes = new HashMap<Class<? extends Annotation>, DTOPropertyType>(); for (Map.Entry<DTOPropertyType, String> entry : dtoPropertyFormats.entrySet()) { annotationTypes.put(entry.getKey().getAnnot(), entry.getKey()); }/*from w w w. j av a 2 s. co m*/ try { String newFormat; DateFormat newDateFormat = null; DateFormat newTimeFormat = null; DateFormat newDateTimeFormat = null; NumberFormat newIntegerFormat = null; NumberFormat newDecimalFormat = null; // create the the custom formatters newFormat = dtoPropertyFormats.get(DTOPropertyType.Date); if (newFormat != null) { newDateFormat = new SimpleDateFormat(newFormat); } newFormat = dtoPropertyFormats.get(DTOPropertyType.Time); if (newFormat != null) { newTimeFormat = new SimpleDateFormat(newFormat); } newFormat = dtoPropertyFormats.get(DTOPropertyType.DateTime); if (newFormat != null) { newDateTimeFormat = new SimpleDateFormat(newFormat); } newFormat = dtoPropertyFormats.get(DTOPropertyType.Integer); if (newFormat != null) { newIntegerFormat = new DecimalFormat(newFormat); } newFormat = dtoPropertyFormats.get(DTOPropertyType.Decimal); if (newFormat != null) { newDecimalFormat = new DecimalFormat(newFormat); } // change formats into the dto and all its children Field[] fields = getClass().getDeclaredFields(); String property; Class<?> fieldType; DTOPropertyType dtoPropertyType; for (Field field : fields) { // ignore the static field if ((field.getModifiers() & java.lang.reflect.Modifier.STATIC) > 0) continue; property = field.getName(); fieldType = field.getType(); if (BaseDTO.class.isAssignableFrom(fieldType)) { // recursion on the children (as single member) BaseDTO dto = (BaseDTO) PropertyUtils.getProperty(this, property); dto.formatValues(dtoPropertyFormats); } else if (BaseDTO[].class.isAssignableFrom(fieldType)) { // recursion on the children (as an array) for (BaseDTO dto : (BaseDTO[]) PropertyUtils.getProperty(this, property)) { dto.formatValues(dtoPropertyFormats); } } else { // format the other (String) values String strValue = (String) PropertyUtils.getProperty(this, property); if (StringUtils.isNotBlank(strValue)) { Object value = null; for (Annotation annot : field.getAnnotations()) { // dtoPropertyType of the current field (or null) dtoPropertyType = annotationTypes.get(annot.annotationType()); // newFormat to be applied to the current field's dtoPropertyType newFormat = dtoPropertyFormats.get(dtoPropertyType); // if not null (the annotation is owned by a managed DtoPropertyType) if (newFormat != null) { // in every managed case, parse the value and apply to it the new format switch (dtoPropertyType) { case Flag: { value = BooleanUtils.toBoolean(strValue); PropertyUtils.setProperty(this, property, value); break; } case Date: { value = dateFormat.parse(strValue); PropertyUtils.setProperty(this, property, newDateFormat.format(value)); break; } case Time: { value = timeFormat.parse(strValue); PropertyUtils.setProperty(this, property, newTimeFormat.format(value)); break; } case DateTime: { value = dateTimeFormat.parse(strValue); PropertyUtils.setProperty(this, property, newDateTimeFormat.format(value)); break; } case Integer: { value = integerFormat.parse(strValue).intValue(); PropertyUtils.setProperty(this, property, newIntegerFormat.format(value)); break; } case Decimal: { value = decimalFormat.parse(strValue); PropertyUtils.setProperty(this, property, newDecimalFormat.format(value)); } default: throw new IllegalArgumentException( "unimplemented format: " + dtoPropertyType.name()); } // end switch } } // non-annotated fields are not modified } } } // update the internal formatters if (newDateFormat != null) dateFormat = newDateFormat; if (newTimeFormat != null) timeFormat = newTimeFormat; if (newDateTimeFormat != null) dateTimeFormat = newDateTimeFormat; if (newIntegerFormat != null) integerFormat = newIntegerFormat; if (newDecimalFormat != null) decimalFormat = newDecimalFormat; } catch (RuntimeException e) { throw e; } catch (Exception e) { // errors that should happen only during the test phase throw new RuntimeException(e); } }
From source file:org.sipfoundry.sipxconfig.rls.ResourceLists.java
public Document getDocument(boolean xmppPresenceEnabled) { Document document = XmlFile.FACTORY.createDocument(); Element lists = document.addElement("lists", NAMESPACE); Element imList = null;/*from w w w . jav a 2 s . c o m*/ DBCursor cursor = m_validUsers.getUsersWithSpeedDial(); while (cursor.hasNext()) { DBObject user = cursor.next(); String userName = user.get(UID).toString(); if (userName.equals("superadmin")) { continue; } if (xmppPresenceEnabled && BooleanUtils.toBoolean(user.get(IM_ENABLED).toString())) { if (imList == null) { imList = createResourceList(lists, XMPP_SERVER.getUserName()); } String userAddrSpec = SipUri.format(userName, m_coreContext.getDomainName(), false); createResource(imList, userAddrSpec, userName); } DBObject speedDial = (DBObject) user.get(SPEEDDIAL); // ignore disabled orbits if (speedDial == null) { continue; } BasicDBList buttons = (BasicDBList) speedDial.get(BUTTONS); Element list = null; if (buttons != null) { list = createResourceList(lists, user.get(UID).toString(), speedDial.get(USER).toString(), speedDial.get(USER_CONS).toString()); Iterator iter = buttons.iterator(); while (iter.hasNext()) { DBObject button = (DBObject) iter.next(); // Append "sipx-noroute=Voicemail" and "sipx-userforward=false" // URI parameters to the target URI to control how the proxy forwards // SUBSCRIBEs to the resource URI. createResource(list, button.get(URI).toString(), button.get(NAME).toString()); } } } return document; }