Package org.joggito.core.descriptors

Examples of org.joggito.core.descriptors.ResourceDescriptor


    assertEquals(5, phonesProp.getMaxCardinality());
  }

  @Test
  public void creatingResourceDescriptors() throws Exception {
    ResourceDescriptor rd = factory.createResource(Person.class);

    assertEquals(Person.getPropertyCount(), rd.getProperties().size());
    assertNotNull(rd.getProperty(FOAF.firstName.getURI()));
    assertNotNull(rd.getProperty(FOAF.family_name.getURI()));
    assertNotNull(rd.getProperty(FOAF.mbox_sha1sum.getURI()));
    assertNotNull(rd.getProperty(FOAF.birthday.getURI()));
    assertNotNull(rd.getProperty(FOAF.phone.getURI()));
  }
View Full Code Here


    // May be the bean is already registered.
    T bean = session.getRegisteredBean(rscID);
    if (bean == null) {
      // Create the bean object.
      final ResourceDescriptor desc = forceGetDescriptor(beanType);
      bean = ReflectUtils.createInstance(beanType, new Object[0]);
      ((ResourceBean) bean).setID(rscID);
     
      // Register the bean object.
      session.registerBean(bean);

      // Set property values.
      Collection<PropertyDescriptor> properties = desc.getProperties();
      for (PropertyDescriptor propDesc : properties) {
        this.setPropertyValue(rsc, bean, propDesc);
      }

    }
View Full Code Here

  public <T> T createBean(Resource rsc) {
    final MetaContext metaContext = session.getMetaContext();

    // find the corresponding descriptor.
    Resource rdfType = rsc.getProperty(RDF.type).getResource();
    ResourceDescriptor descriptor = metaContext.getDescriptor(rdfType);
    if (descriptor == null) {
      throw new DescriptorNotFoundException(rdfType);
    }

    return this.<T> createBean((Class<T>) descriptor.getBeanClass(), rsc);
  }
View Full Code Here

   * Returns the resource descriptor for the given bean type if exists,
   * otherwise throws a {@link DescriptorNotFoundException}.
   */
  private <T> ResourceDescriptor forceGetDescriptor(Class<T> beanType) {
    MetaContext metaContext = session.getMetaContext();
    final ResourceDescriptor desc = metaContext.getDescriptor(beanType);

    if (desc == null) { // no descriptor for bean type.
      throw new DescriptorNotFoundException(beanType);
    }
    return desc;
View Full Code Here

TOP

Related Classes of org.joggito.core.descriptors.ResourceDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.