Package org.cyclos.impl.system
Class ImportHelper
- java.lang.Object
-
- org.cyclos.impl.system.ImportHelper
-
public class ImportHelper extends Object
Helper methods for imports
-
-
Constructor Summary
Constructors Constructor Description ImportHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareAllEmptyValues(List<ImportedLineValue> values, String fieldId, ImportField... importFields)Returns true if all the values of the given fields are emptystatic intcountNumberOfLines(InputStream is)static Pair<String,String>extractCanonicalFieldAndId(String header)Returns the canonical field and the id of the given header.static List<String>getFieldIdsForPrefix(List<ImportedLineValue> values, String prefix)static StringgetFieldValue(List<ImportedLineValue> values, String fieldId)static StringgetFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField)static Map<String,String>getFieldValuesForPrefix(List<ImportedLineValue> values, String prefix)Returns an ordered map[K,V] where K is the field internal name and V is the value.static <DTO extends Bean>
voidsetFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField, DTO dto, Property<String,DTO> prop)static <DTO extends Bean>
voidsetFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField, DTO dto, Property<String,DTO> prop, String defaultValue)Finds the value (fieldValue) in the values set according to the fieldId and the importField.
-
-
-
Method Detail
-
areAllEmptyValues
public static boolean areAllEmptyValues(List<ImportedLineValue> values, String fieldId, ImportField... importFields)
Returns true if all the values of the given fields are empty
-
countNumberOfLines
public static int countNumberOfLines(InputStream is) throws IOException
- Throws:
IOException
-
extractCanonicalFieldAndId
public static Pair<String,String> extractCanonicalFieldAndId(String header)
Returns the canonical field and the id of the given header. For example, if the header is address[2].name it returns [address.name, 2]
-
getFieldIdsForPrefix
public static List<String> getFieldIdsForPrefix(List<ImportedLineValue> values, String prefix)
-
getFieldValue
public static String getFieldValue(List<ImportedLineValue> values, String fieldId)
-
getFieldValue
public static String getFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField)
-
getFieldValuesForPrefix
public static Map<String,String> getFieldValuesForPrefix(List<ImportedLineValue> values, String prefix)
Returns an ordered map[K,V] where K is the field internal name and V is the value. Used for Custom fields and transfer flows were the fields are like field.internalName
-
setFieldValue
public static <DTO extends Bean> void setFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField, DTO dto, Property<String,DTO> prop)
- See Also:
#setFieldValue(List, String, ImportField, EntityDTO, Property, String)
-
setFieldValue
public static <DTO extends Bean> void setFieldValue(List<ImportedLineValue> values, String fieldId, ImportField importField, DTO dto, Property<String,DTO> prop, String defaultValue)
Finds the value (fieldValue) in the values set according to the fieldId and the importField. If fieldValue is not null, then this value will be set to the specified property of the dto. If fieldValue is null, then the default value (if it's not null) will be set to the specified property of the dto- Parameters:
values- the list of values to be searchedfieldId- the id of the fieldimportField- the fielddto- the dto to be filledprop- the property of the dto to be filleddefaultValue-
-
-