use of org.broadleafcommerce.openadmin.dto.BasicFieldMetadata in project BroadleafCommerce by BroadleafCommerce.
the class OfferCustomPersistenceHandler method buildAdvancedVisibilityOptionsFieldMetaData.
protected FieldMetadata buildAdvancedVisibilityOptionsFieldMetaData() {
BasicFieldMetadata advancedLabelMetadata = new BasicFieldMetadata();
advancedLabelMetadata.setFieldType(SupportedFieldType.BOOLEAN_LINK);
advancedLabelMetadata.setForeignKeyCollection(false);
advancedLabelMetadata.setMergedPropertyType(MergedPropertyType.PRIMARY);
advancedLabelMetadata.setName("test");
advancedLabelMetadata.setFriendlyName("OfferImpl_View_Visibility_Options");
advancedLabelMetadata.setGroup(OfferAdminPresentation.GroupName.ActivityRange);
advancedLabelMetadata.setOrder(5000);
advancedLabelMetadata.setDefaultValue("true");
return advancedLabelMetadata;
}
use of org.broadleafcommerce.openadmin.dto.BasicFieldMetadata in project BroadleafCommerce by BroadleafCommerce.
the class OfferCustomPersistenceHandler method buildStackableFieldMetaData.
protected FieldMetadata buildStackableFieldMetaData() {
BasicFieldMetadata qualifiersCanBeTargets = new BasicFieldMetadata();
qualifiersCanBeTargets.setFieldType(SupportedFieldType.BOOLEAN);
qualifiersCanBeTargets.setName(STACKABLE);
qualifiersCanBeTargets.setFriendlyName("OfferImpl_Stackable");
qualifiersCanBeTargets.setTooltip("OfferImpl_Stackable_tooltip");
qualifiersCanBeTargets.setGroup(OfferAdminPresentation.GroupName.CombineStack);
qualifiersCanBeTargets.setOrder(OfferAdminPresentation.FieldOrder.StackableWithOtherOffers);
qualifiersCanBeTargets.setDefaultValue("false");
return qualifiersCanBeTargets;
}
use of org.broadleafcommerce.openadmin.dto.BasicFieldMetadata in project BroadleafCommerce by BroadleafCommerce.
the class SkuCustomPersistenceHandler method createExplicitEnumerationIndividualOptionField.
protected FieldMetadata createExplicitEnumerationIndividualOptionField(ProductOption option, int order) {
BasicFieldMetadata metadata = new BasicFieldMetadata();
List<ProductOptionValue> allowedValues = option.getAllowedValues();
if (CollectionUtils.isNotEmpty(allowedValues)) {
metadata.setFieldType(SupportedFieldType.EXPLICIT_ENUMERATION);
metadata.setMutable(true);
metadata.setInheritedFromType(SkuImpl.class.getName());
metadata.setAvailableToTypes(getPolymorphicClasses(SkuImpl.class, em, skuMetadataCacheService.useCache()));
metadata.setForeignKeyCollection(false);
metadata.setMergedPropertyType(MergedPropertyType.PRIMARY);
// Set up the enumeration based on the product option values
String[][] optionValues = new String[allowedValues.size()][2];
for (int i = 0; i < allowedValues.size(); i++) {
ProductOptionValue value = option.getAllowedValues().get(i);
optionValues[i][0] = value.getId().toString();
optionValues[i][1] = value.getAttributeValue();
}
metadata.setEnumerationValues(optionValues);
metadata.setName(PRODUCT_OPTION_FIELD_PREFIX + option.getId());
metadata.setFriendlyName(option.getLabel());
metadata.setGroup("productOption_group");
metadata.setGroupOrder(-1);
metadata.setOrder(order);
metadata.setExplicitFieldType(SupportedFieldType.UNKNOWN);
metadata.setProminent(false);
metadata.setVisibility(VisibilityEnum.FORM_EXPLICITLY_SHOWN);
metadata.setBroadleafEnumeration("");
metadata.setReadOnly(false);
metadata.setRequiredOverride(BooleanUtils.isFalse(option.getRequired()));
return metadata;
}
return null;
}
use of org.broadleafcommerce.openadmin.dto.BasicFieldMetadata in project BroadleafCommerce by BroadleafCommerce.
the class DynamicFieldPersistenceHandlerHelper method buildDynamicProperty.
public Property buildDynamicProperty(FieldDefinition definition, Class<?> inheritedType) {
Property property = new Property();
property.setName(definition.getName());
BasicFieldMetadata fieldMetadata = new BasicFieldMetadata();
property.setMetadata(fieldMetadata);
fieldMetadata.setFieldType(definition.getFieldType());
fieldMetadata.setMutable(true);
fieldMetadata.setInheritedFromType(inheritedType.getName());
fieldMetadata.setAvailableToTypes(new String[] { inheritedType.getName() });
fieldMetadata.setForeignKeyCollection(false);
fieldMetadata.setMergedPropertyType(MergedPropertyType.PRIMARY);
fieldMetadata.setLength(definition.getMaxLength());
if (definition.getDataDrivenEnumeration() != null && !CollectionUtils.isEmpty(definition.getDataDrivenEnumeration().getEnumValues())) {
int count = definition.getDataDrivenEnumeration().getEnumValues().size();
String[][] enumItems = new String[count][2];
for (int j = 0; j < count; j++) {
DataDrivenEnumerationValue item = definition.getDataDrivenEnumeration().getEnumValues().get(j);
enumItems[j][0] = item.getKey();
enumItems[j][1] = item.getDisplay();
}
fieldMetadata.setEnumerationValues(enumItems);
}
fieldMetadata.setName(definition.getName());
fieldMetadata.setFriendlyName(definition.getFriendlyName());
fieldMetadata.setSecurityLevel(definition.getSecurityLevel() == null ? "" : definition.getSecurityLevel());
fieldMetadata.setVisibility(definition.getHiddenFlag() ? VisibilityEnum.HIDDEN_ALL : VisibilityEnum.VISIBLE_ALL);
fieldMetadata.setTab("General");
fieldMetadata.setTabOrder(100);
fieldMetadata.setExplicitFieldType(SupportedFieldType.UNKNOWN);
fieldMetadata.setLargeEntry(definition.getTextAreaFlag());
fieldMetadata.setProminent(false);
fieldMetadata.setColumnWidth(String.valueOf(definition.getColumnWidth()));
fieldMetadata.setBroadleafEnumeration("");
fieldMetadata.setReadOnly(false);
fieldMetadata.setRequiredOverride(definition.getRequiredFlag());
fieldMetadata.setHint(definition.getHint());
fieldMetadata.setHelpText(definition.getHelpText());
fieldMetadata.setTooltip(definition.getTooltip());
fieldMetadata.setTranslatable(true);
if (definition.getValidationRegEx() != null) {
Map<String, String> itemMap = new HashMap<String, String>();
itemMap.put("regularExpression", definition.getValidationRegEx());
itemMap.put(ConfigurationItem.ERROR_MESSAGE, definition.getValidationErrorMesageKey());
List<Map<String, String>> configurationItems = new ArrayList<Map<String, String>>();
configurationItems.add(itemMap);
fieldMetadata.getValidationConfigurations().put(RegexPropertyValidator.class.getName(), configurationItems);
}
if (definition.getFieldType().equals(SupportedFieldType.ADDITIONAL_FOREIGN_KEY)) {
fieldMetadata.setForeignKeyClass(definition.getAdditionalForeignKeyClass());
fieldMetadata.setOwningClass(definition.getAdditionalForeignKeyClass());
fieldMetadata.setForeignKeyDisplayValueProperty("__adminMainEntity");
}
return property;
}
use of org.broadleafcommerce.openadmin.dto.BasicFieldMetadata in project BroadleafCommerce by BroadleafCommerce.
the class AdminBasicEntityController method getCollectionValueDetails.
@RequestMapping(value = "/{collectionField:.*}/details", method = RequestMethod.GET)
@ResponseBody
public Map<String, String> getCollectionValueDetails(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @PathVariable(value = "collectionField") String collectionField, @RequestParam String ids, @RequestParam MultiValueMap<String, String> requestParams) throws Exception {
String sectionKey = getSectionKey(pathVars);
String sectionClassName = getClassNameForSection(sectionKey);
List<SectionCrumb> sectionCrumbs = getSectionCrumbs(request, null, null);
PersistencePackageRequest ppr = getSectionPersistencePackageRequest(sectionClassName, requestParams, sectionCrumbs, pathVars);
ClassMetadata mainMetadata = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
Property collectionProperty = mainMetadata.getPMap().get(collectionField);
FieldMetadata md = collectionProperty.getMetadata();
ppr = PersistencePackageRequest.fromMetadata(md, sectionCrumbs);
ppr.setStartIndex(getStartIndex(requestParams));
ppr.setMaxIndex(getMaxIndex(requestParams));
if (md instanceof BasicFieldMetadata) {
String idProp = ((BasicFieldMetadata) md).getForeignKeyProperty();
String displayProp = ((BasicFieldMetadata) md).getForeignKeyDisplayValueProperty();
List<String> filterValues = BLCArrayUtils.asList(ids.split(FILTER_VALUE_SEPARATOR_REGEX));
ppr.addFilterAndSortCriteria(new FilterAndSortCriteria(idProp, filterValues));
DynamicResultSet drs = service.getRecords(ppr).getDynamicResultSet();
Map<String, String> returnMap = new HashMap<>();
for (Entity e : drs.getRecords()) {
String id = e.getPMap().get(idProp).getValue();
String disp = e.getPMap().get(displayProp).getDisplayValue();
if (StringUtils.isBlank(disp)) {
disp = e.getPMap().get(displayProp).getValue();
}
returnMap.put(id, disp);
}
return returnMap;
}
return null;
}
Aggregations