long processId = 0L;
long processRequirementId = 0L;
for (int i = 0; i < processListSize; i++) {
String line = readStringValue();
String[] lineTokens = splitBySpace(line, 2 + resourceListSize);
MrProcess process = new MrProcess();
process.setId(processId);
int serviceIndex = Integer.parseInt(lineTokens[0]);
if (serviceIndex >= serviceList.size()) {
throw new IllegalArgumentException("Process with id (" + processId
+ ") has a non existing serviceIndex (" + serviceIndex + ").");
}
MrService service = serviceList.get(serviceIndex);
process.setService(service);
List<MrProcessRequirement> processRequirementList
= new ArrayList<MrProcessRequirement>(resourceListSize);
for (int j = 0; j < resourceListSize; j++) {
MrProcessRequirement processRequirement = new MrProcessRequirement();
processRequirement.setId(processRequirementId);
processRequirement.setProcess(process);
processRequirement.setResource(resourceList.get(j));
processRequirement.setUsage(Integer.parseInt(lineTokens[1 + j]));
processRequirementList.add(processRequirement);
processRequirementId++;
}
process.setProcessRequirementList(processRequirementList);
process.setMoveCost(Integer.parseInt(lineTokens[1 + resourceListSize]));
processList.add(process);
processId++;
}
machineReassignment.setProcessList(processList);
}