-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: persisting featured items in the database
- Loading branch information
Showing
6 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/edu/harvard/iq/dataverse/DataverseFeaturedItemServiceBean.java
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,25 @@ | ||
package edu.harvard.iq.dataverse; | ||
|
||
import jakarta.ejb.Stateless; | ||
import jakarta.inject.Named; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
|
||
import java.io.Serializable; | ||
|
||
@Stateless | ||
@Named | ||
public class DataverseFeaturedItemServiceBean implements Serializable { | ||
|
||
@PersistenceContext(unitName = "VDCNet-ejbPU") | ||
private EntityManager em; | ||
|
||
public DataverseFeaturedItem save(DataverseFeaturedItem dataverseFeaturedItem) { | ||
if (dataverseFeaturedItem.getId() == null) { | ||
em.persist(dataverseFeaturedItem); | ||
return dataverseFeaturedItem; | ||
} else { | ||
return em.merge(dataverseFeaturedItem); | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/edu/harvard/iq/dataverse/api/dto/NewDataverseFeaturedItemDTO.java
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,40 @@ | ||
package edu.harvard.iq.dataverse.api.dto; | ||
|
||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; | ||
|
||
import java.io.InputStream; | ||
|
||
public class NewDataverseFeaturedItemDTO { | ||
private String content; | ||
private int displayOrder; | ||
private InputStream fileInputStream; | ||
private String imageFileName; | ||
|
||
public static NewDataverseFeaturedItemDTO fromFormData(String content, | ||
int order, | ||
InputStream fileInputStream, | ||
FormDataContentDisposition contentDispositionHeader) { | ||
NewDataverseFeaturedItemDTO newDataverseFeaturedItemDTO = new NewDataverseFeaturedItemDTO(); | ||
newDataverseFeaturedItemDTO.content = content; | ||
newDataverseFeaturedItemDTO.displayOrder = order; | ||
newDataverseFeaturedItemDTO.fileInputStream = fileInputStream; | ||
newDataverseFeaturedItemDTO.imageFileName = contentDispositionHeader.getFileName(); | ||
return newDataverseFeaturedItemDTO; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public int getDisplayOrder() { | ||
return displayOrder; | ||
} | ||
|
||
public InputStream getFileInputStream() { | ||
return fileInputStream; | ||
} | ||
|
||
public String getImageFileName() { | ||
return imageFileName; | ||
} | ||
} |
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
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
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