Code Duplication    Length = 45-48 lines in 2 locations

plugins/GraphSemanticLevelMarker/src/main/java/br/ufrj/ppgi/greco/kettle/GraphSemanticLevelMarkerStep.java 1 location

@@ 74-121 (lines=48) @@
71
	/**
72
	 * Metodo chamado para cada linha que entra no step
73
	 */
74
	public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
75
		GraphSemanticLevelMarkerStepMeta meta = (GraphSemanticLevelMarkerStepMeta) smi;
76
		GraphSemanticLevelMarkerStepData data = (GraphSemanticLevelMarkerStepData) sdi;
77
78
		String rulesFileName = meta.getRulesFilename();
79
		String LOVFileName = meta.getBrowseFilename();
80
81
		// Obtem linha do fluxo de entrada e termina caso nao haja mais entrada
82
		Object[] row = getRow();
83
		if (row == null) { // Nao ha mais linhas de dados
84
			setOutputDone();
85
			return false;
86
		}
87
88
		// Executa apenas uma vez. Variavel first definida na superclasse com
89
		// valor true
90
		if (first) {
91
			first = false;
92
93
			// Obtem todas as colunas ateh o step anterior.
94
			// Chamar apenas apos chamar getRow()
95
			data.outputRowMeta = new RowMeta();
96
97
			// Adiciona os metadados do step atual
98
			meta.getFields(data.outputRowMeta, getStepname(), null, null, this);
99
		}
100
101
		// Logica do step
102
		// Leitura de campos Input
103
		RowMetaInterface rowMeta = getInputRowMeta();
104
		int indexGraph = rowMeta.indexOfValue(meta.getInputGraph());
105
		Object graph = (indexGraph >= 0) ? row[indexGraph] : null;
106
107
		// Set output row
108
		Method[] methods = graph.getClass().getMethods();
109
		boolean hasListStatements = false;
110
		for (Method method : methods) {
111
			if (method.getName().equals("listStatements")) {
112
				hasListStatements = true;
113
				break;
114
			}
115
		}
116
117
		if (hasListStatements) {
118
			tripleWriter(graph, null, data, rulesFileName, LOVFileName);
119
		}
120
121
		return true;
122
	}
123
124
	private int tripleWriter(Object model, Object[] row, GraphSemanticLevelMarkerStepData data, String rulesFileName,

plugins/GraphTriplify/src/main/java/br/ufrj/ppgi/greco/kettle/GraphTriplifyStep.java 1 location

@@ 48-92 (lines=45) @@
45
	/**
46
	 * Metodo chamado para cada linha que entra no step
47
	 */
48
	public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
49
		GraphTriplifyStepMeta meta = (GraphTriplifyStepMeta) smi;
50
		GraphTriplifyStepData data = (GraphTriplifyStepData) sdi;
51
52
		// Obtem linha do fluxo de entrada e termina caso nao haja mais entrada
53
		Object[] row = getRow();
54
		if (row == null) { // Nao ha mais linhas de dados
55
			setOutputDone();
56
			return false;
57
		}
58
59
		// Executa apenas uma vez. Variavel first definida na superclasse com
60
		// valor true
61
		if (first) {
62
			first = false;
63
64
			// Obtem todas as colunas ateh o step anterior.
65
			// Chamar apenas apos chamar getRow()
66
			data.outputRowMeta = new RowMeta();
67
68
			// Adiciona os metadados do step atual
69
			meta.getFields(data.outputRowMeta, getStepname(), null, null, this);
70
		}
71
72
		// Logica do step
73
		// Leitura de campos Input
74
		RowMetaInterface rowMeta = getInputRowMeta();
75
		int indexGraph = rowMeta.indexOfValue(meta.getInputGraph());
76
		Object graph = (indexGraph >= 0) ? row[indexGraph] : null;
77
78
		// Set output row
79
		Method[] methods = graph.getClass().getMethods();
80
		boolean hasListStatements = false;
81
		for (Method method : methods) {
82
			if (method.getName().equals("listStatements")) {
83
				hasListStatements = true;
84
				break;
85
			}
86
		}
87
88
		if (hasListStatements) {
89
			tripleWriter(graph, null, data);
90
		}
91
92
		return true;
93
	}
94
95
	private int tripleWriter(Object model, Object[] row, GraphTriplifyStepData data) throws KettleStepException {