@Override public String map( PropertyDescriptor propertyDescriptor ) { return propertyDescriptor.qualifiedName().name(); } }, descriptor.state().properties() ).iterator() );
@Override public void exportDataSources() throws MalformedObjectNameException, MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException { for ( ServiceReference<DataSource> dataSource : dataSources ) { String name = dataSource.identity(); Module module = ( Module ) spi.moduleOf( dataSource ); EntityDescriptor descriptor = module.entityDescriptor( DataSourceConfiguration.class.getName() ); List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(); Map<String, AccessibleObject> properties = new LinkedHashMap<String, AccessibleObject>(); for ( PropertyDescriptor persistentProperty : descriptor.state().properties() ) { if ( !persistentProperty.isImmutable() ) { String propertyName = persistentProperty.qualifiedName().name(); String type = persistentProperty.valueType().mainType().getName(); attributes.add( new MBeanAttributeInfo( propertyName, type, propertyName, true, true, type.equals( "java.lang.Boolean" ) ) ); properties.put( propertyName, persistentProperty.accessor() ); } } List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>(); operations.add( new MBeanOperationInfo( "restart", "Restart DataSource", new MBeanParameterInfo[ 0 ], "void", MBeanOperationInfo.ACTION_INFO ) ); MBeanInfo mbeanInfo = new MBeanInfo( DataSourceConfiguration.class.getName(), name, attributes.toArray( new MBeanAttributeInfo[ attributes.size() ] ), null, operations.toArray( new MBeanOperationInfo[ operations.size() ] ), null ); Object mbean = new ConfigurableDataSource( dataSourceService, mbeanInfo, name, properties ); ObjectName configurableDataSourceName = new ObjectName( "Zest:application=" + application.name() + ",class=Datasource,name=" + name ); server.registerMBean( mbean, configurableDataSourceName ); configurationNames.add( configurableDataSourceName ); } }
@Override public Object map( PropertyDescriptor propertyDescriptor ) { Parameter param = queryAsForm.getFirst( propertyDescriptor.qualifiedName().name() ); if( param == null ) { param = entityAsForm.getFirst( propertyDescriptor.qualifiedName().name() ); } if( param != null ) { String value = param.getValue(); if( value != null ) { try { return valueDeserializer.deserialize( propertyDescriptor.valueType(), value ); } catch( ValueSerializationException e ) { throw new IllegalArgumentException( "Query parameter has invalid JSON format", e ); } } } return null; } },
private void serializeProperties( final EntityState entityState, final Graph graph, final Resource subject, final EntityDescriptor entityType, final boolean includeNonQueryable ) { // Properties for( PropertyDescriptor persistentProperty : entityType.state().properties() ) { Object property = entityState.propertyValueOf( persistentProperty.qualifiedName() ); if( property != null ) { serializeProperty( persistentProperty, property, subject, graph, includeNonQueryable ); } } }
@Override public Object map( PropertyDescriptor ePropDesc ) { String propName = ePropDesc.qualifiedName().name(); try { PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName ); return vState.propertyFor( vPropDesc.accessor() ).get(); } catch( IllegalArgumentException propNotFoundOnValue ) { // Property not found on Value return null; } } };
if( o == null ) json.put( propertyDescriptor.qualifiedName().name(), JSONObject.NULL ); json.put( propertyDescriptor.qualifiedName().name(), o.toString() );
private void serializePropertyTypes( final EntityDescriptor entityDescriptor, final Graph graph, final URI entityTypeUri ) { ValueFactory values = graph.getValueFactory(); // Properties for( PropertyDescriptor persistentProperty : entityDescriptor.state().properties() ) { URI propertyURI = values.createURI( persistentProperty.qualifiedName().toURI() ); graph.add( propertyURI, Rdfs.DOMAIN, entityTypeUri ); graph.add( propertyURI, Rdfs.TYPE, Rdfs.PROPERTY ); // TODO Support more types URI type = dataTypes.get( persistentProperty.valueType().mainType().getName() ); if( type != null ) { graph.add( propertyURI, Rdfs.RANGE, type ); } } } }
private void serializeProperty( PropertyDescriptor persistentProperty, Object property, Resource subject, Graph graph, boolean includeNonQueryable ) { if( !( includeNonQueryable || persistentProperty.queryable() ) ) { return; // Skip non-queryable } ValueType valueType = persistentProperty.valueType(); final ValueFactory valueFactory = graph.getValueFactory(); String propertyURI = persistentProperty.qualifiedName().toURI(); URI predicate = valueFactory.createURI( propertyURI ); String baseURI = propertyURI.substring( 0, propertyURI.indexOf( '#' ) ) + "/"; if( valueType instanceof ValueCompositeType ) { serializeValueComposite( subject, predicate, (ValueComposite) property, valueType, graph, baseURI, includeNonQueryable ); } else { String stringProperty = valueSerializer.serialize( new Options().withoutTypeInfo(), property ); final Literal object = valueFactory.createLiteral( stringProperty ); graph.add( subject, predicate, object ); } }
String value = getValue( propertyDescriptor.qualifiedName().name(), queryAsForm, entityAsForm ); form.add( propertyDescriptor.qualifiedName().name(), value );
if( type instanceof ValueCompositeType ) URI pred = valueFactory.createURI( baseUri, persistentProperty.qualifiedName().name() ); serializeValueComposite( collection, pred, (ValueComposite) propertyValue, type, graph, baseUri + persistentProperty.qualifiedName().name() + "/", includeNonQueryable );
String associationName = descriptor.qualifiedName().name(); if( STRING_TYPE_SPEC.satisfiedBy( descriptor.valueType() ) )
String propertyName = descriptor.qualifiedName().name(); try
if( IDENTITY_STATE_NAME.equals( ePropDesc.qualifiedName() ) ) PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByQualifiedName( ePropDesc.qualifiedName() ); eState.propertyFor( ePropDesc.accessor() ).set( vState.propertyFor( vPropDesc.accessor() ).get() );
if( IDENTITY_STATE_NAME.equals( ePropDesc.qualifiedName() ) ) PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( ePropDesc.qualifiedName().name() ); eState.propertyFor( ePropDesc.accessor() ).set( vState.propertyFor( vPropDesc.accessor() ).get() );