Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a93e67f
moved these to the api repository. ive been pushing these to a storag…
alan-stokes Feb 18, 2025
fc7bb83
added more tests and documents the tests made, linking to the SALT di…
alan-stokes Feb 18, 2025
354b6a2
renamed classes to more match content
alan-stokes Feb 18, 2025
1054dad
maybe fixes the remote test suite.
alan-stokes Feb 18, 2025
ec43b29
still failing to fix remote
alan-stokes Feb 18, 2025
f5a63ce
started the api calls structure. and renmaed a bun ch of classes to c…
alan-stokes Feb 18, 2025
7076adb
maybe works to build the telescope backend.
alan-stokes Feb 19, 2025
1a65cf1
fixes my stupidity over apis. now has paths and a formed input object.
alan-stokes Feb 19, 2025
a8d05be
try again with the enviroment variable for gradle and remote tests
alan-stokes Feb 19, 2025
91a1b9f
trying to figure out the issue with remote. locally works fine
alan-stokes Feb 19, 2025
9f8a104
trying to figure out the issue with remote. locally works fine. if th…
alan-stokes Feb 19, 2025
6f05d24
maybe this will work. using the system enviroment for root to then fi…
alan-stokes Feb 19, 2025
0b23771
try again
alan-stokes Feb 19, 2025
36c8107
try again
alan-stokes Feb 19, 2025
7d6be25
this might be it.
alan-stokes Feb 19, 2025
15c148d
left over changes
alan-stokes Feb 28, 2025
edffb5a
work in progress, remove SimbadResource.java - no longer needed
DJWalker42 Mar 12, 2025
24c9f1b
work in progress
DJWalker42 Mar 14, 2025
9157a66
changes which get us to just needing saving from backend to work
alan-stokes Mar 19, 2025
fd838da
saving now works.
alan-stokes Mar 21, 2025
7911147
saving now works fully
alan-stokes Mar 21, 2025
9af0bc0
filters dodfy data properly now
alan-stokes Mar 24, 2025
ce686d7
Merge remote-tracking branch 'origin/master' into ABS-347-opticalSupport
alan-stokes Mar 24, 2025
148cb24
trying to get the tests system to pull associated branches of depened…
alan-stokes Mar 26, 2025
114085c
trying to get the tests system to pull associated branches of depened…
alan-stokes Mar 26, 2025
a641264
trying to get the tests system to pull associated branches of depened…
alan-stokes Mar 26, 2025
c483c32
trying to get the tests system to pull associated branches of depened…
alan-stokes Mar 26, 2025
2245d9f
back end support done again
alan-stokes Apr 3, 2025
2701b19
Merge remote-tracking branch 'origin/master' into 358-ABS-optical-del…
alan-stokes Apr 4, 2025
2e19fb9
allows deletion of optical telescopes.
alan-stokes Apr 4, 2025
9dde177
Merge pull request #82 from orppst/master
DJWalker42 Apr 7, 2025
1bf45e6
gets the seperate tables to work correctly. still need to populate th…
alan-stokes Apr 8, 2025
b3b78b1
fixes the process for the tables. it now shows telescope name. instur…
alan-stokes Apr 8, 2025
1bbd336
Merge remote-tracking branch 'origin/master' into 376-ABS-optical-UI-…
alan-stokes Apr 9, 2025
a968840
got the extra fields saved and working. ended up cleaning abunch of c…
alan-stokes Apr 9, 2025
fb82882
wip: user can add a list of Targets via either a plain-text file (Tar…
DJWalker42 Apr 10, 2025
d6582eb
assume any file that does not have the extension '.txt.' is STILTS co…
DJWalker42 Apr 14, 2025
afb0b36
set a max number of targets per proposal, check uploaded files agains…
DJWalker42 Apr 14, 2025
0857acc
Add observatory filter to getMyTACMemberProposalCycles()
AllanEngland Apr 15, 2025
349e147
attempt to get the mode to stick in the context without overriding it…
alan-stokes Apr 15, 2025
f5c3160
missing file
alan-stokes Apr 15, 2025
9531f12
remove max number of targets (too restrictive), remove SimbadResource…
DJWalker42 Apr 15, 2025
7e274cf
add '.ecsv' as an allowed file extension (enhanced csv - from AstroPy)
DJWalker42 Apr 15, 2025
683d58c
allow plain text format to have spaces between comma separated values
DJWalker42 Apr 15, 2025
fe83b83
add unit test for ecsv file
DJWalker42 Apr 15, 2025
a3e3427
Merge pull request #87 from orppst/78-ability-to-add-a-list-of-target…
DJWalker42 Apr 15, 2025
096dce6
feedback from astro user says id got timing and moons incorrec.t so s…
alan-stokes Apr 16, 2025
dcc4a11
Merge remote-tracking branch 'origin/master' into 400-ABS-optical-UI-…
alan-stokes Apr 23, 2025
177010a
Modified validation strings
AllanEngland Apr 24, 2025
c91fb92
adds the logic for handling submitting a optical proposal and adjuste…
alan-stokes Apr 29, 2025
2f84156
this nearly works. it seems theres a trnasaction issue that I just ca…
alan-stokes Apr 30, 2025
7a0e7da
think this works now. a clone but wth the issue of its now 2 calls in…
alan-stokes Apr 30, 2025
3e4a529
this now works and saves directly to the database. its still less sta…
alan-stokes May 1, 2025
2cce37a
Change how people and organisations are imported
AllanEngland May 7, 2025
f37b7ae
removed mess
alan-stokes May 7, 2025
a509979
Merge remote-tracking branch 'origin/master' into master-357_ABS-opti…
alan-stokes May 7, 2025
531edb2
Merge branch 'master-357_ABS-optical-submission' into 357_ABS-optical…
alan-stokes May 7, 2025
3168dbe
Remove debug info as contains personal information
AllanEngland May 7, 2025
52da49c
Merge pull request #91 from orppst/72-imported-proposal-wrong-investi…
AllanEngland May 7, 2025
493c63d
added time tracker rest request.
alan-stokes May 12, 2025
3eb461f
fixed upload
alan-stokes May 13, 2025
f458c45
Merge pull request #92 from orppst/409-ABS-NIGHTS_VS_HOURS
alan-stokes May 14, 2025
dfa000a
Merge pull request #89 from orppst/357_ABS-optical-submission
alan-stokes May 14, 2025
f3d55d7
Merge pull request #88 from orppst/400-ABS-optical-UI-overview-table
alan-stokes May 14, 2025
7dbbe63
Merge remote-tracking branch 'origin/master' into 409-ABS-NIGHTS_VS_H…
alan-stokes May 14, 2025
06064da
Merge pull request #93 from orppst/411-ob-mode-master-update
alan-stokes May 14, 2025
926aa45
fixes issue with hours map
alan-stokes May 14, 2025
e98ae59
Merge pull request #94 from orppst/411-ABS-ob-mode
alan-stokes May 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 93 additions & 50 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,98 @@ jobs:

runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
- name: Checkout this repo (main)
uses: actions/checkout@v4
with:
path: main

- name: Checkout common build repo
uses: actions/checkout@v4
with:
repository: orppst/build-logic
path: build-logic

- name: Checkout common lib
uses: actions/checkout@v4
with:
repository: orppst/pst-lib
path: pst-lib

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
build-root-directory: main
cache-disabled: true
cache-overwrite-existing: true
- name: Run Gradle build
working-directory: ./main
run: ./gradlew -U build -x test -Dquarkus.container-image.builder=none

- name: Upload interface definition
uses: actions/upload-artifact@v4
with:
# Artifact name
name: openapi
# A file, directory or wildcard pattern that describes what to upload
path: ./main/build/generated/openapi/openapi.yaml

- name: Run Gradle test
working-directory: ./main
run: ./gradlew --info test

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
main/build/test-results/**/*.xml

- name: Checkout common build repo (build-logic)
uses: actions/checkout@v4
continue-on-error: true
id: checkoutBuild-logic
with:
repository: orppst/build-logic
path: build-logic
ref: ${{ github.event.pull_request && github.event.pull_request.head.ref || github.ref_name }}

- name: Check if build-logic checkout succeeded
if: steps.checkoutBuild-logic.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: orppst/build-logic
path: build-logic
ref: master

- name: Checkout common lib (pst-lib)
uses: actions/checkout@v4
continue-on-error: true
id: checkoutPst-lib
with:
repository: orppst/pst-lib
path: pst-lib
ref: ${{ github.event.pull_request && github.event.pull_request.head.ref || github.ref_name }}


- name: Check if pst-lib checkout succeeded
if: steps.checkoutPst-lib.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: orppst/pst-lib
path: pst-lib
ref: master

- name: Checkout telescope repo (telescope-config-data)
uses: actions/checkout@v4
continue-on-error: true
id: checkoutTelescope-config-data
with:
repository: orppst/telescope-config-data
path: telescope-config-data
ref: ${{ github.event.pull_request && github.event.pull_request.head.ref || github.ref_name }}


- name: Check if telescope-config-data checkout succeeded
if: steps.checkoutTelescope-config-data.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: orppst/telescope-config-data
path: telescope-config-data
ref: main

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
build-root-directory: main
cache-disabled: true
cache-overwrite-existing: true

- name: Run Gradle build
working-directory: ./main
run: ./gradlew -U build -x test -Dquarkus.container-image.builder=none

- name: Upload interface definition
uses: actions/upload-artifact@v4
with:
# Artifact name
name: openapi
# A file, directory or wildcard pattern that describes what to upload
path: ./main/build/generated/openapi/openapi.yaml

- name: Run Gradle test
working-directory: ./main
env:
POLARIS_TELESCOPE_CONFIG_LOCATION: /home/runner/work/pst-api-service/pst-api-service/telescope-config-data/
run: ./gradlew --info test

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
main/build/test-results/**/*.xml
140 changes: 126 additions & 14 deletions src/main/java/org/orph2020/pst/AppLifecycleBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import org.apache.commons.io.FileUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.ivoa.dm.proposal.management.ProposalCycle;
import org.ivoa.dm.proposal.management.Telescope;
import org.ivoa.dm.proposal.prop.*;
import org.jboss.logging.Logger;
import org.orph2020.pst.apiimpl.entities.SubjectMap;
Expand All @@ -19,6 +22,7 @@
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.TypedQuery;
import jakarta.transaction.Transactional;
import org.orph2020.pst.apiimpl.entities.opticalTelescopeService.XmlReaderService;
import org.orph2020.pst.apiimpl.rest.ProposalDocumentStore;

import java.io.File;
Expand All @@ -31,37 +35,138 @@
@ApplicationScoped
public class AppLifecycleBean {

// constant environmental value for where telescope data is located.
private static final String POLARIS_MODE_ENV_NAME =
"POLARIS_TELESCOPE_MODE";

// makes a string based enum with text. to help iterate.
public enum MODES {
OPTICAL("OPTICAL", 0),
RADIO("RADIO", 1),
BOTH("BOTH", 2);

private final String text;
private final int number;

MODES(String text, int number) {
this.text = text;
this.number = number;
}

public String getText() {
return text;
}
public int getValue() { return number; }
}

// exists for the application lifetime no need to close
@PersistenceContext
protected EntityManager em; // exists for the application lifetime no need to close
protected EntityManager em;

@ConfigProperty(name = "document-store.proposals.root")
String documentStoreRoot;

@Inject
ProposalDocumentStore proposalDocumentStore;

// reader for xml files
XmlReaderService xmlReader;

// store for the polaris mode
MODES polarisMode;

private static final Logger LOGGER = Logger.getLogger("ListenerBean");

// produces the array of telescopes.
@Singleton
@Produces
XmlReaderService produceTelescopes() {
return this.xmlReader;
}

// produces the holder for the polaris mode.
@Singleton
@Produces
MODES mode() { return this.polarisMode; }


@Transactional
void onStart(@Observes StartupEvent ev) {
LOGGER.info("The application is starting...");
this.initialiseDatabase();
this.initialiseOpticalTelescopeDatabase();
this.initialisePolarisMode();
}

/**
* processes the environment variable for the polaris mode.
*/
private void initialisePolarisMode() {
String environmentMode = System.getenv(POLARIS_MODE_ENV_NAME);

// handle when no environment variable is set.
if(environmentMode == null) {
this.polarisMode = MODES.RADIO;
LOGGER.log(
Logger.Level.WARN,
"no environment variable was set for" +
POLARIS_MODE_ENV_NAME + ", so defaulting to RADIO setting.");
}

switch (MODES.valueOf(environmentMode)) {
case RADIO -> this.polarisMode = MODES.RADIO;
case OPTICAL -> this.polarisMode = MODES.OPTICAL;
case BOTH -> this.polarisMode = MODES.BOTH;
default -> {
LOGGER.error("NO valid mode was detected. setting to radio.");
this.polarisMode = MODES.RADIO;
}
}
}

/**
* builds the optic telescope database.
*/
private void initialiseOpticalTelescopeDatabase() {
xmlReader = new XmlReaderService();
xmlReader.read();

// add telescopes to the proposal management system.
for (String telescopeName: xmlReader.getTelescopes().keySet()) {
Telescope managementTelescope = new Telescope();
managementTelescope.setName(telescopeName);
em.persist(managementTelescope);
}
}

Long i = em.createQuery("select count(o) from Observatory o", Long.class).getSingleResult();
/**
* builds the basic database that contains proposals and such.
*/
private void initialiseDatabase() {
Long i = em.createQuery(
"select count(o) from Observatory o", Long.class).getSingleResult();
if(i.intValue() == 0) {
LOGGER.info("initializing Database");
// add the example proposals.
// add the example proposals.
FullExample fullExample = new FullExample();
List<ProposalCycle> cycles = fullExample.getManagementModel().getContent(ProposalCycle.class);
List<ProposalCycle> cycles = fullExample.getManagementModel().
getContent(ProposalCycle.class);
LocalDate now = LocalDate.now();
for (ProposalCycle cycle : cycles) {
cycle.setSubmissionDeadline(new Date(now.plusWeeks(2).atStartOfDay().atOffset(ZoneOffset.UTC).toEpochSecond()*1000));
cycle.setObservationSessionStart(new Date(now.plusMonths(2).atStartOfDay().atOffset(ZoneOffset.UTC).toEpochSecond()*1000));
cycle.setObservationSessionEnd(new Date(now.plusMonths(6).atStartOfDay().atOffset(ZoneOffset.UTC).toEpochSecond()*1000));
cycle.setSubmissionDeadline(
new Date(now.plusWeeks(2).atStartOfDay().atOffset(
ZoneOffset.UTC).toEpochSecond()*1000));
cycle.setObservationSessionStart(
new Date(now.plusMonths(2).atStartOfDay().atOffset(
ZoneOffset.UTC).toEpochSecond()*1000));
cycle.setObservationSessionEnd(
new Date(now.plusMonths(6).atStartOfDay().atOffset(
ZoneOffset.UTC).toEpochSecond()*1000));
}
fullExample.saveTodB(em);

for(ObservingProposal pr: fullExample.getProposalModel().getContent(ObservingProposal.class))
for(ObservingProposal pr: fullExample.getProposalModel().getContent(
ObservingProposal.class))
try {
proposalDocumentStore.createStorePaths(pr.getId());
} catch (IOException e) {
Expand All @@ -71,24 +176,31 @@ void onStart(@Observes StartupEvent ev) {
}

//only try to populate the SubjectMap if not already done
TypedQuery<SubjectMap> sq = em.createQuery("select o from SubjectMap o where o.uid = 'bb0b065f-6dc3-4062-9b3e-525c1a1a9bec'", SubjectMap.class);
TypedQuery<SubjectMap> sq = em.createQuery(
"select o from SubjectMap o where o.uid = " +
"'bb0b065f-6dc3-4062-9b3e-525c1a1a9bec'", SubjectMap.class);
if(sq.getResultList().isEmpty()) {

TypedQuery<Person> pq = em.createQuery("select o from Person o", Person.class);
TypedQuery<Person> pq = em.createQuery(
"select o from Person o", Person.class);
for (Person p : pq.getResultList()) {
switch (p.getEMail()) {
case "pi@unreal.not.email":

em.persist(new SubjectMap(p, "bb0b065f-6dc3-4062-9b3e-525c1a1a9bec"));
em.persist(new SubjectMap(p,
"bb0b065f-6dc3-4062-9b3e-525c1a1a9bec"));
break;
case "reviewer@unreal.not.email":
em.persist(new SubjectMap(p, "dda2fd0b-8bb4-4dd1-a216-f75087f3d946"));
em.persist(new SubjectMap(p,
"dda2fd0b-8bb4-4dd1-a216-f75087f3d946"));
break;
case "tacchair@unreal.not.email":
em.persist(new SubjectMap(p, "b0f7b98e-ec1e-4cf9-844c-e9f192c97745"));
em.persist(new SubjectMap(p,
"b0f7b98e-ec1e-4cf9-844c-e9f192c97745"));
break;
case "coi@unreal.not.email":
em.persist(new SubjectMap(p, "33767eee-35a1-4fef-b32a-f9b6fa6b36e6"));
em.persist(new SubjectMap(p,
"33767eee-35a1-4fef-b32a-f9b6fa6b36e6"));
break;
default:
//do nothing
Expand Down
Loading