Search in sources :

Example 26 with DatasetVersion

use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.

the class FileUtilTest method testIsDownloadPopupRequiredHasTermsOfAccess.

@Test
public void testIsDownloadPopupRequiredHasTermsOfAccess() {
    DatasetVersion dsv1 = new DatasetVersion();
    dsv1.setVersionState(DatasetVersion.VersionState.RELEASED);
    TermsOfUseAndAccess termsOfUseAndAccess = new TermsOfUseAndAccess();
    termsOfUseAndAccess.setTermsOfAccess("Terms of *Access* is different than Terms of Use");
    dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess);
    assertEquals(true, FileUtil.isDownloadPopupRequired(dsv1));
}
Also used : DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) TermsOfUseAndAccess(edu.harvard.iq.dataverse.TermsOfUseAndAccess) Test(org.junit.Test)

Example 27 with DatasetVersion

use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.

the class FileUtilTest method testIsDownloadPopupRequiredLicenseCC0.

@Test
public void testIsDownloadPopupRequiredLicenseCC0() {
    DatasetVersion dsv1 = new DatasetVersion();
    dsv1.setVersionState(DatasetVersion.VersionState.RELEASED);
    TermsOfUseAndAccess termsOfUseAndAccess = new TermsOfUseAndAccess();
    termsOfUseAndAccess.setLicense(TermsOfUseAndAccess.License.CC0);
    dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess);
    assertEquals(false, FileUtil.isDownloadPopupRequired(dsv1));
}
Also used : DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) TermsOfUseAndAccess(edu.harvard.iq.dataverse.TermsOfUseAndAccess) Test(org.junit.Test)

Example 28 with DatasetVersion

use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.

the class FileUtilTest method testIsDownloadPopupRequiredHasGuestBook.

@Test
public void testIsDownloadPopupRequiredHasGuestBook() {
    DatasetVersion datasetVersion = new DatasetVersion();
    datasetVersion.setVersionState(DatasetVersion.VersionState.RELEASED);
    Dataset dataset = new Dataset();
    datasetVersion.setDataset(dataset);
    Guestbook guestbook = new Guestbook();
    guestbook.setEnabled(true);
    dataset.setGuestbook(guestbook);
    Dataverse dataverse = new Dataverse();
    guestbook.setDataverse(dataverse);
    assertEquals(true, FileUtil.isDownloadPopupRequired(datasetVersion));
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) Guestbook(edu.harvard.iq.dataverse.Guestbook) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) Dataverse(edu.harvard.iq.dataverse.Dataverse) Test(org.junit.Test)

Example 29 with DatasetVersion

use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.

the class JsonParser method parseDataset.

public Dataset parseDataset(JsonObject obj) throws JsonParseException {
    Dataset dataset = new Dataset();
    dataset.setAuthority(obj.getString("authority", null) == null ? settingsService.getValueForKey(SettingsServiceBean.Key.Authority) : obj.getString("authority"));
    dataset.setProtocol(obj.getString("protocol", null) == null ? settingsService.getValueForKey(SettingsServiceBean.Key.Protocol) : obj.getString("protocol"));
    dataset.setDoiSeparator(obj.getString("doiSeparator", null) == null ? settingsService.getValueForKey(SettingsServiceBean.Key.DoiSeparator) : obj.getString("doiSeparator"));
    dataset.setIdentifier(obj.getString("identifier", null));
    DatasetVersion dsv = new DatasetVersion();
    dsv.setDataset(dataset);
    dsv = parseDatasetVersion(obj.getJsonObject("datasetVersion"), dsv);
    LinkedList<DatasetVersion> versions = new LinkedList<>();
    versions.add(dsv);
    dataset.setVersions(versions);
    return dataset;
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) LinkedList(java.util.LinkedList)

Example 30 with DatasetVersion

use of edu.harvard.iq.dataverse.DatasetVersion in project dataverse by IQSS.

the class MailUtil method getSubjectTextBasedOnNotification.

public static String getSubjectTextBasedOnNotification(UserNotification userNotification, String rootDataverseName, Object objectOfNotification) {
    List<String> rootDvNameAsList = Arrays.asList(BrandingUtil.getInstallationBrandName(rootDataverseName));
    switch(userNotification.getType()) {
        case ASSIGNROLE:
            return BundleUtil.getStringFromBundle("notification.email.assign.role.subject", rootDvNameAsList);
        case REVOKEROLE:
            return BundleUtil.getStringFromBundle("notification.email.revoke.role.subject", rootDvNameAsList);
        case CREATEDV:
            return BundleUtil.getStringFromBundle("notification.email.create.dataverse.subject", rootDvNameAsList);
        case REQUESTFILEACCESS:
            return BundleUtil.getStringFromBundle("notification.email.request.file.access.subject", rootDvNameAsList);
        case GRANTFILEACCESS:
            return BundleUtil.getStringFromBundle("notification.email.grant.file.access.subject", rootDvNameAsList);
        case REJECTFILEACCESS:
            return BundleUtil.getStringFromBundle("notification.email.rejected.file.access.subject", rootDvNameAsList);
        case MAPLAYERUPDATED:
            return BundleUtil.getStringFromBundle("notification.email.update.maplayer", rootDvNameAsList);
        case MAPLAYERDELETEFAILED:
            return BundleUtil.getStringFromBundle("notification.email.maplayer.deletefailed.subject", rootDvNameAsList);
        case CREATEDS:
            return BundleUtil.getStringFromBundle("notification.email.create.dataset.subject", rootDvNameAsList);
        case SUBMITTEDDS:
            return BundleUtil.getStringFromBundle("notification.email.submit.dataset.subject", rootDvNameAsList);
        case PUBLISHEDDS:
            return BundleUtil.getStringFromBundle("notification.email.publish.dataset.subject", rootDvNameAsList);
        case RETURNEDDS:
            return BundleUtil.getStringFromBundle("notification.email.returned.dataset.subject", rootDvNameAsList);
        case CREATEACC:
            return BundleUtil.getStringFromBundle("notification.email.create.account.subject", rootDvNameAsList);
        case CHECKSUMFAIL:
            return BundleUtil.getStringFromBundle("notification.email.checksumfail.subject", rootDvNameAsList);
        case FILESYSTEMIMPORT:
            try {
                DatasetVersion version = (DatasetVersion) objectOfNotification;
                List<String> dsNameAsList = Arrays.asList(version.getDataset().getDisplayName());
                return BundleUtil.getStringFromBundle("notification.email.import.filesystem.subject", dsNameAsList);
            } catch (Exception e) {
                return BundleUtil.getStringFromBundle("notification.email.import.filesystem.subject", rootDvNameAsList);
            }
        case CHECKSUMIMPORT:
            return BundleUtil.getStringFromBundle("notification.email.import.checksum.subject", rootDvNameAsList);
        case CONFIRMEMAIL:
            return BundleUtil.getStringFromBundle("notification.email.verifyEmail.subject", rootDvNameAsList);
    }
    return "";
}
Also used : DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) AddressException(javax.mail.internet.AddressException)

Aggregations

DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)85 Dataset (edu.harvard.iq.dataverse.Dataset)43 Test (org.junit.Test)36 FileMetadata (edu.harvard.iq.dataverse.FileMetadata)25 ArrayList (java.util.ArrayList)24 DataFile (edu.harvard.iq.dataverse.DataFile)19 JsonObject (javax.json.JsonObject)15 Date (java.util.Date)13 StringReader (java.io.StringReader)11 IOException (java.io.IOException)10 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)9 Timestamp (java.sql.Timestamp)9 EJBException (javax.ejb.EJBException)9 JsonParser (edu.harvard.iq.dataverse.util.json.JsonParser)8 JsonObjectBuilder (javax.json.JsonObjectBuilder)8 JsonReader (javax.json.JsonReader)8 DatasetField (edu.harvard.iq.dataverse.DatasetField)7 Dataverse (edu.harvard.iq.dataverse.Dataverse)7 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)7 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)7