Skip to content

Commit

Permalink
Mapped new 'signed' property for INVENTORY-V1 Bundles
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Feb 15, 2022
1 parent 40dab06 commit afbc070
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 0 deletions.
Expand Up @@ -28,8 +28,10 @@
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -117,6 +119,18 @@ protected void onRender(Element parent, int index) {
column.setWidth(80);
configs.add(column);

column = new ColumnConfig();
column.setId("signed");
column.setHeader("Signed");
column.setWidth(50);
column.setRenderer(new GridCellRenderer<GwtInventoryBundle>() {
@Override
public Object render(GwtInventoryBundle gwtInventoryBundle, String property, ColumnData columnData, int col, int row, ListStore<GwtInventoryBundle> listStore, Grid<GwtInventoryBundle> grid) {
return gwtInventoryBundle.getSigned() != null ? gwtInventoryBundle.getSigned() : "N/A";
}
});
configs.add(column);

ColumnModel columnModel = new ColumnModel(configs);

RpcProxy<ListLoadResult<GwtInventoryBundle>> proxy = new RpcProxy<ListLoadResult<GwtInventoryBundle>>() {
Expand Down
Expand Up @@ -97,6 +97,7 @@ public ListLoadResult<GwtInventoryBundle> findDeviceBundles(String scopeIdString
gwtInventoryBundle.setName(inventoryBundle.getName());
gwtInventoryBundle.setVersion(inventoryBundle.getVersion());
gwtInventoryBundle.setStatus(inventoryBundle.getStatus());
gwtInventoryBundle.setSigned(inventoryBundle.getSigned());

gwtInventoryBundles.add(gwtInventoryBundle);
}
Expand Down Expand Up @@ -183,6 +184,7 @@ public List<GwtInventoryDeploymentPackage> findDeviceDeploymentPackages(String s
inventoryBundle.setName(bundleInfo.getName());
inventoryBundle.setVersion(bundleInfo.getVersion());
inventoryBundle.setStatus(bundleInfo.getStatus());
inventoryBundle.setSigned(bundleInfo.getSigned());

gwtPackageBundles.add(inventoryBundle);
}
Expand Down
Expand Up @@ -50,4 +50,12 @@ public String getStatus() {
return get("status");
}

public void setSigned(Boolean signed) {
set("signed", signed);
}

public Boolean getSigned() {
return get("signed");
}

}
Expand Up @@ -55,11 +55,14 @@ components:
type: string
status:
type: string
signed:
type: boolean
example:
id: 0
name: org.eclipse.osgi
version: 3.16.0.v20200828-0759
status: ACTIVE
signed: false
deviceInventoryBundles:
type: object
properties:
Expand Down
Expand Up @@ -35,6 +35,9 @@ public class KuraInventoryBundle {
@JsonProperty("state")
public String state;

@JsonProperty("signed")
public Boolean signed;

/**
* Gets the identifier.
*
Expand Down Expand Up @@ -114,4 +117,24 @@ public String getState() {
public void setState(String state) {
this.state = state;
}

/**
* Whether the bundle is signed.
*
* @return {@code true} if is signed, {@code false} if not or {@code null} if the information is not known.
* @since 1.6.0
*/
public Boolean getSigned() {
return signed;
}

/**
* Sets whether the bundle is signed.
*
* @param signed {@code true} if is signed, {@code false} if not or {@code null} if the information is not known.
* @since 1.6.0
*/
public void setSigned(Boolean signed) {
this.signed = signed;
}
}
Expand Up @@ -97,4 +97,20 @@ public interface DeviceInventoryBundle {
* @since 1.5.0
*/
void setStatus(String status);

/**
* Whether the bundle is signed.
*
* @return {@code true} if is signed, {@code false} if not or {@code null} if the information is not known.
* @since 1.6.0
*/
Boolean getSigned();

/**
* Sets whether the bundle is signed.
*
* @param signed {@code true} if is signed, {@code false} if not or {@code null} if the information is not known.
* @since 1.6.0
*/
void setSigned(Boolean signed);
}
Expand Up @@ -25,6 +25,7 @@ public class DeviceInventoryBundleImpl implements DeviceInventoryBundle {
private String name;
private String version;
private String status;
private Boolean signed;

/**
* Constructor.
Expand Down Expand Up @@ -73,4 +74,14 @@ public String getStatus() {
public void setStatus(String status) {
this.status = status;
}

@Override
public Boolean getSigned() {
return signed;
}

@Override
public void setSigned(Boolean signed) {
this.signed = signed;
}
}
Expand Up @@ -73,6 +73,7 @@ protected KuraRequestPayload translatePayload(InventoryRequestPayload inventoryR
KuraInventoryBundle kuraInventoryBundle = new KuraInventoryBundle();
kuraInventoryBundle.setName(deviceInventoryBundle.getName());
kuraInventoryBundle.setVersion(deviceInventoryBundle.getVersion());
kuraInventoryBundle.setSigned(deviceInventoryBundle.getSigned());

kuraRequestPayload.setBody(getJsonMapper().writeValueAsString(kuraInventoryBundle).getBytes(CHAR_ENCODING));
}
Expand Down
Expand Up @@ -107,6 +107,7 @@ protected DeviceInventoryBundles translate(KuraInventoryBundles kuraInventoryBun
deviceInventoryBundle.setName(kuraInventoryBundle.getName());
deviceInventoryBundle.setVersion(kuraInventoryBundle.getVersion());
deviceInventoryBundle.setStatus(kuraInventoryBundle.getState());
deviceInventoryBundle.setSigned(kuraInventoryBundle.getSigned());

deviceInventoryBundles.addInventoryBundle(deviceInventoryBundle);
});
Expand Down

0 comments on commit afbc070

Please sign in to comment.