use of com.servoy.j2db.server.ngclient.IContextProvider in project servoy-client by Servoy.
the class MediaPropertyType method wrap.
@Override
public MediaWrapper wrap(Object value, MediaWrapper previousValue, PropertyDescription propertyDescription, IWrappingContext dataConverterContext) {
if (previousValue != null && Utils.equalObjects(value, previousValue.mediaUrl)) {
return previousValue;
}
IServoyDataConverterContext servoyDataConverterContext = ((IContextProvider) dataConverterContext.getWebObject()).getDataConverterContext();
FlattenedSolution flattenedSolution = servoyDataConverterContext.getSolution();
INGApplication application = servoyDataConverterContext.getApplication();
String url = getMediaUrl(value, flattenedSolution, application);
if (url != null)
return new MediaWrapper(value, url);
if (value != null && !Utils.equalObjects(value, Integer.valueOf(0)))
Debug.log("cannot convert media " + value + " using converter context " + servoyDataConverterContext);
return null;
}
use of com.servoy.j2db.server.ngclient.IContextProvider in project servoy-client by Servoy.
the class RecordPropertyType method fromJSON.
@Override
public IRecordInternal fromJSON(Object newJSONValue, IRecordInternal previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
IRecordInternal record = null;
if (newJSONValue instanceof JSONObject) {
JSONObject jsonRecord = (JSONObject) newJSONValue;
BaseWebObject webObject = dataConverterContext.getWebObject();
if (webObject != null && jsonRecord.has(FoundsetTypeSabloValue.ROW_ID_COL_KEY)) {
String rowIDValue = jsonRecord.optString(FoundsetTypeSabloValue.ROW_ID_COL_KEY);
Pair<String, Integer> splitHashAndIndex = FoundsetTypeSabloValue.splitPKHashAndIndex(rowIDValue);
if (jsonRecord.has(FoundsetTypeSabloValue.FOUNDSET_ID)) {
int foundsetID = Utils.getAsInteger(jsonRecord.get(FoundsetTypeSabloValue.FOUNDSET_ID));
if (foundsetID >= 0 && webObject instanceof IContextProvider) {
IFoundSetInternal foundset = ((IContextProvider) webObject).getDataConverterContext().getApplication().getFoundSetManager().findFoundset(foundsetID);
if (foundset != null) {
int recordIndex = foundset.getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
if (recordIndex != -1) {
return foundset.getRecord(recordIndex);
}
}
}
}
Collection<PropertyDescription> properties = webObject.getSpecification().getProperties(FoundsetPropertyType.INSTANCE);
for (PropertyDescription foundsetPd : properties) {
FoundsetTypeSabloValue fsSablo = (FoundsetTypeSabloValue) webObject.getProperty(foundsetPd.getName());
int recordIndex = fsSablo.getFoundset().getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
if (recordIndex != -1) {
record = fsSablo.getFoundset().getRecord(recordIndex);
break;
}
}
}
if (// $NON-NLS-1$
record == null && jsonRecord.has("recordhash")) {
// $NON-NLS-1$
record = getReference(jsonRecord.optString("recordhash"));
}
}
return record;
}
use of com.servoy.j2db.server.ngclient.IContextProvider in project servoy-client by Servoy.
the class TagStringPropertyType method toSabloComponentValue.
@Override
public BasicTagStringTypeSabloValue toSabloComponentValue(Object rhinoValue, BasicTagStringTypeSabloValue previousComponentValue, PropertyDescription pd, IWebObjectContext componentOrService) {
if (rhinoValue != null && !RhinoConversion.isUndefinedOrNotFound(rhinoValue)) {
// this code can interpret the new value as a static one or a a tag-aware one depending on the property's config: USE_PARSED_VALUE_IN_RHINO_CONFIG_OPT
String newDesignValue = rhinoValue instanceof String ? (String) rhinoValue : rhinoValue.toString();
DataAdapterList dal = previousComponentValue != null ? previousComponentValue.getDataAdapterList() : null;
if (dal == null && componentOrService != null && componentOrService.getUnderlyingWebObject() instanceof WebFormComponent) {
dal = (DataAdapterList) ((WebFormComponent) componentOrService.getUnderlyingWebObject()).getDataAdapterList();
}
return createNewTagStringTypeSabloValue(newDesignValue, dal, !((TagStringConfig) pd.getConfig()).useParsedValueInRhino(), true, pd, componentOrService.getUnderlyingWebObject() instanceof WebFormComponent ? ((WebFormComponent) componentOrService.getUnderlyingWebObject()) : null, ((IContextProvider) componentOrService.getUnderlyingWebObject()).getDataConverterContext().getApplication(), false);
}
return null;
}
use of com.servoy.j2db.server.ngclient.IContextProvider in project servoy-client by Servoy.
the class FormPropertyType method toRhinoValue.
@Override
public Object toRhinoValue(Object webComponentValue, PropertyDescription pd, IWebObjectContext webObjectContext, Scriptable startScriptable) {
if (webComponentValue instanceof Form) {
return ((Form) webComponentValue).getName();
} else {
if (webComponentValue != null && webObjectContext != null && webObjectContext.getUnderlyingWebObject() instanceof IContextProvider) {
// form is stored as uuid on disk
FlattenedSolution solution = ((IContextProvider) webObjectContext.getUnderlyingWebObject()).getDataConverterContext().getSolution();
Form form = solution.getForm(webComponentValue.toString());
if (form == null) {
form = (Form) solution.searchPersist(webComponentValue.toString());
}
if (form != null) {
return form.getName();
}
}
}
return webComponentValue;
}
use of com.servoy.j2db.server.ngclient.IContextProvider in project servoy-client by Servoy.
the class TitleStringPropertyType method toSabloComponentDefaultValue.
/*
* (non-Javadoc)
*
* @see com.servoy.j2db.server.ngclient.property.types.NGConversions.IFormElementDefaultValueToSabloComponent#toSabloComponentDefaultValue(org.sablo.
* specification.PropertyDescription, com.servoy.j2db.server.ngclient.INGFormElement, com.servoy.j2db.server.ngclient.WebFormComponent,
* com.servoy.j2db.server.ngclient.DataAdapterList)
*/
@Override
public BasicTagStringTypeSabloValue toSabloComponentDefaultValue(PropertyDescription pd, INGFormElement formElement, WebFormComponent component, DataAdapterList dataAdapterList) {
TitleStringConfig titleStringConfig = (TitleStringConfig) pd.getConfig();
String forDataprovider = titleStringConfig.getForDataprovider();
if (forDataprovider != null) {
PropertyDescription forProperty = formElement.getPropertyDescription(forDataprovider);
if (forProperty != null) {
IPropertyType<?> type = forProperty.getType();
if (type instanceof FoundsetLinkedPropertyType) {
Object config = forProperty.getConfig();
if (config instanceof FoundsetLinkedConfig && ((FoundsetLinkedConfig) config).getForFoundsetName() != null) {
String forFoundset = ((FoundsetLinkedConfig) config).getForFoundsetName();
String dataproviderID = (String) formElement.getPropertyValue(forDataprovider);
JSONObject foundsetValue = (JSONObject) formElement.getPropertyValue(forFoundset);
if (foundsetValue != null) {
String foundsetID = foundsetValue.optString(FoundsetPropertyType.FOUNDSET_SELECTOR);
INGApplication application = ((WebFormComponent) component.getUnderlyingWebObject()).getDataConverterContext().getApplication();
Form form = ((IContextProvider) component.getUnderlyingWebObject()).getDataConverterContext().getForm().getForm();
ITable table = FoundsetTypeSabloValue.getTableBasedOfFoundsetPropertyFromFoundsetIdentifier(foundsetID, application, form);
if (table != null) {
Column dataproviderColumn = table.getColumn(dataproviderID);
if (dataproviderColumn != null) {
return toSabloComponentValue(dataproviderColumn.getTitle(), pd, formElement, component, dataAdapterList);
}
}
}
}
}
}
}
return null;
}
Aggregations