Skip to content

Commit

Permalink
[#1326] Operator: extend Agreements service with context
Browse files Browse the repository at this point in the history
let agreement file reside as end implementation desires
  • Loading branch information
eparovyshnaya authored and ruspl-afed committed Apr 10, 2024
1 parent f751436 commit 3fc618c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.passage.loc.agreements.emfforms.renderers;

import java.io.File;
import java.nio.file.Files;
import java.util.Optional;

import javax.inject.Inject;
Expand All @@ -24,7 +25,9 @@
import org.eclipse.emfforms.spi.common.report.ReportService;
import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
import org.eclipse.passage.loc.internal.equinox.AgreementsService;

@SuppressWarnings("restriction")
public final class AgreementFileRenderer extends BaseAgreementFileRenderer {

@Inject
Expand All @@ -38,4 +41,12 @@ protected Optional<File> locatedAgreementFile() {
return new LocatedAgreementFile().get();
}

@Override
protected String residentAgreementResource(File file) throws Exception {
String name = file.getName();
new AgreementsService().get().located(name, getViewModelContext().getDomainModel())
.write(Files.readAllBytes(file.toPath()));
return name;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.passage.loc.agreements.emfforms.renderers;

import java.io.File;
import java.nio.file.Files;
import java.util.Optional;

import org.eclipse.core.databinding.observable.IDecoratingObservable;
Expand All @@ -31,14 +30,12 @@
import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
import org.eclipse.passage.lic.agreements.model.api.Agreement;
import org.eclipse.passage.loc.internal.equinox.AgreementsService;
import org.eclipse.passage.loc.workbench.emfforms.renderers.TextWithButtonRenderer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

@SuppressWarnings("restriction")
/**
* <pre>
* TODO:
Expand Down Expand Up @@ -80,20 +77,15 @@ protected final void locateAgreementContentFile() {
return;
}
try {
reflect(reside(file.get()));
reflect(residentAgreementResource(file.get()));
} catch (Exception e) {
getReportService().report(new RenderingFailedReport(e));
}
}

protected abstract Optional<File> locatedAgreementFile();

private String reside(File file) throws Exception {
String name = file.getName();
new AgreementsService().get().located(name, getViewModelContext().getDomainModel())
.write(Files.readAllBytes(file.toPath()));
return name;
}
protected abstract String residentAgreementResource(File file) throws Exception;

private void reflect(String name) {
if (definedName().orElse("").equals(name)) { //$NON-NLS-1$
Expand Down

0 comments on commit 3fc618c

Please sign in to comment.