List of usage examples for org.apache.commons.lang3 EnumUtils isValidEnum
public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass, final String enumName)
Checks if the specified name is a valid enum for the class.
This method differs from Enum#valueOf in that checks if the name is a valid enum without needing to catch the exception.
From source file:org.aksw.mex.log4mex.Execution.java
/*** * add PerformanceMeasure (related to OverallExecution) * @param m//ww w. j a v a 2 s . c o m * @param v * @return */ public void addPerformance(MEXEnum.EnumMeasures m, double v) throws Exception { String type = ""; String p = m.toString().replace("_", "").toUpperCase(); String paux = m.toString().replace("_", ""); boolean ret = false; try { type = "cla"; if (EnumUtils.isValidEnum(MEXEnum.EnumClassificationMeasure.class, p) == false) { type = "reg"; if (EnumUtils.isValidEnum(MEXEnum.EnumRegressionMeasure.class, p) == false) { type = "sta"; if (EnumUtils.isValidEnum(MEXEnum.EnumStatisticalMeasure.class, p) == false) { type = "clu"; if (EnumUtils.isValidEnum(MEXEnum.EnumClusteringMeasure.class, p) == false) { throw new Exception("measure has not been found: " + m.toString()); } } } } switch (type) { case "cla": addClassificationPerformance(paux, v); break; case "reg": addRegressionPerformance(paux, v); break; case "sta": addStatisticalPerformance(paux, v); break; case "clu": addClusteringPerformance(paux, v); break; default: throw new Exception("measure has not been found: " + p); } } catch (Exception e) { throw (e); } }
From source file:org.anc.lapps.nlp4j.NLP4JCustomTrain.java
/** This method takes in the input data and returns its parameters as an array of strings, * representing the parameters as they would be written to run the jar files from command-line, * to be given as input to the main classes. * * @param data A Data object/*w ww.j a v a2 s . c om*/ * @param outputDirPath A Path to the output directory * @param inputDirPath A Path to the input directory * @return A String representing the parameters of the Data object. */ protected String convertParameters(Data<String> data, Path outputDirPath, Path inputDirPath) throws IOException { StringBuilder params = new StringBuilder(); // Get the payload and convert it back into a HashMap to get all input content from it. String payloadJson = data.getPayload(); Map<String, String> payload = Serializer.parse(payloadJson, HashMap.class); // This boolean for development will be set to true if at least one of the keys corresponds // to a development file. This is needed since this is an optional parameter that might take // multiple input files. boolean developBool = false; // These are the parameters for training that give input. // Since the input can include many train and development files, we process // all keys expecting their labels to include "train", "dev", or "config." for (String key : payload.keySet()) { // If the input file is a train file, we take its content and save it to a // temporary file in the input directory. The entire directory will be given // as the train directory path, and the extension ".trn" will be specified // to distinguish the train files. if (key.contains("train")) { String fileContent = payload.get(key); writeTempFile(key, inputDirPath, fileContent, ".trn"); } // If the input file is a development file, we take its content and save it to a // temporary file in the input directory, after setting the boolean to true. // The entire directory will be given as the development directory path and the // extension ".dev" will be specified to distinguish the development files. else if (key.contains("develop")) { developBool = true; String fileContent = payload.get(key); writeTempFile(key, inputDirPath, fileContent, ".dev"); } // TODO: Add prev for previously trained models: -p } // Add the train directory parameter with the input directory path as an argument, // and specify the "trn" extension for train files. params.append(" -t ").append(inputDirPath).append(" -te trn"); // If the boolean is set to true, add the development directory parameter with the // input directory path as an argument, and specify the "dev" extension for train files. if (developBool) { params.append(" -d ").append(inputDirPath).append(" -de dev"); } if (data.getParameter("mode") != null) { String givenMode = (String) data.getParameter("mode"); if (!EnumUtils.isValidEnum(NLPMode.class, givenMode)) { StringBuilder errorMsg = new StringBuilder("MODE ERROR;"); errorMsg.append(givenMode); return errorMsg.toString(); } params.append(" -mode ").append(data.getParameter("mode")); } // "Name not implemented for Online component." if (data.getParameter("saveModel") != null) { params.append(" -m ").append(outputDirPath).append("/").append(data.getParameter("saveModel")) .append(".xz"); } if (data.getParameter("cv") != null) { params.append(" -cv ").append(data.getParameter("cv")); } // Return the resulting list of parameters to be processed as an array // and given as input to the NLP4J Train main method. return params.toString(); }
From source file:org.anc.lapps.nlp4j.NLP4JCustomTrain.java
/** This method creates the appropriate configuration file in the given temporary input * directory, and returns the path to that file as a String. * * @param dir The path to input directory in which the configuration file should be created * @param inputData The input data from which to extract configuration details * @return A String representing the path to the created configuration file. *///from w ww .j a va 2 s . c om protected String makeConfigFile(Path dir, Data<String> inputData) throws IOException { // This will hold the text for the configuration file, which is in XML format. StringBuilder configTxt = new StringBuilder("<configuration>\r\n"); // START OF TSV FORMAT // Create an array of strings that will hold the field indices, if they are specified String[] tsvIndices = null; String indicesString = ""; // Split the indices by commas, and remove whitespaces to have an array representing // all indices for the corresponding fields if (inputData.getParameter("tsv-indices") != null) { indicesString = (String) inputData.getParameter("tsv-indices"); tsvIndices = indicesString.split(",[ ]*"); } if (inputData.getParameter("tsv-fields") != null) { String fieldsString = (String) inputData.getParameter("tsv-fields"); // Split and remove white spaces String[] tsvFields = fieldsString.split(",[ ]*"); configTxt.append(" <tsv>\r\n"); // If the indices are specified, add each field to its respective index if (tsvIndices != null) { String index, field; for (int i = 0; i < tsvFields.length; i++) { try { index = tsvIndices[i]; field = tsvFields[i]; } // If any field does not have a corresponding index, and the indices // are specified, return a string specifying that there is an error, // which will be handled by the execute function after returning. // (We return a String here and then handle the error in execute in // order to wrap the error appropriately before returning it to the user) catch (IndexOutOfBoundsException e) { StringBuilder errorMsg = new StringBuilder("INDEX ERROR;"); errorMsg.append(indicesString).append(";").append(fieldsString); return errorMsg.toString(); } configTxt.append(" <column index=\"").append(index); configTxt.append("\" field=\"").append(field).append("\"/>\r\n"); } } // If the indices are not specified, assume the fields are listed in the order // they appear in the tsv file, starting with index 0. In this case, go through the // fields and use the index of each field as its index in the configuration file. else { for (int i = 0; i < tsvFields.length; i++) { String field = tsvFields[i]; configTxt.append(" <column index=\"").append(i); configTxt.append("\" field=\"").append(field).append("\"/>\r\n"); } } configTxt.append(" </tsv>\r\n\r\n"); } // END OF TSV FORMAT // START OF LEXICA // This is the path for all lexica dependent files String lexicaPath = "src/main/resources/lexica/"; // A boolean that will be set to true when the first lexical parameter is set. // This is needed because we don't know which, if any, of the components will be // specified, thus we don't know if the lexica header is needed. boolean lexicaSet = false; if (inputData.getParameter("ambiguity") != null) { // Three arrays holding the names, which users can choose from, and their // corresponding filenames and field names String[] ambiguityNames = { "simplified", "simplified-lowercase" }; String[] ambiguityFiles = { "en-ambiguity-classes-simplified.xz", "en-ambiguity-classes-simplified-lowercase.xz" }; String[] ambiguityFields = { "word_form_simplified", "word_form_simplified_lowercase" }; if (!lexicaSet) { lexicaSet = true; configTxt.append(" <lexica>\r\n"); } String givenName = (String) inputData.getParameter("ambiguity"); StringBuilder ambiguityTxt = null; int index = 0; // Loop through the possible names and complete the corresponding XML format for the // configuration file using the index that matches the given name while ((ambiguityTxt == null) && (index < ambiguityNames.length)) { if (ambiguityNames[index] == givenName) { ambiguityTxt = new StringBuilder(" <ambiguity_classes field=\""); ambiguityTxt.append(ambiguityFields[index]).append("\">").append(lexicaPath); ambiguityTxt.append(ambiguityFiles[index]).append("</ambiguity_classes>\r\n"); } index++; } // If no names matches, the user gave an unknown name, thus return a string mentioning the error // which will be handled in the execute method and properly wrapped as an error data object // to be returned to the user if (ambiguityTxt == null) { StringBuilder errorMsg = new StringBuilder("AMBIGUITY ERROR;"); errorMsg.append(givenName); return errorMsg.toString(); } else { configTxt.append(ambiguityTxt); } } if (inputData.getParameter("clusters") != null) { // Three arrays holding the names, which users can choose from, and their // corresponding filenames and field names String[] clustersNames = { "brown-simplified-lc", "brown-twit-lc" }; String[] clustersFiles = { "en-brown-clusters-simplified-lowercase.xz", "en-brown-clusters-twit-lowercase.xz" }; String[] clustersFields = { "word_form_simplified_lowercase", "word_form_lowercase" }; if (!lexicaSet) { lexicaSet = true; configTxt.append(" <lexica>\r\n"); } String givenName = (String) inputData.getParameter("clusters"); StringBuilder clustersTxt = null; int index = 0; // Loop through the possible names and complete the corresponding XML format for the // configuration file using the index that matches the given name while ((clustersTxt == null) && (index < clustersNames.length)) { if (clustersNames[index] == givenName) { clustersTxt = new StringBuilder(" <word_clusters field=\""); clustersTxt.append(clustersFields[index]).append("\">").append(lexicaPath); clustersTxt.append(clustersFiles[index]).append("</word_clusters>\r\n"); } index++; } // If no names matches, the user gave an unknown name, thus return a string mentioning the error // which will be handled in the execute method and properly wrapped as an error data object // to be returned to the user if (clustersTxt == null) { StringBuilder errorMsg = new StringBuilder("CLUSTERS ERROR;"); errorMsg.append(givenName); return errorMsg.toString(); } else { configTxt.append(clustersTxt); } } if (inputData.getParameter("gazetteers") != null) { // Three arrays holding the names, which users can choose from, and their // corresponding filenames and field names String[] namedEntityNames = { "simplified", "simplified-lowercase" }; String[] namedEntityFiles = { "en-named-entity-gazetteers-simplified.xz", "en-named-entity-gazetteers-simplified-lowercase.xz" }; String[] namedEntityFields = { "word_form_simplified", "word_form_simplified_lowercase" }; if (!lexicaSet) { lexicaSet = true; configTxt.append(" <lexica>\r\n"); } String givenName = (String) inputData.getParameter("gazetteers"); StringBuilder NETxt = null; int index = 0; // Loop through the possible names and complete the corresponding XML format for the // configuration file using the index that matches the given name while ((NETxt == null) && (index < namedEntityNames.length)) { if (namedEntityNames[index] == givenName) { NETxt = new StringBuilder(" <named_entity_gazetteers field=\""); NETxt.append(namedEntityFields[index]).append("\">").append(lexicaPath); NETxt.append(namedEntityFiles[index]).append("</named_entity_gazetteers>\r\n"); } index++; } // If no names matches, the user gave an unknown name, thus return a string mentioning the error // which will be handled in the execute method and properly wrapped as an error data object // to be returned to the user if (NETxt == null) { StringBuilder errorMsg = new StringBuilder("NAMED ENTITY ERROR;"); errorMsg.append(givenName); return errorMsg.toString(); } else { configTxt.append(NETxt); } } if (inputData.getParameter("embeddings") != null) { // Three arrays holding the names, which users can choose from, and their // corresponding filenames and field names String[] embeddingsNames = { "undigitalized" }; String[] embeddingsFiles = { "en-word-embeddings-undigitalized.xz" }; String[] embeddingsFields = { "word_form_undigitalized" }; if (!lexicaSet) { lexicaSet = true; configTxt.append(" <lexica>\r\n"); } String givenName = (String) inputData.getParameter("embeddings"); StringBuilder embeddingsTxt = null; int index = 0; // Loop through the possible names and complete the corresponding XML format for the // configuration file using the index that matches the given name while ((embeddingsTxt == null) && (index < embeddingsNames.length)) { if (embeddingsNames[index] == givenName) { embeddingsTxt = new StringBuilder(" <word_embeddings field=\""); embeddingsTxt.append(embeddingsFields[index]).append("\">").append(lexicaPath); embeddingsTxt.append(embeddingsFiles[index]).append("</word_embeddings>\r\n"); } index++; } // If no names matches, the user gave an unknown name, thus return a string mentioning the error // which will be handled in the execute method and properly wrapped as an error data object // to be returned to the user if (embeddingsTxt == null) { StringBuilder errorMsg = new StringBuilder("EMBEDDINGS ERROR;"); errorMsg.append(givenName); return errorMsg.toString(); } else { configTxt.append(embeddingsTxt); } } // If no lexica was set, remove the heading added at the beginning // If lexica was set, end the lexica section in the XML file if (lexicaSet) { configTxt.append(" </lexica>\r\n\r\n"); } // END OF LEXICA // START OF OPTIMIZER if (inputData.getParameter("algorithm") != null) { String givenName = (String) inputData.getParameter("algorithm"); //ArrayList<String> algorithmNames = new ArrayList<>(); //algorithmNames.add("perceptron"); //algorithmNames.add("softmax-regression"); //algorithmNames.add("adagrad"); //algorithmNames.add("adagrad-mini-batch"); //algorithmNames.add("adagrad-regression"); //algorithmNames.add("adadelta-mini-batch"); //if(algorithmNames.contains(givenName)) if (!(givenName.equals("perceptron") || givenName.equals("softmax-regression") || givenName.equals("adagrad") || givenName.equals("adagrad-mini-batch") || givenName.equals("adagrad-regression") || givenName.equals("adadelta-mini-batch"))) { StringBuilder errorMsg = new StringBuilder("ALGORITHM ERROR;"); errorMsg.append(givenName); return errorMsg.toString(); } else { configTxt.append(" <optimizer>\r\n"); configTxt.append(" <algorithm>").append(givenName).append("</algorithm>\r\n"); if (inputData.getParameter("regularization") != null) { String givenNumber = (String) inputData.getParameter("regularization"); configTxt.append(" <l1_regularization>").append(givenNumber) .append("</l1_regularization>\r\n"); } if (inputData.getParameter("rate") != null) { String givenNumber = (String) inputData.getParameter("rate"); configTxt.append(" <learning_rate>").append(givenNumber).append("</learning_rate>\r\n"); } if (inputData.getParameter("cutoff") != null) { String givenNumber = (String) inputData.getParameter("cutoff"); configTxt.append(" <feature_cutoff>").append(givenNumber) .append("</feature_cutoff>\r\n"); } boolean lolsSet = false; if (inputData.getParameter("lols-fixed") != null) { lolsSet = true; String givenNumber = (String) inputData.getParameter("lols-fixed"); configTxt.append(" <lols fixed=\"").append(givenNumber).append("\""); } if (inputData.getParameter("lols-decaying") != null) { String givenNumber = (String) inputData.getParameter("lols-decaying"); if (lolsSet) { configTxt.append(" decaying=\"").append(givenNumber).append("\"/>\r\n"); } // This is assuming that one can set decaying without fixed. // TODO: Check if this is possible else { configTxt.append(" <lols decaying=\"").append(givenNumber).append("\"/>\r\n"); } } if (inputData.getParameter("max-epoch") != null) { String givenNumber = (String) inputData.getParameter("max-epoch"); configTxt.append(" <max_epoch>").append(givenNumber).append("</max_epoch>\r\n"); } if (inputData.getParameter("batch-size") != null) { String givenNumber = (String) inputData.getParameter("batch-size"); configTxt.append(" <batch_size>").append(givenNumber).append("</batch_size>\r\n"); } if (inputData.getParameter("bias") != null) { String givenNumber = (String) inputData.getParameter("bias"); configTxt.append(" <bias>").append(givenNumber).append("</bias>\r\n"); } configTxt.append(" </optimizer>\r\n\r\n"); } } // END OF OPTIMIZER // START OF FEATURES // Before starting a counter and examining subsequent feature templates, check if the feature // indexed at 0 is specified, if so create the header for all feature templates then check // for further indices if ((inputData.getParameter("1-f0-source") != null) && (inputData.getParameter("1-f0-field") != null)) { configTxt.append(" <feature_template>\r\n"); boolean featureFound = true; boolean lineFound = true; // Counter holding the index of the current feature. int f = 0; // NLP4J starts feature indexing at 0 // Counter holding the index of the current feature line int i = 1; // Starts at 1 because we are checking for features within the first feature line // These Strings will hold the user variables String source, window, relation, field, value; // These Strings will hold the name of the parameter to be accessed // They will be changed to look for further features and further lines String sourceKey = "1-f0-source"; String windowKey = "1-f0-window"; String relationKey = "1-f0-relation"; String fieldKey = "1-f0-field"; String valueKey = "1-f0-value"; // These StringBuilders will be used to create the keys when changing the feature number // or line being checked StringBuilder sourceBuilder, windowBuilder, relationBuilder, fieldBuilder, valueBuilder; while (lineFound) { while (featureFound) { if ((inputData.getParameter(sourceKey) != null) && (inputData.getParameter(fieldKey) != null)) { featureFound = true; configTxt.append(" "); if (f == 0) { configTxt.append(" <feature "); } source = (String) inputData.getParameter(sourceKey); if (!EnumUtils.isValidEnum(Source.class, source)) { StringBuilder errorMsg = new StringBuilder("INVALID FEATURE SOURCE ERROR;"); errorMsg.append(source).append(";").append(i).append(";").append(f); return errorMsg.toString(); } configTxt.append("f").append(f); configTxt.append("=\"").append(source); if (inputData.getParameter(windowKey) != null) { window = (String) inputData.getParameter(windowKey); if (!((window.contains("-")) || (window.contains("+")))) { configTxt.append("+"); } configTxt.append(window); } if (inputData.getParameter(relationKey) != null) { relation = (String) inputData.getParameter(relationKey); if (!EnumUtils.isValidEnum(Relation.class, relation)) { StringBuilder errorMsg = new StringBuilder("INVALID FEATURE RELATION ERROR;"); errorMsg.append(source).append(";").append(i).append(";").append(f); return errorMsg.toString(); } configTxt.append("_").append(relation); } field = (String) inputData.getParameter(fieldKey); if (!EnumUtils.isValidEnum(Field.class, field)) { StringBuilder errorMsg = new StringBuilder("INVALID FEATURE FIELD ERROR;"); errorMsg.append(source).append(";").append(i).append(";").append(f); return errorMsg.toString(); } configTxt.append(":").append(field); if (inputData.getParameter(valueKey) != null) { value = (String) inputData.getParameter(valueKey); configTxt.append(":").append(value); } configTxt.append("\""); f++; } else { // If f is not 0, then there has been at least one feature on this line, which // means this line wasn't empty if (f != 0) { lineFound = true; featureFound = true; configTxt.append("/>\r\n"); f = 0; i++; } else { featureFound = false; lineFound = false; } } sourceBuilder = new StringBuilder(); sourceBuilder.append(i).append("-f").append(f).append("-source"); sourceKey = sourceBuilder.toString(); fieldBuilder = new StringBuilder(); fieldBuilder.append(i).append("-f").append(f).append("-field"); fieldKey = fieldBuilder.toString(); windowBuilder = new StringBuilder(); windowBuilder.append(i).append("-f").append(f).append("-window"); windowKey = windowBuilder.toString(); relationBuilder = new StringBuilder(); relationBuilder.append(i).append("-f").append(f).append("-relation"); relationKey = relationBuilder.toString(); valueBuilder = new StringBuilder(); valueBuilder.append(i).append("-f").append(f).append("-value"); valueKey = valueBuilder.toString(); } } configTxt.append(" </feature_template>\r\n\r\n"); } // END OF FEATURES configTxt.append("</configuration>"); Path filePath = writeTempFile("config", dir, configTxt.toString(), ".xml"); return filePath.toString().replace("\\", "/"); }
From source file:org.apache.sysml.parser.BuiltinConstant.java
public static boolean contains(String name) { return EnumUtils.isValidEnum(BuiltinConstant.class, name); }
From source file:org.craftercms.profile.utils.AccessTokenManagerCli.java
private TenantPermission readPermission() throws IOException { while (true) { String tenant = readLineCheckingForEmpty("Enter tenant name (use * for any tenant): "); String[] actions = readLineCheckingForEmpty("Enter allowed actions, separated by comma (valid actions " + "are " + StringUtils.join(TenantAction.values(), ", ") + " or * for any action): ") .split("\\s*,\\s*"); boolean validActions = true; if (!ArrayUtils.contains(actions, "*")) { for (String action : actions) { if (!EnumUtils.isValidEnum(TenantAction.class, action)) { stdOut.println("ERROR: Unrecognized tenant action '" + action + "'"); stdOut.flush();//from ww w . ja v a 2s . c om validActions = false; } } } if (validActions) { TenantPermission permission = new TenantPermission(tenant); permission.setAllowedActions(new HashSet<>(Arrays.asList(actions))); return permission; } } }
From source file:org.efaps.esjp.admin.index.Search_Base.java
/** * Inits the.//from w w w . j a v a2 s . c o m */ private void init() { if (!this.initialized) { try { this.initialized = true; this.resultFields = new LinkedHashMap<>(); this.resultLabels = new HashMap<>(); this.configs = new ArrayList<>(); // this should be replaced by an actual evaluation of which one // of the searches should be used final QueryBuilder indxQueryBldr = new QueryBuilder(CIAdminIndex.IndexSearch); indxQueryBldr.setLimit(1); final List<Instance> searches = indxQueryBldr.getCachedQuery(Search.CACHEKEY).execute(); Instance searchInst = null; if (!searches.isEmpty()) { searchInst = searches.get(0); } if (InstanceUtils.isValid(searchInst)) { final PrintQuery print = new CachedPrintQuery(searchInst, Search.CACHEKEY); print.addAttribute(CIAdminIndex.IndexSearch.Config, CIAdminIndex.IndexSearch.Name); print.execute(); this.name = print.getAttribute(CIAdminIndex.IndexSearch.Name); if (print.getAttribute(CIAdminIndex.IndexSearch.Config) != null) { this.configs = print.getAttribute(CIAdminIndex.IndexSearch.Config); } final QueryBuilder queryBldr = new QueryBuilder(CIAdminIndex.IndexSearchResultField); queryBldr.addWhereAttrEqValue(CIAdminIndex.IndexSearchResultField.SearchLink, searchInst); queryBldr.addOrderByAttributeAsc(CIAdminIndex.IndexSearchResultField.Priority); final MultiPrintQuery multi = queryBldr.getCachedPrint(Search.CACHEKEY); multi.setEnforceSorted(true); multi.addAttribute(CIAdminIndex.IndexSearchResultField.Key, CIAdminIndex.IndexSearchResultField.Label); multi.execute(); while (multi.next()) { final String key = multi.getAttribute(CIAdminIndex.IndexSearchResultField.Key); final String label = multi.getAttribute(CIAdminIndex.IndexSearchResultField.Label); final QueryBuilder keyQueryBldr = new QueryBuilder(CIAdminIndex.IndexSearchResultFieldKey); keyQueryBldr.addWhereAttrEqValue(CIAdminIndex.IndexSearchResultFieldKey.ResultFieldLink, multi.getCurrentInstance()); final MultiPrintQuery keyMulti = keyQueryBldr.getCachedPrint(Search.CACHEKEY); keyMulti.addAttribute(CIAdminIndex.IndexSearchResultField.Key); keyMulti.execute(); final Set<String> keys = new HashSet<>(); while (keyMulti.next()) { final String keyTmp = keyMulti .<String>getAttribute(CIAdminIndex.IndexSearchResultFieldKey.Key); if (EnumUtils.isValidEnum(Indexer.Key.class, keyTmp)) { keys.add(keyTmp); } else { keys.add(DBProperties.getProperty(keyTmp)); } } this.resultFields.put(key, keys); this.resultLabels.put(key, DBProperties.getProperty(label)); } } } catch (final EFapsException e) { LOG.error("Catched", e); } } }
From source file:org.efaps.tests.ci.form.FormValidation.java
/** * Does the field Property UIType has valid values. * @param _ciForm form to be checked./*from ww w.j a v a 2 s .co m*/ */ @Test(dataProvider = "CIForm", dataProviderClass = CIFormDataProvider.class, description = "Field Property 'UIType' must have a value from org.efaps.api.ui.UIType enum.") public void fieldPropertyUITypeValues(final CIForm _ciForm) { for (final CIFormDefinition def : _ciForm.getDefinitions()) { for (final CIFormField field : def.getFields()) { if (field.getCharacter() == null) { final CIFormFieldProperty property = field.getProperty("UIType"); if (property != null) { Assert.assertEquals(EnumUtils.isValidEnum(UIType.class, property.getValue()), true, String.format("Table: '%s', Field: '%s', Property 'UIType' value '%s' invalid.", def.getName(), field.getName(), property.getValue())); } } } } }
From source file:org.efaps.tests.ci.table.TableValidation.java
/** * Does the field attribute has valid values. * @param _ciTable form to be checked./*from w w w.j a v a 2s . c o m*/ */ @Test(dataProvider = "CITable", dataProviderClass = CITableDataProvider.class, description = "Field Property 'UIType' must have a value from org.efaps.api.ui.UIType enum.") public void fieldPropertyUITypeValues(final CITable _ciTable) { for (final CITableDefinition def : _ciTable.getDefinitions()) { for (final CITableField field : def.getFields()) { if (field.getCharacter() == null) { final CITableFieldProperty property = field.getProperty("UIType"); if (property != null) { Assert.assertEquals(EnumUtils.isValidEnum(UIType.class, property.getValue()), true, String.format("Table: '%s', Field: '%s', Property 'UIType' value '%s' invalid.", def.getName(), field.getName(), property.getValue())); } } } } }
From source file:org.efaps.ui.wicket.models.field.FieldConfiguration.java
/** * @return the UIType// www .j a va 2 s . co m */ public UIType getUIType() { final UIType ret; final String uiTypeStr = getProperty(UIFormFieldProperty.UI_TYPE); if (EnumUtils.isValidEnum(UIType.class, uiTypeStr)) { ret = UIType.valueOf(uiTypeStr); } else { ret = UIType.DEFAULT; } return ret; }
From source file:org.efaps.ui.wicket.models.field.UIPicker.java
/** * @param _field fieldPicker this UIObject belongs to * @param _parent parent field this fieldpicker belongs to * @throws CacheReloadException on error during access to command *//*from ww w . ja v a2 s . co m*/ public UIPicker(final FieldPicker _field, final AbstractInstanceObject _parent) throws CacheReloadException { this.cmdUUID = _field.getCommand().getUUID(); this.label = _field.getCommand().getLabelProperty(); this.parent = _parent; final String uiTypeStr = _field.getProperty("UIType"); if (EnumUtils.isValidEnum(UIType.class, uiTypeStr)) { this.uiType = UIType.valueOf(uiTypeStr); } else { this.uiType = UIType.DEFAULT; } }