Skip to content

Commit 3adb359

Browse files
authored
Merge pull request #9 from hkuich/002-fixes
- improved logging for mistakes in configuration files (better point…
2 parents f98b2b4 + 71875cd commit 3adb359

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group 'com.github.bayer-science-for-a-better-life'
8-
version '0.0.1'
8+
version '0.0.2'
99

1010
repositories {
1111
mavenCentral()

src/main/java/configuration/ProcessorConfigEntry.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package configuration;
2+
import org.apache.logging.log4j.LogManager;
3+
import org.apache.logging.log4j.Logger;
4+
25
import java.util.HashMap;
36
import java.util.Map;
47

58
public class ProcessorConfigEntry {
69

10+
private static final Logger appLogger = LogManager.getLogger("com.bayer.dt.grami");
11+
712
private String processor;
813
private String processorType;
914
private String schemaType;
@@ -30,6 +35,9 @@ public HashMap<String, HashMap<String, ConceptGenerator>> getConceptGenerators()
3035
}
3136

3237
public ConceptGenerator getAttributeGenerator(String key) {
38+
if(getConceptGenerators().get("attributes") == null) {
39+
throw new RuntimeException("You have specified the attribute [" + key + "] in your dataConfig file - but there are no attributeGenerators specified in the corresponding processor.");
40+
}
3341
for (Map.Entry<String, ConceptGenerator> entry : getConceptGenerators().get("attributes").entrySet()) {
3442
if (entry.getKey().equals(key)) {
3543
return entry.getValue();

src/main/java/generator/RelationInsertGenerator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private StatementInstance playersInsert(ArrayList<Statement> matchStatements, in
118118
boolean insert = false;
119119
for (Statement st :matchStatements) {
120120
//need to have player in match statement or cannot insert as player in relation
121-
if (st.toString().contains(playerGenerator.getPlayerType())) {
121+
if (st.toString().contains(playerGenerator.getUniquePlayerId())) {
122122
insert = true;
123123
}
124124
}
@@ -140,6 +140,9 @@ private Collection<? extends Statement> playersMatch(String[] tokens, String[] h
140140
for (DataConfigEntry.GeneratorSpecification playerDataConfigEntry : dce.getPlayers()) {
141141
ProcessorConfigEntry.ConceptGenerator playerGenerator = gce.getPlayerGenerator(playerDataConfigEntry.getGenerator());
142142
int playerDataIndex = idxOf(headerTokens, playerDataConfigEntry);
143+
if(playerDataIndex == -1) {
144+
appLogger.error("The column header in your dataconfig mapping to the uniquePlayerId [" + playerGenerator.getUniquePlayerId() + "] cannot be found in the file you specified.");
145+
}
143146
if (tokens.length > playerDataIndex &&
144147
!cleanToken(tokens[playerDataIndex]).isEmpty()) {
145148
StatementInstance ms = Graql

src/main/java/migrator/GraknMigrator.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void migrate(boolean migrateEntities, boolean migrateRelations) throws IO
7070

7171
session.close();
7272
client.close();
73+
appLogger.info("GraMi is finished!");
7374
}
7475

7576
private void migrateThingsInOrder(GraknClient.Session session, boolean migrateEntities, boolean migrateRelations) throws IOException {
@@ -91,11 +92,11 @@ private void getStatusAndMigrate(GraknClient.Session session, String conceptType
9192
String currentProcessor = dce.getProcessor();
9293
if(isOfConceptType(currentProcessor, conceptType)){
9394
appLogger.info("migrating [" + dcEntryKey + "]...");
94-
if (migrationStatus != null && migrationStatus.get(dcEntryKey) != null) {
95+
if (migrationStatus != null && migrationStatus.get(dce.getDataPath()) != null) {
9596
appLogger.info("previous migration status found for entity type: [" + dcEntryKey + "]");
96-
if (!migrationStatus.get(dcEntryKey).isCompleted()) {
97-
appLogger.info(dcEntryKey + " not completely migrated yet, rows already migrated: " + migrationStatus.get(dcEntryKey).getMigratedRows());
98-
getGeneratorAndInsert(session, dce, migrationStatus.get(dcEntryKey).getMigratedRows());
97+
if (!migrationStatus.get(dce.getDataPath()).isCompleted()) {
98+
appLogger.info(dcEntryKey + " not completely migrated yet, rows already migrated: " + migrationStatus.get(dce.getDataPath()).getMigratedRows());
99+
getGeneratorAndInsert(session, dce, migrationStatus.get(dce.getDataPath()).getMigratedRows());
99100
} else {
100101
appLogger.info(dcEntryKey + " is already completely migrated - moving on...");
101102
}
@@ -166,8 +167,8 @@ private void writeThingToGrakn(DataConfigEntry dce, InsertGenerator gen, GraknCl
166167
//insert the rest when loop exits with less than batch size
167168
if (!rows.isEmpty()) {
168169
writeThing(dce, gen, session, rows, batchSizeCounter, header);
170+
appLogger.info("final # rows processed: " + totalRecordCounter);
169171
}
170-
appLogger.info("final # rows processed: " + totalRecordCounter);
171172
} catch (IOException e) {
172173
e.printStackTrace();
173174
}
@@ -250,6 +251,7 @@ private void updateMigrationStatusIsCompleted(DataConfigEntry dce) throws IOExce
250251
try {
251252
Gson gson = new Gson();
252253
Type MigrationStatusMapType = new TypeToken<HashMap<String, MigrationStatus>>(){}.getType();
254+
System.out.println("data path: " + dce.getDataPath() + " and thing: " + dce.getProcessor());
253255
migrationStatus.get(dce.getDataPath()).setCompleted(true);
254256
FileWriter fw = new FileWriter(migrationStatePath);
255257
gson.toJson(migrationStatus, MigrationStatusMapType, fw);

0 commit comments

Comments
 (0)