Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@ViewScoped
@Named
public class ConfigureFragmentBean implements java.io.Serializable{
public class ConfigureFragmentBean implements java.io.Serializable {

private static final Logger logger = Logger.getLogger(ConfigureFragmentBean.class.getName());

Expand Down Expand Up @@ -63,11 +63,11 @@ public ExternalTool getConfigurePopupTool() {
}

public ExternalToolHandler getConfigurePopupToolHandler() {
if(fileId == null) {
if (fileId == null) {
//on first UI load, method is called before fileId is set. There may be a better way to handle this
return null;
}
if(toolHandler != null) {
if (toolHandler != null) {
return toolHandler;
}

Expand All @@ -84,8 +84,7 @@ public ExternalToolHandler getConfigurePopupToolHandler() {
return toolHandler;
}

public void setConfigureFileId(Long setFileId)
{
public void setConfigureFileId(Long setFileId) {
fileId = setFileId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public void setId(Long id) {
public String getStrValue() {
return strValue;
}

public void setStrValue(String strValue) {
this.strValue = strValue;

}

private String identifier;
Expand All @@ -78,20 +78,24 @@ public String getIdentifier() {
public void setIdentifier(String identifier) {
this.identifier = identifier;
}




private int displayOrder;
public int getDisplayOrder() { return this.displayOrder;}
public void setDisplayOrder(int displayOrder) {this.displayOrder = displayOrder;}



public int getDisplayOrder() {
return this.displayOrder;
}

public void setDisplayOrder(int displayOrder) {
this.displayOrder = displayOrder;
}

@ManyToOne
// @JoinColumn( nullable = false ) TODO this breaks for the N/A value. need to create an N/A type for that value.
private DatasetFieldType datasetFieldType;
public DatasetFieldType getDatasetFieldType() {
return datasetFieldType;
}

public void setDatasetFieldType(DatasetFieldType datasetFieldType) {
this.datasetFieldType = datasetFieldType;
}
Expand All @@ -107,7 +111,6 @@ public void setControlledVocabAlternates(Collection<ControlledVocabAlternate> co
this.controlledVocabAlternates = controlledVocabAlternates;
}


@Override
public int hashCode() {
int hash = 0;
Expand All @@ -128,5 +131,5 @@ public boolean equals(Object object) {
public String toString() {
return "edu.harvard.iq.dataverse.ControlledVocabularyValue[ id=" + id + " ]";
}

}
12 changes: 5 additions & 7 deletions src/main/java/edu/harvard/iq/dataverse/DataCitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public DataCitation(DatasetVersion dsv) {
this(dsv, false);
}


public DataCitation(DatasetVersion dsv, boolean direct) {
this.direct = direct;
getCommonValuesFrom(dsv);
Expand Down Expand Up @@ -196,7 +195,7 @@ public String toString(boolean html) {
}

if (persistentId != null) {
// always show url format
// always show url format
citationList.add(formatURL(persistentId.toURL().toString(), persistentId.toURL().toString(), html));
}
citationList.add(formatString(publisher, html));
Expand Down Expand Up @@ -596,13 +595,13 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {

}

public Map<String, String> getDataCiteMetadata() {
public Map<String, String> getDataCiteMetadata() {
Map<String, String> metadata = new HashMap<>();
String authorString = getAuthorsString();

if (authorString.isEmpty()) {
authorString = ":unav";
}
}
String producerString = getPublisher();

if (producerString.isEmpty()) {
Expand All @@ -614,10 +613,9 @@ public Map<String, String> getDataCiteMetadata() {
metadata.put("datacite.publisher", producerString);
metadata.put("datacite.publicationyear", getYear());
return metadata;
}
}


// helper methods
// helper methods
private String formatString(String value, boolean escapeHtml) {
return formatString(value, escapeHtml, "");
}
Expand Down
35 changes: 17 additions & 18 deletions src/main/java/edu/harvard/iq/dataverse/DataCiteRESTfullClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,24 @@ public String inactiveDataset(String doi) {
public static void main(String[] args) throws Exception {
String doi = "10.5072/DVN/274533";
DataCiteRESTfullClient client = new DataCiteRESTfullClient("https://mds.test.datacite.org", "DATACITE.HARVARD", "DVNapitest");
// System.out.println(client.getUrl(doi));
// System.out.println(client.getMetadata(doi));
// System.out.println(client.postMetadata(readAndClose("C:/Users/luopc/Desktop/datacite.xml", "utf-8")));
// System.out.println(client.postUrl("10.5072/000000001", "http://opendata.pku.edu.cn/dvn/dv/DAIM/faces/study/StudyPage.xhtml?globalId=hdl:TEST/10027&studyListingIndex=1_1acc4e9f23fa10b3cc0500d9eb5e"));
// client.close();
// String doi2 = "10.1/1.0003";
// SimpleRESTfullClient client2 = new SimpleRESTfullClient("https://162.105.140.119:8443/mds", "PKULIB.IR", "luopengcheng","localhost.keystore");
// System.out.println(client2.getUrl("10.1/1.0002"));
// System.out.println(client2.getUrl("10.1/1.0002"));
// System.out.println(client2.getMetadata(doi2));
// client2.postUrl("10.1/1.0003", "http://ir.pku.edu.cn");
// System.out.println(client2.postUrl("10.1/1.0008", "http://ir.pku.edu.cn"));
// System.out.println(client2.postMetadata(FileUtil.loadAsString(new File("C:/Users/luopc/Desktop/test/datacite-example-ResourceTypeGeneral_Collection-v3.0.xml"), "utf-8")));
// System.out.println(client2.getMetadata("10.1/1.0007"));
// System.out.println(client2.inactiveDataSet("10.1/1.0007"));
// client2.close();
}
// System.out.println(client.getUrl(doi));
// System.out.println(client.getMetadata(doi));
// System.out.println(client.postMetadata(readAndClose("C:/Users/luopc/Desktop/datacite.xml", "utf-8")));
// System.out.println(client.postUrl("10.5072/000000001", "http://opendata.pku.edu.cn/dvn/dv/DAIM/faces/study/StudyPage.xhtml?globalId=hdl:TEST/10027&studyListingIndex=1_1acc4e9f23fa10b3cc0500d9eb5e"));
// client.close();
// String doi2 = "10.1/1.0003";
// SimpleRESTfullClient client2 = new SimpleRESTfullClient("https://162.105.140.119:8443/mds", "PKULIB.IR", "luopengcheng","localhost.keystore");
// System.out.println(client2.getUrl("10.1/1.0002"));
// System.out.println(client2.getUrl("10.1/1.0002"));
// System.out.println(client2.getMetadata(doi2));
// client2.postUrl("10.1/1.0003", "http://ir.pku.edu.cn");
// System.out.println(client2.postUrl("10.1/1.0008", "http://ir.pku.edu.cn"));
// System.out.println(client2.postMetadata(FileUtil.loadAsString(new File("C:/Users/luopc/Desktop/test/datacite-example-ResourceTypeGeneral_Collection-v3.0.xml"), "utf-8")));
// System.out.println(client2.getMetadata("10.1/1.0007"));
// System.out.println(client2.inactiveDataSet("10.1/1.0007"));
// client2.close();
}


// private static String readAndClose(String file, String encoding) throws IOException{
// BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),encoding));
// StringBuilder str = new StringBuilder();
Expand Down
50 changes: 20 additions & 30 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@
* @author gdurand
*/
@NamedQueries({
@NamedQuery( name="DataFile.removeFromDatasetVersion",
query="DELETE FROM FileMetadata f WHERE f.datasetVersion.id=:versionId and f.dataFile.id=:fileId"),
@NamedQuery(name="DataFile.findDataFileByIdProtocolAuth",
query="SELECT s FROM DataFile s WHERE s.identifier=:identifier AND s.protocol=:protocol AND s.authority=:authority")
@NamedQuery(name="DataFile.removeFromDatasetVersion",
query="DELETE FROM FileMetadata f WHERE f.datasetVersion.id=:versionId and f.dataFile.id=:fileId"),
@NamedQuery(name="DataFile.findDataFileByIdProtocolAuth",
query="SELECT s FROM DataFile s WHERE s.identifier=:identifier AND s.protocol=:protocol AND s.authority=:authority")
})
@Entity
@Table(indexes = {@Index(columnList="ingeststatus")
, @Index(columnList="checksumvalue")
, @Index(columnList="contenttype")
, @Index(columnList="restricted")})
@Table(indexes = {
@Index(columnList="ingeststatus"),
@Index(columnList="checksumvalue"),
@Index(columnList="contenttype"),
@Index(columnList="restricted")
})
public class DataFile extends DvObject implements Comparable {
private static final Logger logger = Logger.getLogger(DatasetPage.class.getCanonicalName());
private static final long serialVersionUID = 1L;
Expand All @@ -80,7 +82,6 @@ public class DataFile extends DvObject implements Comparable {
@Column( nullable = false )
@Pattern(regexp = "^.*/.*$", message = "{contenttype.slash}")
private String contentType;


// @Expose
// @SerializedName("storageIdentifier")
Expand Down Expand Up @@ -141,7 +142,6 @@ public String toString() {
@Column(nullable = false)
private String checksumValue;


/* start: FILE REPLACE ATTRIBUTES */

// For the initial version of a file, this will be equivalent to the ID
Expand All @@ -160,9 +160,7 @@ public String toString() {
@Column(nullable=true)
private Long previousDataFileId;
/* endt: FILE REPLACE ATTRIBUTES */




@Expose
@Column(nullable=true)
private Long filesize; // Number of bytes in file. Allows 0 and null, negative numbers not permitted
Expand Down Expand Up @@ -225,8 +223,7 @@ public DataFile(String contentType) {
this.fileMetadatas = new ArrayList<>();
initFileReplaceAttributes();
}



/**
* All constructors should use this method
* to initialize this file replace attributes
Expand Down Expand Up @@ -301,6 +298,7 @@ public JsonArrayBuilder getTagLabelsAsJsonArrayBuilder(){
}
return builder;
}

public void setTags(List<DataFileTag> dataFileTags) {
this.dataFileTags = dataFileTags;
}
Expand Down Expand Up @@ -633,7 +631,6 @@ public String getUnf() {
}
return null;
}


@ManyToMany
@JoinTable(name = "fileaccessrequests",
Expand Down Expand Up @@ -701,12 +698,12 @@ protected String toStringExtras() {
FileMetadata fmd = getLatestFileMetadata();
return "label:" + (fmd!=null? fmd.getLabel() : "[no metadata]");
}
@Override
public <T> T accept( Visitor<T> v ) {
return v.visit(this);
}

@Override
public <T> T accept( Visitor<T> v ) {
return v.visit(this);
}

@Override
public String getDisplayName() {
return getLatestFileMetadata().getLabel();
Expand Down Expand Up @@ -734,7 +731,6 @@ public boolean hasGeospatialTag(){
return false;
}


/**
* Set rootDataFileId
* @param rootDataFileId
Expand Down Expand Up @@ -792,9 +788,7 @@ public String toJSON(){

return serializeAsJSON(false);
}




public JsonObject asGsonObject(boolean prettyPrint){

String overarchingKey = "data";
Expand Down Expand Up @@ -876,7 +870,6 @@ public JsonObject asGsonObject(boolean prettyPrint){
jsonObj.getAsJsonObject().add("checksum", checkSumJSONMap);

return jsonObj.getAsJsonObject();

}

/**
Expand All @@ -890,7 +883,6 @@ private String serializeAsJSON(boolean prettyPrint){

//return fullFileJSON.
return fullFileJSON.toString();

}

public String getPublicationDateFormattedYYYYMMDD() {
Expand All @@ -906,8 +898,6 @@ public String getCreateDateFormattedYYYYMMDD() {
}
return null;
}


} // end of class


Expand Down
Loading