Item14089: Adding a mode=application to CopyContrib

pencil
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release:
Applies To: Extension
Component: CopyContrib
Branches: master
Reported By: BramVanOosterhout
Waiting For:
Last Change By: MichaelDaum

Proposal (10 June 2016)

The application mode is similar to the topics mode. The following parameters will be honoured:
Name Description Default
source A list of topics to be copied %BASEWEB%.%BASETOPIC%
destination The destination web where the topics are to be copied  
template A template web to be used in case the destination web does not exist yet and needs to be created on the base of a template _default

The source parameter will take a comma separated list of the form:
source_topic_name => target_topic_name [copy_type]. White space will be ignored.

The significance of the parts is:
source_topic_name The topic to be copied. The name can be of the form web.topic. Web defaults to the BASEWEB. Mandatory
target_topic_name The topic name to be created in the destination web. Defaults to the topic in the source_topic_name Optional
[copy_type] The copy_type can be topic or stub. The default is topic. Optional

For example:
mode=application;source=BookLayout;destination=Book;template=_default
will copy %BASEWEB%.BookLayout to Book.BookLayout. The Book web is created if it does not exist.

mode=application;source=ApplicationWebPreferencese=>WebPreferences;destination=Book;template=_default
will copy %BASEWEB%.ApplicationWebPreferences to Book.WebPreferences. The Book web is created if it does not exist.

mode=application;source=Applications.RenderSimpleTopicCreator[stub];destination=Book;template=_default
will copy Applications.RenderSimpleTopicCreator to Book.RenderSimpleTopicCreator as a stub. The Book web is created if it does not exist.

mode=application;source=ApplicationWebHome=>WebHome[stub];destination=Book;template=_default
will copy %BASEWEB%.ApplicationWebHome to Book.WebHome as a stub. The Book web is created if it does not exist.

As you can see, this construct caters for all deployment requirements of applications. A particular web can be supported by multiple applications. Home pages and preferences can be distributed as part of the Applications web.

Comments welcome

-- BramVanOosterhout - 10 Jun 2016

Implementation (12 August 2016)

Following up, I have created an implementation of the design presented. I attach the code. In summary I have:
  • added a mode application to CopyContrib.pm
  • implemented CopyContrib/ApplicationAgent.pm which:
    • copies the default web
    • uses TopicAgent to copy topics
    • implements new functionality to create stubs

I have also implemented a new workbench function RenderApplicationDeployer, which takes a DeploymentList topic as input. The DeploymentList topic contains a table of the form:
source_topic_name target_topic_name copy_type

RenderApplicationDeployer uses this table to generate the mode=application input parameters:
source_topic_name => target_topic_name [copy_type]

I have attached that code as well.

Now that I have completed this, I have a few questions:
  • I could not work out how to use the WebAgent to create a web, without additional topics. Can that be done?
  • I copy the stub in the ApplicationAgent. I wonder whether there is virtue in implementing a separate TopicStubAgent and leaving the ApplicationAgent to integrate the parts.
  • The RenderApplicationDeployer function turned out to be tricky in dealing with the defaults. I wonder whether it would be worthwhile (or confusing) to extend the application mode with an additional copy_type: deploymentlist. The DeploymentList topic can then be passed as
    source=DeploymentList [edploymentlist]
    and the parsing can be done more robustly in the ApplicationAgent.

-- BramVanOosterhout - 12 Aug 2016

Complete implementation for review (31 March 2017)

I have completed my updates to the CopyContrib for mode=applications

The updated files are avalable in CopyContrib-Application.tgz. They are:
file Purpose/Change
lib/Foswiki/Contrib/CopyContrib.pm Added the stub and application mode.
lib/Foswiki/Contrib/CopyContrib/CopyAgent.pm minor change. Added scalar.
lib/Foswiki/Contrib/CopyContrib/WebAgent.pm minor change. Propagated the debug parameter.
lib/Foswiki/Contrib/CopyContrib/TopicStubAgent.pm new module. Derived from TopicAgent.pm and will create a stub for a given topic.
lib/Foswiki/Contrib/CopyContrib/ApplicationAgent.pm new module. Implements the copy of a web with new syntax.
data/System/CopyContrib.txt Added descriptions for modes application and stub.

I have also created an example of the use of the application as part of the WikiWorkbench.

The additional files are available in WikiWorkbenchContrib-Deployment.tgz.

The example will deploy a new web, supporting the development of an application. It uses the DeploymentList. You can jump there in the Applications web. You are presented with a deployment list which has a Deploy button at the bottom.

Clicking Deploy will create a web similar to that created by the New WikiApplication button on the Applications.WebHome page.

The deployment list On successful completion...
DeploymentList.png Success.png

... creates the Testweb

Testweb.png

Have a look. I look forward to your comments.

-- BramVanOosterhout - 31 Mar 2017
 
I Attachment Action Size Date Who Comment
ApplicationAgent.tgztgz ApplicationAgent.tgz manage 3 K 12 Aug 2016 - 04:57 BramVanOosterhout Code for the Application agent
CopyContrib-Application.tgztgz CopyContrib-Application.tgz manage 7 K 31 Mar 2017 - 14:10 BramVanOosterhout The CopyContrib updates
DeploymentList.pngpng DeploymentList.png manage 60 K 31 Mar 2017 - 14:03 BramVanOosterhout The deployment list
RenderApplicationDeployer.tgztgz RenderApplicationDeployer.tgz manage 1 K 12 Aug 2016 - 04:59 BramVanOosterhout Text for the application deployer function
Success.pngpng Success.png manage 10 K 31 Mar 2017 - 14:03 BramVanOosterhout On successful creation...
Testweb.pngpng Testweb.png manage 109 K 31 Mar 2017 - 14:04 BramVanOosterhout ... the Testweb exists.
WikiWorkbenchContrib-Deployment.tgztgz WikiWorkbenchContrib-Deployment.tgz manage 3 K 31 Mar 2017 - 14:10 BramVanOosterhout The wiki work bench example
Topic revision: r6 - 20 Jun 2017, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy