/** * Finds all attribute names except managed like <code>id</code>, * <code>created_at</code>, <code>updated_at</code> and <code>record_version</code>, depending on argument. * * @param managed if true, time managed attributes <code>created_at</code> and <code>updated_at</code> will not be included (they are managed automatically). * If false (not managed) <code>created_at</code> and <code>updated_at</code> will be included in output. * @return list of all attributes except <code>id</code>, <code>created_at</code>, <code>updated_at</code> and * <code>record_version</code>, depending on argument. */ public Set<String> getAttributeNamesSkipGenerated(boolean managed) { //TODO: can cache this, but will need a cache for managed=true an another for managed=false Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNamesSkipId()); if(managed){ attributesNames.remove("created_at"); attributesNames.remove("updated_at"); } attributesNames.remove(versionColumn); return attributesNames; }
/** * Copies all attribute values (except for ID, created_at and updated_at) from other instance to this one. * * @param other source model. */ public void copyFrom(Model other) { if (!metaModelLocal.getTableName().equals(other.metaModelLocal.getTableName())) { throw new IllegalArgumentException("can only copy between the same types"); } Map<String, Object> otherAttributes = other.getAttributes(); for (String name : metaModelLocal.getAttributeNamesSkipId()) { attributes.put(name, otherAttributes.get(name)); dirtyAttributeNames.add(name); // Why not use setRaw() here? Does the same and avoids duplication of code... (Garagoth) // other.setRaw(name, getRaw(name)); } }
/** * Finds all attribute names except managed like <code>id</code>, * <code>created_at</code>, <code>updated_at</code> and <code>record_version</code>, depending on argument. * * @param managed if true, time managed attributes <code>created_at</code> and <code>updated_at</code> will not be included (they are managed automatically). * If false (not managed) <code>created_at</code> and <code>updated_at</code> will be included in output. * @return list of all attributes except <code>id</code>, <code>created_at</code>, <code>updated_at</code> and * <code>record_version</code>, depending on argument. */ public Set<String> getAttributeNamesSkipGenerated(boolean managed) { //TODO: can cache this, but will need a cache for managed=true an another for managed=false Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNamesSkipId()); if (managed) { attributesNames.remove("created_at"); attributesNames.remove("updated_at"); } attributesNames.remove(versionColumn); return attributesNames; }
/** * Finds all attribute names except managed like <code>id</code>, * <code>created_at</code>, <code>updated_at</code> and <code>record_version</code>, depending on argument. * * @param managed if true, time managed attributes <code>created_at</code> and <code>updated_at</code> will not be included (they are managed automatically). * If false (not managed) <code>created_at</code> and <code>updated_at</code> will be included in output. * @return list of all attributes except <code>id</code>, <code>created_at</code>, <code>updated_at</code> and * <code>record_version</code>, depending on argument. */ public Set<String> getAttributeNamesSkipGenerated(boolean managed) { //TODO: can cache this, but will need a cache for managed=true an another for managed=false Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNamesSkipId()); if(managed){ attributesNames.remove("created_at"); attributesNames.remove("updated_at"); } attributesNames.remove(versionColumn); return attributesNames; }
/** * Finds all attribute names except managed like <code>id</code>, * <code>created_at</code>, <code>updated_at</code> and <code>record_version</code>, depending on argument. * * @param managed if true, time managed attributes <code>created_at</code> and <code>updated_at</code> will not be included (they are managed automatically). * If false (not managed) <code>created_at</code> and <code>updated_at</code> will be included in output. * @return list of all attributes except <code>id</code>, <code>created_at</code>, <code>updated_at</code> and * <code>record_version</code>, depending on argument. */ public Set<String> getAttributeNamesSkipGenerated(boolean managed) { //TODO: can cache this, but will need a cache for managed=true an another for managed=false Set<String> attributes = new CaseInsensitiveSet(getAttributeNamesSkipId()); if(managed){ attributes.remove("created_at"); attributes.remove("updated_at"); } attributes.remove(versionColumn); return attributes; }
/** * Copies all attribute values (except for ID, created_at and updated_at) from other instance to this one. * * @param other source model. */ public void copyFrom(Model other) { if (!metaModelLocal.getTableName().equals(other.metaModelLocal.getTableName())) { throw new IllegalArgumentException("can only copy between the same types"); } Map<String, Object> otherAttributes = other.getAttributes(); for (String name : metaModelLocal.getAttributeNamesSkipId()) { attributes.put(name, otherAttributes.get(name)); dirtyAttributeNames.add(name); // Why not use setRaw() here? Does the same and avoids duplication of code... (Garagoth) // other.setRaw(name, getRaw(name)); } }
/** * Copies all attribute values (except for ID, created_at and updated_at) from other instance to this one. * * @param other source model. */ public void copyFrom(Model other) { if (!getMetaModelLocal().getTableName().equals(other.getMetaModelLocal().getTableName())) { throw new IllegalArgumentException("can only copy between the same types"); } Map<String, Object> otherAttributes = other.getAttributes(); for (String name : getMetaModelLocal().getAttributeNamesSkipId()) { attributes.put(name, otherAttributes.get(name)); dirtyAttributeNames.add(name); // Why not use setRaw() here? Does the same and avoids duplication of code... (Garagoth) // other.setRaw(name, getRaw(name)); } }