Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models and houses #1686

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ RUN mkdir ${TEMP_DIR} \
&& cp /gridappsd/services/gridappsd-toolbox/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \
&& cd \
&& rm -rf ${TEMP_DIR}

# Get the CIMHub from the proper repository
RUN mkdir ${TEMP_DIR} \
&& cd ${TEMP_DIR} \
&& git clone https://github.com/GRIDAPPSD/CIMHub -b prefix \
&& cd CIMHub \
&& mkdir -p /gridappsd/CIMHub \
&& rm .git -rf \
&& cp -r * /gridappsd/CIMHub \
&& cd \
&& rm -rf ${TEMP_DIR}

# Copy initial applications and services into the container.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.apache.jena.query.ResultSet;

import gov.pnnl.goss.gridappsd.dto.PowergridModelInfo;

public interface PowergridModelDataManager {
public enum ResultFormat {
JSON, XML, CSV
Expand Down Expand Up @@ -36,6 +38,16 @@ public enum ResultFormat {
String queryMeasurementDictByObject(String resultFormat, String modelId, String objectType, String objectId, String processId, String username) throws Exception ;
ResultSet queryMeasurementDictByObjectResultSet(String modelId, String objectType, String objectId, String processId, String username);

void insertMeasurements(String modelId, String modelName, String processId, String username) throws Exception;
void dropMeasurements(String modelId, String modelName, String processId, String username);
void insertAllMeasurements( String processId, String username, List<PowergridModelInfo> modelList) throws Exception;
void dropAllMeasurements(String processId, String username, List<PowergridModelInfo> modelList) throws Exception;

void insertHouses(String modelId, String modelName, String region, double seed, double scale, String processId, String username) throws Exception;
void dropHouses(String modelId, String modelName, String processId, String username);
void insertAllHouses(String processId, String username, List<PowergridModelInfo> modelList) throws Exception;
void dropAllHouses(String processId, String username, List<PowergridModelInfo> modelList) throws Exception;


void putModel(String modelId, String model, String inputFormat, String processId, String username);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,66 @@ public Serializable handle(Serializable requestContent, String processId, String
//TODO send error
}
return dataManager.queryMeasurementDictByObject(pgDataRequest.getResultFormat(), pgDataRequest.getModelId(), pgDataRequest.getObjectType(), pgDataRequest.getObjectId(), processId, username);
} else if(PowergridModelDataRequest.RequestType.INSERT_ALL_HOUSES.toString().equals(pgDataRequest.requestType)){

dataManager.insertAllHouses(processId, username, pgDataRequest.getModelList());
return true;
} else if(PowergridModelDataRequest.RequestType.INSERT_HOUSES.toString().equals(pgDataRequest.requestType)){
if ((pgDataRequest.getModelId()==null || pgDataRequest.getModelId().length()==0) && (pgDataRequest.getModel().getModelId()==null || pgDataRequest.getModel().getModelId().length()==0)){
return "{\"message\":\"No model provided\"}";
}

if((pgDataRequest.getModelId()!=null && pgDataRequest.getModelId().length()>0))
dataManager.insertHouses(pgDataRequest.getModelId(), pgDataRequest.getModelName(), "3", 0, 1.0, processId, username);
else{
dataManager.insertHouses(pgDataRequest.getModel().getModelId(), pgDataRequest.getModel().getModelName(), pgDataRequest.getModel().getRegion(), pgDataRequest.getModel().getSeed(), pgDataRequest.getModel().getScale(), processId, username);
}
return true;
} else if(PowergridModelDataRequest.RequestType.DROP_HOUSES.toString().equals(pgDataRequest.requestType)){
if ((pgDataRequest.getModelId()==null || pgDataRequest.getModelId().length()==0) && (pgDataRequest.getModel().getModelId()==null || pgDataRequest.getModel().getModelId().length()==0)){
return "{\"message\":\"No model provided\"}";
}

if((pgDataRequest.getModelId()!=null && pgDataRequest.getModelId().length()>0))
dataManager.dropHouses(pgDataRequest.getModelId(), pgDataRequest.getModelName(), processId, username);
else{
dataManager.dropHouses(pgDataRequest.getModel().getModelId(), pgDataRequest.getModel().getModelName(), processId, username);
}
return true;
} else if(PowergridModelDataRequest.RequestType.DROP_ALL_HOUSES.toString().equals(pgDataRequest.requestType)){
dataManager.dropAllHouses(processId, username, pgDataRequest.getModelList());
return true;
} else if(PowergridModelDataRequest.RequestType.INSERT_ALL_MEASURMENTS.toString().equals(pgDataRequest.requestType)){
dataManager.insertAllMeasurements(processId, username, pgDataRequest.getModelList());
return true;
} else if(PowergridModelDataRequest.RequestType.INSERT_MEASUREMENTS.toString().equals(pgDataRequest.requestType)){
if ((pgDataRequest.getModelId()==null || pgDataRequest.getModelId().length()==0) && (pgDataRequest.getModel().getModelId()==null || pgDataRequest.getModel().getModelId().length()==0)){
return "{\"message\":\"No model provided\"}";
}

if((pgDataRequest.getModelId()!=null && pgDataRequest.getModelId().length()>0))
dataManager.insertMeasurements(pgDataRequest.getModelId(), pgDataRequest.getModelName(), processId, username);
else{
dataManager.insertMeasurements(pgDataRequest.getModel().getModelId(), pgDataRequest.getModel().getModelName(), processId, username);
}

return true;
} else if(PowergridModelDataRequest.RequestType.DROP_MEASUREMENTS.toString().equals(pgDataRequest.requestType)){
if ((pgDataRequest.getModelId()==null || pgDataRequest.getModelId().length()==0) && (pgDataRequest.getModel().getModelId()==null || pgDataRequest.getModel().getModelId().length()==0)){
return "{\"message\":\"No model provided\"}";
}

if((pgDataRequest.getModelId()!=null && pgDataRequest.getModelId().length()>0))
dataManager.dropMeasurements(pgDataRequest.getModelId(), pgDataRequest.getModelName(), processId, username);
else{
dataManager.dropMeasurements(pgDataRequest.getModel().getModelId(), pgDataRequest.getModel().getModelName(), processId, username);
}

return true;
} else if(PowergridModelDataRequest.RequestType.DROP_ALL_MEASUREMENTS.toString().equals(pgDataRequest.requestType)){
dataManager.dropAllMeasurements(processId, username, pgDataRequest.getModelList());

return true;
} else {
//TODO report error, request type not recognized
System.out.println("DOESNT RECOGNIZE REQUEST TYPE "+pgDataRequest.requestType);
Expand Down
Loading