The following document contains the results of PMD's CPD 4.1.
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/ModelColumn.java | 86 | 
| pl/edu/agh/cast/model/ModelColumnParameter.java | 59 | 
        ModelColumnParameter other = (ModelColumnParameter)obj;
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (name == null) {
            if (other.name != null) {
                return false;
            }
        } else if (!name.equals(other.name)) {
            return false;
        }
        if (!possibleValues.equals(other.possibleValues)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/rawdata/stat/ErrorType.java | 119 | 
| pl/edu/agh/cast/rawdata/stat/ErrorTypeWithReplacment.java | 48 | 
	}
	/**
	 * 
	 * {@inheritDoc}
	 * 
	 * @see pl.edu.agh.cast.rawdata.stat.ErrorType#toString()
	 */
	@Override
	public String toString() {
		StringBuffer res = new StringBuffer();
		res.append("[ErrorType code: ").append(getCode()) //$NON-NLS-1$
		        .append(", severity: ").append(getSeverity()).append(//$NON-NLS-1$
		                ", message: ").append(getMessage()).append(//$NON-NLS-1$
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/ModelColumn.java | 122 | 
| pl/edu/agh/cast/model/ModelColumnParameter.java | 75 | 
        if (!possibleValues.equals(other.possibleValues)) {
            return false;
        }
        return true;
    }
    /**
     * {@inheritDoc}
     *
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        StringBuilder hash = new StringBuilder();
        if (id != null) {
            hash.append(id);
        }
        if (name != null) {
            hash.append(name);
        }
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 88 | 
| pl/edu/agh/cast/model/mapper/internal/XMLLoader.java | 81 | 
		if (typeMap == null) {
			typeMap = new HashMap<String, Class>();
		}
		String typeName = Helper.mappedTypeName(klass);
		if (typeMap.get(typeName) == null) {
			typeMap.put(typeName, klass);
		}
		// String dataSetId = _conditions.get(key);
		// Reader file = new FileReader(.fileFor(_path, dataSetId));
		try {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/rawdata/logging/AbstractRawDataMonitorable.java | 44 | 
| pl/edu/agh/cast/rawdata/stat/BrokenDataInfo.java | 314 | 
	}
	/**
	 * 
	 * {@inheritDoc}
	 * 
	 * @see pl.edu.agh.cast.rawdata.logging.IRawDataMonitorable#
	 *      registerObserver(pl.edu.agh.cast.rawdata.logging.IRawDataObserver)
	 * 
	 */
	public void registerObserver(IRawDataObserver observer) {
		Assert.isNotNull(observer, "Cannot register null value register"); //$NON-NLS-1$
		if (!observers.contains(observer)) {
			observers.add(observer);
			log.debug("The following observer has been registered: " //$NON-NLS-1$
			        + observer.toString());
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 197 | 
| pl/edu/agh/cast/model/mapper/Node.java | 585 | 
			updateNodeStmt = mapper.getConnection().prepareStatement(stmtStr, Statement.RETURN_GENERATED_KEYS);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	/**
	 * Save metamodel node in the DB.
	 * <p>
	 * The saving process is recursive. The node is saved first and then all source and destination links are saved.
	 * </p>
	 * TODO implement transactions
	 *
	 * @return True if the node was saved successfully or it's been saved earlier.
	 */
	public boolean save() {
		if (saved) {
			return true;
			// System.out.println("Save node ");
		}
		// validation
		if (typeName == null || typeName.equals("")) { //$NON-NLS-1$
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 723 | 
| pl/edu/agh/cast/model/mapper/Link.java | 741 | 
        ResultSet rs = findWithDstStmt.executeQuery();
        List<Link> result = new LinkedList<Link>();
        while (rs.next()) {
            result.add(createLink(rs, 0));
        }
        return result;
    }
    /**
     * Print out the stats of the link cache.
     */
    public static void stats() {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/AbstractModelDataLoader.java | 202 | 
| pl/edu/agh/cast/model/base/DataImporter.java | 145 | 
				startDate = new Date(Long.parseLong(tokens.get(2)));
				isDateParsed = true;
			} catch (NumberFormatException e) {
				// ignore the exception - we will try to parse the date using
				// SimpleFormatDate
			}
			SimpleDateFormat sdf = new SimpleDateFormat();
			for (String datePattern : SUPPORTED_DATE_FORMATS) {
				if (isDateParsed) {
					break;
				}
				try {
					sdf.applyPattern(datePattern);
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 192 | 
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 210 | 
	public static Method[] mappedLinkMethods(Class klass) {
		Method[] methods1 = klass.getDeclaredMethods();
		List<Method> result = new LinkedList<Method>();
		for (Method method : methods1) {
			if (method.isAnnotationPresent(MapLink.class)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Node.java | 741 | 
| pl/edu/agh/cast/model/mapper/Node.java | 798 | 
			while (rs.next()) {
				nodes.add(loadNode(rs, eager));
			}
			return nodes;
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 226 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 369 | 
			Object value = entry.getMethod().invoke(mappable);
			String attributeName = entry.getAnnotation().name();
			if (attributeName.equals("")) { //$NON-NLS-1$
				attributeName = entry.getMethod().getName();
			}
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 287 | 
| pl/edu/agh/cast/model/mapper/Node.java | 619 | 
				ResultSet rs = insertNodeStmt.getGeneratedKeys();
				if (rs.next()) {
					setId(rs.getLong(1));
					setSaved(true);
				} else {
					throw new SQLException("Cannot obtain the last node id"); //$NON-NLS-1$
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/Entity.java | 81 | 
| pl/edu/agh/cast/model/base/Entity.java | 101 | 
    public void removeRelation(IRelation relation) {
        if (relation.getSource() == this || relation.getTarget() == this) {
            if (relation.getSource() == this) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 220 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 366 | 
			appendAttributesXML(mappable, klass.getSuperclass());
		}
		for (AttributeEntry entry : Helper.getMappedAttributes(klass)) {
			Object value = entry.getMethod().invoke(mappable);
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/DataSet.java | 204 | 
| pl/edu/agh/cast/model/base/Relation.java | 180 | 
        return id;
    }
    /**
     * To Timed relations are equal if their source and target nodes have the same id.
     *
     * @param other
     *            The object to compare.
     * @return true if the objects are equal.
     */
    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof Relation)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 196 | 
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 214 | 
			if (method.isAnnotationPresent(MapLink.class)) {
				result.add(method);
			}
		}
		return result.toArray(new Method[0]);
	}
	/**
	 * Checks if given class is mapped to metamodel.
	 *
	 * @param klass
	 *            Checked class
	 * @return True if the class is mapped.
	 */
	public static boolean isSuperMapped(Class klass) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 152 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 124 | 
			saveLinks(object, node, (Class<Mappable>)klass.getSuperclass());
			// TODO DO NOT USE PRINTLN
			// System.out.println("Saving... " + klass.getSimpleName() +" " +
			// object);
		}
		// TODO custom save !!
		for (LinkEntry entry : Helper.getMappedLinks(klass)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/DataSet.java | 205 | 
| pl/edu/agh/cast/model/mapper/Node.java | 1202 | 
	}
	/**
	 *
	 * {@inheritDoc}
	 *
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof Node)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/ModelColumn.java | 69 | 
| pl/edu/agh/cast/model/ModelColumnParameter.java | 43 | 
    }
    /**
     * {@inheritDoc}
     *
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) { // the same object
            return true;
        }
        if (!(obj instanceof ModelColumnParameter)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 298 | 
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 318 | 
		AttributeEntry[] entries = new AttributeEntry[methods1.length];
		for (int i = 0; i < entries.length; i++) {
			entries[i] = new AttributeEntry(methods1[i], methods1[i].getAnnotation(MapAttribute.class));
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 150 | 
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 241 | 
	private void loadAttributes(Node node, Mappable object, Class<Mappable> klass) throws Exception {
		if (Helper.isSuperMapped(klass)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Node.java | 709 | 
| pl/edu/agh/cast/model/mapper/Node.java | 745 | 
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * Find all nodes with given type name which satisfy given set of conditions.
	 *
	 * @param typeName
	 *            The name of the type
	 * @param conditions
	 *            Map containing pairs: attribute name => value defining conditions which must be met for model
	 *            object for metamodel node to be loaded.
	 * @return Nodes with given type name
	 */
	public static List<Node> find(String typeName, SortedMap<String, Object> conditions) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 140 | 
| pl/edu/agh/cast/model/mapper/Link.java | 148 | 
        initialize(src, dst, name, priority.ordinal(), null, null, 0, 0);
    }
    public Link(Node src, Node dst, String name, Priority priority, String srcAcc, String dstAcc, int srcPosition,
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 267 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 286 | 
buffer.append(Helper.mappedTypeName(relation.getClass())); buffer.append(SINGLE_SPACE); buffer.append(ID); buffer.append(EQUAL_W_QUOTE);  | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 203 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 178 | 
		Type klass2 = method.getReturnType();
		if (klass2 != null && klass2.equals(List.class)) {
			Method setter = thatItem.getClass().getMethod(method.getName());
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Mapper.java | 237 | 
| pl/edu/agh/cast/model/mapper/internal/XMLLoader.java | 68 | 
	public XMLLoader(Map<Node, Mappable> cache, Class klass, Map<String, Class> typeMap,
	        SortedMap<String, Object> conditions, IProject project) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/Model.java | 174 | 
| pl/edu/agh/cast/model/base/Model.java | 203 | 
        Set<IEntity> entities = new HashSet<IEntity>();
        for (IDataSet set : dataSets) {
            for (IRelation relation : set.getRelations()) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/DataSet.java | 168 | 
| pl/edu/agh/cast/model/base/Model.java | 205 | 
            for (IRelation relation : set.getRelations()) {
                entities.add(relation.getSource());
                entities.add(relation.getTarget());
            }
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/DataSet.java | 129 | 
| pl/edu/agh/cast/model/base/Model.java | 180 | 
        List<IRelation> result = new LinkedList<IRelation>();
        result.addAll(relations);
        return result;
    }
    /**
     *
     * {@inheritDoc}
     *
     * @see pl.edu.agh.cast.model.base.IModel#getEntities()
     */
    public Collection<IEntity> getEntities() {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/rawdata/stat/BrokenDataInfo.java | 329 | 
| pl/edu/agh/cast/rawdata/stat/BrokenDataInfo.java | 349 | 
			observers.remove(observer);
			Set<DataRow> rows = brokenRows.keySet();
			for (DataRow row : rows) {
				row.unregisterObserver(observer);
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 199 | 
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 210 | 
+ linkMapping.name() + " for " //$NON-NLS-1$ + klass + " [" + node.getId() //$NON-NLS-1$ + "]"); //$NON-NLS-1$ }  | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/rawdata/DataRow.java | 147 | 
| pl/edu/agh/cast/rawdata/stat/ErrorType.java | 118 | 
        return code.compareTo(o.code);
    }
    /**
     *
     * {@inheritDoc}
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuffer res = new StringBuffer();
        res.append("[ErrorType code: ").append(getCode()) //$NON-NLS-1$
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 91 | 
| pl/edu/agh/cast/model/mapper/internal/Helper.java | 95 | 
		} else {
			accessor = getAnnotatedMethod(klass, linkName).getName().substring(3);
			linkToAccessor = new HashMap<String, String>(5);
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 108 | 
| pl/edu/agh/cast/model/mapper/internal/XMLLoader.java | 100 | 
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return Collections.emptyList();
	}
	private IModel loadModel() throws Exception {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/annotation/MapAttribute.java | 39 | 
| pl/edu/agh/cast/model/mapper/annotation/MapLink.java | 41 | 
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@Inherited
public @interface MapLink {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/ModelUtil.java | 83 | 
| pl/edu/agh/cast/model/ModelUtil.java | 238 | 
		for (IConfigurationElement element : elements) {
			if (element.getAttribute(BasePlugin.MODEL_ID).equals(modelId)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/rawdata/DataRow.java | 148 | 
| pl/edu/agh/cast/rawdata/stat/BrokenCellInfo.java | 59 | 
	}
	/**
	 * 
	 * {@inheritDoc}
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuffer res = new StringBuffer();
		res.append("Data row: ").append(getSourceRow().toString()).append(//$NON-NLS-1$
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 285 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 302 | 
buffer.append(LT_W_SLASH); buffer.append(Helper.mappedTypeName(relation.getClass())); buffer.append(GT_W_NEW_LINE);  | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 266 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 275 | 
buffer.append(LT_W_SLASH); buffer.append(Helper.mappedTypeName(mappable.getClass())); buffer.append(GT_W_NEW_LINE);  | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 76 | 
| pl/edu/agh/cast/model/mapper/internal/XMLSaver.java | 176 | 
			}
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	private void saveModelProps(IModel model) throws IOException {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 265 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 244 | 
						throw new RuntimeException("Too many links for attribute " + attributeName //$NON-NLS-1$
						        + " for " + klass + "[" + node.getId() //$NON-NLS-1$ //$NON-NLS-2$
						        + "]"); //$NON-NLS-1$
					} else {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 241 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 122 | 
	private void saveLinks(Mappable object, Node node, Class<Mappable> klass) throws Exception {
		if (Helper.isSuperMapped(klass)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 152 | 
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 243 | 
			loadAttributes(node, object, (Class<Mappable>)klass.getSuperclass());
		}
		for (Method method : Helper.mappedAttributeMethods(klass)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 150 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 122 | 
	private void saveLinks(Mappable object, Node node, Class<Mappable> klass) throws Exception {
		if (Helper.isSuperMapped(klass)) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/DBLoader.java | 77 | 
| pl/edu/agh/cast/model/mapper/internal/DBSaver.java | 62 | 
	public boolean save() {
		if (!Mapper.isDBPresent()) {
			log.warn("DB is not initialized"); //$NON-NLS-1$
			return false;
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/internal/AttributeEntry.java | 41 | 
| pl/edu/agh/cast/model/mapper/internal/LinkEntry.java | 43 | 
	public LinkEntry(Method method, MapLink annotation) {
		key = method;
		value = annotation;
	}
	/**
	 * Method getter.
	 *
	 * @return The method.
	 */
	public Method getMethod() {
		return key;
	}
	/**
	 * Annotation getter.
	 *
	 * @return The annotation.
	 */
	public MapLink getAnnotation() {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Node.java | 1040 | 
| pl/edu/agh/cast/model/mapper/Node.java | 1056 | 
			Node node = createNode(resultSet, 9);
			if (link.getSrcId() == this.id) {
				link.setSrc(this);
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 525 | 
| pl/edu/agh/cast/model/mapper/Link.java | 568 | 
        Link link;
        // try link cache first
        link = linkCache.get(linkId);
        if (link != null) {
            return link;
        }
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/mapper/Link.java | 140 | 
| pl/edu/agh/cast/model/mapper/Link.java | 144 | 
        initialize(src, dst, name, priority.ordinal(), srcAccessor, dstAccessor, 0, 0);
    }
    public Link(Node src, Node dst, String name, Priority priority) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/Relation.java | 230 | 
| pl/edu/agh/cast/model/base/TimedRelation.java | 148 | 
	public final int getFixedHashCode() {
		return null == id ? super.hashCode() : id.hashCode();
	}
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/base/AbstractModelDataLoader.java | 123 | 
| pl/edu/agh/cast/model/base/AbstractModelDataLoader.java | 173 | 
		index = mapping.get(DATE_INDEX);
		if (index != null && index < row.size()) {
 | |
| File | Line | 
|---|---|
| pl/edu/agh/cast/model/ModelColumn.java | 160 | 
| pl/edu/agh/cast/model/ModelColumnParameter.java | 98 | 
    }
    public String getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public Set<String> getPossibleValues() {
 | |