protected List<String> getFieldNames( String fieldNamespace, String fieldName, ServiceContext serviceContext) { String[] fieldsDisplayValues = StringUtil.split( (String) serviceContext.getAttribute(fieldNamespace + FIELDS_DISPLAY_NAME)); List<String> privateFieldNames = ListUtil.fromArray(new String[] {FIELDS_DISPLAY_NAME}); List<String> fieldNames = new ArrayList<>(); if ((fieldsDisplayValues.length == 0) || privateFieldNames.contains(fieldName)) { fieldNames.add(fieldNamespace + fieldName); } else { for (String namespacedFieldName : fieldsDisplayValues) { String fieldNameValue = StringUtil.extractFirst(namespacedFieldName, INSTANCE_SEPARATOR); if (fieldNameValue.equals(fieldName)) { fieldNames.add(fieldNamespace + namespacedFieldName); } } } return fieldNames; }
protected int countFieldRepetition(String[] fieldsDisplayValues, String fieldName) { int count = 0; for (String fieldsDisplayValue : fieldsDisplayValues) { String prefix = StringUtil.extractFirst(fieldsDisplayValue, INSTANCE_SEPARATOR); if (prefix.equals(fieldName)) { count++; } } return count; }
@Override public String[] getFieldsDisplayValues(Field fieldsDisplayField) throws Exception { DDMStructure ddmStructure = fieldsDisplayField.getDDMStructure(); List<String> fieldsDisplayValues = new ArrayList<>(); String[] values = splitFieldsDisplayValue(fieldsDisplayField); for (String value : values) { String fieldName = StringUtil.extractFirst(value, DDMImpl.INSTANCE_SEPARATOR); if (ddmStructure.hasField(fieldName)) { fieldsDisplayValues.add(fieldName); } } return fieldsDisplayValues.toArray(new String[fieldsDisplayValues.size()]); }