String name = inv.getString("name");
Long sourceId = inv.getLong("source-id");
Long gspGroupId = inv.getLong("gsp-group-id");
if (!inv.isValid()) {
throw new UserException(document());
}
Source supplySource = Source.getSource(sourceId);
GeneratorType type = null;
if (supplySource.getCode().equals(Source.GENERATOR_CODE)
|| supplySource.getCode().equals(
Source.GENERATOR_NETWORK_CODE)) {
Long generatorTypeId = inv.getLong("generator-type-id");
if (!inv.isValid()) {
throw new UserException(document());
}
type = GeneratorType.getGeneratorType(generatorTypeId);
}
GspGroup gspGroup = GspGroup.getGspGroup(gspGroupId);
update(name, supplySource, type, gspGroup);