Skip to content

Commit

Permalink
backend: change view attributes endpoint location
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 23, 2017
1 parent 9348632 commit 48dac8c
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ViewRowAttributesRestController
private static final String PARAM_ViewId = "viewId";
private static final String PARAM_RowId = "rowId";

/* package */static final String ENDPOINT = ViewRestController.ENDPOINT + "/{" + PARAM_ViewId + "}/{" + PARAM_RowId + "}";
/* package */static final String ENDPOINT = ViewRestController.ENDPOINT + "/{" + PARAM_ViewId + "}/{" + PARAM_RowId + "}/attributes";

@Autowired
private UserSession userSession;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package de.metas.ui.web.view;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import de.metas.ui.web.view.json.JSONViewRowAttributes;
import de.metas.ui.web.view.json.JSONViewRowAttributesLayout;
import de.metas.ui.web.window.datatypes.json.JSONDocument;
import de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent;
import de.metas.ui.web.window.datatypes.json.JSONLookupValuesList;

/*
* #%L
* metasfresh-webui-api
* %%
* Copyright (C) 2017 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

/**
* @deprecated To be deleted after https://github.com/metasfresh/metasfresh-webui-frontend/issues/783 is implemented.
*/
@RestController
@RequestMapping(value = ViewRowAttributesRestController_OLD.ENDPOINT)
@Deprecated
public class ViewRowAttributesRestController_OLD
{
private static final String PARAM_WindowId = ViewRestController.PARAM_WindowId;
private static final String PARAM_ViewId = "viewId";
private static final String PARAM_RowId = "rowId";
/* package */static final String ENDPOINT = ViewRestController.ENDPOINT + "/{" + PARAM_ViewId + "}/{" + PARAM_RowId + "}";

@Autowired
private ViewRowAttributesRestController delegate;

@GetMapping("/layout")
public JSONViewRowAttributesLayout getAttributesLayout(
@PathVariable(PARAM_WindowId) final String windowIdStr //
, @PathVariable(PARAM_ViewId) final String viewIdStr //
, @PathVariable(PARAM_RowId) final String rowIdStr //
)
{
return delegate.getAttributesLayout(windowIdStr, viewIdStr, rowIdStr);
}

@GetMapping
public JSONViewRowAttributes getData(
@PathVariable(PARAM_WindowId) final String windowIdStr //
, @PathVariable(PARAM_ViewId) final String viewIdStr //
, @PathVariable(PARAM_RowId) final String rowIdStr //
)
{
return delegate.getData(windowIdStr, viewIdStr, rowIdStr);
}

@PatchMapping
public List<JSONDocument> processChanges(
@PathVariable(PARAM_WindowId) final String windowIdStr //
, @PathVariable(PARAM_ViewId) final String viewIdStr //
, @PathVariable(PARAM_RowId) final String rowIdStr //
, @RequestBody final List<JSONDocumentChangedEvent> events //
)
{
return delegate.processChanges(windowIdStr, viewIdStr, rowIdStr, events);
}

@GetMapping("/attribute/{attributeName}/typeahead")
public JSONLookupValuesList getAttributeTypeahead(
@PathVariable(PARAM_WindowId) final String windowIdStr //
, @PathVariable(PARAM_ViewId) final String viewIdStr//
, @PathVariable(PARAM_RowId) final String rowIdStr //
, @PathVariable("attributeName") final String attributeName //
, @RequestParam(name = "query", required = true) final String query //
)
{
return delegate.getAttributeTypeahead(windowIdStr, viewIdStr, rowIdStr, attributeName, query);
}

@GetMapping("/attribute/{attributeName}/dropdown")
public JSONLookupValuesList getAttributeDropdown(
@PathVariable(PARAM_WindowId) final String windowIdStr //
, @PathVariable(PARAM_ViewId) final String viewIdStr //
, @PathVariable(PARAM_RowId) final String rowIdStr //
, @PathVariable("attributeName") final String attributeName //
)
{
return delegate.getAttributeDropdown(windowIdStr, viewIdStr, rowIdStr, attributeName);
}
}

0 comments on commit 48dac8c

Please sign in to comment.