/** * Constructs a new {@code MandatoryPropertyException} instance. * * @param descriptor * the violated property descriptor. * @param targetComponent * the target component. */ public MandatoryPropertyException(IPropertyDescriptor descriptor, Object targetComponent) { super("Mandatory property [" + descriptor.getName() + "] on component [" + targetComponent + "]."); this.descriptor = descriptor; this.targetComponent = targetComponent; }
private void rollbackProperty(Object proxy, IPropertyDescriptor propertyDescriptor, Object oldProperty) { // boolean wasPropertyProcessorsEnabled = propertyProcessorsEnabled; // try { // propertyProcessorsEnabled = false; // setProperty(proxy, propertyDescriptor, oldProperty); // } finally { // propertyProcessorsEnabled = wasPropertyProcessorsEnabled; // } straightSetProperty(proxy, propertyDescriptor.getName(), oldProperty); }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") public void initializePropertyIfNeeded(IComponent componentOrEntity, IPropertyDescriptor propertyDescriptor) { if (propertyDescriptor instanceof ICollectionPropertyDescriptor) { String propertyName = propertyDescriptor.getName(); Object propertyValue = componentOrEntity .straightGetProperty(propertyName); sortCollectionProperty(componentOrEntity, propertyName); for (Iterator<IEntity> ite = ((Collection<IEntity>) propertyValue) .iterator(); ite.hasNext();) { IEntity collectionElement = ite.next(); if (isEntityRegisteredForDeletion(collectionElement)) { ite.remove(); } } } }
for (IComponentDescriptor<?> ancestorDescriptor : ancestorDescs) { for (IPropertyDescriptor propertyDescriptor : ancestorDescriptor.getPropertyDescriptors()) { allDescriptors.put(propertyDescriptor.getName(), propertyDescriptor); for (IPropertyDescriptor propertyDescriptor : declaredPropertyDescriptors) { propertyDescriptor = refinePropertyDescriptor(propertyDescriptor); allDescriptors.put(propertyDescriptor.getName(), propertyDescriptor);
/** * Directly gets all property values out of the property store without any * other operation. * * @param proxy * the proxy to straight get the properties from. * @return The map of properties. */ protected Map<String, Object> straightGetProperties(Object proxy) { Map<String, Object> allProperties = new HashMap<>(); for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { String propertyName = propertyDescriptor.getName(); if (!(propertyDescriptor.isComputed() && propertyDescriptor.getPersistenceFormula() == null)) { allProperties.put(propertyName, straightGetProperty(proxy, propertyName)); } } return allProperties; }
tempToStringProperty = "id"; } else { tempToStringProperty = getPropertyDescriptors().iterator().next().getName();
for (IPropertyDescriptor pd : baseComponentDescriptor.getPropertyDescriptors()) { if (propertyName.equals(pd.getPersistenceFormula())) { fixedPropertyName = pd.getName();
/** * Gets a property value. * * @param proxy * the proxy to get the property of. * @param propertyDescriptor * the property descriptor to get the value for. * @return the property value. */ @SuppressWarnings("unchecked") protected Object getProperty(Object proxy, IPropertyDescriptor propertyDescriptor) { if (propertyDescriptor instanceof ICollectionPropertyDescriptor) { return getCollectionProperty(proxy, (ICollectionPropertyDescriptor<? extends IComponent>) propertyDescriptor); } if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return getReferenceProperty(proxy, (IReferencePropertyDescriptor<IComponent>) propertyDescriptor); } Object propertyValue = straightGetProperty(proxy, propertyDescriptor.getName()); return propertyValue; }
private void checkIntegrity(Object proxy) { checkMandatoryProperties(proxy); if (propertyProcessorsEnabled) { for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { if (!propertyDescriptor.isComputed()) { propertyDescriptor.preprocessSetter(proxy, straightGetProperty(proxy, propertyDescriptor.getName())); } } } }
EnumQueryStructure enumQueryStructure = new EnumQueryStructure( (IEnumerationPropertyDescriptor) getQueryDescriptor().getPropertyDescriptor( propertyDescriptor.getName())); put(propertyDescriptor.getName(), enumQueryStructure); } else if (propertyDescriptor instanceof ComparableQueryStructureDescriptor) { IComponentDescriptor<?> referencedDescriptor = ((ComparableQueryStructureDescriptor) propertyDescriptor) .getReferencedDescriptor(); ComparableQueryStructure comparableQueryStructure = new ComparableQueryStructure(referencedDescriptor, getComponentFactory(), getQueryDescriptor().getPropertyDescriptor(propertyDescriptor.getName())); put(propertyDescriptor.getName(), comparableQueryStructure);
QueryComponent referencedQueryComponent = new QueryComponent(referencedDescriptor, getComponentFactory()); referencedQueryComponent.translate(translationProvider, locale); referencedQueryComponent.addPropertyChangeListener(new InlinedComponentTracker(propertyDescriptor.getName())); put((String) key, referencedQueryComponent); return referencedQueryComponent;
private void checkMandatoryProperties(Object proxy) { if (propertyProcessorsEnabled) { for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { if (!propertyDescriptor.isComputed()) { if (propertyDescriptor.isMandatory()) { Object newValue = straightGetProperty(proxy, propertyDescriptor.getName()); if (newValue == null || (isInitialized(newValue) && newValue instanceof Collection<?> && ((Collection<?>) newValue).isEmpty())) { throw new MandatoryPropertyException(propertyDescriptor, proxy); } } if (propertyDescriptor instanceof ICollectionPropertyDescriptor<?> && !((ICollectionPropertyDescriptor<?>) propertyDescriptor).getReferencedDescriptor() .isNullElementAllowed()) { Object newValue = straightGetProperty(proxy, propertyDescriptor.getName()); if (isInitialized(newValue) && newValue instanceof Collection<?>) { for (Object element : ((Collection<?>) newValue)) { if (element == null) { throw new MandatoryPropertyException(propertyDescriptor, proxy); } } } } } } } }
private void completeWithComputedNlsDescriptors(IPropertyDescriptor rawDescriptor) { String barePropertyName = rawDescriptor.getName(); if (barePropertyName.endsWith(RAW_SUFFIX)) { barePropertyName = barePropertyName.substring(0, barePropertyName.length() - RAW_SUFFIX.length()); } BasicStringPropertyDescriptor nlsDescriptor = (BasicStringPropertyDescriptor) rawDescriptor.clone(); nlsDescriptor.setName(barePropertyName + NLS_SUFFIX); nlsDescriptor.setDelegateWritable(true); nlsDescriptor.setComputed(true); if (!isPurelyAbstract()) { nlsDescriptor.setSqlName("(SELECT T.TRANSLATED_VALUE FROM {tableName}_T T WHERE T." + "T_{tableName}_ID = ID AND T.LANGUAGE = :JspressoSessionGlobals.language AND " + "T.PROPERTY_NAME = '" + barePropertyName + "')"); } BasicStringPropertyDescriptor rawOrNlsDescriptor = (BasicStringPropertyDescriptor) rawDescriptor.clone(); rawOrNlsDescriptor.setName(barePropertyName); rawOrNlsDescriptor.setDelegateWritable(true); rawOrNlsDescriptor.setComputed(true); if (!isPurelyAbstract()) { rawOrNlsDescriptor.setSqlName( "CASE WHEN " + nlsDescriptor.getSqlName() + " IS NULL THEN " + ((BasicPropertyDescriptor) rawDescriptor) .getSqlName() + " ELSE " + nlsDescriptor.getSqlName() + " END"); } propertyDescriptorsMap.put(nlsDescriptor.getName(), nlsDescriptor); propertyDescriptorsMap.put(rawOrNlsDescriptor.getName(), rawOrNlsDescriptor); }
private IValueConnector createColumnConnector(String columnId, IComponentDescriptor<?> descriptor) { IPropertyDescriptor propertyDescriptor = descriptor .getPropertyDescriptor(columnId); if (propertyDescriptor == null) { throw new ViewException("No property " + columnId + " defined for " + descriptor.getComponentContract()); } if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return connectorFactory.createCompositeValueConnector(columnId, ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getToStringProperty()); } return connectorFactory.createValueConnector(propertyDescriptor.getName()); }
private IValueConnector createColumnConnector(String columnId, IComponentDescriptor<?> descriptor) { IPropertyDescriptor propertyDescriptor = descriptor .getPropertyDescriptor(columnId); if (propertyDescriptor == null) { throw new ViewException("No property " + columnId + " defined for " + descriptor.getComponentContract()); } if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return connectorFactory.createCompositeValueConnector(columnId, ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getToStringProperty()); } return connectorFactory.createValueConnector(propertyDescriptor.getName()); }
private IValueConnector createColumnConnector(String columnId, IComponentDescriptor<?> descriptor) { IPropertyDescriptor propertyDescriptor = descriptor .getPropertyDescriptor(columnId); if (propertyDescriptor == null) { throw new ViewException("No property " + columnId + " defined for " + descriptor.getComponentContract()); } if (propertyDescriptor instanceof IReferencePropertyDescriptor) { return connectorFactory.createCompositeValueConnector(columnId, ((IReferencePropertyDescriptor<?>) propertyDescriptor) .getReferencedDescriptor().getToStringProperty()); } return connectorFactory.createValueConnector(propertyDescriptor.getName()); }
if (propertyDescriptor instanceof IScalarPropertyDescriptor && ((IScalarPropertyDescriptor) propertyDescriptor).getDefaultValue() != null) { newMap.put(propertyDescriptor.getName(), ((IScalarPropertyDescriptor) propertyDescriptor).getDefaultValue());
/** * Carbon copies all scalar properties. * * @param componentToClone * the source. * @param clonedComponent * the copy. * @param entityFactory * the entity factory to use. */ public static void carbonCopyComponent(IComponent componentToClone, IComponent clonedComponent, IEntityFactory entityFactory) { if (componentToClone == clonedComponent) { return; } IComponentDescriptor<?> componentDescriptor = entityFactory.getComponentDescriptor(componentToClone .getComponentContract()); for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { if (!(propertyDescriptor instanceof IRelationshipEndPropertyDescriptor) && /* propertyDescriptor.isModifiable() */!(propertyDescriptor.isComputed() && propertyDescriptor .getPersistenceFormula() == null)) { String propertyName = propertyDescriptor.getName(); clonedComponent.straightSetProperty(propertyName, ObjectUtils.cloneIfPossible(componentToClone.straightGetProperty(propertyName))); } } } }
/** * Performs delayed configuration. */ protected void finishConfiguration() { setDescription(getQueriedComponentsDescriptor().getDescription()); setIcon(getQueriedComponentsDescriptor().getIcon()); List<String> qProperties = new ArrayList<>(); for (String queryableProperty : queryComponentsDescriptorProvider.getQueryableProperties()) { IPropertyDescriptor propertyDescriptor = getPropertyDescriptor(queryableProperty); if (propertyDescriptor instanceof ComparableQueryStructureDescriptor) { for (String nestedRenderedProperty : ((ComparableQueryStructureDescriptor) propertyDescriptor) .getRenderedProperties()) { qProperties.add(propertyDescriptor.getName() + "." + nestedRenderedProperty); } } else { qProperties.add(propertyDescriptor.getName()); } } setRenderedProperties(qProperties); setQueryableProperties(queryComponentsDescriptorProvider.getQueryableProperties()); setToStringProperty(getQueriedComponentsDescriptor().getToStringProperty()); setToHtmlProperty(getQueriedComponentsDescriptor().getToHtmlProperty()); setAutoCompleteProperty(getQueriedComponentsDescriptor().getAutoCompleteProperty()); setUnclonedProperties(getQueriedComponentsDescriptor().getUnclonedProperties()); setPageSize(getQueriedComponentsDescriptor().getPageSize()); setOrderingProperties(getQueriedComponentsDescriptor().getOrderingProperties()); }
if (propertyView != null) { RComponent peer = propertyView.getPeer(); if (propertyDescriptor != null && propertyDescriptor.getName() != null) { peer.setLabel(propertyDescriptor.getI18nName(actionHandler, locale));