use of com.servoy.j2db.server.ngclient.property.FoundsetLinkedPropertyType 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;
}
use of com.servoy.j2db.server.ngclient.property.FoundsetLinkedPropertyType in project servoy-client by Servoy.
the class ValueListPropertyType method getDependenciesToOtherProperties.
protected ValuelistPropertyDependencies getDependenciesToOtherProperties(PropertyDescription pd, IPropertyDescriptionProvider propertyDescriptionProvider) {
ValueListConfig config = (ValueListConfig) pd.getConfig();
String dataproviderPropertyName = config.getFor();
String foundsetPropertyName = null;
// this is really only used I think when you have a custom valuelist with date values (without separate display values) - to convert the String defined dates in the custom valuelist into actual Date values
String formatPropertyName = null;
boolean dataproviderResolveValuelist = false;
if (dataproviderPropertyName != null) {
PropertyDescription dpPropertyDef = propertyDescriptionProvider.getPropertyDescription(dataproviderPropertyName);
Object dpConfig = null;
if (dpPropertyDef != null) {
dpConfig = dpPropertyDef.getConfig();
}
if (dpPropertyDef != null && (dpPropertyDef.getType() instanceof FoundsetLinkedPropertyType)) {
foundsetPropertyName = ((FoundsetLinkedConfig) dpPropertyDef.getConfig()).getForFoundsetName();
dpConfig = ((FoundsetLinkedConfig) dpPropertyDef.getConfig()).getWrappedPropertyDescription().getConfig();
}
if (dpConfig instanceof DataproviderConfig && ((DataproviderConfig) dpConfig).shouldResolveValuelist()) {
dataproviderResolveValuelist = true;
}
}
Collection<PropertyDescription> properties = propertyDescriptionProvider.getProperties(FormatPropertyType.INSTANCE);
for (PropertyDescription formatPd : properties) {
// compare whether format and valueList property are for same property (dataprovider) or if format is used for valuelist property itself
if (formatPd.getConfig() instanceof String[] && ((String[]) formatPd.getConfig()).length > 0) {
for (String formatForClauseEntry : ((String[]) formatPd.getConfig())) {
if (dataproviderPropertyName.equals(formatForClauseEntry) || pd.getName().equals(formatForClauseEntry)) {
formatPropertyName = formatPd.getName();
break;
}
}
// there can/should be only one format property for a specific valuelist; we found it
if (formatPropertyName != null)
break;
}
}
return new ValuelistPropertyDependencies(dataproviderPropertyName, foundsetPropertyName, formatPropertyName, dataproviderResolveValuelist);
}
Aggregations