-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1107 Implemented web ui resources for master info provider that retu…
…rns the master configuration. Also implemented tg-ui-action logic that retrieves the master's info and sets the appropriate properties of action
- Loading branch information
1 parent
d8a142c
commit 2dd7f03
Showing
12 changed files
with
426 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
platform-pojo-bl/src/main/java/ua/com/fielden/platform/master/MasterInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package ua.com.fielden.platform.master; | ||
|
||
import ua.com.fielden.platform.entity.AbstractEntity; | ||
import ua.com.fielden.platform.entity.annotation.DescTitle; | ||
import ua.com.fielden.platform.entity.annotation.IsProperty; | ||
import ua.com.fielden.platform.entity.annotation.KeyTitle; | ||
import ua.com.fielden.platform.entity.annotation.KeyType; | ||
import ua.com.fielden.platform.entity.annotation.Observable; | ||
import ua.com.fielden.platform.entity.annotation.Title; | ||
|
||
@KeyType(String.class) | ||
@KeyTitle("Element Name") | ||
@DescTitle("Element URI") | ||
public class MasterInfo extends AbstractEntity<String> { | ||
|
||
@IsProperty | ||
@Title("Width") | ||
private String width; | ||
|
||
@IsProperty | ||
@Title("Hegiht") | ||
private String height; | ||
|
||
@IsProperty | ||
@Title("Width Unit") | ||
private String widthUnit; | ||
|
||
@IsProperty | ||
@Title(value = "Height Unit", desc = "Desc") | ||
private String heightUnit; | ||
|
||
@IsProperty | ||
@Title("Refresh parent centre after save?") | ||
private boolean shouldRefreshParentCentreAfterSave = false; | ||
|
||
@IsProperty | ||
@Title("Require Selection Criteria") | ||
private String requireSelectionCriteria; | ||
|
||
@IsProperty | ||
@Title("Require Selected Entities") | ||
private String requireSelectedEntities; | ||
|
||
@IsProperty | ||
@Title("Require Master Entity") | ||
private String requireMasterEntity; | ||
|
||
@IsProperty | ||
@Title(value = "Entity Type", desc = "Desc") | ||
private String entityType; | ||
|
||
@IsProperty | ||
@Title(value = "Entity Id", desc = "Desc") | ||
private Long entityId; | ||
|
||
@Observable | ||
public MasterInfo setEntityId(final Long entityId) { | ||
this.entityId = entityId; | ||
return this; | ||
} | ||
|
||
public Long getEntityId() { | ||
return entityId; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setEntityType(final String entityType) { | ||
this.entityType = entityType; | ||
return this; | ||
} | ||
|
||
public String getEntityType() { | ||
return entityType; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setRequireMasterEntity(final String requireMasterEntity) { | ||
this.requireMasterEntity = requireMasterEntity; | ||
return this; | ||
} | ||
|
||
public String getRequireMasterEntity() { | ||
return requireMasterEntity; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setRequireSelectedEntities(final String requireSelectedEntities) { | ||
this.requireSelectedEntities = requireSelectedEntities; | ||
return this; | ||
} | ||
|
||
public String getRequireSelectedEntities() { | ||
return requireSelectedEntities; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setRequireSelectionCriteria(final String requireSelectionCriteria) { | ||
this.requireSelectionCriteria = requireSelectionCriteria; | ||
return this; | ||
} | ||
|
||
public String getRequireSelectionCriteria() { | ||
return requireSelectionCriteria; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setShouldRefreshParentCentreAfterSave(final boolean shouldRefreshParentCentreAfterSave) { | ||
this.shouldRefreshParentCentreAfterSave = shouldRefreshParentCentreAfterSave; | ||
return this; | ||
} | ||
|
||
public boolean getShouldRefreshParentCentreAfterSave() { | ||
return shouldRefreshParentCentreAfterSave; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setHeightUnit(final String heightUnit) { | ||
this.heightUnit = heightUnit; | ||
return this; | ||
} | ||
|
||
public String getHeightUnit() { | ||
return heightUnit; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setWidthUnit(final String widthUnit) { | ||
this.widthUnit = widthUnit; | ||
return this; | ||
} | ||
|
||
public String getWidthUnit() { | ||
return widthUnit; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setHeight(final String height) { | ||
this.height = height; | ||
return this; | ||
} | ||
|
||
public String getHeight() { | ||
return height; | ||
} | ||
|
||
@Observable | ||
public MasterInfo setWidth(final String width) { | ||
this.width = width; | ||
return this; | ||
} | ||
|
||
public String getWidth() { | ||
return width; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...n/java/ua/com/fielden/platform/web/factories/webui/MasterInfoProviderResourceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ua.com.fielden.platform.web.factories.webui; | ||
|
||
import org.restlet.Request; | ||
import org.restlet.Response; | ||
import org.restlet.Restlet; | ||
import org.restlet.data.Method; | ||
|
||
import ua.com.fielden.platform.utils.IDates; | ||
import ua.com.fielden.platform.web.app.IWebUiConfig; | ||
import ua.com.fielden.platform.web.interfaces.IDeviceProvider; | ||
import ua.com.fielden.platform.web.resources.RestServerUtil; | ||
import ua.com.fielden.platform.web.resources.webui.MasterInfoProviderResource; | ||
import ua.com.fielden.platform.web.view.master.MasterInfoProvider; | ||
|
||
public class MasterInfoProviderResourceFactory extends Restlet { | ||
|
||
private final MasterInfoProvider masterInfoProvider; | ||
private final IDeviceProvider deviceProvider; | ||
private final IDates dates; | ||
private final RestServerUtil restUtil; | ||
|
||
public MasterInfoProviderResourceFactory(final IWebUiConfig webApp, final IDeviceProvider deviceProvider, final IDates dates, final RestServerUtil restUtil) { | ||
this.masterInfoProvider = new MasterInfoProvider(webApp); | ||
this.deviceProvider = deviceProvider; | ||
this.dates = dates; | ||
this.restUtil = restUtil; | ||
} | ||
|
||
/** | ||
* Invokes on GET request from client. | ||
*/ | ||
@Override | ||
public void handle(final Request request, final Response response) { | ||
super.handle(request, response); | ||
|
||
if (Method.GET.equals(request.getMethod())) { | ||
new MasterInfoProviderResource( | ||
masterInfoProvider, | ||
restUtil, | ||
deviceProvider, | ||
dates, | ||
getContext(), | ||
request, | ||
response // | ||
).handle(); | ||
} | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...src/main/java/ua/com/fielden/platform/web/resources/webui/MasterInfoProviderResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ua.com.fielden.platform.web.resources.webui; | ||
|
||
import static ua.com.fielden.platform.web.utils.WebUiResourceUtils.handleUndesiredExceptions; | ||
|
||
import org.restlet.Context; | ||
import org.restlet.Request; | ||
import org.restlet.Response; | ||
import org.restlet.representation.Representation; | ||
import org.restlet.resource.Get; | ||
|
||
import ua.com.fielden.platform.entity.AbstractEntity; | ||
import ua.com.fielden.platform.utils.IDates; | ||
import ua.com.fielden.platform.web.interfaces.IDeviceProvider; | ||
import ua.com.fielden.platform.web.resources.RestServerUtil; | ||
import ua.com.fielden.platform.web.resources.webui.exceptions.MissingEntityType; | ||
import ua.com.fielden.platform.web.view.master.MasterInfoProvider; | ||
|
||
public class MasterInfoProviderResource extends AbstractWebResource { | ||
|
||
private final MasterInfoProvider masterInfoProvider; | ||
private final RestServerUtil restUtil; | ||
|
||
public MasterInfoProviderResource(final MasterInfoProvider masterInfoProvider, final RestServerUtil restUtil, final IDeviceProvider deviceProvider, final IDates dates, final Context context, final Request request, final Response response) { | ||
super(context, request, response, deviceProvider, dates); | ||
this.masterInfoProvider = masterInfoProvider; | ||
this.restUtil = restUtil; | ||
} | ||
|
||
@Get | ||
@Override | ||
public Representation get() { | ||
return handleUndesiredExceptions(getResponse(), () -> restUtil.singleJsonRepresentation(masterInfoProvider.getMasterInfo(getEntityType(), getEntityId())), restUtil); | ||
} | ||
|
||
private Long getEntityId() { | ||
return Long.valueOf(getRequest().getAttributes().get("entityId").toString()); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private Class<? extends AbstractEntity<?>> getEntityType() { | ||
final String entityType = getRequest().getAttributes().get("entityType").toString(); | ||
try { | ||
return (Class<? extends AbstractEntity<?>>) Class.forName(entityType); | ||
} catch (final ClassNotFoundException e) { | ||
throw new MissingEntityType(String.format("The entity type class is missing for type: %s", entityType), e); | ||
} | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...c/main/java/ua/com/fielden/platform/web/resources/webui/exceptions/MissingEntityType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ua.com.fielden.platform.web.resources.webui.exceptions; | ||
|
||
public class MissingEntityType extends RuntimeException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public MissingEntityType(final String msg) { | ||
super(msg); | ||
} | ||
|
||
public MissingEntityType(final String msg, final Throwable cause) { | ||
super(msg, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.