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.opencastproject.workflow.handler.videoeditor.VideoEditorWorkflowOperationHandler.java
/** * {@inheritDoc}//from w ww.j av a 2 s . co m * * @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance, * JobContext) */ @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mp = workflowInstance.getMediaPackage(); logger.info("Start editor workflow for mediapackage {}", mp.getIdentifier().compact()); // get configuration WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation(); String smilFlavorsProperty = StringUtils .trimToNull(worflowOperationInstance.getConfiguration(SMIL_FLAVORS_PROPERTY)); if (smilFlavorsProperty == null) { throw new WorkflowOperationException( String.format("Required configuration property %s not set", SMIL_FLAVORS_PROPERTY)); } String targetSmilFlavorProperty = StringUtils .trimToNull(worflowOperationInstance.getConfiguration(TARGET_SMIL_FLAVOR_PROPERTY)); if (targetSmilFlavorProperty == null) { throw new WorkflowOperationException( String.format("Required configuration property %s not set", TARGET_SMIL_FLAVOR_PROPERTY)); } String previewTrackFlavorsProperty = StringUtils .trimToNull(worflowOperationInstance.getConfiguration(PREVIEW_FLAVORS_PROPERTY)); if (previewTrackFlavorsProperty == null) { logger.info("Configuration property '{}' not set, use preview tracks from smil catalog", PREVIEW_FLAVORS_PROPERTY); } if (StringUtils .trimToNull(worflowOperationInstance.getConfiguration(TARGET_FLAVOR_SUBTYPE_PROPERTY)) == null) { throw new WorkflowOperationException( String.format("Required configuration property %s not set", TARGET_FLAVOR_SUBTYPE_PROPERTY)); } final boolean interactive = BooleanUtils .toBoolean(worflowOperationInstance.getConfiguration(INTERACTIVE_PROPERTY)); // check at least one smil catalog exists SimpleElementSelector elementSelector = new SimpleElementSelector(); for (String flavor : asList(smilFlavorsProperty)) { elementSelector.addFlavor(flavor); } Collection<MediaPackageElement> smilCatalogs = elementSelector.select(mp, false); MediaPackageElementBuilder mpeBuilder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder(); if (smilCatalogs.isEmpty()) { // There is nothing to do, skip the operation if (!interactive) { logger.info("Skipping cutting opertion since no edit decision list is available"); return skip(workflowInstance, context); } // Without SMIL catalogs and without preview tracks, there is nothing we can do if (previewTrackFlavorsProperty == null) { throw new WorkflowOperationException(String.format( "No smil catalogs with flavor %s nor preview files with flavor %s found in mediapackage %s", smilFlavorsProperty, previewTrackFlavorsProperty, mp.getIdentifier().compact())); } // Basd on the preview trcks, create new and empty SMIL catalog TrackSelector trackSelector = new TrackSelector(); for (String flavor : asList(previewTrackFlavorsProperty)) { trackSelector.addFlavor(flavor); } Collection<Track> previewTracks = trackSelector.select(mp, false); if (previewTracks.isEmpty()) { throw new WorkflowOperationException( String.format("No preview tracks found in mediapackage %s with flavor %s", mp.getIdentifier().compact(), previewTrackFlavorsProperty)); } Track[] previewTracksArr = previewTracks.toArray(new Track[previewTracks.size()]); MediaPackageElementFlavor smilFlavor = MediaPackageElementFlavor.parseFlavor(smilFlavorsProperty); for (Track previewTrack : previewTracks) { try { SmilResponse smilResponse = smilService.createNewSmil(mp); smilResponse = smilService.addParallel(smilResponse.getSmil()); smilResponse = smilService.addClips(smilResponse.getSmil(), smilResponse.getEntity().getId(), previewTracksArr, 0L, previewTracksArr[0].getDuration()); Smil smil = smilResponse.getSmil(); InputStream is = null; try { // put new smil into workspace is = IOUtils.toInputStream(smil.toXML(), "UTF-8"); URI smilURI = workspace.put(mp.getIdentifier().compact(), smil.getId(), SMIL_FILE_NAME, is); MediaPackageElementFlavor trackSmilFlavor = previewTrack.getFlavor(); if (!"*".equals(smilFlavor.getType())) { trackSmilFlavor = new MediaPackageElementFlavor(smilFlavor.getType(), trackSmilFlavor.getSubtype()); } if (!"*".equals(smilFlavor.getSubtype())) { trackSmilFlavor = new MediaPackageElementFlavor(trackSmilFlavor.getType(), smilFlavor.getSubtype()); } Catalog catalog = (Catalog) mpeBuilder.elementFromURI(smilURI, MediaPackageElement.Type.Catalog, trackSmilFlavor); catalog.setIdentifier(smil.getId()); mp.add(catalog); } finally { IOUtils.closeQuietly(is); } } catch (Exception ex) { throw new WorkflowOperationException(String.format( "Failed to create smil catalog for mediapackage %s", mp.getIdentifier().compact()), ex); } } } // check target smil catalog exists MediaPackageElementFlavor targetSmilFlavor = MediaPackageElementFlavor .parseFlavor(targetSmilFlavorProperty); Catalog[] targetSmilCatalogs = mp.getCatalogs(targetSmilFlavor); if (targetSmilCatalogs == null || targetSmilCatalogs.length == 0) { if (!interactive) return skip(workflowInstance, context); // create new empty smil to fill it from editor UI try { SmilResponse smilResponse = smilService.createNewSmil(mp); Smil smil = smilResponse.getSmil(); InputStream is = null; try { // put new smil into workspace is = IOUtils.toInputStream(smil.toXML(), "UTF-8"); URI smilURI = workspace.put(mp.getIdentifier().compact(), smil.getId(), SMIL_FILE_NAME, is); Catalog catalog = (Catalog) mpeBuilder.elementFromURI(smilURI, MediaPackageElement.Type.Catalog, targetSmilFlavor); catalog.setIdentifier(smil.getId()); mp.add(catalog); } finally { IOUtils.closeQuietly(is); } } catch (Exception ex) { throw new WorkflowOperationException( String.format("Failed to create an initial empty smil catalog for mediapackage %s", mp.getIdentifier().compact()), ex); } logger.info("Holding for video edit..."); return createResult(mp, Action.PAUSE); } else { logger.debug("Move on, SMIL catalog ({}) already exists for media package '{}'", targetSmilFlavor, mp); return resume(workflowInstance, context, Collections.<String, String>emptyMap()); } }
From source file:org.opencastproject.workflow.handler.workflow.CleanupWorkflowOperationHandler.java
/** * {@inheritDoc}/*from ww w.jav a2s .com*/ * * @see org.opencastproject.workflow.api.AbstractWorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance, * JobContext) */ @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String flavors = currentOperation.getConfiguration(PRESERVE_FLAVOR_PROPERTY); final List<MediaPackageElementFlavor> flavorsToPreserve = new ArrayList<MediaPackageElementFlavor>(); boolean deleteExternal = BooleanUtils.toBoolean(currentOperation.getConfiguration(DELETE_EXTERNAL)); // If the configuration does not specify flavors, remove them all for (String flavor : asList(flavors)) { flavorsToPreserve.add(MediaPackageElementFlavor.parseFlavor(flavor)); } String baseUrl = workspace.getBaseUri().toString(); // Find all external working file repository base Urls List<String> externalWfrBaseUrls = new ArrayList<String>(); if (deleteExternal) { try { for (ServiceRegistration reg : serviceRegistry .getServiceRegistrationsByType(WorkingFileRepository.SERVICE_TYPE)) { if (baseUrl.startsWith(reg.getHost())) continue; externalWfrBaseUrls.add(UrlSupport.concat(reg.getHost(), reg.getPath())); } } catch (ServiceRegistryException e) { logger.error("Unable to load WFR services from service registry: {}", e.getMessage()); throw new WorkflowOperationException(e); } } // Some URIs are shared by multiple elements. If one of these elements should be deleted but another should not, we // must keep the file. Set<URI> urisToDelete = new HashSet<URI>(); Set<URI> urisToKeep = new HashSet<URI>(); for (MediaPackageElement element : mediaPackage.getElements()) { if (element.getURI() == null) continue; String elementUri = element.getURI().toString(); if (!elementUri.startsWith(baseUrl)) { if (deleteExternal) { String wfrBaseUrl = null; for (String url : externalWfrBaseUrls) { if (element.getURI().toString().startsWith(url)) { wfrBaseUrl = url; break; } } if (wfrBaseUrl == null) continue; HttpDelete delete; if (elementUri.startsWith( UrlSupport.concat(wfrBaseUrl, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX))) { String wfrDeleteUrl = elementUri.substring(0, elementUri.lastIndexOf("/")); delete = new HttpDelete(wfrDeleteUrl); } else if (elementUri.startsWith( UrlSupport.concat(wfrBaseUrl, WorkingFileRepository.COLLECTION_PATH_PREFIX))) { delete = new HttpDelete(elementUri); } else { logger.info("Unable to handle URI {}", elementUri); continue; } HttpResponse response = null; try { response = client.execute(delete); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_NO_CONTENT || statusCode == HttpStatus.SC_OK) { logger.info("Sucessfully deleted external URI {}", delete.getURI()); } else if (statusCode == HttpStatus.SC_NOT_FOUND) { logger.info("External URI {} has already been deleted", delete.getURI()); } else { logger.info("Unable to delete external URI {}, status code '{}' returned", delete.getURI(), statusCode); } } catch (TrustedHttpClientException e) { logger.warn("Unable to execute DELETE request on external URI {}", delete.getURI()); throw new WorkflowOperationException(e); } finally { client.close(response); } } continue; } // remove the element if it doesn't match the flavors to preserve boolean remove = true; for (MediaPackageElementFlavor flavor : flavorsToPreserve) { if (flavor.matches(element.getFlavor())) { remove = false; break; } } if (remove) { urisToDelete.add(element.getURI()); mediaPackage.remove(element); } else { urisToKeep.add(element.getURI()); } } // Remove all of the files to keep from the one to delete urisToDelete.removeAll(urisToKeep); // Now remove the files to delete for (URI uri : urisToDelete) { try { workspace.delete(uri); } catch (Exception e) { logger.warn("Unable to delete {}", uri); } } return createResult(mediaPackage, Action.CONTINUE); }
From source file:org.opencastproject.workflow.impl.OsgiWorkflowCleanupScheduler.java
@Override public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException { unschedule();/* w w w. j av a 2 s . c o m*/ if (properties != null) { logger.debug("Updating configuration..."); enabled = BooleanUtils.toBoolean((String) properties.get(PARAM_KEY_ENABLED)); logger.debug("enabled = {}", enabled); cronExpression = (String) properties.get(PARAM_KEY_CRON_EXPR); if (StringUtils.isBlank(cronExpression)) throw new ConfigurationException(PARAM_KEY_CRON_EXPR, "Cron expression must be valid"); logger.debug("cronExpression = {}", cronExpression); try { lifetimeSuccessfulJobs = Integer.valueOf((String) properties.get(PARAM_KEY_LIFETIME_SUCCEEDED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_LIFETIME_SUCCEEDED, "Lifetime must be a valid integer", e); } logger.debug("lifetimeFinishedJobs = {}", lifetimeSuccessfulJobs); try { lifetimeFailedJobs = Integer.valueOf((String) properties.get(PARAM_KEY_LIFETIME_FAILED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_LIFETIME_FAILED, "Lifetime must be a valid integer", e); } logger.debug("lifetimeFailedJobs = {}", lifetimeFailedJobs); try { lifetimeStoppedJobs = Integer.valueOf((String) properties.get(PARAM_KEY_LIFETIME_STOPPED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_LIFETIME_STOPPED, "Lifetime must be a valid integer", e); } logger.debug("lifetimeStoppedJobs = {}", lifetimeStoppedJobs); try { lifetimeParentlessJobs = Integer.valueOf((String) properties.get(PARAM_KEY_LIFETIME_PARENTLESS)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_LIFETIME_PARENTLESS, "Lifetime must be a valid integer", e); } logger.debug("lifetimeParentlessJobs = {}", lifetimeParentlessJobs); } schedule(); }
From source file:org.opencastproject.workflow.impl.WorkflowCleanupScanner.java
@Override public void updated(@SuppressWarnings("rawtypes") Dictionary properties) throws ConfigurationException { boolean enabled = false; String cronExpression;//from www. j ava 2 s . c o m unschedule(); if (properties != null) { logger.debug("Updating configuration..."); enabled = BooleanUtils.toBoolean((String) properties.get(AbstractScanner.PARAM_KEY_ENABLED)); setEnabled(enabled); logger.debug("enabled = {}", enabled); cronExpression = (String) properties.get(AbstractScanner.PARAM_KEY_CRON_EXPR); if (StringUtils.isBlank(cronExpression)) { throw new ConfigurationException(AbstractScanner.PARAM_KEY_CRON_EXPR, "Cron expression must be valid"); } setCronExpression(cronExpression); logger.debug("cronExpression = {}", cronExpression); try { bufferForSuccessfulJobs = Integer.valueOf((String) properties.get(PARAM_KEY_BUFFER_SUCCEEDED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_BUFFER_SUCCEEDED, "Buffer must be a valid integer", e); } logger.debug("bufferForSuccessfulJobs = {}", bufferForSuccessfulJobs); try { bufferForFailedJobs = Integer.valueOf((String) properties.get(PARAM_KEY_BUFFER_FAILED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_BUFFER_FAILED, "Buffer must be a valid integer", e); } logger.debug("bufferForFailedJobs = {}", bufferForFailedJobs); try { bufferForStoppedJobs = Integer.valueOf((String) properties.get(PARAM_KEY_BUFFER_STOPPED)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_BUFFER_STOPPED, "Buffer must be a valid integer", e); } logger.debug("bufferForStoppedJobs = {}", bufferForStoppedJobs); try { bufferForParentlessJobs = Integer.valueOf((String) properties.get(PARAM_KEY_BUFFER_PARENTLESS)); } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_BUFFER_PARENTLESS, "Buffer must be a valid integer", e); } logger.debug("bufferForParentlessJobs = {}", bufferForParentlessJobs); } schedule(); }
From source file:org.opencommercesearch.FacetHandler.java
/** * Appends the country and/or site if the facet is country and/or site specific. If the fieldName already ends * with the country code, nothing gets appended. * @param fieldName is the field name/* w ww . j av a 2 s . co m*/ * @param facet is the facet's document * @return the calculated facet name */ static String fieldName(String fieldName, SolrQuery query, Document facet) { if (fieldName == null || facet == null) { return fieldName; } String country = query.get(RuleManagerParams.COUNTRY_ID, "US"); String site = query.get(RuleManagerParams.CATALOG_ID); if (BooleanUtils.toBoolean(facet.get(FacetConstants.FIELD_BY_COUNTRY)) == Boolean.TRUE && !fieldName.endsWith(country)) { fieldName += country; } if (BooleanUtils.toBoolean(facet.get(FIELD_BY_SITE)) == Boolean.TRUE && site != null) { fieldName += site; } return fieldName; }
From source file:org.openhab.io.dropbox.internal.DropboxService.java
@SuppressWarnings("rawtypes") @Override//from www. j a va 2 s . co m public void updated(Dictionary config) throws ConfigurationException { if (config == null) { logger.debug("Updated() was called with a null config!"); return; } DropboxSynchronizer synchronizer = getDropboxSynchronizer(); String appKeyString = Objects.toString(config.get("appkey"), null); if (isNotBlank(appKeyString)) { appKey = appKeyString; } String appSecretString = Objects.toString(config.get("appsecret"), null); if (isNotBlank(appSecretString)) { appSecret = appSecretString; } String pat = Objects.toString(config.get("personalAccessToken"), null); if (isNotBlank(pat)) { personalAccessToken = pat; } if (logger.isDebugEnabled()) { StringBuffer message = new StringBuffer(); message.append("Authentication parameters to be used:\r\n"); if (isNotBlank(personalAccessToken)) { message.append(" Personal access token = " + personalAccessToken + "\r\n"); } else { message.append(" appkey = " + appKey + "\r\n"); message.append(" appsecret = " + appSecret + "\r\n"); } logger.debug(message.toString()); } if (isBlank(personalAccessToken) && (isBlank(appKey) || isBlank(appSecret))) { throw new ConfigurationException("dropbox:authentication", "The Dropbox authentication parameters are incorrect! " + "The parameter 'personalAccesstoken' must be set, or both of" + " the parameters 'appkey' and 'appsecret' must be set. Please" + " check your configuration."); } else if (isNotBlank(appKey) && isNotBlank(appSecret)) { appInfo = new DbxAppInfo(appKey, appSecret); } String fakeModeString = Objects.toString(config.get("fakemode"), null); if (isNotBlank(fakeModeString)) { synchronizer.setFakeMode(BooleanUtils.toBoolean(fakeModeString)); } String contentDirString = Objects.toString(config.get("contentdir"), null); synchronizer.setContentDir(contentDirString); String uploadIntervalString = Objects.toString(config.get("uploadInterval"), null); if (isNotBlank(uploadIntervalString)) { uploadInterval = uploadIntervalString; } String downloadIntervalString = Objects.toString(config.get("downloadInterval"), null); if (isNotBlank(downloadIntervalString)) { downloadInterval = downloadIntervalString; } String syncModeString = Objects.toString(config.get("syncmode"), null); if (isNotBlank(syncModeString)) { try { syncMode = DropboxSyncMode.valueOf(syncModeString.toUpperCase()); } catch (IllegalArgumentException iae) { throw new ConfigurationException("dropbox:syncmode", "Unknown SyncMode '" + syncModeString + "'. Valid SyncModes are 'DROPBOX_TO_LOCAL', 'LOCAL_TO_DROPBOX' and 'BIDIRECTIONAL'."); } } String uploadFilterString = Objects.toString(config.get("uploadfilter"), null); if (isNotBlank(uploadFilterString)) { String[] newFilterElements = uploadFilterString.split(","); synchronizer.setUploadFilterElements(Arrays.asList(newFilterElements)); } String downloadFilterString = Objects.toString(config.get("downloadfilter"), null); if (isNotBlank(downloadFilterString)) { String[] newFilterElements = downloadFilterString.split(","); synchronizer.setDownloadFilterElements(Arrays.asList(newFilterElements)); } // we got this far, so we define this synchronizer as properly configured ... isProperlyConfigured = true; logger.debug("Dropbox I/O is properly configured. Activating synchronizer."); activateSynchronizer(); }
From source file:org.openhab.io.dropbox.internal.DropboxSynchronizer.java
@SuppressWarnings("rawtypes") @Override//w w w . ja v a2 s. c o m public void updated(Dictionary config) throws ConfigurationException { if (config != null) { isProperlyConfigured = false; String appKeyString = (String) config.get("appkey"); if (isNotBlank(appKeyString)) { DropboxSynchronizer.appKey = appKeyString; } String appSecretString = (String) config.get("appsecret"); if (isNotBlank(appSecretString)) { DropboxSynchronizer.appSecret = appSecretString; } if (isBlank(DropboxSynchronizer.appKey) || isBlank(DropboxSynchronizer.appSecret)) { throw new ConfigurationException("dropbox:appkey", "The parameters 'appkey' or 'appsecret' are missing! Please refer to your 'openhab.cfg'"); } String fakeModeString = (String) config.get("fakemode"); if (isNotBlank(fakeModeString)) { DropboxSynchronizer.fakeMode = BooleanUtils.toBoolean(fakeModeString); } String contentDirString = (String) config.get("contentdir"); if (isNotBlank(contentDirString)) { DropboxSynchronizer.contentDir = contentDirString; } String uploadIntervalString = (String) config.get("uploadInterval"); if (isNotBlank(uploadIntervalString)) { DropboxSynchronizer.uploadInterval = uploadIntervalString; } String downloadIntervalString = (String) config.get("downloadInterval"); if (isNotBlank(downloadIntervalString)) { DropboxSynchronizer.downloadInterval = downloadIntervalString; } String syncModeString = (String) config.get("syncmode"); if (isNotBlank(syncModeString)) { try { DropboxSynchronizer.syncMode = DropboxSyncMode.valueOf(syncModeString.toUpperCase()); } catch (IllegalArgumentException iae) { throw new ConfigurationException("dropbox:syncmode", "Unknown SyncMode '" + syncModeString + "'. Valid SyncModes are 'DROPBOX_TO_LOCAL', 'LOCAL_TO_DROPBOX' and 'BIDIRECTIONAL'."); } } String uploadFilterString = (String) config.get("uploadfilter"); if (isNotBlank(uploadFilterString)) { String[] newFilterElements = uploadFilterString.split(","); uploadFilterElements = Arrays.asList(newFilterElements); } String downloadFilterString = (String) config.get("downloadfilter"); if (isNotBlank(downloadFilterString)) { String[] newFilterElements = downloadFilterString.split(","); downloadFilterElements = Arrays.asList(newFilterElements); } // we got thus far, so we define this synchronizer as properly configured ... isProperlyConfigured = true; activateSynchronizer(); } }
From source file:org.openhab.io.dropbox.internal.DropboxSynchronizerImpl.java
@SuppressWarnings("rawtypes") @Override/*from w w w . ja v a 2 s .com*/ public void updated(Dictionary config) throws ConfigurationException { if (config != null) { isProperlyConfigured = false; String appKeyString = (String) config.get("appkey"); if (isNotBlank(appKeyString)) { DropboxSynchronizerImpl.appKey = appKeyString; } String appSecretString = (String) config.get("appsecret"); if (isNotBlank(appSecretString)) { DropboxSynchronizerImpl.appSecret = appSecretString; } if (isBlank(DropboxSynchronizerImpl.appKey) || isBlank(DropboxSynchronizerImpl.appSecret)) { throw new ConfigurationException("dropbox:appkey", "The parameters 'appkey' or 'appsecret' are missing! Please refer to your 'openhab.cfg'"); } String initializeString = (String) config.get("initialize"); if (isNotBlank(initializeString)) { DropboxSynchronizerImpl.initializeDropboxOnReset = BooleanUtils.toBoolean(initializeString); } String contentDirString = (String) config.get("contentdir"); if (isNotBlank(contentDirString)) { DropboxSynchronizerImpl.contentDir = contentDirString; } String uploadIntervalString = (String) config.get("uploadInterval"); if (isNotBlank(uploadIntervalString)) { DropboxSynchronizerImpl.uploadInterval = uploadIntervalString; } String downloadIntervalString = (String) config.get("downloadInterval"); if (isNotBlank(downloadIntervalString)) { DropboxSynchronizerImpl.downloadInterval = downloadIntervalString; } String syncModeString = (String) config.get("syncmode"); if (isNotBlank(syncModeString)) { try { DropboxSynchronizerImpl.syncMode = DropboxSyncMode.valueOf(syncModeString.toUpperCase()); } catch (IllegalArgumentException iae) { throw new ConfigurationException("dropbox:syncmode", "Unknown SyncMode '" + syncModeString + "'. Valid SyncModes are 'DROPBOX_TO_LOCAL', 'LOCAL_TO_DROPBOX' and 'BIDIRECTIONAL'."); } } String uploadFilterString = (String) config.get("uploadfilter"); if (isNotBlank(uploadFilterString)) { String[] newFilterElements = uploadFilterString.split(","); uploadFilterElements.addAll(Arrays.asList(newFilterElements)); } String downloadFilterString = (String) config.get("downloadfilter"); if (isNotBlank(downloadFilterString)) { String[] newFilterElements = downloadFilterString.split(","); downloadFilterElements.addAll(Arrays.asList(newFilterElements)); } // we got thus far, so we define this synchronizer as properly configured ... isProperlyConfigured = true; activate(); } }
From source file:org.openhab.io.imperihome.internal.processor.ItemProcessor.java
private boolean isInverted(Map<TagType, List<String>> issTags) { return issTags.containsKey(TagType.INVERT) && BooleanUtils.toBoolean(issTags.get(TagType.INVERT).get(0)); }
From source file:org.openmrs.module.clinicalsummary.task.DateCreatedEvaluatorProcessor.java
public void processSummary() { // remove the concept cache every night CacheUtils.clearConceptCache();// w w w. j av a 2 s . c o m CacheUtils.clearEncounterTypeCache(); // location is clustered, clusters are separated by comma String clusterNames = Context.getAdministrationService() .getGlobalProperty(TaskParameters.LOCATION_GROUP_LIST); if (clusterNames != null) { String[] clusterName = StringUtils.split(clusterNames, TaskParameters.CLUSTER_SEPARATOR); GlobalProperty globalProperty = Context.getAdministrationService() .getGlobalPropertyObject(TaskParameters.PROCESSOR_COUNTER); // start with the first cluster (offset = 0) when the counter is not a number Integer clusterOffset = NumberUtils.toInt(globalProperty.getPropertyValue(), 0); if (clusterOffset >= 0 && clusterOffset < ArrayUtils.getLength(clusterName)) { GlobalProperty initProperty = Context.getAdministrationService() .getGlobalPropertyObject(TaskParameters.PROCESSOR_INITIALIZED); String currentCluster = clusterName[clusterOffset]; // check whether all cluster have been initialized or not Boolean initialized = BooleanUtils.toBoolean(initProperty.getPropertyValue()); Cohort cohort; String[] locationIds = StringUtils.split(currentCluster); for (int i = 0; i < ArrayUtils.getLength(locationIds); i++) { log.info("Processing location with id: " + locationIds[i]); // default return to -1 because no such location with id -1 Location location = Context.getLocationService() .getLocation(NumberUtils.toInt(locationIds[i], -1)); if (!initialized) { cohort = Context.getService(CoreService.class).getDateCreatedCohort(location, null, null); } else { // regenerate when there's new obs Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -(clusterName.length + 1)); Date date = calendar.getTime(); cohort = Context.getService(CoreService.class).getDateCreatedCohort(location, date, new Date()); } evaluate(cohort); } clusterOffset++; if (clusterOffset == ArrayUtils.getLength(clusterName)) { clusterOffset = 0; initialized = true; } globalProperty.setPropertyValue(String.valueOf(clusterOffset)); Context.getAdministrationService().saveGlobalProperty(globalProperty); initProperty.setPropertyValue(String.valueOf(initialized)); Context.getAdministrationService().saveGlobalProperty(initProperty); } } }