Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Aug 7, 2024
1 parent 05c87ba commit 746ce92
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ private ResponseEntity<StreamingResponseBody> handleInternalLobDownload(String d
handlebarsMimeType = tableConfiguration.getColumnByIndex(columnIndex).getApplicationType();
}

if (version.equals(ViewerConstants.SIARD_DK)) {
if (version.equals(ViewerConstants.SIARD_DK_2010) || version.equals(ViewerConstants.SIARD_DK_2020)) {
String filePath = row.getCells().get(row.getCells().keySet().toArray()[row.getCells().size() - 1]).getValue();
return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
DownloadUtils.stream(new BufferedInputStream(new FileInputStream(filePath)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ public class ViewerConstants {
public static final String SIARD_V20 = "2.0";
public static final String SIARD_V21 = "2.1";
public static final String SIARD_DK = "dk";

public static final String SIARD_DK_2010 = "dk-2010";
public static final String SIARD_DK_2020 = "dk-2020";
/*
* DBPTK Metadata
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,21 @@ private void setupFooterButtons() {
if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_DESKTOP)) {
message = messages.SIARDHomePageTextForDeleteAllFromDesktop();
}
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
deleteAll();
if (database.getVersion().equals(ViewerConstants.SIARD_DK_2010) || database.getVersion().equals(ViewerConstants.SIARD_DK_2020)) {
Dialogs.showInformationDialog(messages.SIARDHomePageDialogTitleForDelete(),
"SIARD deletion only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link");
} else {
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
deleteAll();
}
}
}
});
});
}
} else if (ViewerDatabaseStatus.INGESTING.equals(database.getStatus())) {
Dialogs.showInformationDialog(messages.SIARDManagerPageInformationDialogTitle(),
messages.SIARDManagerPageTextForWaitForFinishing(), messages.basicActionClose(), "btn btn-link");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ private void browseButton() {
private void handleBrowseAction() {
if (database.getStatus().equals(ViewerDatabaseStatus.METADATA_ONLY)) {
// Initial state
if (database.getVersion().equals(ViewerConstants.SIARD_V21) || database.getVersion().equals(ViewerConstants.SIARD_DK)) {
if (database.getVersion().equals(ViewerConstants.SIARD_V21)
|| database.getVersion().equals(ViewerConstants.SIARD_DK_2010)
|| database.getVersion().equals(ViewerConstants.SIARD_DK_2020)) {
if (!btnIngestClicked) {
btnIngestClicked = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.databasepreservation.common.client.common.DefaultAsyncCallback;
import com.databasepreservation.common.client.common.NavigationPanel;
import com.databasepreservation.common.client.common.dialogs.CommonDialogs;
import com.databasepreservation.common.client.common.dialogs.Dialogs;
import com.databasepreservation.common.client.common.fields.GenericField;
import com.databasepreservation.common.client.common.fields.MetadataField;
import com.databasepreservation.common.client.common.utils.ApplicationType;
Expand Down Expand Up @@ -66,7 +67,13 @@ public NavigationPanel build() {
btnEditMetadata.setText(messages.SIARDHomePageButtonTextEditMetadata());
btnEditMetadata.addStyleName("btn btn-outline-primary btn-edit");
btnEditMetadata.addClickHandler(clickEvent -> {
HistoryManager.gotoSIARDEditMetadata(database.getUuid());
if (database.getVersion().equals(ViewerConstants.SIARD_DK_2010)
|| database.getVersion().equals(ViewerConstants.SIARD_DK_2020)) {
Dialogs.showInformationDialog("Edit metadata information", "Metadata edition only supports SIARD version 2.1.",
messages.basicActionUnderstood(), "btn btn-link");
} else {
HistoryManager.gotoSIARDEditMetadata(database.getUuid());
}
});

// Migration button
Expand Down Expand Up @@ -109,18 +116,24 @@ public NavigationPanel build() {
if (database.getPath() != null && !database.getPath().isEmpty()) {
btnDelete.setText(messages.SIARDHomePageButtonTextForDeleteIngested());
btnDelete.addClickHandler(event -> {
if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
&& !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
delete();
if (database.getVersion().equals(ViewerConstants.SIARD_DK_2010)
|| database.getVersion().equals(ViewerConstants.SIARD_DK_2020)) {
Dialogs.showInformationDialog("Delete metadata information",
"Metadata deletion only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link");
} else {
if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
&& !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
delete();
}
}
}
});
});
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.util.Map;
import java.util.Set;

import com.databasepreservation.modules.siard.SIARDDK2020ModuleFactory;
import com.databasepreservation.modules.siard.SIARDDKEditFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
Expand Down Expand Up @@ -84,6 +82,10 @@
import com.databasepreservation.modules.config.ImportConfigurationModuleFactory;
import com.databasepreservation.modules.jdbc.in.JDBCImportModule;
import com.databasepreservation.modules.siard.SIARD2ModuleFactory;
import com.databasepreservation.modules.siard.SIARDDK2010EditFactory;
import com.databasepreservation.modules.siard.SIARDDK2010ModuleFactory;
import com.databasepreservation.modules.siard.SIARDDK2020EditFactory;
import com.databasepreservation.modules.siard.SIARDDK2020ModuleFactory;
import com.databasepreservation.modules.siard.SIARDEditFactory;
import com.databasepreservation.modules.siard.SIARDValidateFactory;
import com.databasepreservation.modules.viewer.DbvtkModuleFactory;
Expand Down Expand Up @@ -606,10 +608,13 @@ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUU
try {
Reporter reporter = new NoOpReporter();
SIARDEdition siardEdition = SIARDEdition.newInstance();

if (siardVersion.equals(ViewerConstants.SIARD_DK)) {
siardEdition.editModule(new SIARDDKEditFactory()).editModuleParameter(SIARDDKEditFactory.PARAMETER_FOLDER,
if (siardVersion.equals(ViewerConstants.SIARD_DK_2010)) {
siardEdition.editModule(new SIARDDK2010EditFactory()).editModuleParameter(
SIARDDK2010EditFactory.PARAMETER_FOLDER,
Collections.singletonList(siardPath.toAbsolutePath().toString()));
} else if (siardVersion.equals(ViewerConstants.SIARD_DK_2020)) {
siardEdition.editModule(new SIARDDK2020EditFactory()).editModuleParameter(
SIARDDK2020EditFactory.PARAMETER_FOLDER, Collections.singletonList(siardPath.toAbsolutePath().toString()));
} else {
siardEdition.editModule(new SIARDEditFactory()).editModuleParameter(SIARDEditFactory.PARAMETER_FILE,
Collections.singletonList(siardPath.toAbsolutePath().toString()));
Expand Down Expand Up @@ -708,10 +713,14 @@ private static void convertSIARDtoSolr(Path siardPath, String databaseUUID, Stri
// XXX remove this workaround after fix of NPE
databaseMigration.filterFactories(new ArrayList<>());

if (siardVersion.equals(ViewerConstants.SIARD_DK)) {
if (siardVersion.equals(ViewerConstants.SIARD_DK_2020)) {
databaseMigration.importModule(new SIARDDK2020ModuleFactory())
.importModuleParameter(SIARDDK2020ModuleFactory.PARAMETER_FOLDER, siardPath.toAbsolutePath().toString())
.importModuleParameter(SIARDDK2020ModuleFactory.PARAMETER_AS_SCHEMA, "public");
} else if (siardVersion.equals(ViewerConstants.SIARD_DK_2010)) {
databaseMigration.importModule(new SIARDDK2010ModuleFactory())
.importModuleParameter(SIARDDK2010ModuleFactory.PARAMETER_FOLDER, siardPath.toAbsolutePath().toString())
.importModuleParameter(SIARDDK2010ModuleFactory.PARAMETER_AS_SCHEMA, "public");
} else if (siardVersion.equals(ViewerConstants.SIARD_V21)) {
databaseMigration.importModule(new SIARD2ModuleFactory())
.importModuleParameter(SIARD2ModuleFactory.PARAMETER_FILE, siardPath.toAbsolutePath().toString())
Expand Down

0 comments on commit 746ce92

Please sign in to comment.