/** * 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()); }
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 DbAttribute getDbAttribute() { try { return objAttribute.getDbAttribute(); } catch (ExpressionException e) { return null; } }
/** * @since 1.2 */ public ColumnDescriptor(ObjAttribute objAttribute, DbAttribute dbAttribute, String columnAlias) { this(dbAttribute, columnAlias); this.dataRowKey = objAttribute.getDbAttributePath(); this.javaClass = objAttribute.getType(); }
/** * Returns an ObjAttribute stripped of any server-side information, such as * DbAttribute mapping. * * @since 1.2 */ public ObjAttribute getClientAttribute() { ObjAttribute attribute = new ObjAttribute(getName()); attribute.setType(getType()); // TODO: will likely need "userForLocking" property as well. return attribute; } }
private void validateDbAttribute(ObjAttribute attribute, ValidationResult validationResult) { if (attribute.getEntity().isAbstract()) { dbAttribute = attribute.getDbAttribute(); } catch (ExpressionException e) { attribute.getName(), e.getExpressionString()); return; addFailure(validationResult, attribute, "ObjAttribute '%s' has no DbAttribute mapping", attribute.getName()); return; attribute.getName(), attribute.getDbAttributeName());
if (attribute instanceof EmbeddedAttribute || embeddableNames.contains(attribute.getType())) { this.attributeSaved = new EmbeddedAttribute(); } else { this.attributeSaved = new ObjAttribute(); relTargets = new ArrayList<DbEntity>(attribute.getEntity().getDataMap().getDbEntities()); view.getAttributeName().setText(attribute.getName()); if (attribute.getDbAttributePath() != null) { if (attribute.getDbAttributePath().contains(".")) { String path = attribute.getDbAttributePath(); view.getCurrentPathLabel().setText(path.replace(".", " -> ")); } else { view.getCurrentPathLabel().setText(attribute.getDbAttributePath()); view.getSourceEntityLabel().setText(attribute.getEntity().getName()); view.getTypeComboBox().setSelectedItem(attribute.getType()); if (attribute.getDbAttribute() == null) { if (attribute.getParent() instanceof ObjEntity) { DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity(); if (attribute.getDbAttribute() != null) { setSelectionPath(); ObjAttribute copyAttrSaved = new ObjAttribute(); copyObjAttribute(copyAttrSaved, attributeSaved);
if (registeredTypesList.contains(newType) || !mediator.getEmbeddableNamesInCurrentDataDomain().contains(newType)) { attributeNew = new ObjAttribute(); attributeNew.setDbAttributePath(attribute.getDbAttributePath()); } else { attributeNew = new EmbeddedAttribute(); attributeNew.setDbAttributePath(null); attributeNew.setName(attribute.getName()); attributeNew.setEntity(entity); attributeNew.setParent(attribute.getParent()); attributeNew.setType(attribute.getType()); attributeNew.setUsedForLocking(attribute.isUsedForLocking());
public void setDuplicatedAttributes(List<ObjAttribute> attributes) { if (duplicatedAttributes == null) { duplicatedAttributes = new LinkedList<DuplicatedAttributeInfo>(); } duplicatedAttributes.clear(); for (ObjAttribute attribute : attributes) { DuplicatedAttributeInfo attributeInfo = new DuplicatedAttributeInfo(attribute.getName(), attribute.getType(), superEntity.getAttribute(attribute.getName()).getType(), DELETE_ACTION); duplicatedAttributes.add(attributeInfo); } attributesTable.setModel(new DuplicatedAttributeTableModel(getMediator(), this, duplicatedAttributes)); }
/** * Implements an attributes compilation step. Called internally from "compile". */ protected void compileAttributes(Map allDescriptors) { // only include this entity attributes and skip superclasses... Iterator it = entity.getDeclaredAttributes().iterator(); while (it.hasNext()) { ObjAttribute attribute = (ObjAttribute) it.next(); Class propertyType = attribute.getJavaClass(); PropertyAccessor accessor = makeAccessor(attribute.getName(), propertyType); allDescriptors.put(attribute.getName(), persistent ? new SimplePersistentProperty(this, accessor) : new SimpleProperty(this, accessor)); } }
private void addMissingAttribute(ObjEntity entity, DbAttribute da) { ObjAttribute oa = new ObjAttribute(); oa.setName(NameBuilder.builder(oa, entity).baseName(nameGenerator.objAttributeName(da)).name()); oa.setEntity(entity); oa.setType(getTypeForObjAttribute(da)); oa.setDbAttributePath(da.getName()); entity.addAttribute(oa); fireAttributeAdded(oa); }
private void processStartObjAttribute(Attributes atts) { String name = atts.getValue("", "name"); String type = atts.getValue("", "type"); String lock = atts.getValue("", "lock"); ObjAttribute oa = new ObjAttribute(name); oa.setType(type); oa.setUsedForLocking(TRUE.equalsIgnoreCase(lock)); objEntity.addAttribute(oa); String dbPath = atts.getValue("", "db-attribute-path"); if (dbPath == null) { dbPath = atts.getValue("", "db-attribute-name"); } oa.setDbAttributePath(dbPath); }
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()); } }
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; }
/** * Recursively appends all attributes in the entity inheritance hierarchy. */ final void appendAttributes(Map<String, ObjAttribute> map) { map.putAll(getAttributeMapInternal()); ObjEntity superEntity = getSuperEntity(); if (superEntity != null) { SortedMap<String, ObjAttribute> attributeMap = new TreeMap<>(); superEntity.appendAttributes(attributeMap); for (String attributeName : attributeMap.keySet()) { String overridedDbPath = attributeOverrides.get(attributeName); ObjAttribute attribute = new ObjAttribute(attributeMap.get(attributeName)); attribute.setEntity(this); if (overridedDbPath != null) { attribute.setDbAttributePath(overridedDbPath); } map.put(attributeName, attribute); } } }
/** * @since 1.24 */ public CayenneAgAttribute(ObjAttribute objAttribute, Class<?> type) { super(objAttribute.getName(), type); this.objAttribute = objAttribute; }
objectAttribute.setDbAttributePath(attribute.getName()); objectAttribute.setType(TypesMapping.getJavaBySqlType(attribute.getType())); attributes.put(objectAttribute.getName(), objectAttribute);
public String getType() { return objAttribute.getType(); }
public String getDbAttributeName() { return objAttribute.getDbAttributeName(); }