Skip to content

Commit

Permalink
allow multiple publisedTo
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomociti committed Sep 12, 2024
1 parent 0f8cffe commit f90efcb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apis/core/lib/domain/job/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function createPublishJob({
revision: project.nextRevision,
publishGraph: organization.publishGraph,
status: metadata?.pointer.out(schema.creativeWorkStatus).term,
publishedTo: metadata?.pointer.out(schema.workExample).term,
publishedTo: metadata?.pointer.out(schema.workExample).terms,
})

const cubeId = isCsvProject(project)
Expand Down
22 changes: 12 additions & 10 deletions cli/lib/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,21 @@ async function getJob(jobUri: string, Hydra: HydraClient): Promise<{
}

const getProfile = () => {
// 'https://cube.link/v0.2.1/shape/standalone-constraint-constraint'
// 'https://cube.link/latest/shape/standalone-constraint-constraint'
// 'https://cube.link/latest/shape/profile-opendataswiss'
// 'https://cube.link/latest/shape/profile-visualize'
const publishedTo = jobResource.representation?.root?.publishedTo?.value
if (publishedTo === 'https://ld.admin.ch/application/opendataswiss') {
return 'https://cube.link/latest/shape/profile-opendataswiss'
const publishedTo = jobResource.representation?.root?.publishedTo
if (publishedTo?.length === 1) {
if (publishedTo[0].value === 'https://ld.admin.ch/application/opendataswiss') {
return 'https://cube.link/v0.2.2/shape/profile-opendataswiss-lindas'
}
if (publishedTo[0].value === 'https://ld.admin.ch/application/visualize') {
return 'https://cube.link/v0.2.2/shape/profile-visualize'
}
}
if (publishedTo === 'https://ld.admin.ch/application/visualize') {
return 'https://cube.link/latest/shape/profile-visualize'
if (publishedTo?.length === 2) {
// todo
return 'https://cube.link/v0.2.2/shape/profile-visualize'
}

return 'https://cube.link/v0.2.1/shape/standalone-constraint-constraint'
return 'https://cube.link/v0.2.2/shape/standalone-constraint-constraint'
}

const projectResource = await Hydra.loadResource<CsvProject | ImportProject>(job.project)
Expand Down
12 changes: 6 additions & 6 deletions packages/model/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface PublishJob extends Job {
project: NamedNode
revision: number
publishGraph: NamedNode
publishedTo: Term | undefined
publishedTo: Term[]
status?: Term
query?: string
workExamples: CreativeWork[]
Expand Down Expand Up @@ -137,17 +137,17 @@ export function PublishJobMixin<Base extends Constructor<RdfResource>>(base: Bas
@property({ path: schema.creativeWorkStatus })
status?: NamedNode

get publishedTo(): Term | undefined {
get publishedTo(): Term[] {
return this.pointer
.out(schema.workExample)
.filter(example => example.out(schema.encodingFormat).terms.length === 0)
.term
.terms
}

set publishedTo(term: Term | undefined) {
if (term) {
set publishedTo(terms: Term[]) {
terms.forEach(term => {
this.pointer.addOut(schema.workExample, term)
}
})
}

get workExamples(): CreativeWork[] {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/Publication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<span v-if="job.status" class="tag">
<external-term :resource="job.status" />
</span>
<span v-if="job.publishedTo" class="tag">
<external-term :resource="job.publishedTo" />
<span v-for="(publication, index) in job.publishedTo" :key="index" class="tag">
<external-term :resource="publication" />
</span>
</div>
</job-item>
Expand Down

0 comments on commit f90efcb

Please sign in to comment.