Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

KM report - add commands

Hi,

when coding a custom report, there is the possibility to add 'commands', more particular in the code in :

/**

  • Gets a single command by its name.

*/

public IReportCommand getCommand(IName name) throws ResourceException {

return (IReportCommand)KenGDeleteReport.m_commandMap.get(name);

}

/**

  • Gets a list of command which can be processed.

*/

public List getCommands() throws ResourceException {

return KenGDeleteReport.m_commandList;

}

Can someone give an example of some implemented code?

Thanks for the help :o))

replied

Hi Kevin,

I used this code to make commands work in a report:


      static class CreateCommand implements IReportCommand {
  	
  	    public static final IName NAME = new Name(IWcmConst.SAP_WCM_NAMESPACE + IWcmConst.NAMESPACE_SEPARATOR + "reporting", "create");
  	    public static final CreateCommand INSTANCE = new CreateCommand();
  	
  	    public IName getName() {
  	      return NAME;
  	    }
  	
  	    public String getDisplayName(Locale locale) {
  	      return RepositoryPropagationReport.getBundleText(locale, "cmd.disp.create", "Create");
  	    }
  	
  	    public String getDescription(Locale locale) {
  	      return RepositoryPropagationReport.getBundleText(locale, "cmd.desc.create", "Create structure of test data.");
  	    }
  	
  	    public IReportInputMeta getMeta() {
  	      return ReportInputMeta.getInstance(PARAM_NAMES_CREATE, PARAM_DEFINITIONS_CREATE, PARAM_DEFAULTS_CREATE);
  	    }
  	
  	  }

      static class ClearCommand implements IReportCommand {
			
	    public static final IName NAME = new Name(IWcmConst.SAP_WCM_NAMESPACE + IWcmConst.NAMESPACE_SEPARATOR + "reporting", "clear");
	    public static final ClearCommand INSTANCE = new ClearCommand();
	
	    public IName getName() {
	      return NAME;
	    }
	
	    public String getDisplayName(Locale locale) {
	      return RepositoryPropagationReport.getBundleText(locale, "cmd.disp.clear", "Clear");
	    }
	
	    public String getDescription(Locale locale) {
	      return RepositoryPropagationReport.getBundleText(locale, "cmd.desc.clear", "Clear content of root RID collection");
	    }
	
	    public IReportInputMeta getMeta() {
	      return ReportInputMeta.EMPTY_INSTANCE;
	    }
	
	  }


[...]

  static {
    Map tmap = new HashMap();
    tmap.put(ClearCommand.NAME, ClearCommand.INSTANCE);
    tmap.put(CreateCommand.NAME, CreateCommand.INSTANCE);
    COMMANDMAP = Collections.unmodifiableMap(tmap);
    List tlist = new ArrayList();
    tlist.add(ClearCommand.INSTANCE);
    tlist.add(CreateCommand.INSTANCE);
    COMMANDLIST = Collections.unmodifiableList(tlist);
  }

[...]

  public IReportCommand getCommand(IName name) throws ResourceException {
    return (IReportCommand) COMMANDMAP.get(name);
  }
  
  public List getCommands() throws ResourceException {
    return COMMANDLIST;
  }

[...]

  public IReportResult execute(IReportInput input, IResourceContext context, IResultReceiver receiver) 
  		throws ResourceException, InterruptedException {

    // get selected commands
    IReportCommandInput createInput = null;
    IReportCommandInput clearInput = null;
    for (Iterator it = input.getCommandInputs().iterator(); it.hasNext(); ) {
      IReportCommandInput i = (IReportCommandInput)it.next();
      if (i.getCommandName().equals(CreateCommand.NAME)) {
        createInput = i;
      }
      if (i.getCommandName().equals(ClearCommand.NAME)) {
        clearInput = i;
      }
    }

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question