CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToOneDescriptor.java29
org/kuali/rice/core/framework/persistence/jpa/metadata/ObjectDescriptor.java117
		sb.append("ObjectDescriptor = [ ");
		sb.append("targetEntity:").append(targetEntity.getName()).append(", ");
		sb.append("cascade = { ");
		for (CascadeType ct : cascade) {
			sb.append(ct).append(" ");
		}
		sb.append("}, ");
		sb.append("fetch:").append(fetch).append(", ");
		sb.append("optional:").append(optional);
		if (!joinColumnDescriptors.isEmpty()) {
			sb.append(", join columns = { ");
			for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
		sb.append(" ]");
		return sb.toString();
	}
	
}
FileLine
org/kuali/rice/core/framework/persistence/jpa/type/HibernateKualiEncryptDecryptUserType.java34
org/kuali/rice/core/framework/persistence/jpa/type/KualiDecimalIntegerPercentFieldType.java34
public class KualiDecimalIntegerPercentFieldType extends HibernateImmutableValueUserType implements UserType {
	/**
	 * Retrieves a value from the given ResultSet and decrypts it
	 * 
	 * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object)
	 */
	public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
		String value = rs.getString(names[0]);
		String converted = null;

		if (value != null) {
	        try {
	            converted = CoreApiServiceLocator.getEncryptionService().decrypt(value);
	        }
	        catch (GeneralSecurityException gse) {
	            throw new RuntimeException("Unable to decrypt value from db: " + gse.getMessage());
	        }
	        
	        if (converted == null) {
				converted = value;
			}
		}

        return converted;
	}

	/**
	 * Encrypts the value if possible and then sets that on the PreparedStatement
	 * 
	 * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int)
	 */
	public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
		String converted = null;

		if (value != null) {
	        try {
	            converted = CoreApiServiceLocator.getEncryptionService().encrypt(value);
	        }
	        catch (GeneralSecurityException gse) {
	            throw new RuntimeException("Unable to encrypt value to db: " + gse.getMessage());
	        }
		}
        
        if (converted == null) {
        	st.setNull(index, Types.VARCHAR);
        } else {
        	st.setString(index, converted);
        }
	}

	/**
	 * Returns String.class
	 * 
	 * @see org.hibernate.usertype.UserType#returnedClass()
	 */
	public Class returnedClass() {
		return String.class;
	}

	/**
	 * Returns an array with the SQL VARCHAR type as the single member
	 * 
	 * @see org.hibernate.usertype.UserType#sqlTypes()
	 */
	public int[] sqlTypes() {
		return new int[] { Types.VARCHAR };
	}

}
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToOneDescriptor.java38
org/kuali/rice/core/framework/persistence/jpa/metadata/OneToOneDescriptor.java53
		if (!joinColumnDescriptors.isEmpty()) {
			sb.append(", join columns = { ");
			for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
		sb.append(" ]");
		return sb.toString();
	}
	
}
FileLine
org/kuali/rice/core/framework/persistence/jpa/type/HibernateKualiIntegerPercentFieldType.java46
org/kuali/rice/core/framework/persistence/jpa/type/HibernateKualiPercentFieldType.java48
        if (source != null && source instanceof BigDecimal) {
            BigDecimal converted = (BigDecimal) source;

            // Once we have converted, we need to convert again to KualiPercent.
            KualiPercent percentConverted = new KualiPercent((BigDecimal) converted);

            return percentConverted;

        }
        else {
            return null;
        }
	}

	/**
	 * This overridden method ...
	 * 
	 * @see HibernateImmutableValueUserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int)
	 */
	@Override
	public void nullSafeSet(PreparedStatement st, Object source, int index)
			throws HibernateException, SQLException {
	       Object converted = source;

	        if (source instanceof KualiPercent) {
	            converted = ((KualiPercent) source).bigDecimalValue();
	        }

	        if (converted == null) {
	        	st.setNull(index, Types.DECIMAL); 
	        } else {
	        	st.setBigDecimal(index, ((BigDecimal)converted));
	        }
	}

	/**
	 * This overridden method ...
	 * 
	 * @see HibernateImmutableValueUserType#returnedClass()
	 */
	public Class returnedClass() {
		return BigDecimal.class;
	}

	/**
	 * Returns an array with the SQL VARCHAR type as the single member
	 * 
	 * @see org.hibernate.usertype.UserType#sqlTypes()
	 */
	public int[] sqlTypes() {
		return new int[] { Types.DECIMAL };
	}

}
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java110
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java163
					final Object value = field.get(owner);
					if (value != null) {
						final Field fieldToSet = getField(pkObject.getClass(), fieldDescriptor.getName());
						fieldToSet.setAccessible(true);
						fieldToSet.set(pkObject, value);
					}
				}
				
				return pkObject;
			} catch (SecurityException se) {
				LOG.error(se.getMessage(), se);
			} catch (InstantiationException ie) {
				LOG.error(ie.getMessage(), ie);
			} catch (IllegalAccessException iae) {
				LOG.error(iae.getMessage(), iae);
			} catch (NoSuchFieldException nsfe) {
				LOG.error(nsfe.getMessage(), nsfe);
			}
		} else {
			for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) {
				try {
					Field field = getField(owner.getClass(), fieldDescriptor.getName());
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToManyDescriptor.java53
org/kuali/rice/core/framework/persistence/jpa/metadata/OneToOneDescriptor.java51
			sb.append(", mappedBy:").append(mappedBy);
		}
		if (!joinColumnDescriptors.isEmpty()) {
			sb.append(", join columns = { ");
			for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToManyDescriptor.java55
org/kuali/rice/core/framework/persistence/jpa/metadata/ObjectDescriptor.java126
		if (!joinColumnDescriptors.isEmpty()) {
			sb.append(", join columns = { ");
			for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToManyDescriptor.java70
org/kuali/rice/core/framework/persistence/jpa/metadata/ObjectDescriptor.java128
			for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
		sb.append(" ]");
		return sb.toString();
	}
	
}
FileLine
org/kuali/rice/core/framework/persistence/jdbc/sql/SQLUtils.java201
org/kuali/rice/core/framework/persistence/jdbc/sql/SQLUtils.java221
            if (util.group(1).length() < 2) {
                monthBuf.append("0").append(util.group(1));
            } else {
                monthBuf.append(util.group(1));
            }

            if (util.group(2).length() < 2) {
                dateBuf.append("0").append(util.group(2));
            } else {
                dateBuf.append(util.group(2));
            }

            return new DateComponent(yearBuf.toString(), monthBuf.toString(), dateBuf.toString());

            // small date format yyyy/M/d | yyyy/MM/dd | yyyy-M-d | yyyy-MM-dd
        } else if (regexSplitExpression.equals(DATE_REGEX_SMALL_FOUR_DIGIT_YEAR_FIRST_SPLIT)) {
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java453
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java547
						}
						//descriptor.addFkField(entityDescriptor.getFieldByColumnName(jc.name()).getName());
						//descriptor.addFkField(entitesByClass.get(field.getType()).getFieldByColumnName(jc.name()).getName());
						descriptor.setInsertable(jc.insertable());
						descriptor.setUpdateable(jc.updatable());
					}
					if (field.isAnnotationPresent(JoinColumns.class)) {
						JoinColumns jcs = field.getAnnotation(JoinColumns.class);
						for (JoinColumn jc : jcs.value()) {
							descriptor.addJoinColumnDescriptor(constructJoinDescriptor(jc));
							descriptor.addFkField(entityDescriptor.getFieldByColumnName(jc.name()).getName());
							descriptor.setInsertable(jc.insertable());
							descriptor.setUpdateable(jc.updatable());
						} 
					}
					entityDescriptor.add(descriptor);
				}

				if (field.isAnnotationPresent(ManyToMany.class)) {
FileLine
org/kuali/rice/core/framework/persistence/platform/MySQLDatabasePlatform.java62
org/kuali/rice/core/framework/persistence/platform/OracleDatabasePlatform.java75
			statement = connection.prepareStatement("select " + sequenceName + ".nextval from dual");
			resultSet = statement.executeQuery();

			if (!resultSet.next()) {
				throw new RuntimeException("Error retrieving next option id for action list from sequence.");
			}
			return new Long(resultSet.getLong(1));
		} catch (SQLException e) {
			throw new RuntimeException("Error retrieving next option id for action list from sequence.", e);
		} catch (LookupException e) {
			throw new RuntimeException("Error retrieving next option id for action list from sequence.", e);
		} finally {
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
				}
			}
			if (resultSet != null) {
				try {
					resultSet.close();
				} catch (SQLException e) {
				}
			}
		}
	}

    public String getLockRouteHeaderQuerySQL(String documentId, boolean wait) {
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToManyDescriptor.java57
org/kuali/rice/core/framework/persistence/jpa/metadata/ManyToManyDescriptor.java70
			for (JoinColumnDescriptor joinColumnDescriptor : inverseJoinColumnDescriptors) {				
				sb.append(" jc = { ");
				sb.append("name:").append(joinColumnDescriptor.getName()).append(", ");
				sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", ");
				sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", ");
				sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", ");
				sb.append("updateable:").append(joinColumnDescriptor.isUpdateable());
				sb.append(" }");
			}
			sb.append(" } ");
		}
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java472
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java567
					ManyToMany relation = field.getAnnotation(ManyToMany.class);
					descriptor.setAttributeName(field.getName());
					if (relation.targetEntity().equals(void.class)) {
						descriptor.setTargetEntity((Class)((ParameterizedType)field.getGenericType()).getActualTypeArguments()[0]);
					} else {
						descriptor.setTargetEntity(relation.targetEntity());
						fieldDescriptor.setTargetClazz(relation.targetEntity());
					}
					descriptor.setCascade(relation.cascade());
					descriptor.setFetch(relation.fetch());
					descriptor.setMappedBy(relation.mappedBy());
FileLine
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java455
org/kuali/rice/core/framework/persistence/jpa/metadata/MetadataManager.java601
							descriptor.setInsertable(jc.insertable());
							descriptor.setUpdateable(jc.updatable());
						}
						if (field.isAnnotationPresent(JoinColumns.class)) {
							JoinColumns jcs = field.getAnnotation(JoinColumns.class);
							for (JoinColumn jc : jcs.value()) {
								descriptor.addJoinColumnDescriptor(constructJoinDescriptor(jc));
								descriptor.addFkField(entityDescriptor.getFieldByColumnName(jc.name()).getName());
								descriptor.setInsertable(jc.insertable());
								descriptor.setUpdateable(jc.updatable());
							} 
						}