public Feature toDto ( InternalFeature feature , int featureIncludes ) throws GeomajasException { if ( feature == null ) { return null ; } Feature dto = new Feature ( feature . getId ( ) ) ; if ( ( featureIncludes & VectorLayerService . FEATURE_INCLUDE_ATTRIBUTES ) != 0 && null != feature . getAttributes ( ) ) { // need to assure lazy attributes are converted to non-lazy attributes Map < String , Attribute > attributes = new HashMap < String , Attribute > ( ) ; for ( Map . Entry < String , Attribute > entry : feature . getAttributes ( ) . entrySet ( ) ) { Attribute value = entry . getValue ( ) ; if ( value instanceof LazyAttribute ) { value = ( ( LazyAttribute ) value ) . instantiate ( ) ; } attributes . put ( entry . getKey ( ) , value ) ; } dto . setAttributes ( attributes ) ; } if ( ( featureIncludes & VectorLayerService . FEATURE_INCLUDE_LABEL ) != 0 ) { dto . setLabel ( feature . getLabel ( ) ) ; } if ( ( featureIncludes & VectorLayerService . FEATURE_INCLUDE_GEOMETRY ) != 0 ) { dto . setGeometry ( toDto ( feature . getGeometry ( ) ) ) ; } if ( ( featureIncludes & VectorLayerService . FEATURE_INCLUDE_STYLE ) != 0 && null != feature . getStyleInfo ( ) ) { dto . setStyleId ( feature . getStyleInfo ( ) . getStyleId ( ) ) ; } InternalFeatureImpl vFeature = ( InternalFeatureImpl ) feature ; dto . setClipped ( vFeature . isClipped ( ) ) ; dto . setUpdatable ( feature . isEditable ( ) ) ; dto . setDeletable ( feature . isDeletable ( ) ) ; return dto ; }
Convert the server side feature to a DTO feature that can be sent to the client .