Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ To be able to start the connector locally you will need to:

1. Install all needed dependencies with `npm install`
2. Copy the missing matrix-js dependency `npm run fix-olm-dependency`
3. Start the application using `npm run start`
3. Start the application using the command `npm run start`
5 changes: 4 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ SCICAT_LOGIN_ENDPOINT=/Users/login
SCICAT_USERNAME=
SCICAT_PASSWORD=
SCICAT_PROPOSAL_TRIGGERING_STATUSES="SCHEDULING, ALLOCATED"
SCICAT_EXPERIMENT_TRIGGERING_STATUSES="ACTIVE"
SCICAT_JWT=<token>

PROPOSAL_FOLDERS_CREATION_GROUP_PREFIX=""
PROPOSAL_FOLDERS_CREATION_TRIGGERING_STATUSES="PROPOSAL_ACCEPTED"
Expand All @@ -36,6 +38,7 @@ SYNAPSE_OAUTH_ISSUER=https://server-scichat.swap.ess.eu
## The following variables enable the different functionalities available in the connector
## true or false
ENABLE_SCICAT_PROPOSAL_UPSERT=false
ENABLE_SCICAT_EXPERIMENT_UPSERT=false
ENABLE_SCICHAT_ROOM_CREATION=false
ENABLE_NICOS_TO_SCICHAT_MESSAGES=false
ENABLE_PROPOSAL_FOLDERS_CREATION=false
Expand All @@ -59,4 +62,4 @@ ONE_IDENTITY_API_PASSWORD=

VISA_QUEUE_NAME=dummy
VISA_SYNCING_TRIGGERING_STATUSES="ALLOCATED"
VISA_DATABASE_URL=postgres://postgres:qwerty123@127.0.0.1:5434/visa
VISA_DATABASE_URL=postgres://postgres:qwerty123@127.0.0.1:5434/visa
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ExperimentCreationQueueConsumer extends QueueConsumer {
}

getExchangeName(): string {
return process.env.USER_OFFICE_CORE_EXCHANGE_NAME as string;
return process.env.EXPERIMENT_CREATION_EXCHANGE_NAME as string;
}

onMessage: ConsumerCallback = async (type, message) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Test Abstract",
"human_name": "UOS Proposal Status",
"value": "ALLOCATED",
},
"visitor_1_affiliation": {
"human_name": "Visitor 1 Affiliation",
"value": "ESS",
},
"visitor_1_email": {
"human_name": "Visitor 1 Email",
"value": "test@example.com",
Expand All @@ -51,6 +55,7 @@ Test Abstract",
},
"ownerGroup": "testuser",
"parentProposalId": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down Expand Up @@ -96,6 +101,7 @@ Test Abstract",
},
"ownerGroup": "testuser",
"parentProposalId": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down Expand Up @@ -141,6 +147,7 @@ Test Abstract",
},
"ownerGroup": "testuser",
"parentProposalId": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ exports[`getCreateScicatProposalDto includes co-PI, DAU and instrument metadata
},
},
"ownerGroup": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down Expand Up @@ -204,6 +205,7 @@ exports[`getCreateScicatProposalDto maps proposal to create DTO correctly 1`] =
},
},
"ownerGroup": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down Expand Up @@ -277,6 +279,7 @@ exports[`getUpdateScicatProposalDto maps proposal to update DTO correctly 1`] =
},
},
"ownerGroup": "158548",
"pi_affiliation": "ESS",
"pi_email": "john.doe@example.com",
"pi_firstname": "John",
"pi_lastname": "Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ describe('getCreateScicatExperimentDto', () => {
expect(dto).toMatchSnapshot();
});

it('maps the proposer institution to pi_affiliation', () => {
const dto = getCreateScicatExperimentDto(
createBaseUoExperiment(),
instrumentIds
);

expect(dto.pi_affiliation).toBe('ESS');
});

it('leaves pi_affiliation undefined when the proposer has no institution', () => {
const experiment = createBaseUoExperiment();
delete experiment.proposal.proposer.institution;

const dto = getCreateScicatExperimentDto(experiment, instrumentIds);

expect(dto.pi_affiliation).toBeUndefined();
});

it('skips visitor entries when user is null', () => {
const dto = getCreateScicatExperimentDto(
createBaseUoExperiment({
Expand All @@ -101,6 +119,15 @@ describe('getUpdateScicatExperimentDto', () => {
expect(dto).toMatchSnapshot();
});

it('maps the proposer institution to pi_affiliation', () => {
const dto = getUpdateScicatExperimentDto(
createBaseUoExperiment(),
instrumentIds
);

expect(dto.pi_affiliation).toBe('ESS');
});

it('should not include proposalId', () => {
const dto = getUpdateScicatExperimentDto(
createBaseUoExperiment(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const buildMetadata = (experiment: UOExperimentDto): MdEntry => {
`visitor_${i}_orcid`,
`Visitor ${i} ORCID`,
registration.user.oidcSub
),
metadataEntry(
`visitor_${i}_affiliation`,
`Visitor ${i} Affiliation`,
registration.user.institution
)
);
});
Expand All @@ -90,6 +95,7 @@ export const getCreateScicatExperimentDto = (
pi_firstname: proposer.firstname,
pi_lastname: proposer.lastname,
pi_email: proposer.email,
pi_affiliation: proposer.institution,
instrumentIds,
ownerGroup: scicatApi.serviceUsername || '',
accessGroups: [proposal.proposalId],
Expand Down Expand Up @@ -118,6 +124,7 @@ export const getUpdateScicatExperimentDto = (
pi_firstname: proposer.firstname,
pi_lastname: proposer.lastname,
pi_email: proposer.email,
pi_affiliation: proposer.institution,
instrumentIds,
ownerGroup: scicatApi.serviceUsername,
accessGroups: [proposal.proposalId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const getCreateScicatProposalDto = (
pi_firstname: proposer.firstname,
pi_lastname: proposer.lastname,
pi_email: proposer.email,
pi_affiliation: proposer.institution,
instrumentIds,
ownerGroup: proposal.proposalId,
accessGroups: [],
Expand All @@ -149,6 +150,7 @@ export const getUpdateScicatProposalDto = (
pi_firstname: proposer.firstname,
pi_lastname: proposer.lastname,
pi_email: proposer.email,
pi_affiliation: proposer.institution,
instrumentIds,
ownerGroup: proposal.proposalId,
accessGroups: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type CreateScicatProposalDto = {
pi_email: string;
pi_firstname: string;
pi_lastname: string;
pi_affiliation?: string;
email: string;
type: 'Proposal' | 'Experiment';
firstname: string;
Expand All @@ -35,6 +36,7 @@ export type UpdateScicatProposalDto = {
pi_email?: string;
pi_firstname?: string;
pi_lastname?: string;
pi_affiliation?: string;
email: string;
firstname?: string;
lastname?: string;
Expand Down
Loading