Skip to content

Commit

Permalink
#150 DocumentViewRestController - getById, getByIds
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Feb 19, 2017
1 parent 559eb42 commit 908378a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.metas.ui.web.view;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -22,6 +23,7 @@
import de.metas.ui.web.view.json.JSONDocumentViewLayout;
import de.metas.ui.web.view.json.JSONDocumentViewResult;
import de.metas.ui.web.window.datatypes.DocumentId;
import de.metas.ui.web.window.datatypes.json.JSONDocument;
import de.metas.ui.web.window.datatypes.json.JSONLookupValuesList;
import de.metas.ui.web.window.datatypes.json.JSONOptions;
import de.metas.ui.web.window.datatypes.json.JSONViewDataType;
Expand Down Expand Up @@ -156,6 +158,37 @@ public JSONDocumentViewResult getViewData(
return JSONDocumentViewResult.of(result);
}

@GetMapping("/{viewId}/byIds")
public List<JSONDocument> getByIds(
@PathVariable(PARAM_WindowId) final int adWindowId //
, @PathVariable("viewId") final String viewId//
, @PathVariable("ids") @ApiParam("comma separated IDs") final String idsListStr)
{
userSession.assertLoggedIn();

final Set<DocumentId> documentIds = DocumentId.ofCommaSeparatedString(idsListStr);

final List<IDocumentView> result = documentViewsRepo.getView(viewId)
.assertWindowIdMatches(adWindowId)
.getByIds(documentIds);
return JSONDocument.ofDocumentViewList(result);
}

@GetMapping("/{viewId}/{id}")
public JSONDocument getById(
@PathVariable(PARAM_WindowId) final int adWindowId //
, @PathVariable("viewId") final String viewId//
, @PathVariable("id") final String idStr)
{
final DocumentId documentId = DocumentId.of(idStr);

final IDocumentView record = documentViewsRepo.getView(viewId)
.assertWindowIdMatches(adWindowId)
.getById(documentId);

return JSONDocument.ofDocumentView(record);
}

@GetMapping("/{viewId}/filter/{filterId}/attribute/{parameterName}/typeahead")
public JSONLookupValuesList getFilterParameterTypeahead(
@PathVariable(PARAM_WindowId) final int adWindowId //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static List<JSONDocument> ofDocumentViewList(final List<IDocumentView> do
.collect(Collectors.toList());
}

private static JSONDocument ofDocumentView(final IDocumentView documentView)
public static JSONDocument ofDocumentView(final IDocumentView documentView)
{
final JSONDocument jsonDocument = new JSONDocument(documentView.getDocumentPath());

Expand Down

0 comments on commit 908378a

Please sign in to comment.