-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package doi | ||
|
||
type Provider interface { | ||
Publish(did, description string) (string, string, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package doi | ||
|
||
import ( | ||
materialCommons "github.com/CHESSComputing/golib/MaterialCommons" | ||
) | ||
|
||
type MaterialCommons struct { | ||
} | ||
|
||
func (m *MaterialCommons) Publish(did, description string) (string, string, error) { | ||
doi, doiLink, err := materialCommons.Publish(did, description) | ||
return doi, doiLink, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package doi | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/CHESSComputing/golib/zenodo" | ||
) | ||
|
||
type Zenodo struct { | ||
} | ||
|
||
func (z *Zenodo) Publish(did, description string) (string, string, error) { | ||
var doi, doiLink string | ||
var err error | ||
docId, err := zenodo.CreateRecord() | ||
if err != nil { | ||
return doi, doiLink, err | ||
} | ||
|
||
// add foxden record | ||
// TODO: add to FoxdenRecord MetaData | ||
frec := zenodo.FoxdenRecord{Beamline: "test-beamline", Type: "raw-data", MetaData: "todo"} | ||
err = zenodo.AddRecord(docId, "foxden-meta.json", frec) | ||
|
||
// create new meta-data record | ||
creator := zenodo.Creator{Name: "FOXDEN", Affiliation: "Cornell University"} | ||
mrec := zenodo.MetaDataRecord{ | ||
PublicationType: "deliverable", | ||
UploadType: "dataset", | ||
Description: description, | ||
Keywords: []string{"FOXDEN"}, | ||
Title: fmt.Sprintf("FOXDEN dataset did=%s", did), | ||
Licences: []string{"MIT"}, | ||
Creators: []zenodo.Creator{creator}, | ||
} | ||
|
||
err = zenodo.UpdateRecord(docId, mrec) | ||
if err != nil { | ||
return doi, doiLink, err | ||
} | ||
|
||
// publish record | ||
doiRecord, err := zenodo.PublishRecord(docId) | ||
if err != nil { | ||
return doi, doiLink, err | ||
} | ||
return doiRecord.Doi, doiRecord.DoiUrl, nil | ||
} |