use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class EquipmentMigrationTest method setUp.
/**
* @throws java.lang.Exception
*/
@Override
public void setUp() throws Exception {
super.setUp();
gameMode = SettingsHandler.getGame().getName();
MigrationRule equipRule = new MigrationRule(ObjectType.EQUIPMENT, "OldKey1");
equipRule.setMaxVer("6.0.1");
equipRule.setNewKey("NewKey1");
SystemCollections.addToMigrationRulesList(equipRule, gameMode);
MigrationRule equipRule2 = new MigrationRule(ObjectType.EQUIPMENT, "OldKey2");
equipRule2.setMaxVer("6.0.1");
equipRule2.setMinVer("5.17.7");
equipRule2.setNewKey("LateNewKey");
SystemCollections.addToMigrationRulesList(equipRule2, gameMode);
MigrationRule equipRule2A = new MigrationRule(ObjectType.EQUIPMENT, "OldKey2");
equipRule2A.setMaxVer("5.16.4");
equipRule2A.setMaxDevVer("5.17.5");
equipRule2A.setNewKey("EarlyNewKey");
SystemCollections.addToMigrationRulesList(equipRule2A, gameMode);
MigrationRule equipRuleDiffGame = new MigrationRule(ObjectType.EQUIPMENT, "OldKey3");
equipRuleDiffGame.setMaxVer("6.0.0");
equipRuleDiffGame.setNewKey("NewKeyModern");
SystemCollections.addToMigrationRulesList(equipRuleDiffGame, "modern");
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class RaceMigrationTest method setUp.
/**
* @throws java.lang.Exception
*/
@Override
public void setUp() throws Exception {
super.setUp();
gameMode = SettingsHandler.getGame().getName();
MigrationRule raceRule = new MigrationRule(ObjectType.RACE, "OldKey1");
raceRule.setMaxVer("6.0.1");
raceRule.setNewKey("NewKey1");
SystemCollections.addToMigrationRulesList(raceRule, gameMode);
MigrationRule raceRule2 = new MigrationRule(ObjectType.RACE, "OldKey2");
raceRule2.setMaxVer("6.0.1");
raceRule2.setMinVer("5.17.7");
raceRule2.setNewKey("LateNewKey");
SystemCollections.addToMigrationRulesList(raceRule2, gameMode);
MigrationRule raceRule2A = new MigrationRule(ObjectType.RACE, "OldKey2");
raceRule2A.setMaxVer("5.16.4");
raceRule2A.setMaxDevVer("5.17.5");
raceRule2A.setNewKey("EarlyNewKey");
SystemCollections.addToMigrationRulesList(raceRule2A, gameMode);
MigrationRule raceRuleDiffGame = new MigrationRule(ObjectType.RACE, "OldKey3");
raceRuleDiffGame.setMaxVer("6.0.0");
raceRuleDiffGame.setNewKey("NewKeyModern");
SystemCollections.addToMigrationRulesList(raceRuleDiffGame, "modern");
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoaderTest method testParseFirstTokenValidRace.
@Test
public void testParseFirstTokenValidRace() {
MigrationRule migrationRule = migrationLoader.parseFirstToken("RACE:Old Key", "", sourceURI);
assertNotNull(migrationRule);
assertEquals("Object type", ObjectType.RACE, migrationRule.getObjectType());
assertEquals("Old key", "Old Key", migrationRule.getOldKey());
assertNull("Old category", migrationRule.getOldCategory());
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class MigrationLoader method parseLine.
/**
* @see pcgen.persistence.lst.LstLineFileLoader#parseLine(pcgen.rules.context.LoadContext, java.lang.String, java.net.URI)
*/
@Override
public void parseLine(LoadContext context, String lstLine, URI sourceURI) throws PersistenceLayerException {
final StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM);
String firstToken = colToken.nextToken().trim();
final MigrationRule migrationRule = parseFirstToken(firstToken, lstLine, sourceURI);
if (migrationRule == null) {
return;
}
Map<String, LstToken> tokenMap = TokenStore.inst().getTokenMap(MigrationLstToken.class);
while (colToken.hasMoreTokens()) {
final String colString = colToken.nextToken().trim();
final int idxColon = colString.indexOf(':');
String key = "";
try {
key = colString.substring(0, idxColon);
} catch (StringIndexOutOfBoundsException e) {
// TODO Handle Exception
}
MigrationLstToken token = (MigrationLstToken) tokenMap.get(key);
if (token != null) {
final String value = colString.substring(idxColon + 1);
LstUtils.deprecationCheck(token, migrationRule.getOldKey(), sourceURI, value);
if (!token.parse(migrationRule, value, getGameMode())) {
Logging.errorPrint("Error parsing migration rule " + migrationRule.getOldKey() + ':' + sourceURI + ':' + colString + "\"");
return;
}
} else {
Logging.errorPrint("Unknown token " + key + " in migration rule '" + lstLine + "' in " + sourceURI.toString());
return;
}
}
// Check for mandatory tokens and interrelationship rules
boolean errorFound = false;
if (migrationRule.getMaxVer() == null) {
Logging.errorPrint("Missing required token MAXVER in migration rule '" + lstLine + "' in " + sourceURI.toString());
errorFound = true;
}
if (migrationRule.getNewKey() == null) {
Logging.errorPrint("Missing required token NEWKEY in migration rule '" + lstLine + "' in " + sourceURI.toString());
errorFound = true;
}
if (migrationRule.getMinVer() == null && migrationRule.getMinDevVer() != null) {
Logging.errorPrint("MINVER is required when MINDEVVER is used. Migration rule was '" + lstLine + "' in " + sourceURI.toString());
errorFound = true;
}
if (migrationRule.getMaxVer() != null && migrationRule.getMaxDevVer() != null && CoreUtility.compareVersions(migrationRule.getMaxVer(), migrationRule.getMaxDevVer()) >= 0) {
Logging.errorPrint("MAXVER must be before MAXDEVVER. Migration rule was '" + lstLine + "' in " + sourceURI.toString());
errorFound = true;
}
if (migrationRule.getMinVer() != null && migrationRule.getMinDevVer() != null && CoreUtility.compareVersions(migrationRule.getMinVer(), migrationRule.getMinDevVer()) >= 0) {
Logging.errorPrint("MINVER must be before MINDEVVER. Migration rule was '" + lstLine + "' in " + sourceURI.toString());
errorFound = true;
}
if (errorFound) {
// Abandon this rule.
return;
}
SystemCollections.addToMigrationRulesList(migrationRule, gameMode);
}
use of pcgen.core.system.MigrationRule in project pcgen by PCGen.
the class AbilityMigrationTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
gameMode = SettingsHandler.getGame().getName();
MigrationRule abilityRule = new MigrationRule(ObjectType.ABILITY, "OldCat", "OldKey1");
abilityRule.setMaxVer("6.0.1");
abilityRule.setNewKey("NewKey1");
SystemCollections.addToMigrationRulesList(abilityRule, gameMode);
MigrationRule abilityRule2 = new MigrationRule(ObjectType.ABILITY, "OldCat", "OldKey2");
abilityRule2.setMaxVer("6.0.1");
abilityRule2.setMinVer("5.17.7");
abilityRule2.setNewKey("LateNewKey");
SystemCollections.addToMigrationRulesList(abilityRule2, gameMode);
MigrationRule abilityRule2A = new MigrationRule(ObjectType.ABILITY, "OldCat", "OldKey2");
abilityRule2A.setMaxVer("5.16.4");
abilityRule2A.setMaxDevVer("5.17.5");
abilityRule2A.setNewCategory("EarlyNewCat");
abilityRule2A.setNewKey("EarlyNewKey");
SystemCollections.addToMigrationRulesList(abilityRule2A, gameMode);
MigrationRule abilityRuleDiffGame = new MigrationRule(ObjectType.ABILITY, "OldCat", "OldKey3");
abilityRuleDiffGame.setMaxVer("6.0.0");
abilityRuleDiffGame.setNewKey("NewKeyModern");
SystemCollections.addToMigrationRulesList(abilityRuleDiffGame, "modern");
}
Aggregations