if(fieldSet == null)
return;
for(Field field : fieldSet)
{
CommonField commonField = new CommonField();
commonField.setId(field.getId().toString());
commonField.setName(field.getName());
commonField.setType(field.getType().toString().split("\\_")[1]);
if(field.getDataType() != null)
commonField.setDataType(field.getDataType().toString().split("\\_")[1]);
fieldMap.put(commonField.getId(), commonField);
if(field.getType().equals(Field.Type.t_selection))
{
if(field.getOptions() != null && field.getOptions().size() > 0)
{
fieldOptionMap.put(commonField.getId(), new TreeSet<CommonOption>());
for(Option option : field.getOptions())
{
CommonOption commonOption = new CommonOption();
commonOption.setId(option.getId().toString());
commonOption.setName(option.getName());
fieldOptionMap.get(commonField.getId()).add(commonOption);
}
}
}
else if(field.getType().equals(Field.Type.t_reference))
{
Data[] referenceArray = das.queryTemplateFieldReferences(templateId, field.getId());
if(referenceArray != null && referenceArray.length > 0)
{
fieldOptionMap.put(commonField.getId(), new TreeSet<CommonOption>());
for(Data reference : referenceArray)
{
CommonOption commonOption = new CommonOption();
commonOption.setId(reference.getId().toString());
commonOption.setName(reference.getTitle());
fieldOptionMap.get(commonField.getId()).add(commonOption);
}
}
}
else if(field.getType().equals(Field.Type.t_attachment))
{
Attachment[] attachmentArray = das.queryTemplateFieldAttachments(templateId, field.getId());
if(attachmentArray != null && attachmentArray.length > 0)
{
fieldOptionMap.put(commonField.getId(), new TreeSet<CommonOption>());
for(Attachment attachment : attachmentArray)
{
CommonOption commonOption = new CommonOption();
commonOption.setId(attachment.getId().toString());
commonOption.setName(attachment.getName());
fieldOptionMap.get(commonField.getId()).add(commonOption);
}
}
}
}
}