Skip to content

Commit

Permalink
fix: fix renamed properties in schema (#224)
Browse files Browse the repository at this point in the history
Refs: #222
  • Loading branch information
grigoriev authored Sep 24, 2024
1 parent 87e087f commit e4ef40d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
25 changes: 13 additions & 12 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1325,15 +1325,6 @@
},
"ExportParams": {
"properties": {
"Location path": {
"description": "Document path for export",
"type": "string"
},
"Project ID": {
"description": "The unique identifier for the project",
"example": "elibrary",
"type": "string"
},
"chapters": {
"description": "Specific higher level chapters",
"items": {
Expand Down Expand Up @@ -1390,7 +1381,7 @@
"type": "boolean"
},
"headerFooter": {
"description": "Header Footer settings name",
"description": "Header/Footer settings name",
"type": "string"
},
"headersColor": {
Expand Down Expand Up @@ -1422,6 +1413,11 @@
"description": "Localization settings name",
"type": "string"
},
"locationPath": {
"description": "Document path for export",
"example": "Specification/Product Specification",
"type": "string"
},
"markReferencedWorkitems": {
"description": "Referenced work items should be marked in the document",
"type": "boolean"
Expand Down Expand Up @@ -1456,8 +1452,13 @@
],
"type": "string"
},
"projectId": {
"description": "The unique identifier for the project",
"example": "elibrary",
"type": "string"
},
"revision": {
"description": "The specific revision of the document to export",
"description": "The specific revision of the document",
"type": "string"
},
"urlQueryParameters": {
Expand All @@ -1478,7 +1479,7 @@
}
},
"required": [
"Location path"
"documentType"
],
"type": "object"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Map;
Expand All @@ -14,16 +16,16 @@
@NoArgsConstructor
@AllArgsConstructor
public class ExportParams {
@Schema(name = "Project ID", example = "elibrary", description = "The unique identifier for the project")
private String projectId;
@Schema(description = "The unique identifier for the project", example = "elibrary")
private @Nullable String projectId;

@Schema(name = "Location path", required = true, description = "Document path for export")
private String locationPath;
@Schema(description = "Document path for export", example = "Specification/Product Specification")
private @Nullable String locationPath;

@Schema(description = "The specific revision of the document to export")
private String revision;
@Schema(description = "The specific revision of the document")
private @Nullable String revision;

@Schema(description = "The type of document to export", example = "LIVE_DOC")
@Schema(description = "The type of document", example = "LIVE_DOC")
private DocumentType documentType;

@Schema(description = "Cover page settings name")
Expand All @@ -32,7 +34,7 @@ public class ExportParams {
@Schema(description = "CSS settings name")
private String css;

@Schema(description = "Header Footer settings name")
@Schema(description = "Header/Footer settings name")
private String headerFooter;

@Schema(description = "Localization settings name")
Expand All @@ -44,7 +46,7 @@ public class ExportParams {
@Schema(description = "Color to be used for headers in the document. By default dark blue color (Polarion's default)")
private String headersColor;

@Schema(description = "The orientation of the exported document", defaultValue = "PORTRAIT")
@Schema(description = "The page orientation of the exported document", defaultValue = "PORTRAIT")
private Orientation orientation = Orientation.PORTRAIT;

@Schema(description = "The paper size of the exported document", defaultValue = "A4")
Expand Down Expand Up @@ -92,10 +94,9 @@ public class ExportParams {
@Schema(description = "Internal content")
private String internalContent;

public DocumentType getDocumentType() {
// Default to DOCUMENT
public @NotNull DocumentType getDocumentType() {
if (documentType == null) {
return DocumentType.LIVE_DOC;
documentType = DocumentType.LIVE_DOC;
}
return documentType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ public DocumentData<IRichPage> getLiveReport(@Nullable ITrackerProject project,

public DocumentData<IRichPage> getLiveReport(@Nullable ITrackerProject project, @NotNull ExportParams exportParams, boolean withContent) {
return TransactionalExecutor.executeSafelyInReadOnlyTransaction(transaction -> {

String projectId = project != null ? project.getId() : "";
RichPageReference richPageReference = RichPageReference.fromPath(createPath(projectId, exportParams.getLocationPath()));
String locationPath = exportParams.getLocationPath();
if (locationPath == null) {
throw new IllegalArgumentException("Location path is required for export");
}

RichPageReference richPageReference = RichPageReference.fromPath(createPath(projectId, locationPath));
if (exportParams.getRevision() != null) {
richPageReference = richPageReference.getWithRevision(exportParams.getRevision());
}
Expand Down Expand Up @@ -93,11 +99,13 @@ public DocumentData<ITestRun> getTestRun(@NotNull ITrackerProject project, @NotN

public DocumentData<ITestRun> getTestRun(@NotNull ITrackerProject project, @NotNull ExportParams exportParams, boolean withContent) {
return TransactionalExecutor.executeSafelyInReadOnlyTransaction(transaction -> {

String projectId = project.getId();
Map<String, String> urlQueryParameters = exportParams.getUrlQueryParameters();
if (urlQueryParameters == null || !urlQueryParameters.containsKey(URL_QUERY_PARAM_ID)) {
throw new IllegalArgumentException("TestRun id is required for export");
}

TestRunReference testRunReference = TestRunReference.fromPath(createPath(projectId, urlQueryParameters.get(URL_QUERY_PARAM_ID)));
if (exportParams.getRevision() != null) {
testRunReference = testRunReference.getWithRevision(exportParams.getRevision());
Expand All @@ -113,9 +121,9 @@ public DocumentData<ITestRun> getTestRun(@NotNull ITrackerProject project, @NotN
}

return DocumentData.builder(DocumentType.TEST_RUN, testRun.getOldApi())
.projectName(project != null ? project.getName() : "")
.projectName(project.getName())
.lastRevision(testRun.getOldApi().getLastRevision())
.baselineName(project != null ? getRevisionBaseline(projectId, testRun.getOldApi(), exportParams.getRevision()) : "")
.baselineName(getRevisionBaseline(projectId, testRun.getOldApi(), exportParams.getRevision()))
.id(testRun.getOldApi().getId())
.title(testRun.getOldApi().getLabel())
.content(documentContent)
Expand All @@ -132,6 +140,11 @@ public DocumentData<IWikiPage> getWikiPage(@Nullable ITrackerProject project, @N
return TransactionalExecutor.executeSafelyInReadOnlyTransaction(transaction -> {

String projectId = project != null ? project.getId() : "";
String locationPath = exportParams.getLocationPath();
if (locationPath == null) {
throw new IllegalArgumentException("Location path is required for export");
}

WikiPageReference wikiPageReference = WikiPageReference.fromPath(createPath(projectId, exportParams.getLocationPath()));
if (exportParams.getRevision() != null) {
wikiPageReference = wikiPageReference.getWithRevision(exportParams.getRevision());
Expand Down Expand Up @@ -162,6 +175,11 @@ public DocumentData<IModule> getLiveDoc(@NotNull ITrackerProject project, @NotNu
public DocumentData<IModule> getLiveDoc(@NotNull ITrackerProject project, @NotNull ExportParams exportParams, boolean withContent) {
return TransactionalExecutor.executeSafelyInReadOnlyTransaction(transaction -> {

String locationPath = exportParams.getLocationPath();
if (locationPath == null) {
throw new IllegalArgumentException("Location path is required for export");
}

DocumentReference documentReference = DocumentReference.fromPath(createPath(project.getId(), exportParams.getLocationPath()));
if (exportParams.getRevision() != null) {
documentReference = documentReference.getWithRevision(exportParams.getRevision());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public class DleToolbarStatusProvider extends ConfigurationStatusProvider {
ILocation location = ScopeUtils.getDefaultLocation().append(".polarion/context.properties");
String content = new SettingsService().read(location, null);

return getConfigurationStatus(DLE_TOOLBAR, content, "scriptInjection.dleEditorHead=<script src=\"/polarion/pdf-exporter/js/starter.js\"></script>.*<script>PdfExporterStarter.injectToolbar();</script>");
return getConfigurationStatus(DLE_TOOLBAR, content, "scriptInjection.dleEditorHead=<script src=\"/polarion/pdf-exporter/js/starter.js\"></script>.*<script>PdfExporterStarter.injectToolbar(.*);</script>");
}
}

0 comments on commit e4ef40d

Please sign in to comment.