Skip to content

Commit

Permalink
Fix style NeedBraces
Browse files Browse the repository at this point in the history
  • Loading branch information
yichen88 committed Aug 30, 2017
1 parent 1ff968b commit 67e1029
Show file tree
Hide file tree
Showing 145 changed files with 1,816 additions and 920 deletions.
4 changes: 3 additions & 1 deletion EU2Mod_MB/src/main/java/itesla/converter/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ private ModelicaModel EUparser() throws IOException{
public void convert2MO() throws IOException {
File frm = new File(pathfrm);
String nameModel = frm.getName().split("\\.")[0];
if (init) nameModel = nameModel+"_init";
if (init) {
nameModel = nameModel + "_init";
}
File outFile = new File(pathOut, nameModel + ".mo");
BufferedWriter out = new BufferedWriter(new FileWriter(outFile));

Expand Down
1 change: 1 addition & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<module name="TreeWalker">
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="NeedBraces"/>
<module name="UnusedImports"/>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,12 @@ public static void convert(Network n, List< Contingency > contingencies, Forecas
int typeBus = 0; // Default -> PQ bus
double minimumVoltage = b.getVoltageLevel().getLowVoltageLimit() / baseKV;
double maximumVoltage = b.getVoltageLevel().getHighVoltageLimit() / baseKV;
if( Double.isNaN( minimumVoltage ) )
if( Double.isNaN( minimumVoltage ) ) {
minimumVoltage = defaultMinimumVoltage;
if( Double.isNaN( maximumVoltage ) )
}
if( Double.isNaN( maximumVoltage ) ) {
maximumVoltage = defaultMaximumVoltage;
}
double desiredVoltage = 1.0;
if( !Double.isNaN( b.getV() ) ) {
desiredVoltage = b.getV() / baseKV;
Expand Down Expand Up @@ -349,10 +351,12 @@ public static void convert(Network n, List< Contingency > contingencies, Forecas
loadMW += gen.getTargetP();
}
generationMVAR += gen.getTargetQ();
if( gen.getMinP() > 0.0 )
if( gen.getMinP() > 0.0 ) {
minimumGenerationMW += gen.getMinP();
if( gen.getMaxP() > 0.0 )
}
if( gen.getMaxP() > 0.0 ) {
maximumGenerationMW += gen.getMaxP();
}
minimumGenerationMVAR += gen.getReactiveLimits().getMinQ((float)0);
maximumGenerationMVAR += gen.getReactiveLimits().getMaxQ((float)0);
if( gen.isVoltageRegulatorOn() ) {
Expand All @@ -362,14 +366,18 @@ public static void convert(Network n, List< Contingency > contingencies, Forecas
}
}
// Correct generation limits
if( generationMW > maximumGenerationMW )
if( generationMW > maximumGenerationMW ) {
maximumGenerationMW = generationMW;
if( generationMW < minimumGenerationMW )
}
if( generationMW < minimumGenerationMW ) {
minimumGenerationMW = generationMW;
if( generationMVAR > maximumGenerationMVAR )
}
if( generationMVAR > maximumGenerationMVAR ) {
maximumGenerationMVAR = generationMVAR;
if( generationMVAR < minimumGenerationMVAR )
}
if( generationMVAR < minimumGenerationMVAR ) {
minimumGenerationMVAR = generationMVAR;
}
// Update generation of the PQ bus
if( typeBus == 0 ) {
minimumGenerationMW = 0;
Expand Down Expand Up @@ -445,10 +453,12 @@ public static void convert(Network n, List< Contingency > contingencies, Forecas
int typeBus = 0; // Default -> PQ bus
double minimumVoltage = dl.getTerminal().getBusView().getBus().getVoltageLevel().getLowVoltageLimit() / baseKV;
double maximumVoltage = dl.getTerminal().getBusView().getBus().getVoltageLevel().getHighVoltageLimit() / baseKV;
if( Double.isNaN( minimumVoltage ) )
if( Double.isNaN( minimumVoltage ) ) {
minimumVoltage = defaultMinimumVoltage;
if( Double.isNaN( maximumVoltage ) )
}
if( Double.isNaN( maximumVoltage ) ) {
maximumVoltage = defaultMaximumVoltage;
}
double desiredVoltage = dl.getTerminal().getBusView().getBus().getV() / baseKV;
double desiredAngle = dl.getTerminal().getBusView().getBus().getAngle();
double generationMW = 0.0;
Expand Down Expand Up @@ -644,10 +654,12 @@ public static void convert(Network n, List< Contingency > contingencies, Forecas
int typeBus = 0; // Default -> PQ bus
double minimumVoltage = t.getLeg1().getTerminal().getBusView().getBus().getVoltageLevel().getLowVoltageLimit() / baseKV;
double maximumVoltage = t.getLeg1().getTerminal().getBusView().getBus().getVoltageLevel().getHighVoltageLimit() / baseKV;
if( Double.isNaN( minimumVoltage ) )
if( Double.isNaN( minimumVoltage ) ) {
minimumVoltage = defaultMinimumVoltage;
if( Double.isNaN( maximumVoltage ) )
}
if( Double.isNaN( maximumVoltage ) ) {
maximumVoltage = defaultMaximumVoltage;
}
double desiredVoltage = t.getLeg1().getTerminal().getBusView().getBus().getV() / baseKV;
double desiredAngle = t.getLeg1().getTerminal().getBusView().getBus().getAngle();
double generationMW = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ public String updateRecord(String id, String[] headers, Object[] values) {
writer.close();

// if no id is provided, rely on server-side auto-increment mechanism
if (id == null) id = "autoIncrement";
if (id == null) {
id = "autoIncrement";
}

try (InputStream is = httpClient.postHttpRequest(new HistoDbUrl(config,
"data/" + id + ".csv", // WARN here one must NOT use the itesla suffix (not supporting POST of new data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ public List<SecurityRule> getRules(String workflowId, RuleAttributeSet attribute
StringBuilder path = new StringBuilder();
path.append(RULES_PREFIX).append(workflowId)
.append("/itesla/rules/").append(attributeSet);
if (contingencyId != null) path.append("/").append(contingencyId);
if (securityIndexType != null) path.append("/").append(securityIndexType.getLabel());
if (contingencyId != null) {
path.append("/").append(contingencyId);
}
if (securityIndexType != null) {
path.append("/").append(securityIndexType.getLabel());
}
path.append(".json");

List<SecurityRule> result = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public static Zone getZone(ActionsContingencies actionContingencies , BigInteger
for(Zone z :zones.getZone())
{
BigInteger zoneNumber=z.getNumber();
if (zoneNumber.equals(number))
if (zoneNumber.equals(number)) {
return z;
}
}

return null;
Expand All @@ -60,8 +61,9 @@ public static Zone getZone(ActionsContingencies actionContingencies, String name
for(Zone z :zones.getZone())
{
String zoneName=z.getName();
if (zoneName.equals(name))
if (zoneName.equals(name)) {
return z;
}
}
}
return null;
Expand All @@ -80,16 +82,15 @@ public static Set<Zone> getZone( ActionsContingencies actionContingencies, Netwo
for(Zone z :xmlZones.getZone())
{

if (z.getVoltageLevels() != null)
for ( eu.itesla_project.iidm.actions_contingencies.xml.mapping.VoltageLevel zvl: z.getVoltageLevels().getVoltageLevel())
{
if (z.getVoltageLevels() != null) {
for (eu.itesla_project.iidm.actions_contingencies.xml.mapping.VoltageLevel zvl : z.getVoltageLevels().getVoltageLevel()) {

if (networkVoltagelevelId.equals(zvl.getID()) )
{
if (networkVoltagelevelId.equals(zvl.getID())) {
zones.add(z);
break;
}
}
}

}
}
Expand All @@ -107,8 +108,9 @@ public static List<Contingency> getContingenciesByZone ( ActionsContingencies ac
Contingencies contingencies =actionContingencies.getContingencies();

for (Contingency c :contingencies.getContingency()){
if (c.getZones().getNum().contains(number))
if (c.getZones().getNum().contains(number)) {
contingencyList.add(c);
}
}

return (contingencyList.size() >0) ? contingencyList: null;
Expand All @@ -134,11 +136,14 @@ public static List<Contingency> getContingencies ( ActionsContingencies actionCo
for (BigInteger znum :c.getZones().getNum())
{
Zone zoneInfo=getZone( actionContingencies , znum);
if (zoneInfo.getName().equals(name))
if (zoneInfo.getName().equals(name)) {
contingencyList.add(c);
}
}

} else System.out.println(" contignecy "+ c.getName() + " c.getZones() is null");
} else {
System.out.println(" contignecy " + c.getName() + " c.getZones() is null");
}
}

return (contingencyList.size()>0) ? contingencyList: null;
Expand All @@ -160,14 +165,17 @@ public static List<ElementaryAction> getElementaryActionsByZone (ActionsContinge
List<ElementaryAction> eactions = actionContingencies.getElementaryActions().getElementaryAction();
for (ElementaryAction eaction :eactions)
{
if (eaction.getZones()!=null && eaction.getZones().getNum().contains(number))
if (eaction.getZones()!=null && eaction.getZones().getNum().contains(number)) {
eactionsList.add(eaction);
}

}

return (eactionsList.size()>0) ? eactionsList: null;

} else return null;
} else {
return null;
}

}

Expand All @@ -187,23 +195,31 @@ public static List<ElementaryAction> getElementaryActionsByZone (ActionsContinge
{
if (eaction.getZones()!=null)
{
for (Zone z :eaction.getZones().getZone())
if (z.getName().equals(name)) eactionsList.add(eaction);
for (Zone z :eaction.getZones().getZone()) {
if (z.getName().equals(name)) {
eactionsList.add(eaction);
}
}

}
}
return (eactionsList.size()>0) ? eactionsList: null;

} else return null;
} else {
return null;
}

}


public static boolean containsAction(String id, List<eu.itesla_project.modules.contingencies.Action> actions)
{

for (eu.itesla_project.modules.contingencies.Action act : actions)
if ( act.getId().equals(id) ) return true;
for (eu.itesla_project.modules.contingencies.Action act : actions) {
if (act.getId().equals(id)) {
return true;
}
}

return false;

Expand All @@ -213,17 +229,21 @@ public static boolean containsAction(String id, List<eu.itesla_project.modules.c
public static boolean containsContingency(String id, List<eu.itesla_project.contingency.Contingency> contingency)
{
System.out.println(" Contingency: "+ id);
for (eu.itesla_project.contingency.Contingency ctg : contingency)
if ( ctg.equals(id) ) return true;
for (eu.itesla_project.contingency.Contingency ctg : contingency) {
if (ctg.equals(id)) {
return true;
}
}
return false;
}


public static ConstraintType getConstraintType(String type) {
if(type.equals("overload"))
if(type.equals("overload")) {
return ConstraintType.BRANCH_OVERLOAD;
else
} else {
return ConstraintType.valueOf(type);
}
}


Expand Down

0 comments on commit 67e1029

Please sign in to comment.