use of com.servoy.j2db.util.UUID in project servoy-client by Servoy.
the class FormPropertyType method toTemplateJSONValue.
@Override
public JSONWriter toTemplateJSONValue(JSONWriter writer, String key, Object formElementValue, PropertyDescription pd, DataConversion browserConversionMarkers, FormElementContext formElementContext) throws JSONException {
if (formElementValue == null)
return writer;
FlattenedSolution fs = formElementContext.getFlattenedSolution();
Form form = null;
if (formElementValue instanceof Integer) {
form = fs.getForm(((Integer) formElementValue).intValue());
} else if (formElementValue instanceof String || formElementValue instanceof UUID) {
form = fs.getForm(formElementValue.toString());
if (form == null) {
form = (Form) fs.searchPersist(formElementValue.toString());
}
}
if (form != null) {
writer.key(key);
writer.value(form.getName());
if (CurrentWindow.safeGet() instanceof INGClientWindow) {
((INGClientWindow) CurrentWindow.get()).registerAllowedForm(form.getName(), formElementContext.getFormElement());
}
}
return writer;
}
use of com.servoy.j2db.util.UUID in project servoy-client by Servoy.
the class FormElementHelper method getFormComponentCache.
public FormComponentCache getFormComponentCache(INGFormElement formElement, PropertyDescription pd, JSONObject formElementValue, Form form, FlattenedSolution fs) {
ConcurrentMap<UUID, Map<String, FormComponentCache>> cache = formElement.getDesignId() != null ? formComponentElementsForDesign : formComponentElements;
Solution solutionCopy = fs.getSolutionCopy(false);
FlattenedSolution usedFS = getSharedFlattenedSolution(fs);
if (solutionCopy != null && solutionCopy.getForm(formElement.getForm().getName()) != null) {
usedFS = fs;
// if the form is a solution model for we can't use the standard caches.
cache = solutionCopy.getRuntimeProperty(SOLUTION_MODEL_CACHE);
if (cache == null) {
cache = new ConcurrentHashMap<UUID, Map<String, FormComponentCache>>();
solutionCopy.setRuntimeProperty(SOLUTION_MODEL_CACHE, cache);
}
}
return getFormComponentFromCache(formElement, pd, formElementValue, form, usedFS, cache);
}
use of com.servoy.j2db.util.UUID in project servoy-client by Servoy.
the class JSDatabaseManager method js_convertToDataSet.
/**
* @clonedesc js_convertToDataSet(IFoundSetInternal)
*
* @sampleas js_convertToDataSet(IFoundSetInternal)
*
* @param values The values array.
* @param dataproviderNames The property names array.
*
* @return JSDataSet with the data.
*/
public JSDataSet js_convertToDataSet(Object[] values, String[] dataproviderNames) {
if (values == null) {
return null;
}
// $NON-NLS-1$
String[] dpnames = { "id" };
ColumnType[] dptypes = { ColumnType.getInstance(IColumnTypes.INTEGER, Integer.MAX_VALUE, 0) };
List<Object[]> lst = new ArrayList<Object[]>();
Object[] array = values;
if (dataproviderNames != null) {
dpnames = dataproviderNames;
}
Map<String, Method> getters = new HashMap<String, Method>();
for (Object o : array) {
if (o instanceof Number || o instanceof String || o instanceof UUID || o instanceof Date) {
if (o instanceof Double && ((Double) o).doubleValue() == ((Double) o).intValue()) {
o = new Integer(((Double) o).intValue());
}
lst.add(new Object[] { o });
} else if (o instanceof Scriptable) {
List<Object> row = new ArrayList<Object>();
for (String dpname : dpnames) {
if (((Scriptable) o).has(dpname, (Scriptable) o))
row.add(ScriptVariableScope.unwrap(((Scriptable) o).get(dpname, (Scriptable) o)));
}
if (dpnames.length != row.size() || dpnames.length == 0) {
// for backward compatibility
lst.add(new Object[] { o });
} else {
lst.add(row.toArray());
}
} else if (o != null) {
// try reflection
List<Object> row = new ArrayList<Object>();
for (String dpname : dpnames) {
Method m = getMethod(o, dpname, getters);
if (m != null) {
try {
row.add(m.invoke(o, (Object[]) null));
} catch (Exception e) {
Debug.error(e);
}
}
}
if (dpnames.length != row.size() || dpnames.length == 0) {
// for backward compatibility
lst.add(new Object[] { o });
} else {
lst.add(row.toArray());
}
}
}
return new JSDataSet(application, BufferedDataSetInternal.createBufferedDataSet(dpnames, dptypes, lst, false));
}
Aggregations