Skip to content

Commit

Permalink
Checkstyle_indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yichen88 committed Sep 25, 2017
1 parent b3a0d78 commit 342385d
Show file tree
Hide file tree
Showing 107 changed files with 2,180 additions and 2,240 deletions.
3 changes: 3 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
<module name="EmptyStatement"/>
<module name="HideUtilityClassConstructor"/>
<module name="IllegalImport"/>
<module name="Indentation"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="RedundantImport"/>
<module name="RightCurly"/>
<module name="SuppressWarningsHolder"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="UnusedImports"/>
Expand All @@ -38,4 +40,5 @@
<module name="SuppressionFilter">
<property name="file" value="suppressions.xml"/>
</module>
<module name="SuppressWarningsFilter"/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -431,27 +431,27 @@ private List<String> writeDymolaInputs(Path workingDir, List<Contingency> contin
// TODO here it is assumed that contingencies ids in csv file start from 0 (i.e. 0 is the first contingency); id should be decoupled from the implementation
try (final Stream<Path> pathStream = Files.walk(dymolaExportPath)) {
pathStream.filter((p) -> !p.toFile().isDirectory() && p.toFile().getAbsolutePath().contains("events_") && p.toFile().getAbsolutePath().endsWith(".mo")).
forEach(p -> {
GenericArchive archive = ShrinkWrap.createDomain().getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
Files.copy(modelicaPowerSystemLibraryPath, rootDir.resolve(modelicaPowerSystemLibraryPath.getFileName()));
Files.copy(Paths.get(p.toString()), rootDir.resolve(DymolaUtil.DYMOLA_SIM_MODEL_INPUT_PREFIX + ".mo"));

String[] c = p.getFileName().toString().replace(".mo", "").split("_");
try (OutputStream os = Files.newOutputStream(dymolaExportPath.getParent().resolve(DymolaUtil.DYMOLAINPUTZIPFILENAMEPREFIX + "_" + c[c.length - 1] + ".zip"))) {
archive.as(ZipExporter.class).exportTo(os);
retList.add(new String( c[c.length - 1]));
} catch (IOException e) {
//e.printStackTrace();
throw new RuntimeException(e);
}

forEach(p -> {
GenericArchive archive = ShrinkWrap.createDomain().getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
Files.copy(modelicaPowerSystemLibraryPath, rootDir.resolve(modelicaPowerSystemLibraryPath.getFileName()));
Files.copy(Paths.get(p.toString()), rootDir.resolve(DymolaUtil.DYMOLA_SIM_MODEL_INPUT_PREFIX + ".mo"));

String[] c = p.getFileName().toString().replace(".mo", "").split("_");
try (OutputStream os = Files.newOutputStream(dymolaExportPath.getParent().resolve(DymolaUtil.DYMOLAINPUTZIPFILENAMEPREFIX + "_" + c[c.length - 1] + ".zip"))) {
archive.as(ZipExporter.class).exportTo(os);
retList.add(new String(c[c.length - 1]));
} catch (IOException e) {
//e.printStackTrace();
throw new RuntimeException(e);
}

});
} catch (IOException e) {
throw new RuntimeException(e);
}

});
}
retList.sort(Comparator.<String>naturalOrder());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,46 @@
*/
public class RetryOnExceptionStrategy {
public static final int DEFAULT_RETRIES = 3;
public static final long DEFAULT_WAIT_TIME_IN_MILLI = 2000;
public static final long DEFAULT_WAIT_TIME_IN_MILLI = 2000;

private int numberOfRetries;
private int numberOfTriesLeft;
private long timeToWait;
private int numberOfRetries;
private int numberOfTriesLeft;
private long timeToWait;

public RetryOnExceptionStrategy() {
this(DEFAULT_RETRIES, DEFAULT_WAIT_TIME_IN_MILLI);
}
public RetryOnExceptionStrategy() {
this(DEFAULT_RETRIES, DEFAULT_WAIT_TIME_IN_MILLI);
}

public RetryOnExceptionStrategy(int numberOfRetries,
long timeToWait) {
this.numberOfRetries = numberOfRetries;
numberOfTriesLeft = numberOfRetries;
this.timeToWait = timeToWait;
}
public RetryOnExceptionStrategy(int numberOfRetries,
long timeToWait) {
this.numberOfRetries = numberOfRetries;
numberOfTriesLeft = numberOfRetries;
this.timeToWait = timeToWait;
}

public boolean shouldRetry() {
return numberOfTriesLeft > 0;
}
public boolean shouldRetry() {
return numberOfTriesLeft > 0;
}

public void errorOccured(Exception e) throws Exception {
numberOfTriesLeft--;
if (!shouldRetry()) {
String excMsg = (e != null) ? e.getMessage() : "";
throw new Exception("Retry Failed: Total " + numberOfRetries
+ " attempts made at interval " + getTimeToWait()
+ "ms - Exception message: " + excMsg);
}
waitUntilNextTry();
public void errorOccured(Exception e) throws Exception {
numberOfTriesLeft--;
if (!shouldRetry()) {
String excMsg = (e != null) ? e.getMessage() : "";
throw new Exception("Retry Failed: Total " + numberOfRetries
+ " attempts made at interval " + getTimeToWait()
+ "ms - Exception message: " + excMsg);
}
waitUntilNextTry();
}

public long getTimeToWait() {
return timeToWait;
}
public long getTimeToWait() {
return timeToWait;
}

private void waitUntilNextTry() {
try {
Thread.sleep(getTimeToWait());
} catch (InterruptedException ignored) {
}
private void waitUntilNextTry() {
try {
Thread.sleep(getTimeToWait());
} catch (InterruptedException ignored) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MoContingencyElementType getMoType() {
}

//TODO
@Override
@Override
public AbstractTrippingTask toTask() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static Bus selectSlackbus(Network network, EurostagEchExportConfig config
}

private static Bus selectSlackbusCriteria1(Network network, EurostagEchExportConfig config, Set<String> busesToAvoid) {
return StreamSupport.stream(EchUtil.getBuses(network, config).spliterator(), false)
return StreamSupport.stream(EchUtil.getBuses(network, config).spliterator(), false)
.sorted((b1, b2) -> b1.getId().compareTo(b2.getId()))
.filter(b -> !busesToAvoid.contains(b.getId())
&& b.getConnectedComponent() != null && b.getConnectedComponent().getNum() == Component.MAIN_NUM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static void writeLimits(Network network, EurostagDictionary dictionary, OutputSt

private void writeScenarios(Domain domain, List<Contingency> contingencies, OutputStream os) throws IOException {
GenericArchive archive = new EurostagScenario(parameters, config).writeFaultSeqArchive(domain, contingencies, network, dictionary,
faultNum -> FAULT_SEQ_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(faultNum)));
faultNum -> FAULT_SEQ_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(faultNum)));
archive.as(ZipExporter.class).exportTo(os);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void writeFaultSeq(BufferedWriter writer, Contingency contingency, Networ
.append(" R 1 0.");
writer.newLine();
}
break;
break;

case GENERATOR: {
Generator g = network.getGenerator(element.getId());
Expand Down Expand Up @@ -224,7 +224,7 @@ public void writeFaultSeq(BufferedWriter writer, Contingency contingency, Networ
.append(" 0. 0.");
writer.newLine();
}
break;
break;

default:
throw new AssertionError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public static Zone getZone(ActionsContingencies actionContingencies, BigInteger
Zones zones = actionContingencies.getZones();

for (Zone z : zones.getZone()) {
BigInteger zoneNumber = z.getNumber();
if (zoneNumber.equals(number)) {
return z;
}
BigInteger zoneNumber = z.getNumber();
if (zoneNumber.equals(number)) {
return z;
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
}
)
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("checkstyle:indentation")
public class ConnectionSchema implements Serializable {
private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
@SuppressWarnings("checkstyle:indentation")
public class Internal implements Serializable {
private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public TableRow() {
super();
}

public TableRow(Parameter...parameters) {
public TableRow(Parameter... parameters) {
super();
for (Parameter parameter : parameters) {
addParameter(parameter);
}
for (Parameter parameter : parameters) {
addParameter(parameter);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,24 @@
@Remote(DDBManager.class)
@WebService
@EndpointProperties(value = {
@EndpointProperty(key = "ws-security.validate.token", value = "false")
@EndpointProperty(key = "ws-security.validate.token", value = "false")
})
@InInterceptors(interceptors = {
"org.apache.cxf.interceptor.LoggingInInterceptor",
"eu.itesla_project.iidm.ddb.util.WsSecurityInterceptor",
"org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor",
"org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor"}
)
"org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor"
})
@OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor")
@XmlSeeAlso({
eu.itesla_project.iidm.ddb.model.ParameterBoolean.class,
eu.itesla_project.iidm.ddb.model.ParameterString.class,
eu.itesla_project.iidm.ddb.model.ParameterInteger.class,
eu.itesla_project.iidm.ddb.model.ParameterFloat.class,
eu.itesla_project.iidm.ddb.model.ParameterTable.class })
eu.itesla_project.iidm.ddb.model.ParameterTable.class
})
@RolesAllowed({"user"})
@SuppressWarnings("checkstyle:indentation")
public class DDBManagerBean implements DDBManager {
@Inject
private Logger log;
Expand All @@ -95,7 +97,7 @@ protected Principal getCallerPrincipal() {
// System.out.println(" Principal name: " + sctxLookup.getCallerPrincipal().getName());
Principal cPrincipal = sctxLookup.getCallerPrincipal();
return cPrincipal;
}
}

@WebMethod(operationName = "saveModelTemplateContainer")
public ModelTemplateContainer save(ModelTemplateContainer p) {
Expand Down Expand Up @@ -412,18 +414,18 @@ public int findSimulatorsAllCount() {
@WebMethod(operationName = "saveSimulator")
public SimulatorInst save(SimulatorInst p) {
Principal cPrincipal = getCallerPrincipal();
if (p == null) {
throw new RuntimeException("SimulatorInst must be not null");
}
if (p == null) {
throw new RuntimeException("SimulatorInst must be not null");
}
log.log(Level.FINE, "Persisting SimulatorInst" + p);
if (p.getId() == null) {
em.persist(p);
} else {
em.merge(p);
}
// parameterEventSrc.fire(parameter);
return p;
}
return p;
}

@WebMethod(operationName = "deleteSimulator")
public void delete(SimulatorInst simInst) {
Expand All @@ -436,7 +438,7 @@ public void delete(SimulatorInst simInst) {
SimulatorInst simInst2 = em.merge(simInst);
em.remove(simInst2);
// parameterEventSrc.fire(parameter);
}
}


/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
*/

public class Resources {
// use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly
@SuppressWarnings("unused")
@Produces
@PersistenceContext
private EntityManager em;
// use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly
@SuppressWarnings("unused")
@Produces
@PersistenceContext
private EntityManager em;

@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
@Produces
public Logger produceLog(InjectionPoint injectionPoint) {
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}

0 comments on commit 342385d

Please sign in to comment.