I have 3 problems :
1/ I would like to display some ProductOption fields into an EntitySearchDialog which contains ProductOptionValues :
Code: Select all
getPresenterSequenceSetupManager().addOrReplaceItem(new PresenterSetupItem("subscriptionProductOptionValuesDS", new SubscriptionProductOptionValueDataSourceFactory(), new AsyncCallbackAdapter() {
@Override
public void onSetupSuccess(DataSource result) {
CustomCriteriaListGridDataSource productOptionValueSearchDataSource = (CustomCriteriaListGridDataSource)result;
subscriptionProductOptionValuesDS = productOptionValueSearchDataSource;
productOptionValueSearchDataSource.resetPermanentFieldVisibility(
"attributeValue",
//DISPLAY PRODUCT OPTION LABEL HERE
"productOption.label"
);
EntitySearchDialog productOptionValueSearchView = new EntitySearchDialog(productOptionValueSearchDataSource);
library.put("productOptionValueSearchView", productOptionValueSearchView);
}
}));
But the class ProductOptionValueImpl doesn't have the attribute "populateToOneFields=PopulateToOneFieldsEnum.TRUE" so i can't display productOption attributes (like label). Can i override it by xml or is there another way to display theses attributes ?
2/ The second problem is to retrieve productOptionValues (but with a custom query) so i have a CustomCriteriaListGridDataSource :
Code: Select all
public class SubscriptionProductOptionValueDataSourceFactory implements DataSourceFactory {
protected CustomCriteriaListGridDataSource dataSource = null;
public void createDataSource(String name, OperationTypes operationTypes, Object[] additionalItems, AsyncCallback<DataSource> cb) {
if (dataSource == null) {
operationTypes = new OperationTypes(OperationType.BASIC, OperationType.BASIC, OperationType.BASIC, OperationType.BASIC, OperationType.BASIC);
PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes, new String[]{}, new ForeignKey[]{});
persistencePerspective.addPersistencePerspectiveItem(PersistencePerspectiveItemType.FOREIGNKEY, new ForeignKey("productOption", EntityImplementations.PRODUCT_OPTION, null));
DataSourceModule[] modules = new DataSourceModule[]{
new BasicClientEntityModule(CeilingEntities.PRODUCT_OPTION_VALUE, persistencePerspective, AppServices.DYNAMIC_ENTITY)
};
CustomCriteriaListGridDataSource dataSource = new CustomCriteriaListGridDataSource(name, persistencePerspective, AppServices.DYNAMIC_ENTITY, modules, true, false, false, false, false);
dataSource.setCustomCriteria(new String[]{"searchSubscriptionProductOptionValuesList"});
dataSource.buildFields(null, false, cb);
} else {
if (cb != null) {
cb.onSuccess(dataSource);
}
}
}
}
A custom persistence handler, with an override on the fetch method :
Code: Select all
@Override
public DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
String ceilingEntityFullyQualifiedClassname = persistencePackage.getCeilingEntityFullyQualifiedClassname();
try {
PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
Map<String, FieldMetadata> originalProps = helper.getSimpleMergedProperties(ProductOptionValue.class.getName(), persistencePerspective);
//Pull back the productOptionValues based on the criteria from the client
BaseCtoConverter ctoConverter = helper.getCtoConverter(persistencePerspective, cto,
ceilingEntityFullyQualifiedClassname, originalProps);
String subscriptionId = persistencePackage.getCustomCriteria()[1];
//HERE MY CUSTOM REQUEST TO RETRIEVE productOptionValues
Entity[] entities = helper.getRecords(originalProps, productOptionvalues);
return new DynamicResultSet(entities, entities.length);
} catch (Exception e) {
LOG.error("Unable to execute persistence activity", e);
throw new ServiceException("Unable to perform fetch for entity: "+ceilingEntityFullyQualifiedClassname, e);
}
}
It works but if i filter on a column, fetch method is called again and retrieve all productOptionValues...It's normal because i don't use the dynamicDao with queryCriteria:
Code: Select all
List<Serializable> records = dynamicEntityDao.query(queryCriteria,
Class.forName(persistencePackage.getCeilingEntityFullyQualifiedClassname()));
But is it possible to use my custom query and use queryCriteria to filter on? Because by default your dynamicEntityDao retrieve all datas of a given class.For instance i can't retrieve only productOptionValues of all ProductOptions of a given product by using only your dynamicEntityDao.
3/ When i select a ProductOptionValue, the field in the popup is still empty :

however i believe that the annotation on my attribute is correct :
Code: Select all
@ManyToOne(targetEntity=ProductOptionValueImpl.class)
@JoinColumn(name = "PRODUCT_OPTION_VALUE_ID", nullable = false)
@AdminPresentation(friendlyName="Option", group = "SubscriptionOption_Group", order=1)
@AdminPresentationToOneLookup(lookupDisplayProperty="attributeValue") //HERE
private ProductOptionValue productOptionValue;
PS : if i edit the row, then the field is correctly filled
Thanks in advance for your help