/modules/apps/dynamic-data-mapping/dynamic-data-mapping-data-provider-impl/src/main/java/com/liferay/dynamic/data/mapping/data/provider/internal/rest/DDMRESTDataProviderSettings.java

https://github.com/danielreuther/liferay-portal · Java · 158 lines · 128 code · 14 blank · 16 comment · 0 complexity · 461ef9d31d1d47c24d5762602225394d MD5 · raw file

  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.dynamic.data.mapping.data.provider.internal.rest;
  15. import com.liferay.dynamic.data.mapping.annotations.DDMForm;
  16. import com.liferay.dynamic.data.mapping.annotations.DDMFormField;
  17. import com.liferay.dynamic.data.mapping.annotations.DDMFormLayout;
  18. import com.liferay.dynamic.data.mapping.annotations.DDMFormLayoutColumn;
  19. import com.liferay.dynamic.data.mapping.annotations.DDMFormLayoutPage;
  20. import com.liferay.dynamic.data.mapping.annotations.DDMFormLayoutRow;
  21. import com.liferay.dynamic.data.mapping.annotations.DDMFormRule;
  22. import com.liferay.dynamic.data.mapping.data.provider.DDMDataProviderParameterSettings;
  23. /**
  24. * @author Marcellus Tavares
  25. */
  26. @DDMForm(
  27. rules = {
  28. @DDMFormRule(
  29. actions = {
  30. "setVisible('filterParameterName', true)",
  31. "setRequired('filterParameterName', true)"
  32. },
  33. condition = "equals(getValue('filterable'), true)"
  34. ),
  35. @DDMFormRule(
  36. actions = {
  37. "setVisible('pagination', false)",
  38. "setVisible('paginationStartParameterName', false)",
  39. "setVisible('paginationEndParameterName', false)",
  40. "setRequired('paginationStartParameterName', equals(getValue('pagination'), true))",
  41. "setRequired('paginationEndParameterName', equals(getValue('pagination'), true))"
  42. },
  43. condition = "TRUE"
  44. )
  45. }
  46. )
  47. @DDMFormLayout(
  48. {
  49. @DDMFormLayoutPage(
  50. {
  51. @DDMFormLayoutRow(
  52. {
  53. @DDMFormLayoutColumn(
  54. size = 12,
  55. value = {
  56. "url", "username", "password", "filterable",
  57. "filterParameterName", "cacheable",
  58. "pagination", "paginationStartParameterName",
  59. "paginationEndParameterName", "timeout",
  60. "inputParameters", "outputParameters"
  61. }
  62. )
  63. }
  64. )
  65. }
  66. )
  67. }
  68. )
  69. public interface DDMRESTDataProviderSettings
  70. extends DDMDataProviderParameterSettings {
  71. @DDMFormField(
  72. label = "%cache-data-on-the-first-request",
  73. properties = "showAsSwitcher=true"
  74. )
  75. public boolean cacheable();
  76. @DDMFormField(
  77. label = "%support-filtering-by-keyword",
  78. properties = "showAsSwitcher=true"
  79. )
  80. public boolean filterable();
  81. @DDMFormField(
  82. label = "%filter-parameter-name",
  83. properties = {
  84. "placeholder=%enter-a-name-that-matches-one-of-the-rest-providers-parameters",
  85. "tooltip=%the-parameter-whose-value-will-be-used-as-a-filter-by-the-rest-provider"
  86. }
  87. )
  88. public String filterParameterName();
  89. @DDMFormField(
  90. label = "%support-pagination", predefinedValue = "false",
  91. properties = "showAsSwitcher=true"
  92. )
  93. public boolean pagination();
  94. @DDMFormField(
  95. label = "%end-parameter-name", predefinedValue = "end",
  96. properties = {
  97. "placeholder=%enter-a-name-that-matches-one-of-the-rest-providers-parameters",
  98. "tooltip=%the-parameter-whose-value-will-be-used-as-an-end-by-the-rest-provider"
  99. }
  100. )
  101. public String paginationEndParameterName();
  102. @DDMFormField(
  103. label = "%start-parameter-name", predefinedValue = "start",
  104. properties = {
  105. "placeholder=%enter-a-name-that-matches-one-of-the-rest-providers-parameters",
  106. "tooltip=%the-parameter-whose-value-will-be-used-as-a-start-by-the-rest-provider"
  107. }
  108. )
  109. public String paginationStartParameterName();
  110. @DDMFormField(
  111. label = "%password",
  112. properties = {
  113. "placeholder=%enter-a-password",
  114. "tooltip=%provide-the-password-for-authenticating-to-the-rest-provider"
  115. },
  116. type = "password"
  117. )
  118. public String password();
  119. @DDMFormField(
  120. dataType = "integer", label = "%timeout", predefinedValue = "1000",
  121. properties = {
  122. "placeholder=%enter-time-in-milliseconds",
  123. "tooltip=%data-provider-timeout-message"
  124. },
  125. required = true, type = "numeric",
  126. validationErrorMessage = "%please-enter-an-integer-between-1000-and-30000-milliseconds",
  127. validationExpression = "(timeout >= 1000) && (timeout <= 30000)"
  128. )
  129. public String timeout();
  130. @DDMFormField(
  131. label = "%url", properties = "placeholder=%enter-the-rest-service-url",
  132. required = true, validationErrorMessage = "%please-enter-a-valid-url",
  133. validationExpression = "isURL(url)"
  134. )
  135. public String url();
  136. @DDMFormField(
  137. label = "%user-name",
  138. properties = {
  139. "placeholder=%enter-a-user-name",
  140. "tooltip=%provide-the-user-name-for-authenticating-to-the-rest-provider"
  141. }
  142. )
  143. public String username();
  144. }