Package pt.webdetails.cdf.dd.model.core.writer

Examples of pt.webdetails.cdf.dd.model.core.writer.IThingWriterFactory


      throws ThingWriteException
  {
    MetaModel model = (MetaModel)t;
    StringBuilder out = (StringBuilder)output;

    IThingWriterFactory factory = context.getFactory();
    assert factory != null;

    // GLOBAL PROPERTIES
    for(PropertyType prop : model.getPropertyTypes())
    {
      IThingWriter propWriter;
      try
      {
        propWriter = factory.getWriter(prop);
        assert propWriter != null;
      }
      catch(UnsupportedThingException ex)
      {
        ThingWriteException ex2 = new ThingWriteException(ex);
        if(context.getBreakOnError()) { throw ex2; }
        _logger.error(ex2);
        continue;
      }

      propWriter.write(out, context, prop);
    }

    // COMPONENTS
    // Components output their own properties
    for(ComponentType comp : model.getComponentTypes())
    {
      IThingWriter compWriter;
      try
      {
        compWriter = factory.getWriter(comp);
        assert compWriter != null;
      }
      catch(UnsupportedThingException ex)
      {
        ThingWriteException ex2 = new ThingWriteException(ex);
View Full Code Here


    // OwnProperties
    if(comp.getPropertyUsageCount() > 0)
    {
      Element custPropsElem = null;

      IThingWriterFactory factory = context.getFactory();
      for(PropertyTypeUsage propUsage : comp.getPropertyUsages())
      {
        if(propUsage.isOwned())
        {
          if(custPropsElem == null)
          {
            if(implElem == null)
            {
              implElem = contentsElem.addElement("Implementation");
            }
           
            custPropsElem = implElem.addElement("CustomProperties");
          }

          PropertyType prop = propUsage.getProperty();
          IThingWriter writer;
          try
          {
            writer = factory.getWriter(prop);
          }
          catch (UnsupportedThingException ex)
          {
            throw new ThingWriteException(ex);
          }
View Full Code Here

   
    // --------------
    // OWN PROPERTIES
    if(comp.getPropertyUsageCount() > 0)
    {
      IThingWriterFactory factory = context.getFactory();
      for(PropertyTypeUsage propUsage : comp.getPropertyUsages())
      {
        if(propUsage.isOwned())
        {
          PropertyType prop = propUsage.getProperty();
          IThingWriter writer;
          try
          {
            writer = factory.getWriter(prop);
          }
          catch (UnsupportedThingException ex)
          {
            throw new ThingWriteException(ex);
          }
View Full Code Here

    WidgetComponentType widget = createWidgetComponentType( wcdf );
    if ( widget == null ) {
      return null;
    }

    IThingWriterFactory factory = new XmlThingWriterFactory();
    IThingWriteContext context = new DefaultThingWriteContext( factory, true );

    IThingWriter writer;
    try {
      writer = factory.getWriter( widget );
    } catch ( UnsupportedThingException ex ) {
      logger.error( "No writer to write widget component type to XML", ex );
      return null;
    }
View Full Code Here

      }
    }
  }

  private String writeJsDefinition( MetaModel model ) {
    IThingWriterFactory factory = new CdeRunJsThingWriterFactory();
    IThingWriter writer;

    try {
      writer = factory.getWriter( model );
    } catch ( UnsupportedThingException ex ) {
      logger.error( "Error while obtaining the model writer from the factory.", ex );
      return null;
    }
View Full Code Here

 
  public void write(IRWAccess access, CggRunJsDashboardWriteContext context, Dashboard dash) throws ThingWriteException
  {
    assert context.getDashboard() == dash;
   
    IThingWriterFactory factory = context.getFactory();
    Iterable<Component> comps = dash.getRegulars();
    for(Component comp : comps)
    {
      if(StringUtils.isNotEmpty(comp.getName()) &&
         (comp instanceof GenericComponent) &&
         !(comp instanceof WidgetComponent))
      {
        GenericComponent genComp = (GenericComponent)comp;
        if(genComp.getMeta().tryGetAttributeValue("cdwSupport", "false").equalsIgnoreCase("true") &&
           genComp.tryGetAttributeValue("cdwRender", "false").equalsIgnoreCase("true"))
        {
          IThingWriter writer;
          try
          {
            writer = factory.getWriter(genComp);
          }
          catch (UnsupportedThingException ex)
          {
            throw new ThingWriteException(ex);
          }
View Full Code Here

    }

    // ---------------
    // TODO: HACK: Delegate writing the component definition to the corresponding CdfRunJs writer
    // Should this be done differently?
    IThingWriterFactory writerFactory = new CdfRunJsThingWriterFactory();
    IThingWriter compWriter;
    try
    {
      compWriter = writerFactory.getWriter(comp);
    }
    catch(UnsupportedThingException ex)
    {
      throw new ThingWriteException("Error while obtaining a writer for rendering the generic component.", ex);
    }
View Full Code Here

    String dataSourceName = comp.tryGetPropertyValue("dataSource", null);
    if(StringUtils.isNotEmpty(dataSourceName))
    {
      DataSourceComponent dsComp = dash.getDataSource(dataSourceName);

      IThingWriterFactory factory = context.getFactory();
      IThingWriter dsWriter;
      try
      {
        dsWriter = factory.getWriter(dsComp);
      }
      catch (UnsupportedThingException ex)
      {
        throw new ThingWriteException(ex);
      }
View Full Code Here

    }
   
    CdfRunJsDashboardWriteContext childContext = context.withIndent(indent);
    childContext.setIsFirstInList(true);
   
    IThingWriterFactory factory = context.getFactory();
    for(PropertyTypeUsage propUsage : compType.getPropertiesByDefinition(definitionName))
    {
      String propName = propUsage.getName();
      // The 'name' property is handled specially
      if(!(isDefaultDefinition && "name".equalsIgnoreCase(propName)))
      {
        PropertyBinding propBind = comp.tryGetPropertyBindingByName(propName);
        if(propBind != null)
        {
          IThingWriter writer;
          try
          {
            writer = factory.getWriter(propBind);
          }
          catch(UnsupportedThingException ex)
          {
            throw new ThingWriteException(ex);
          }
         
          // TODO: empty properties are not output
          // and the NEWLINE is already output...
          if(!isDefaultDefinition && childContext.isFirstInList())
          {
            out.append(NEWLINE);
          }
         
          writer.write(out, childContext, propBind);
        }
      }
    }
   
    if(comp.getExtensionPropertyBindingCount() > 0)
    {
      // HACK: CCC V1 properties have to go into the "chartDefinition" definition...
      boolean isCCC = compType.getName().startsWith("ccc");
      if(isCCC ? !isDefaultDefinition : isDefaultDefinition)
      {
        Iterable<ExtensionPropertyBinding> propBinds = comp.getExtensionPropertyBindings();
        for(ExtensionPropertyBinding propBind : propBinds)
        {
          IThingWriter writer;
          try
          {
            writer = factory.getWriter(propBind);
          }
          catch(UnsupportedThingException ex)
          {
            throw new ThingWriteException(ex);
          }
View Full Code Here

TOP

Related Classes of pt.webdetails.cdf.dd.model.core.writer.IThingWriterFactory

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.