use of org.jaffa.util.SplitString in project jaffa-framework by jaffa-projects.
the class FormDefinitionViewerComponent method loadFormTemplate.
// .//GEN-END:_addListeners_1_be
// All the custom code goes here//GEN-FIRST:_custom
public File loadFormTemplate() throws FrameworkException, ApplicationExceptions, IOException {
String formTemplate = getFormDefinitionViewerOutDto().getFormTemplate();
if (formTemplate != null) {
FormDefinitionViewerInDto inputDto = new FormDefinitionViewerInDto();
inputDto.setFormId(m_formId);
if (m_tx == null)
m_tx = (IFormDefinitionViewer) Factory.createObject(IFormDefinitionViewer.class);
byte[] formTemplateContents = m_tx.loadFormTemplate(inputDto);
// int i = formTemplate.lastIndexOf(".pdf");
// String prifix = i>0 ? formTemplate : formTemplate.substring(0,i);
// File formTemplateFile=File.createTempFile(prifix,"pdf");
SplitString ss = new SplitString(formTemplate, ".", false);
String suffix = ss.getSuffix() != null ? "." + ss.getSuffix() : null;
File formTemplateFile = File.createTempFile("jaffa", suffix);
OutputStream outputStream = null;
try {
outputStream = new BufferedOutputStream(new FileOutputStream(formTemplateFile));
outputStream.write(formTemplateContents);
outputStream.flush();
} finally {
if (outputStream != null)
outputStream.close();
}
return formTemplateFile;
}
return null;
}
use of org.jaffa.util.SplitString in project jaffa-framework by jaffa-projects.
the class MappingFilter method getFieldList.
private static void getFieldList(Class dao, List out, String prefix, boolean includeKeys) {
String lastField = null;
if (prefix != null) {
SplitString ss = new SplitString(prefix, ".", false);
if (ss.isValid())
lastField = ss.getSuffix();
else
lastField = ss.getPrefix();
}
GraphMapping mapper = MappingFactory.getInstance(dao);
if (mapper == null) {
log.error("Can't find mapping for class " + dao.getName());
return;
}
String[] fields = mapper.getDataFieldNames();
if (fields != null) {
for (int i = 0; i < fields.length; i++) {
String name = fields[i];
if (includeKeys || !mapper.isKeyField(name)) {
String fullName = name;
if (prefix != null)
fullName = prefix + name;
PropertyDescriptor pd = mapper.getDataFieldDescriptor(name);
if (pd != null && pd.getReadMethod() != null) {
Class c = pd.getReadMethod().getReturnType();
boolean array = c.isArray();
if (array)
c = c.getComponentType();
if (DomainDAO.class.isAssignableFrom(c)) {
if (lastField == null || !lastField.equals(name)) {
getFieldList(c, out, fullName + ".", array);
if (array)
fullName = "*" + fullName;
else
fullName = "+" + fullName;
} else {
log.debug("Stopped Recursion @ Path=" + fullName);
fullName = null;
}
}
} else
log.debug("Can't introspect field " + name);
if (// Don't add if nulled out to prevent recursion
fullName != null)
out.add(fullName);
}
}
}
}
Aggregations