MutableCommitLogLogEntity setIgnoreAttributes(boolean ignore) { if (ignore) { for (ObjAttribute a : entity.getAttributes()) { this.ignoredProperties.add(a.getName()); } } return this; }
public Collection<ObjAttribute> allAttributes() { if (subentities == null) { return entity.getAttributes(); } Collection<ObjAttribute> c = new ArrayList<>(); appendDeclaredAttributes(c); // add base attributes if any ObjEntity superEntity = entity.getSuperEntity(); if (superEntity != null) { c.addAll(superEntity.getAttributes()); } return c; }
public Collection allAttributes() { if (subentities == null) { return entity.getAttributes(); } Collection c = new ArrayList(); appendDeclaredAttributes(c); // add base attributes if any ObjEntity superEntity = entity.getSuperEntity(); if (superEntity != null) { c.addAll(superEntity.getAttributes()); } return c; }
private void initMapKeys() { this.mapKeys.clear(); mapKeys.add(DEFAULT_MAP_KEY); // Object target can be null when selected target DbEntity has no ObjEntities if (objectTarget == null) { return; } for (ObjAttribute attribute : this.objectTarget.getAttributes()) { mapKeys.add(attribute.getName()); } view.mapKeysCombo.removeAllItems(); for (String s : mapKeys) view.mapKeysCombo.addItem(s); if (mapKey != null && !mapKeys.contains(mapKey)) { mapKey = DEFAULT_MAP_KEY; view.mapKeysCombo.setSelectedItem(mapKey); } }
private boolean isManyToMany() { boolean isNotHaveAttributes = joinEntity.getAttributes().size() == 0; return isNotHaveAttributes && reverseRelationship1 != null && reverseRelationship1.isToDependentPK() && reverseRelationship2 != null && reverseRelationship2.isToDependentPK() && entity1 != null && entity2 != null; }
/** * Returns a list of ObjAttributes that are mapped to foreign keys. * * @since 1.2 */ public Collection getMeaningfulFKs(ObjEntity objEntity) { List fks = new ArrayList(2); Iterator it = objEntity.getAttributes().iterator(); while (it.hasNext()) { ObjAttribute property = (ObjAttribute) it.next(); DbAttribute column = property.getDbAttribute(); // check if adding it makes sense at all if (column != null && column.isForeignKey()) { fks.add(column); } } return fks; }
/** * Returns a list of DbAttributes that are mapped to foreign keys. * * @since 1.2 */ public Collection<DbAttribute> getMeaningfulFKs(ObjEntity objEntity) { List<DbAttribute> fks = new ArrayList<>(2); for (ObjAttribute property : objEntity.getAttributes()) { DbAttribute column = property.getDbAttribute(); // check if adding it makes sense at all if (column != null && column.isForeignKey()) { fks.add(column); } } return fks; }
private List<ObjAttribute> getDuplicatedAttributes(ObjEntity superEntity) { List<ObjAttribute> result = new LinkedList<ObjAttribute>(); ObjEntity entity = mediator.getCurrentObjEntity(); for (ObjAttribute attribute : entity.getAttributes()) { if (superEntity.getAttribute(attribute.getName()) != null) { result.add(attribute); } } return result; }
public ObjAttributeTableModel(ObjEntity entity, ProjectController mediator, Object eventSource) { super(mediator, eventSource, wrapObjAttributes(entity.getAttributes())); // take a copy this.entity = entity; this.dbEntity = entity.getDbEntity(); // order using local comparator Collections.sort(objectList, new AttributeComparator()); }
/** * Remove attributes from objEntity, if superEntity has attributes with same * names. */ private void removeShadowAttributes(ObjEntity objEntity, ObjEntity superEntity) { List<String> delList = new ArrayList<>(); // if subAttr and superAttr have same names, adds subAttr to delList for (ObjAttribute subAttr : objEntity.getDeclaredAttributes()) { for (ObjAttribute superAttr : superEntity.getAttributes()) { if (subAttr.getName().equals(superAttr.getName())) { delList.add(subAttr.getName()); } } } if (!delList.isEmpty()) { for (String i : delList) { objEntity.removeAttribute(i); } } }
public ValidationResult visitObjEntity(ObjEntity entity) { objEntityValidator.validate(entity, validationResult); for (ObjAttribute attr : entity.getAttributes()) { visitObjAttribute(attr); } for (ObjRelationship rel : entity.getRelationships()) { visitObjRelationship(rel); } return validationResult; }
public static Collection<ObjAttribute> findObjAttributesForDbRelationship(ProjectController mediator, DbRelationship relationship) { DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode(); List<ObjAttribute> attributes = new ArrayList<>(); String[] dbAttrPathByDot; if (domain != null) { for (DataMap map : domain.getDataMaps()) { for (ObjEntity entity : map.getObjEntities()) { for (ObjAttribute objAttribute : entity.getAttributes()) { if(objAttribute.getDbAttributePath() != null) { dbAttrPathByDot = objAttribute.getDbAttributePath() .split(Pattern.quote(".")); for (String partOfPath : dbAttrPathByDot) { if (partOfPath.equals(relationship.getName())) { attributes.add(objAttribute); } } } } } } } return attributes; } }
public EntityIdCoder(ObjEntity entity) { this.entityName = entity.getName(); this.converters = new TreeMap<String, Converter>(); for (ObjAttribute attribute : entity.getAttributes()) { if (attribute.isPrimaryKey()) { converters.put(attribute.getDbAttributeName(), create(attribute.getJavaClass())); } } for (DbAttribute attribute : entity.getDbEntity().getPrimaryKeys()) { if (!converters.containsKey(attribute.getName())) { String type = TypesMapping .getJavaBySqlType(attribute.getType()); try { converters.put(attribute.getName(), create(Util.getJavaClass(type))); } catch (ClassNotFoundException e) { throw new CayenneRuntimeException( "Can't instantiate class " + type, e); } } } if (converters.isEmpty()) { throw new IllegalArgumentException("Entity has no PK definied: " + entity.getName()); } this.idSize = (int) Math.ceil(converters.size() / 0.75d); }
for(ObjAttribute attribute: entity.getAttributes()){ if(attribute instanceof EmbeddedAttribute){ if(oldNameEmbeddableToNewName.size()>0 && oldNameEmbeddableToNewName.containsKey(attribute.getType())){
for (ObjAttribute comparisonAttribute : entity.getAttributes()) { if (attribute != comparisonAttribute) { String dbAttributePath = attribute.getDbAttributePath();
private void searchInObjEntities(Pattern pattern, List<SearchResultEntry> result, DataMap dataMap) { for (ObjEntity ent : dataMap.getObjEntities()) { if (match(ent.getName(), pattern)) { result.add(new SearchResultEntry(ent, ent.getName())); } for (ObjAttribute attr : ent.getAttributes()) { if (match(attr.getName(), pattern)) { result.add(new SearchResultEntry(attr, ent.getName() + "." + attr.getName())); } } for (ObjRelationship rel : ent.getRelationships()) { if (match(rel.getName(), pattern)) { result.add(new SearchResultEntry(rel, ent.getName() + "." + rel.getName())); } } } }
for (ObjAttribute attribute : objEntity.getAttributes()) { attribute.updateDbAttributePath();
for (ObjAttribute a : entity.getAttributes()) { if (a.isUsedForLocking() != on) { a.setUsedForLocking(on);
for (ObjAttribute attribute : entity.getAttributes()) { if (attribute instanceof EmbeddedAttribute) { EmbeddedAttribute embeddedAttribute = (EmbeddedAttribute) attribute;
protected <T> void loadCayenneEntity(CayenneAgEntity<T> agEntity, AgDataMap dataMap) { for (ObjAttribute a : objEntity.getAttributes()) { Class<?> type = typeForName(a.getType()); CayenneAgAttribute agAttribute = new CayenneAgAttribute(a, type);