Since version 1.1.2, columns in input and output products of work-plans can be injected from other plugins.

Work-plans plugin injects 2 basic columns by itself so consider that as a good documentation.

In order to add a column

you should add a class for a column loader (preferably: com.qcadoo.mes....yourPlugin.workPlansColumnExtension.YourPluginColumnLoader.java, to hold convention), which looks a little bit like this:

@Component
public class PluginNameColumnLoader {

    @Autowired
    private WorkPlansColumnLoaderService workPlansColumnLoaderService;

    private static final Logger LOG = LoggerFactory.getLogger(PluginNameColumnLoader.class);

    public void addPluginNameColumnsForProducts() {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Columns for input and output products table will be populated ...");
        }
 
        workPlansColumnLoaderService.fillColumnsForProducts(PluginNameConstants.PLUGIN_IDENTIFIER);
    }
 

    public void deletePluginNameColumnsForProducts() {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Columns for input and output products table will be unpopulated ...");
        }

        workPlansColumnLoaderService.clearColumnsForProducts(PluginNameConstants.PLUGIN_IDENTIFIER);
    }
}

then you have to add a column definition xml, which this time has to be in the following location:

/plugin-name/src/main/resources/pluginName/model/data/columnForProducts.xml

and it looks like this:

 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 copyright comment 
 -->
  
 <column>
 <row IDENTIFIER="" NAME="" DESCRIPTION="" COLUMNFILLER="" TYPE="" ACTIVE="" />
 </column>

The last thing you have to do is to add invocations of the columnLoader methods in the multiTenantEnable and multiTenantDisable methods of the class that is called by this thing:

 <custom:custom class="SomeClass" />

in your qcadoo-plugin.xml.

And the SomeClass should have something like this in it (it can have other things, but those are relevant to column addition):

 @Component
 public class SomeClass extends Module {
 
     @Autowired
     private PluginNameColumnLoader pluginNameColumnLoader;
 
     @Override
     @Transactional
     public void multiTenantEnable() {
         pluginNameColumnLoader.addPluginNameColumnsForProducts();
     }
 

     @Override
     @Transactional
     public void multiTenantDisable() {
         agfoColumnLoader.deletePluginNameColumnsForProducts();
     }
 }

 

In order to fill the column

This one is simple, you create a class, preferably in the workPlansColumnExtension package where columnLoader class lies, named: YourPluginColumnFiller.java but that's not mandatory. That class has to implement the ColumnFiller interface like this:

public class PluginNameColumnFiller implements ColumnFiller {

    @Override
    public Map<Entity, Map<String, String>> getValues(List<Entity> orders) {
        // returning the map of column values 
    }
}  

that method takes a list of orders in the argument, and has to return map of the following structure:

That's all there is to it.