private CCapability asCCapability(final String id, final CapabilityStorageItem item) {
   final CCapability capability = new CCapability();
   capability.setId(id);
   capability.setVersion(item.getVersion());
   capability.setTypeId(item.getType());
   capability.setEnabled(item.isEnabled());
   capability.setNotes(item.getNotes());
   if (item.getProperties() != null) {
     for (Map.Entry<String, String> entry : item.getProperties().entrySet()) {
       final CCapabilityProperty property = new CCapabilityProperty();
       property.setKey(entry.getKey());
       property.setValue(entry.getValue());
       capability.addProperty(property);
     }
   }
   return capability;
 }
Ejemplo n.º 2
0
  static CCapability asCCapability(final CapabilityResource resource) {
    assert resource != null : "Resource cannot be null";

    final CCapability capability = new CCapability();

    capability.setId(resource.getId());
    capability.setName(resource.getName());
    capability.setTypeId(resource.getTypeId());

    if (resource.getProperties() != null) {
      for (final CapabilityPropertyResource propery : resource.getProperties()) {
        final CCapabilityProperty capabilityProp = new CCapabilityProperty();
        capabilityProp.setKey(propery.getKey());
        capabilityProp.setValue(propery.getValue());

        capability.addProperty(capabilityProp);
      }
    }

    return capability;
  }