コード例 #1
0
ファイル: JdbcObjectDataDao.java プロジェクト: jfifield/crm
 /**
  * @see
  *     org.programmerplanet.crm.data.dao.ObjectDataDao#deleteObjectRelationships(org.programmerplanet.crm.metadata.Relationship,
  *     org.programmerplanet.crm.metadata.ObjectDefinition, java.util.UUID)
  */
 public void deleteObjectRelationships(
     Relationship relationship, ObjectDefinition parentObjectDefinition, UUID parentId) {
   String sql = "DELETE FROM " + relationship.getTableName();
   sql += " WHERE " + parentObjectDefinition.getTableName() + "_id = ?::uuid";
   Object[] params = new Object[] {parentId.toString()};
   this.getJdbcTemplate().update(sql, params);
 }
コード例 #2
0
ファイル: JdbcObjectDataDao.java プロジェクト: jfifield/crm
 /**
  * @see
  *     org.programmerplanet.crm.data.dao.ObjectDataDao#getObjectsAvailableForLinking(org.programmerplanet.crm.metadata.ObjectDefinition,
  *     java.util.List, org.programmerplanet.crm.metadata.Relationship,
  *     org.programmerplanet.crm.metadata.ObjectDefinition, java.util.UUID)
  */
 public List<ObjectData> getObjectsAvailableForLinking(
     ObjectDefinition objectDefinition,
     List<FieldDefinition> fieldDefinitions,
     Relationship relationship,
     ObjectDefinition parentObjectDefinition,
     UUID id) {
   StringBuffer sql = new StringBuffer();
   sql.append("SELECT ot.id, ");
   for (FieldDefinition fieldDefinition : fieldDefinitions) {
     String columnName = fieldDefinition.getColumnName();
     sql.append("ot.");
     sql.append(columnName);
     sql.append(", ");
   }
   sql.delete(sql.length() - 2, sql.length());
   sql.append(" FROM ");
   sql.append(objectDefinition.getTableName());
   sql.append(" AS ot ");
   sql.append("WHERE NOT EXISTS (");
   sql.append("SELECT * FROM ");
   sql.append(relationship.getTableName());
   sql.append(" AS rt ");
   sql.append("WHERE rt.");
   sql.append(objectDefinition.getTableName());
   sql.append("_id = ot.id ");
   sql.append("AND rt.");
   sql.append(parentObjectDefinition.getTableName());
   sql.append("_id = ?::uuid)");
   List<Map> data =
       this.getJdbcTemplate().queryForList(sql.toString(), new Object[] {id.toString()});
   convertUUIDValues(data, fieldDefinitions);
   List<ObjectData> objects = createObjectDataList(objectDefinition, fieldDefinitions, data);
   return objects;
 }
コード例 #3
0
ファイル: JdbcObjectDataDao.java プロジェクト: jfifield/crm
 /**
  * @see
  *     org.programmerplanet.crm.data.dao.ObjectDataDao#insertObjectRelationship(org.programmerplanet.crm.metadata.Relationship,
  *     org.programmerplanet.crm.metadata.ObjectDefinition, java.util.UUID,
  *     org.programmerplanet.crm.metadata.ObjectDefinition, java.util.UUID)
  */
 public void insertObjectRelationship(
     Relationship relationship,
     ObjectDefinition parentObjectDefinition,
     UUID parentId,
     ObjectDefinition childObjectDefinition,
     UUID childId) {
   String sql = "INSERT INTO " + relationship.getTableName();
   sql +=
       " ("
           + parentObjectDefinition.getTableName()
           + "_id, "
           + childObjectDefinition.getTableName()
           + "_id)";
   sql += " VALUES (?::uuid, ?::uuid)";
   Object[] params = new Object[] {parentId.toString(), childId.toString()};
   this.getJdbcTemplate().update(sql, params);
 }