Search in sources :

Example 1 with DocumentId

use of edu.stanford.bmir.protege.web.shared.csv.DocumentId in project webprotege by protegeproject.

the class FileUploadResponse method getDocumentId.

/**
 * For an upload that was accepted ({@link #wasUploadAccepted()} returns <code>true</code>) this method gets
 * the documentId of the upload.
 * @return The document Id
 */
public DocumentId getDocumentId() {
    if (jsonObject == null) {
        return new DocumentId("");
    }
    if (!wasUploadAccepted()) {
        return new DocumentId("");
    }
    JSONValue value = jsonObject.get(FileUploadResponseAttributes.UPLOAD_FILE_ID.name());
    if (value == null) {
        return new DocumentId("");
    }
    JSONString string = value.isString();
    if (string == null) {
        return new DocumentId("");
    }
    return new DocumentId(string.stringValue().trim());
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) JSONString(com.google.gwt.json.client.JSONString)

Example 2 with DocumentId

use of edu.stanford.bmir.protege.web.shared.csv.DocumentId in project webprotege by protegeproject.

the class GetCSVGridActionHandler method execute.

@Nonnull
@Override
public GetCSVGridResult execute(@Nonnull GetCSVGridAction action, @Nonnull ExecutionContext executionContext) {
    DocumentId documentId = action.getCSVDocumentId();
    File file = new File(uploadsDirectory, documentId.getDocumentId());
    if (!file.exists()) {
        throw new RuntimeException("CSV file does not exist");
    }
    CSVGrid grid = getCSVGrid(file, action.getRowLimit());
    return new GetCSVGridResult(grid);
}
Also used : GetCSVGridResult(edu.stanford.bmir.protege.web.shared.csv.GetCSVGridResult) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) CSVGrid(edu.stanford.bmir.protege.web.shared.csv.CSVGrid) Nonnull(javax.annotation.Nonnull)

Example 3 with DocumentId

use of edu.stanford.bmir.protege.web.shared.csv.DocumentId in project webprotege by protegeproject.

the class UploadAndMergeProjectWorkflow method uploadProject.

private void uploadProject(final ProjectId projectId) {
    UploadFileDialogController uploadFileDialogController = new UploadFileDialogController("Upload ontologies", new UploadFileResultHandler() {

        @Override
        public void handleFileUploaded(DocumentId fileDocumentId) {
            startMergeWorkflow(projectId, fileDocumentId);
        }

        @Override
        public void handleFileUploadFailed(String errorMessage) {
            GWT.log("Upload failed");
        }
    });
    WebProtegeDialog.showDialog(uploadFileDialogController);
}
Also used : UploadFileResultHandler(edu.stanford.bmir.protege.web.client.upload.UploadFileResultHandler) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) UploadFileDialogController(edu.stanford.bmir.protege.web.client.upload.UploadFileDialogController)

Example 4 with DocumentId

use of edu.stanford.bmir.protege.web.shared.csv.DocumentId in project webprotege by protegeproject.

the class CsvImportPresenter method startImport.

public void startImport() {
    UploadFileResultHandler uploadResultHandler = new UploadFileResultHandler() {

        @Override
        public void handleFileUploaded(final DocumentId fileDocumentId) {
            WebProtegeDialog<CSVImportDescriptor> csvImportDialog = new WebProtegeDialog<>(new CSVImportDialogController(projectId, fileDocumentId, baseClass, dispatchServiceManager, new CSVImportViewImpl(primitiveDataEditorProvider)));
            csvImportDialog.setVisible(true);
        }

        @Override
        public void handleFileUploadFailed(String errorMessage) {
            ProgressMonitor.get().hideProgressMonitor();
            MessageBox.showAlert("Error uploading CSV file", errorMessage);
        }
    };
    UploadFileDialogController controller = new UploadFileDialogController("Upload CSV", uploadResultHandler);
    WebProtegeDialog.showDialog(controller);
}
Also used : CSVImportViewImpl(edu.stanford.bmir.protege.web.client.csv.CSVImportViewImpl) UploadFileResultHandler(edu.stanford.bmir.protege.web.client.upload.UploadFileResultHandler) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) CSVImportDialogController(edu.stanford.bmir.protege.web.client.csv.CSVImportDialogController) UploadFileDialogController(edu.stanford.bmir.protege.web.client.upload.UploadFileDialogController) CSVImportDescriptor(edu.stanford.bmir.protege.web.shared.csv.CSVImportDescriptor)

Example 5 with DocumentId

use of edu.stanford.bmir.protege.web.shared.csv.DocumentId in project webprotege by protegeproject.

the class CreateNewProjectPresenter method handleSourcesUploadComplete.

private void handleSourcesUploadComplete(FormPanel.SubmitCompleteEvent event, ProjectCreatedHandler projectCreatedHandler) {
    FileUploadResponse response = new FileUploadResponse(event.getResults());
    if (response.wasUploadAccepted()) {
        DocumentId documentId = response.getDocumentId();
        NewProjectSettings newProjectSettings = new NewProjectSettings(loggedInUserManager.getLoggedInUserId(), view.getProjectName(), view.getProjectDescription(), documentId);
        submitCreateNewProjectRequest(newProjectSettings, projectCreatedHandler);
    } else {
        MessageBox.showAlert("Upload Failed", response.getUploadRejectedMessage());
    }
}
Also used : FileUploadResponse(edu.stanford.bmir.protege.web.client.upload.FileUploadResponse) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId)

Aggregations

DocumentId (edu.stanford.bmir.protege.web.shared.csv.DocumentId)7 Nonnull (javax.annotation.Nonnull)3 UploadFileDialogController (edu.stanford.bmir.protege.web.client.upload.UploadFileDialogController)2 UploadFileResultHandler (edu.stanford.bmir.protege.web.client.upload.UploadFileResultHandler)2 OntologyDiff (edu.stanford.bmir.protege.web.shared.merge.OntologyDiff)2 IOException (java.io.IOException)2 JSONString (com.google.gwt.json.client.JSONString)1 JSONValue (com.google.gwt.json.client.JSONValue)1 CSVImportDialogController (edu.stanford.bmir.protege.web.client.csv.CSVImportDialogController)1 CSVImportViewImpl (edu.stanford.bmir.protege.web.client.csv.CSVImportViewImpl)1 WebProtegeDialog (edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog)1 FileUploadResponse (edu.stanford.bmir.protege.web.client.upload.FileUploadResponse)1 OntologyDiff2OntologyChanges (edu.stanford.bmir.protege.web.server.diff.OntologyDiff2OntologyChanges)1 CSVGrid (edu.stanford.bmir.protege.web.shared.csv.CSVGrid)1 CSVImportDescriptor (edu.stanford.bmir.protege.web.shared.csv.CSVImportDescriptor)1 GetCSVGridResult (edu.stanford.bmir.protege.web.shared.csv.GetCSVGridResult)1 DiffElement (edu.stanford.bmir.protege.web.shared.diff.DiffElement)1 ActionExecutionException (edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException)1 ComputeProjectMergeResult (edu.stanford.bmir.protege.web.shared.merge.ComputeProjectMergeResult)1 MergeUploadedProjectResult (edu.stanford.bmir.protege.web.shared.merge.MergeUploadedProjectResult)1