Search in sources :

Example 1 with AttributeAccessDescriptorDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto in project open-smart-grid-platform by OSGP.

the class AssociationLnListTypeMappingTest method testAssociationLnListTypeDtoMappingWithNonEmptyLists.

@Test
public void testAssociationLnListTypeDtoMappingWithNonEmptyLists() {
    // build test data
    final List<AttributeAccessItemDto> listAttributeAccessItemDto = new ArrayList<>();
    final AttributeAccessModeTypeDto accessMode = AttributeAccessModeTypeDto.NO_ACCESS;
    final List<Integer> listInteger = new ArrayList<>();
    final AccessSelectorListDto accessSelectors = new AccessSelectorListDto(listInteger);
    listAttributeAccessItemDto.add(new AttributeAccessItemDto(1, accessMode, accessSelectors));
    final AttributeAccessDescriptorDto attributeAccessDescriptorDto = new AttributeAccessDescriptorDto(listAttributeAccessItemDto);
    final List<MethodAccessItemDto> listMethodAccessItemDto = new ArrayList<>();
    final MethodAccessDescriptorDto methodAccessDescriptorDto = new MethodAccessDescriptorDto(listMethodAccessItemDto);
    final AssociationLnListElementDto associationLnElementDto = new AssociationLnListElementDto(72, 2, new CosemObisCodeDto(new int[] { 1, 1, 1, 1, 1, 1 }), new AccessRightDto(attributeAccessDescriptorDto, methodAccessDescriptorDto));
    final AssociationLnListTypeDto associationLnListTypeDto = new AssociationLnListTypeDtoBuilder().withNonEmptyLists(associationLnElementDto).build();
    // actual mapping
    final AssociationLnListType associationLnListType = this.configurationMapper.map(associationLnListTypeDto, AssociationLnListType.class);
    // check values
    assertThat(associationLnListType).isNotNull();
    this.checkAssociationLnListElementMapping(associationLnListType.getAssociationLnListElement(), associationLnListTypeDto.getAssociationLnListElement());
}
Also used : AccessRightDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto) AttributeAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto) AssociationLnListElementDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto) ArrayList(java.util.ArrayList) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto) AccessSelectorListDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto) AssociationLnListType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType) AssociationLnListTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto) AttributeAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto) MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto) AttributeAccessModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto) Test(org.junit.jupiter.api.Test)

Example 2 with AttributeAccessDescriptorDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method convertAttributeAccessDescriptor.

private AttributeAccessDescriptorDto convertAttributeAccessDescriptor(final List<DataObject> attributeAccessDescriptor) throws ProtocolAdapterException {
    final List<AttributeAccessItemDto> attributeAccessItems = new ArrayList<>();
    for (final DataObject attributeAccessItemRaw : attributeAccessDescriptor) {
        final List<DataObject> attributeAccessItem = attributeAccessItemRaw.getValue();
        final AccessSelectorListDto asl;
        if (attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_SELECTORS_INDEX).isNull()) {
            asl = new AccessSelectorListDto(Collections.emptyList());
        } else {
            final List<DataObject> accessSelectorsObjects = attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_SELECTORS_INDEX).getValue();
            asl = new AccessSelectorListDto(this.convertAccessSelectors(accessSelectorsObjects));
        }
        attributeAccessItems.add(new AttributeAccessItemDto(this.dlmsHelper.readLong(attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ATTRIBUTE_ID_INDEX), "").intValue(), AttributeAccessModeTypeDto.values()[this.dlmsHelper.readLong(attributeAccessItem.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_ACCESS_MODE_INDEX), "").intValue()], asl));
    }
    return new AttributeAccessDescriptorDto(attributeAccessItems);
}
Also used : AccessSelectorListDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto) AttributeAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto) ArrayList(java.util.ArrayList)

Example 3 with AttributeAccessDescriptorDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method convertAccessRights.

private AccessRightDto convertAccessRights(final DataObject dataObject) throws ProtocolAdapterException {
    if (!dataObject.isComplex()) {
        return null;
    }
    final List<DataObject> accessRights = dataObject.getValue();
    final List<DataObject> attributeAccessDescriptorObjects = accessRights.get(ACCESS_RIGHTS_ATTRIBUTE_ACCESS_INDEX).getValue();
    final AttributeAccessDescriptorDto attributeAccessDescriptor = this.convertAttributeAccessDescriptor(attributeAccessDescriptorObjects);
    final List<DataObject> methodAccessDescriptorObjects = accessRights.get(ACCESS_RIGHTS_METHOD_ACCESS_INDEX).getValue();
    final MethodAccessDescriptorDto methodAccessDescriptor = this.convertMethodAccessDescriptor(methodAccessDescriptorObjects);
    return new AccessRightDto(attributeAccessDescriptor, methodAccessDescriptor);
}
Also used : AccessRightDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)

Aggregations

AttributeAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessDescriptorDto)3 ArrayList (java.util.ArrayList)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 AccessRightDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessRightDto)2 AccessSelectorListDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AccessSelectorListDto)2 AttributeAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessItemDto)2 MethodAccessDescriptorDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)2 Test (org.junit.jupiter.api.Test)1 AssociationLnListType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.AssociationLnListType)1 AssociationLnListElementDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListElementDto)1 AssociationLnListTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AssociationLnListTypeDto)1 AttributeAccessModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AttributeAccessModeTypeDto)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1 MethodAccessItemDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto)1