List of usage examples for org.apache.commons.lang3 EnumUtils getEnum
public static <E extends Enum<E>> E getEnum(final Class<E> enumClass, final String enumName)
Gets the enum for the class, returning null if not found.
This method differs from Enum#valueOf in that it does not throw an exception for an invalid enum name.
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
/** * Does some thing in old style.// w w w . j a va 2 s . co m * * @deprecated use {@link #MDRCacheRuleService()} instead. */ @Deprecated public boolean isCodeTypePresentInMDRList(String listName, List<CodeType> valuesToMatch) { MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName); if (anEnum == null) { log.error(THE_LIST + listName + DOESN_T_EXIST_IN_MDR_MODULE); return false; } List<String> codeListValues = MDRCacheHolder.getInstance().getList(anEnum); if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) { return false; } for (CodeType codeType : valuesToMatch) { if (!codeListValues.contains(codeType.getValue())) { return false; } } return true; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
public boolean isCodeTypeListIdPresentInMDRList(String listName, List<CodeType> valuesToMatch) { MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName); if (anEnum == null) { log.error(THE_LIST + listName + DOESN_T_EXIST_IN_MDR_MODULE); return false; }//from w ww. j ava 2 s .c om List<String> codeListValues = MDRCacheHolder.getInstance().getList(anEnum); if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) { return false; } for (CodeType codeType : valuesToMatch) { if (!codeListValues.contains(codeType.getListId())) return false; } return true; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
/** * Does some thing in old style./*from w w w .j av a 2 s . com*/ * * @deprecated use {@link #MDRCacheRuleService()} instead. */ @Deprecated public boolean isIdTypePresentInMDRList(String listName, List<IdType> valuesToMatch) { MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName); if (anEnum == null) { log.error(THE_LIST + listName + DOESN_T_EXIST_IN_MDR_MODULE); return false; } List<String> codeListValues = MDRCacheHolder.getInstance().getList(anEnum); if (CollectionUtils.isEmpty(valuesToMatch) || CollectionUtils.isEmpty(codeListValues)) { return false; } for (IdType codeType : valuesToMatch) { if (!codeListValues.contains(codeType.getValue())) return false; } return true; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
/** * Does some thing in old style./*from ww w . j a v a 2 s .c om*/ * * @deprecated use {@link #MDRCacheRuleService()} instead. */ @Deprecated public boolean isIdTypePresentInMDRList(IdType id) { if (id == null) { return false; } String schemeId = id.getSchemeId(); String value = id.getValue(); MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, schemeId); if (anEnum == null) { log.error(THE_LIST + schemeId + DOESN_T_EXIST_IN_MDR_MODULE); return false; } List<String> codeListValues = MDRCacheHolder.getInstance().getList(anEnum); return codeListValues.contains(value); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.business.AbstractFact.java
/** * Does some thing in old style.// w ww .ja va 2 s . c o m * * @deprecated use {@link #MDRCacheRuleService()} instead. */ @Deprecated public String getDataTypeForMDRList(String listName, String codeValue) { MDRAcronymType anEnum = EnumUtils.getEnum(MDRAcronymType.class, listName); if (anEnum == null || codeValue == null) { log.error(THE_LIST + listName + DOESN_T_EXIST_IN_MDR_MODULE); return StringUtils.EMPTY; } List<ObjectRepresentation> representations = MDRCacheHolder.getInstance() .getObjectRepresentationList(anEnum); boolean valueFound = false; if (CollectionUtils.isNotEmpty(representations)) { for (ObjectRepresentation representation : representations) { List<ColumnDataType> columnDataTypes = representation.getFields(); if (CollectionUtils.isEmpty(columnDataTypes)) { continue; } for (ColumnDataType columnDataType : columnDataTypes) { if ("code".equals(columnDataType.getColumnName()) && columnDataType.getColumnValue().equals(codeValue)) { valueFound = true; break; } } if (valueFound) { for (ColumnDataType columnDataType : columnDataTypes) { if ("dataType".equals(columnDataType.getColumnName())) { return columnDataType.getColumnValue(); } } } } } return StringUtils.EMPTY; }
From source file:org.aliuge.crawler.extractor.selector.action.ActionFactory.java
@SuppressWarnings("unchecked") public static SelectorAction create(Element element, String c) { if ("string".equals(c)) { StringActionType $type = EnumUtils.getEnum(StringActionType.class, element.attr("operation")); if (null == $type) { try { throw new Exception( "?" + element.tagName() + "operation"); } catch (Exception e) { e.printStackTrace();// www. jav a2 s. co m } } switch ($type) { case after: return new StringAfterAction(element.attr("split")); case afterLast: return new StringAfterLastAction(element.attr("split")); case before: return new StringBeforeAction(element.attr("split")); case beforeLast: return new StringBeforeLastAction(element.attr("split")); case between: return new StringBetweenAction(element.attr("exp")); case filter: return new StringFilterAction(element.attr("filter"), element.attr("charType")); case replace: /* * return new * StringReplaceAction(element.attr("exp"),element.attr * ("replacement")); */ String exp = element.attr("exp"); String[] kv = exp.split(","); if (kv.length == 2) { return new StringReplaceAction(kv[0], kv[1]); } case split: return new StringSplitAction(element.attr("split"), element.attr("index")); case sub: return new StringSubAction(element.attr("exp")); case suffix: return new StringSuffixAction(element.attr("suffix")); case perfix: return new StringPerfixAction(element.attr("perfix")); case regex: return new StringRegexAction(element.attr("exp")); default: break; } } else if ("integer".equals(c) || "int".equals(c)) { IntegerActionType $type = EnumUtils.getEnum(IntegerActionType.class, element.attr("operation")); switch ($type) { case abs: return new IntegerAbsAction(); case between: try { return new IntegerBetweenAction(element.attr("exp"), element.attr("default")); } catch (IntegerBetweenExpressionException e) { e.printStackTrace(); } default: break; } } else if ("date".equals(c)) { } else if ("numerica".equals(c)) { IntegerActionType $type = EnumUtils.getEnum(IntegerActionType.class, element.attr("operation")); switch ($type) { case abs: return new IntegerAbsAction(); case between: try { return new IntegerBetweenAction(element.attr("exp"), element.attr("default")); } catch (Exception e) { e.printStackTrace(); } default: break; } } else if ("file".equals(c)) { FileActionType $type = EnumUtils.getEnum(FileActionType.class, element.attr("operation")); switch ($type) { case download: String dir = element.attr("dir"); String temp = element.attr("fileName"); boolean md5File = false, asyn; if (StringUtils.isNotBlank(temp)) { if ("{md5}".equals(temp)) { md5File = true; } } else md5File = true; temp = element.attr("asyn"); if (StringUtils.isNotBlank(temp)) { asyn = Boolean.parseBoolean(temp); } else { asyn = true; } return new DownLoadFileAction(dir, md5File, asyn); case download_resize: String dir2 = element.attr("dir"); String temp2 = element.attr("fileName"); boolean md5File2 = false, asyn2; if (StringUtils.isNotBlank(temp2)) { if ("{md5}".equals(temp2)) { md5File2 = true; } } else md5File2 = true; temp2 = element.attr("asyn"); if (StringUtils.isNotBlank(temp2)) { asyn2 = Boolean.parseBoolean(temp2); } else { asyn2 = true; } DownLoadImageResizeAction resizeAction = new DownLoadImageResizeAction(dir2, md5File2, asyn2); temp2 = element.attr("width"); if (StringUtils.isNotBlank(temp2)) { resizeAction.setW(Integer.parseInt(temp2)); } temp2 = element.attr("height"); if (StringUtils.isNotBlank(temp2)) { resizeAction.setH(Integer.parseInt(temp2)); } temp2 = element.attr("quality"); if (StringUtils.isNotBlank(temp2)) { resizeAction.setQuality(Float.parseFloat(temp2)); } temp2 = element.attr("del"); if (StringUtils.isNotBlank(temp2)) { resizeAction.setDeleteOldFile(Boolean.parseBoolean(temp2)); } return resizeAction; default: break; } } else { StringActionType $type = EnumUtils.getEnum(StringActionType.class, element.attr("operation")); if (null == $type) { try { throw new Exception( "?" + element.tagName() + "operation"); } catch (Exception e) { e.printStackTrace(); } } switch ($type) { case after: return new StringAfterAction(element.attr("split")); case afterLast: return new StringAfterLastAction(element.attr("split")); case before: return new StringBeforeAction(element.attr("split")); case beforeLast: return new StringBeforeLastAction(element.attr("split")); case between: return new StringBetweenAction(element.attr("exp")); case filter: return new StringFilterAction(element.attr("filter"), element.attr("charType")); case replace: return new StringReplaceAction(element.attr("search"), element.attr("replacement")); case split: return new StringSplitAction(element.attr("split"), element.attr("index")); case sub: return new StringSubAction(element.attr("exp")); case suffix: return new StringSuffixAction(element.attr("suffix")); case perfix: return new StringPerfixAction(element.attr("perfix")); default: break; } } return null; }
From source file:org.aliuge.crawler.extractor.selector.action.string.StringFilterAction.java
/** * //from ww w. j av a 2 s .c om * @param filterString * @param charType */ public StringFilterAction(String filterString, String charType) { super(); this.filterString = filterString; if (StringUtils.isNotBlank(charType)) { String is[] = charType.split(","); for (String i : is) { CharType ct = EnumUtils.getEnum(CharType.class, i); set.add(ct); } } }
From source file:org.aliuge.crawler.jobconf.StoreConfig.java
public StoreConfig loadConfig(Document confDoc) throws StorageException { Document doc = confDoc;/*w w w . j a v a 2 s . c o m*/ super.setJobName(doc.select("job").attr("name")); super.setIndexName(doc.select("job").attr("indexName")); Elements e = doc.select("store"); this.type = e.select("type").text(); if (StringUtils.isNotBlank(e.select("threadNum").text())) { this.threadNum = Integer.parseInt(e.select("threadNum").text()); } String className = e.select("plugin").text(); if (StringUtils.isNotBlank(className)) { this.pluginClass = className; } if (!StorageType.containsValue(this.type)) { log.info("?" + this.type); throw new StorageException( "???store? mysql,hbase,elasticSearch,localFile,mongodb"); } if (this.type.equalsIgnoreCase(StorageType.hbase.getValue())) { String tName = e.select("table").first().attr("name"); String fName = e.select("family").first().text(); this.hconfig = new HBaseConfig(tName, fName); } else if (this.type.equalsIgnoreCase(StorageType.mongodb.getValue())) { String dbName = e.select("db").first().attr("name"); String collection = e.select("collection").first().text(); String port = e.select("port").text(); String host = e.select("host").text(); this.mongodbConfig = new MongodbConfig(dbName, collection, host, port); } else if (this.type.equalsIgnoreCase(StorageType.mysql.getValue())) { } else if (this.type.equalsIgnoreCase(StorageType.elasticsearch.getValue())) { } // id? String idPolicy = e.select("idPolicy").text(); if (StringUtils.isNotBlank(idPolicy)) { id = EnumUtils.getEnum(IDPolicy.class, idPolicy); if (!IDPolicy.auto.equals(id)) { String pref = e.select("ref").text(); if (StringUtils.isNotBlank(pref)) { this.policyRef = pref; } if (StringUtils.isBlank(this.policyRef)) { try { throw new ConfigurationException("ID??"); } catch (Exception e2) { e2.printStackTrace(); } } } } return this; }
From source file:org.efaps.admin.index.Searcher.java
/** * Search./* ww w . java 2 s . c o m*/ * * @param _search the search * @return the search result * @throws EFapsException on error */ protected SearchResult executeSearch(final ISearch _search) throws EFapsException { final SearchResult ret = new SearchResult(); try { LOG.debug("Starting search with: {}", _search.getQuery()); final StandardQueryParser queryParser = new StandardQueryParser(Index.getAnalyzer()); queryParser.setAllowLeadingWildcard(true); if (EFapsSystemConfiguration.get().containsAttributeValue(KernelSettings.INDEXDEFAULTOP)) { queryParser.setDefaultOperator(EnumUtils.getEnum(StandardQueryConfigHandler.Operator.class, EFapsSystemConfiguration.get().getAttributeValue(KernelSettings.INDEXDEFAULTOP))); } else { queryParser.setDefaultOperator(StandardQueryConfigHandler.Operator.AND); } final Query query = queryParser.parse(_search.getQuery(), "ALL"); final IndexReader reader = DirectoryReader.open(Index.getDirectory()); Sort sort = _search.getSort(); if (sort == null) { sort = new Sort(new SortField(Key.CREATED.name(), SortField.Type.LONG, true)); } final FacetsConfig facetConfig = Index.getFacetsConfig(); final DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(Index.getTaxonomyDirectory()); final IndexSearcher searcher = new IndexSearcher(reader); final FacetsCollector fc = new FacetsCollector(); final TopFieldDocs topFieldDocs = FacetsCollector.search(searcher, query, _search.getNumHits(), sort, fc); if (_search.getConfigs().contains(SearchConfig.ACTIVATE_DIMENSION)) { final Facets facets = new FastTaxonomyFacetCounts(taxoReader, facetConfig, fc); for (final FacetResult result : facets.getAllDims(1000)) { LOG.debug("FacetResult {}.", result); final DimConfig dimConfig = facetConfig.getDimConfig(result.dim); final Dimension retDim = new Dimension().setKey(result.dim); ret.getDimensions().add(retDim); for (final LabelAndValue labelValue : result.labelValues) { final DimValue dimValue = new DimValue().setLabel(labelValue.label) .setValue(labelValue.value.intValue()); dimValue.setPath(new String[] { retDim.getKey() }); retDim.getValues().add(dimValue); if (dimConfig.hierarchical) { addSubDimension(facets, dimValue, result.dim, labelValue.label); } } } } ret.setHitCount(topFieldDocs.totalHits); if (ret.getHitCount() > 0) { final ScoreDoc[] hits = topFieldDocs.scoreDocs; LOG.debug("Found {} hits.", hits.length); for (int i = 0; i < hits.length; ++i) { final Document doc = searcher.doc(hits[i].doc); final String oid = doc.get(Key.OID.name()); final String text = doc.get(Key.MSGPHRASE.name()); LOG.debug("{}. {}\t {}", i + 1, oid, text); final Instance instance = Instance.get(oid); final List<Instance> list; if (this.typeMapping.containsKey(instance.getType())) { list = this.typeMapping.get(instance.getType()); } else { list = new ArrayList<Instance>(); this.typeMapping.put(instance.getType(), list); } list.add(instance); final Element element = new Element().setOid(oid).setText(text); for (final Entry<String, Collection<String>> entry : _search.getResultFields().entrySet()) { for (final String name : entry.getValue()) { final String value = doc.get(name); if (value != null) { element.addField(name, value); } } } this.elements.put(instance, element); } } reader.close(); checkAccess(); ret.getElements().addAll(this.elements.values()); } catch (final IOException | QueryNodeException e) { LOG.error("Catched Exception", e); } return ret; }
From source file:org.efaps.admin.ui.field.Filter.java
/** * Setter method for instance variable {@link #base}. * * @param _baseName value for instance variable {@link #base} *//* w ww . j a v a 2 s . co m*/ protected void evalBase(final String _baseName) { final FilterBase baseTmp = EnumUtils.getEnum(FilterBase.class, _baseName.toUpperCase()); if (baseTmp != null) { this.base = baseTmp; } activate(); }