Skip to content

Commit

Permalink
Alpha release of the new CERT tool
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbarno committed Apr 27, 2023
1 parent 7e3fe1f commit 6538b88
Show file tree
Hide file tree
Showing 2,850 changed files with 142,883 additions and 36,430 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ mvn clean install
#### **As a single runnable JAR**

```shell
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.18-runnable.jar
java -jar coda-calibration/calibration-standalone/target/calibration-standalone-1.0.19-runnable.jar
```

#### **GUI alone**

```shell
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.18-runnable.jar
java -jar coda-calibration/calibration-gui/target/calibration-gui-1.0.19-runnable.jar
```

#### **Calibration REST service alone**

```shell
java -jar coda-calibration/calibration-service/application/target/application-1.0.18-runnable.jar
java -jar coda-calibration/calibration-service/application/target/application-1.0.19-runnable.jar
```

#### A note about HTTPS
Expand Down Expand Up @@ -188,4 +188,4 @@ The `Coda Calibration Tool` is provided under the [Apache License](LICENSE.txt).
by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
```

`LLNL-CODE-743439`
`LLNL-CODE-743439, LLNL-CODE-848318`
2 changes: 1 addition & 1 deletion calibration-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>gov.llnl.gnem.apps.coda.calibration</groupId>
<artifactId>coda-calibration</artifactId>
<version>1.0.18.3</version>
<version>1.0.19</version>
</parent>

<artifactId>calibration-gui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright (c) 2018, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory
* CODE-743439.
* All rights reserved.
* This file is part of CCT. For details, see https://github.com/LLNL/coda-calibration-tool.
*
* This file is part of CCT. For details, see https://github.com/LLNL/coda-calibration-tool.
*
* Licensed under the Apache License, Version 2.0 (the “Licensee”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the license.
*
* This work was performed under the auspices of the U.S. Department of Energy
Expand All @@ -25,8 +25,7 @@
@Component
@ConfigurationProperties("app")
public class AppProperties {

private String baseTitle = "Coda Calibration";
private String baseTitle = "";
private Integer height = 800;
private Integer width = 600;
private Boolean debugEnabled = Boolean.FALSE;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,26 @@
@ComponentScan("gov.llnl.gnem.apps.coda.envelope.model")
@ComponentScan("gov.llnl.gnem.apps.coda.envelope.gui")
@ComponentScan("gov.llnl.gnem.apps.coda.calibration.gui")
@ComponentScan("gov.llnl.gnem.apps.coda.spectra.gui")
public class GuiApplication extends Application {

public enum ApplicationMode {
CERT, CCT
}

static final String CERT_TITLE = "Coda Envelope Ratio Tool";
static final String CCT_TITLE = "Coda Calibration Tool";

private static final Logger log = LoggerFactory.getLogger(GuiApplication.class);

private ConfigurableApplicationContext springContext;
private static ConfigurableApplicationContext springContext;

private Stage primaryStage;
private static Stage primaryStage;

private EventBus bus;

private static ApplicationMode startupMode;

@PostConstruct
void started() {
Locale.setDefault(Locale.ENGLISH);
Expand All @@ -78,9 +88,10 @@ void started() {
public GuiApplication() {
}

public GuiApplication(ConfigurableApplicationContext springContext, EventBus bus) {
public GuiApplication(ConfigurableApplicationContext springContext, EventBus bus, ApplicationMode mode) {
this.springContext = springContext;
this.bus = bus;
GuiApplication.startupMode = mode;
}

public static void main(String[] args) {
Expand Down Expand Up @@ -130,13 +141,20 @@ public void start(Stage primaryStage) throws Exception {
Class<GuiApplication> clazz = GuiApplication.class;
String className = clazz.getSimpleName() + ".class";
String classPath = clazz.getResource(className).toString();
String baseTitle = props.getBaseTitle();
String baseTitle = "";

if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
baseTitle = CCT_TITLE;
} else {
baseTitle = CERT_TITLE;
}

if (classPath.startsWith("jar")) {
String manifestPath = classPath.substring(0, classPath.indexOf('!') + 1) + "/META-INF/MANIFEST.MF";
Manifest mf = new Manifest(new URL(manifestPath).openStream());
Attributes atts = mf.getMainAttributes();
// Put this info in the log to help with analysis
log.info(
log.debug(
"Version:{} Commit:{} Branch:{} By:{} at {}",
atts.getValue("Implementation-Version"),
atts.getValue("Implementation-Build"),
Expand All @@ -147,7 +165,7 @@ public void start(Stage primaryStage) throws Exception {
baseTitle += " Built at " + atts.getValue("Build-Timestamp");
} else {
// Class not from JAR
log.info("{} not running from a jar.", baseTitle);
log.debug("{} not running from a jar.", baseTitle);
}
props.setBaseTitle(baseTitle);
} catch (IOException e) {
Expand All @@ -156,7 +174,13 @@ public void start(Stage primaryStage) throws Exception {
}

Platform.setImplicitExit(true);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/CodaGui.fxml"));
FXMLLoader fxmlLoader = null;

if (startupMode == ApplicationMode.CERT) {
fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/CertGui.fxml"));
} else {
fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/CodaGui.fxml"));
}
fxmlLoader.setControllerFactory(springContext::getBean);

try {
Expand All @@ -174,6 +198,43 @@ public void start(Stage primaryStage) throws Exception {
}
}

static public void changeApplicationMode() {

if (GuiApplication.getStartupMode() == ApplicationMode.CCT) {
GuiApplication.startupMode = ApplicationMode.CERT;
} else {
GuiApplication.startupMode = ApplicationMode.CCT;
}

Platform.runLater(() -> {
primaryStage.close();
});

AppProperties props = springContext.getBean(AppProperties.class);
FXMLLoader fxmlLoader = null;
if (GuiApplication.startupMode == ApplicationMode.CERT) {
props.setBaseTitle(CERT_TITLE);
fxmlLoader = new FXMLLoader(GuiApplication.class.getResource("/fxml/CertGui.fxml"));
} else {
props.setBaseTitle(CCT_TITLE);
fxmlLoader = new FXMLLoader(GuiApplication.class.getResource("/fxml/CodaGui.fxml"));
}
fxmlLoader.setControllerFactory(springContext::getBean);

try {
Parent root = fxmlLoader.load();
Platform.runLater(() -> {
primaryStage.setTitle(props.getBaseTitle());
Scene scene = new Scene(root, props.getHeight(), props.getWidth());
primaryStage.setScene(scene);
primaryStage.show();
});
} catch (IllegalStateException | IOException e) {
log.error("Unable to load main panel FXML file, terminating. {}", e.getMessage(), e);
Platform.exit();
}
}

@Override
public void stop() throws Exception {
try {
Expand All @@ -187,6 +248,14 @@ public void stop() throws Exception {
System.exit(0);
}

public static ApplicationMode getStartupMode() {
return startupMode;
}

public static void setStartupMode(ApplicationMode startupMode) {
GuiApplication.startupMode = startupMode;
}

public Stage getPrimaryStage() {
return primaryStage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
/*
* Copyright (c) 2019, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory
* CODE-743439.
* All rights reserved.
* This file is part of CCT. For details, see https://github.com/LLNL/coda-calibration-tool.
*
* Licensed under the Apache License, Version 2.0 (the “Licensee”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the license.
*
* This work was performed under the auspices of the U.S. Department of Energy
* by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
*/
package gov.llnl.gnem.apps.coda.calibration.gui;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.web.reactive.function.client.ExchangeStrategies;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
import com.fasterxml.jackson.databind.module.SimpleModule;

import gov.llnl.gnem.apps.coda.calibration.model.domain.SiteFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.calibration.model.domain.SpectraMeasurementMetadata;
import gov.llnl.gnem.apps.coda.calibration.model.domain.SpectraMeasurementMetadataImpl;
import gov.llnl.gnem.apps.coda.calibration.model.domain.WaveformMetadataImpl;
import gov.llnl.gnem.apps.coda.calibration.model.domain.mixins.SharedFrequencyBandParametersJsonMixin;
import gov.llnl.gnem.apps.coda.calibration.model.domain.mixins.SiteFrequencyBandParametersJsonMixin;
import gov.llnl.gnem.apps.coda.common.model.domain.SharedFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.common.model.domain.WaveformMetadata;

@Configuration
public class WebfluxConfig {

private final ObjectMapper objectMapper;

@Autowired
public WebfluxConfig(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
this.objectMapper.addMixIn(SharedFrequencyBandParameters.class, SharedFrequencyBandParametersJsonMixin.class);
this.objectMapper.addMixIn(SiteFrequencyBandParameters.class, SiteFrequencyBandParametersJsonMixin.class);

SimpleModule module = new SimpleModule("SpectraMeasurementMapper", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(SpectraMeasurementMetadata.class, SpectraMeasurementMetadataImpl.class);
resolver.addMapping(WaveformMetadata.class, WaveformMetadataImpl.class);
module.setAbstractTypes(resolver);
this.objectMapper.registerModule(module);
}

@Bean
public ExchangeStrategies configureJacksonExchangeStrategies() {
return ExchangeStrategies.builder().codecs(clientCodecConfigurer -> {
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder(objectMapper);
decoder.setMaxInMemorySize(-1);
clientCodecConfigurer.customCodecs().registerWithDefaultConfig(decoder);
clientCodecConfigurer.customCodecs().registerWithDefaultConfig(new Jackson2JsonEncoder(objectMapper));
//Unlimited
clientCodecConfigurer.defaultCodecs().maxInMemorySize(-1);
}).build();
}
}
/*
* Copyright (c) 2019, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory
* CODE-743439.
* All rights reserved.
* This file is part of CCT. For details, see https://github.com/LLNL/coda-calibration-tool.
*
* Licensed under the Apache License, Version 2.0 (the “Licensee”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the license.
*
* This work was performed under the auspices of the U.S. Department of Energy
* by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
*/
package gov.llnl.gnem.apps.coda.calibration.gui;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.web.reactive.function.client.ExchangeStrategies;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
import com.fasterxml.jackson.databind.module.SimpleModule;

import gov.llnl.gnem.apps.coda.calibration.model.domain.SiteFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.calibration.model.domain.SpectraMeasurementMetadata;
import gov.llnl.gnem.apps.coda.calibration.model.domain.SpectraMeasurementMetadataImpl;
import gov.llnl.gnem.apps.coda.calibration.model.domain.WaveformMetadataImpl;
import gov.llnl.gnem.apps.coda.calibration.model.domain.mixins.SharedFrequencyBandParametersJsonMixin;
import gov.llnl.gnem.apps.coda.calibration.model.domain.mixins.SiteFrequencyBandParametersJsonMixin;
import gov.llnl.gnem.apps.coda.common.model.domain.SharedFrequencyBandParameters;
import gov.llnl.gnem.apps.coda.common.model.domain.WaveformMetadata;

@Configuration
public class WebfluxConfig {

private final ObjectMapper objectMapper;

@Autowired
public WebfluxConfig(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
this.objectMapper.addMixIn(SharedFrequencyBandParameters.class, SharedFrequencyBandParametersJsonMixin.class);
this.objectMapper.addMixIn(SiteFrequencyBandParameters.class, SiteFrequencyBandParametersJsonMixin.class);

SimpleModule module = new SimpleModule("SpectraMeasurementMapper", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(SpectraMeasurementMetadata.class, SpectraMeasurementMetadataImpl.class);
resolver.addMapping(WaveformMetadata.class, WaveformMetadataImpl.class);
module.setAbstractTypes(resolver);
this.objectMapper.registerModule(module);
}

@Bean
public ExchangeStrategies configureJacksonExchangeStrategies() {
return ExchangeStrategies.builder().codecs(clientCodecConfigurer -> {
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder(objectMapper);
decoder.setMaxInMemorySize(-1);
clientCodecConfigurer.customCodecs().registerWithDefaultConfig(decoder);
clientCodecConfigurer.customCodecs().registerWithDefaultConfig(new Jackson2JsonEncoder(objectMapper));
//Unlimited
clientCodecConfigurer.defaultCodecs().maxInMemorySize(-1);
}).build();
}
}
Loading

0 comments on commit 6538b88

Please sign in to comment.