Faster database mode boot.
Reduced # of DB queries.
This commit is contained in:
parent
74e70dd21a
commit
c71ce6ff92
|
|
@ -211,6 +211,7 @@ public class DatabaseDataStore extends DataStore
|
||||||
results = statement.executeQuery("SELECT * FROM griefprevention_claimdata;");
|
results = statement.executeQuery("SELECT * FROM griefprevention_claimdata;");
|
||||||
|
|
||||||
ArrayList<Claim> claimsToRemove = new ArrayList<Claim>();
|
ArrayList<Claim> claimsToRemove = new ArrayList<Claim>();
|
||||||
|
ArrayList<Claim> subdivisionsToLoad = new ArrayList<Claim>();
|
||||||
|
|
||||||
while(results.next())
|
while(results.next())
|
||||||
{
|
{
|
||||||
|
|
@ -218,7 +219,6 @@ public class DatabaseDataStore extends DataStore
|
||||||
{
|
{
|
||||||
//skip subdivisions
|
//skip subdivisions
|
||||||
long parentId = results.getLong("parentid");
|
long parentId = results.getLong("parentid");
|
||||||
if(parentId != -1) continue;
|
|
||||||
|
|
||||||
long claimID = results.getLong("id");
|
long claimID = results.getLong("id");
|
||||||
|
|
||||||
|
|
@ -294,44 +294,17 @@ public class DatabaseDataStore extends DataStore
|
||||||
String [] managerNames = managersString.split(";");
|
String [] managerNames = managersString.split(";");
|
||||||
managerNames = this.convertNameListToUUIDList(managerNames);
|
managerNames = this.convertNameListToUUIDList(managerNames);
|
||||||
|
|
||||||
Claim topLevelClaim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builderNames, containerNames, accessorNames, managerNames, claimID);
|
Claim claim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builderNames, containerNames, accessorNames, managerNames, claimID);
|
||||||
|
|
||||||
this.addClaim(topLevelClaim, false);
|
if(parentId == -1)
|
||||||
|
|
||||||
//look for any subdivisions for this claim
|
|
||||||
Statement statement2 = this.databaseConnection.createStatement();
|
|
||||||
ResultSet childResults = statement2.executeQuery("SELECT * FROM griefprevention_claimdata WHERE parentid=" + topLevelClaim.id + ";");
|
|
||||||
|
|
||||||
while(childResults.next())
|
|
||||||
{
|
{
|
||||||
String lesserCornerString = childResults.getString("lessercorner");
|
//top level claim
|
||||||
lesserBoundaryCorner = this.locationFromString(lesserCornerString);
|
this.addClaim(claim, false);
|
||||||
|
}
|
||||||
String greaterCornerString = childResults.getString("greatercorner");
|
else
|
||||||
greaterBoundaryCorner = this.locationFromString(greaterCornerString);
|
{
|
||||||
|
//subdivision
|
||||||
buildersString = childResults.getString("builders");
|
subdivisionsToLoad.add(claim);
|
||||||
builderNames = buildersString.split(";");
|
|
||||||
builderNames = this.convertNameListToUUIDList(builderNames);
|
|
||||||
|
|
||||||
containersString = childResults.getString("containers");
|
|
||||||
containerNames = containersString.split(";");
|
|
||||||
containerNames = this.convertNameListToUUIDList(containerNames);
|
|
||||||
|
|
||||||
accessorsString = childResults.getString("accessors");
|
|
||||||
accessorNames = accessorsString.split(";");
|
|
||||||
accessorNames = this.convertNameListToUUIDList(accessorNames);
|
|
||||||
|
|
||||||
managersString = childResults.getString("managers");
|
|
||||||
managerNames = managersString.split(";");
|
|
||||||
managerNames = this.convertNameListToUUIDList(managerNames);
|
|
||||||
|
|
||||||
Claim childClaim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, null, builderNames, containerNames, accessorNames, managerNames, null);
|
|
||||||
|
|
||||||
//add this claim to the list of children of the current top level claim
|
|
||||||
childClaim.parent = topLevelClaim;
|
|
||||||
topLevelClaim.children.add(childClaim);
|
|
||||||
childClaim.inDataStore = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
catch(SQLException e)
|
||||||
|
|
@ -339,6 +312,18 @@ public class DatabaseDataStore extends DataStore
|
||||||
GriefPrevention.AddLogEntry("Unable to load a claim. Details: " + e.getMessage() + " ... " + results.toString());
|
GriefPrevention.AddLogEntry("Unable to load a claim. Details: " + e.getMessage() + " ... " + results.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add subdivisions to their parent claims
|
||||||
|
for(Claim childClaim : subdivisionsToLoad)
|
||||||
|
{
|
||||||
|
//find top level claim parent
|
||||||
|
Claim topLevelClaim = this.getClaimAt(childClaim.getLesserBoundaryCorner(), true, null);
|
||||||
|
|
||||||
|
//add this claim to the list of children of the current top level claim
|
||||||
|
childClaim.parent = topLevelClaim;
|
||||||
|
topLevelClaim.children.add(childClaim);
|
||||||
|
childClaim.inDataStore = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < claimsToRemove.size(); i++)
|
for(int i = 0; i < claimsToRemove.size(); i++)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user