public ObjEntity getEntity() { return objAttribute.getEntity(); }
public Object getParent() { return objAttribute.getEntity(); }
/** * Returns a DbAttribute mapped by this ObjAttribute. */ public DbAttribute getDbAttribute() { Iterator<CayenneMapEntry> pathIterator = getDbPathIterator(getEntity()); CayenneMapEntry o = null; while (pathIterator.hasNext()) { o = pathIterator.next(); } if (o == null) { return getParentDbAttribute(getEntity()); } return (DbAttribute) o; }
public Iterator<CayenneMapEntry> getDbPathIterator() { return getDbPathIterator(getEntity()); }
private void checkSuperEntityAttributes(ObjAttribute attribute, ValidationResult validationResult) { // Check there is an attribute in entity and super entity at the same time boolean selfAttribute = false; if (attribute.getEntity().getDeclaredAttribute(attribute.getName()) != null) { selfAttribute = true; } ObjEntity superEntity = attribute.getEntity().getSuperEntity(); if (selfAttribute && superEntity != null && superEntity.getAttribute(attribute.getName()) != null) { addFailure(validationResult, attribute, "'%s' and super '%s' can't have attribute '%s' together ", attribute.getEntity().getName(), superEntity.getName(), attribute.getName()); } }
model.addElement("Attributes: "); for (ObjAttribute objAttribute : fObjAttributesForDbRelationship) { model.addElement(objAttribute.getEntity().getName() + "." + objAttribute.getName());
/** * Returns <code>true</code> if attribute inherited from a super entity. * * @since 3.0 */ public boolean isInherited() { ObjEntity owningEntity = getEntity(); if (owningEntity == null) { return false; } ObjEntity superEntity = owningEntity.getSuperEntity(); if (superEntity == null) { return false; } return superEntity.getAttribute(getName()) != null; }
public boolean visitAttribute(AttributeProperty property) { ObjAttribute oa = property.getAttribute(); if (visited.add(oa.getDbAttributePath())) { entityResult.addObjectField( oa.getEntity().getName(), oa.getName(), prefix + index[0]++); } return true; }
public Iterator getDbPathIterator() { if (dbAttributePath == null) { return IteratorUtils.EMPTY_ITERATOR; } ObjEntity ent = (ObjEntity) getEntity(); if (ent == null) { return IteratorUtils.EMPTY_ITERATOR; } DbEntity dbEnt = ent.getDbEntity(); if (dbEnt == null) { return IteratorUtils.EMPTY_ITERATOR; } int lastPartStart = dbAttributePath.lastIndexOf('.'); if (lastPartStart < 0) { Attribute attribute = dbEnt.getAttribute(dbAttributePath); if (attribute == null) { return IteratorUtils.EMPTY_ITERATOR; } return IteratorUtils.singletonIterator(attribute); } return dbEnt.resolvePathComponents(dbAttributePath); }
private void copyObjAttribute(ObjAttribute attributeSaved, ObjAttribute attribute) { attributeSaved.setDbAttributePath(attribute.getDbAttributePath()); attributeSaved.setName(attribute.getName()); attributeSaved.setEntity(attribute.getEntity()); attributeSaved.setParent(attribute.getParent()); attributeSaved.setType(attribute.getType()); attributeSaved.setUsedForLocking(attribute.isUsedForLocking()); if (attributeSaved instanceof EmbeddedAttribute) { Map<String, String> attrOverrides; if (attribute instanceof EmbeddedAttribute) { attrOverrides = ((EmbeddedAttribute) attribute).getAttributeOverrides(); } else { attrOverrides = new HashMap<>(); } if (attrOverrides.size() > 0) { Iterator it = attrOverrides.entrySet().iterator(); while (it.hasNext()) { Map.Entry attrOv = (Map.Entry) it.next(); ((EmbeddedAttribute) attributeSaved).addAttributeOverride(attrOv.getKey().toString(), attrOv .getValue().toString()); } } } }
public boolean visitAttribute(AttributeProperty property) { ObjAttribute oa = property.getAttribute(); if (visited.add(oa.getDbAttributePath())) { result.addObjectField(oa.getEntity().getName(), "fetch." + prefix + "." + oa.getName(), prefix + "." + oa.getDbAttributeName()); } return true; }
public boolean isSameObjAttribute(ObjEntityViewField field) { if (objAttribute != null) { ObjAttribute fieldAttribute = field.getObjAttribute(); if (fieldAttribute == null) return false; boolean same = (objAttribute.equals(fieldAttribute) || (objAttribute .getEntity() .equals(fieldAttribute.getEntity()) && objAttribute.getName().equals( fieldAttribute.getName()))); return same; } else if (isLookup()) { if (field.isLookup()) return getLookupField().isSameObjAttribute(field.getLookupField()); else return getLookupField().isSameObjAttribute(field); } return false; } }
private String getDBAttrType(String dbAttributeName) { DbEntity currentEnt = ((ObjEntity) attr.getEntity()).getDbEntity(); if (currentEnt != null && currentEnt.getAttributes() != null && dbAttributeName != null) { DbAttribute dbAttr = (DbAttribute) currentEnt.getAttribute(dbAttributeName); if (dbAttr != null) { return TypesMapping.getSqlNameByType(dbAttr.getType()); } } return null; }
public TargetPropertyWriter getOrCreateWriter(AttributeProperty property) { if (!entity.equals(property.getAttribute().getEntity())) { throw new LmRuntimeException("Property belongs to a different entity: " + property.getName()); } return getOrCreateWriter( property.getName(), ASTDbPath.DB_PREFIX + property.getAttribute().getDbAttributeName(), () -> new TargetAttributePropertyWriter(property) ); }
@Override public void setUpdatedValueAt(Object value, int row, int col) { EmbeddableAttribute attribute = getEmbeddableAttribute(row); if (col == DB_ATTRIBUTE) { attribute.setDbAttributeName(value != null ? value.toString() : null); fireTableCellUpdated(row, col); this.isAttributeOverrideChange = true; ((ObjAttributeInfoDialogView) ((ObjAttributeInfoDialog) eventSource) .getView()).getSaveButton().setEnabled(true); if (value != null) { DbEntity currentEnt = ((ObjEntity) attr.getEntity()).getDbEntity(); if (currentEnt != null) { DbAttribute dbAttr = (DbAttribute) currentEnt.getAttribute(value .toString()); if (dbAttr != null) { fireTableCellUpdated(DB_ATTRIBUTE_TYPE, col); } } } fireTableRowsUpdated(row, row); } }
private void initComboBoxes() { Collection<String> nameAttr = null; if (attributeSaved != null) { DbEntity currentEnt = ((ObjEntity) attributeSaved.getEntity()).getDbEntity(); if (currentEnt != null) { nameAttr = ModelerUtil.getDbAttributeNames(mediator, currentEnt); embeddableModel.setCellEditor(nameAttr, view.getOverrideAttributeTable()); embeddableModel.setComboBoxes( nameAttr, view.getOverrideAttributeTable().convertColumnIndexToView( OverrideEmbeddableAttributeTableModel.DB_ATTRIBUTE)); } } }
!attribute.isInherited()) { ObjEntity entity = attribute.getEntity();
/** * Creates a clone of an ObjAttribute argument. * * @since 3.0 */ public ObjAttribute(ObjAttribute attribute) { setName(attribute.getName()); setType(attribute.getType()); setEntity(attribute.getEntity()); setDbAttributePath(attribute.getDbAttributePath()); setUsedForLocking(attribute.isUsedForLocking()); }
private ValidationFailure validateAttribute(ObjAttribute attribute) { String name = attribute.getEntity().getName(); ValidationFailure emptyName = BeanValidationFailure.validateNotEmpty(name, "attribute.name", attribute.getName()); if (emptyName != null) { return emptyName; } ValidationFailure badName = CodeValidationUtil.validateJavaIdentifier(name, "attribute.name", attribute.getName()); if (badName != null) { return badName; } ValidationFailure emptyType = BeanValidationFailure.validateNotEmpty(name, "attribute.type", attribute.getType()); if (emptyType != null) { return emptyType; } ValidationFailure badType = BeanValidationFailure.validateJavaClassName(name, "attribute.type", attribute.getType()); if (badType != null) { return badType; } return null; }
private void validateDbAttribute(ObjAttribute attribute, ValidationResult validationResult) { if (attribute.getEntity().isAbstract()) {