Programmatically create phases

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatically create phases

tiffanymlk
Hi,

I would like to programmatically add the same phases whenever a project is created. Has anyone every tried to do such a thing?


I inserted the following code in the 'createProject' method of the ProjectServices.xml files.
<if-empty field="parameters.templateId"> 
         <set field="createProjectPhase.workEffortName" value="Phase1"/> 
            <set field="createProjectPhase.workEffortParentId" from-field="parameters.projectId"/> 
         <call-simple-method method-name="createProjectPhase"/> 
        </if-empty> 


And this is the 'createProjectPhase' method:
 <simple-method method-name="createProjectPhase" short-description="Create a project phase and optionally assign"> 
         
        <if-empty field="parameters.statusId"> 
            <set field="parameters.statusId" value="PTS_CREATED"/> 
        </if-empty> 
        <call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/> 
        <set field="parameters.workEffortId" from-field="newEntity.workEffortId"/> 
         
        <if-not-empty field="parameters.partyId"> 
            <call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
        </if-not-empty> 
         
        <if-not-empty field="parameters.estimatedHours"> 
            <set field="parameters.estimatedDuration" from-field="parameters.estimatedHours" type="Double"/> 
            <if-empty field="parameters.skillTypeId"> 
                <set field="parameters.skillTypeId" value="_NA_"/> 
            </if-empty> 
            <call-simple-method method-name="createWorkEffortSkillStandard" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/> 
        </if-not-empty> 
    </simple-method> 

Any help would be much appreciated, thanks

steph.
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

BJ Freeman
not sure what you mean by phases.
if you mean the folders with basic files to work from then you can use
ant create-project
it will create all the folders and copy template files to them for you
to start to work.

=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


tiffanymlk sent the following on 3/30/2010 4:26 AM:

> Hi,
>
> I would like to programmatically add the same phases whenever a project is
> created. Has anyone every tried to do such a thing?
>
>
> I inserted the following code in the 'createProject' method of the
> ProjectServices.xml files.
> <if-empty field="parameters.templateId">
>          <set field="createProjectPhase.workEffortName" value="Phase1"/>
>             <set field="createProjectPhase.workEffortParentId"
> from-field="parameters.projectId"/>
>          <call-simple-method method-name="createProjectPhase"/>
>         </if-empty>
>
>
> And this is the 'createProjectPhase' method:
>  <simple-method method-name="createProjectPhase" short-description="Create a
> project phase and optionally assign">
>         <!-- create task -->
>         <if-empty field="parameters.statusId">
>             <set field="parameters.statusId" value="PTS_CREATED"/>
>         </if-empty>
>         <call-simple-method method-name="createWorkEffort"
> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>         <set field="parameters.workEffortId"
> from-field="newEntity.workEffortId"/>
>         <!-- optionally assign to party -->
>         <if-not-empty field="parameters.partyId">
>             <call-simple-method method-name="assignPartyToWorkEffort"
> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>         </if-not-empty>
>         <!-- optionally enter estimated time and required skill -->
>         <if-not-empty field="parameters.estimatedHours">
>             <set field="parameters.estimatedDuration"
> from-field="parameters.estimatedHours" type="Double"/>
>             <if-empty field="parameters.skillTypeId">
>                 <set field="parameters.skillTypeId" value="_NA_"/>
>             </if-empty>
>             <call-simple-method method-name="createWorkEffortSkillStandard"
> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>         </if-not-empty>
>     </simple-method>
>
> Any help would be much appreciated, thanks
>
> steph.


Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

tiffanymlk
I'm actually referring to the phases that can be created in a project (in the projectmgr module). As part of an assignment, I need to customize this module in order to automatically create a set of phases whenever a project is created. For instance, when a user creates a project in the projectmsg module, the following phases will be automatically created:
plan phase
development phase
deployment phase.

This means that all the projects that will be created, will have the above phases. in other words, I sort of want to hard code these phases.

I know that there are a 'createProject' method and a 'createProjectPhase' method in the ProjectServices.xml file, so I thought of calling the 'createProjectPhase' method from the 'createProject' method. So I wrote the following code in the 'createProject' method:

<if-empty field="parameters.templateId">
         <set field="createProjectPhase.workEffortName" value="Estimation"/>
            <set field="createProjectPhase.workEffortParentId" from-field="parameters.projectId"/>
         <call-simple-method method-name="createProjectPhase"/>

But it didn't work. So I thought maybe someone could help me, cos the truth is I'm also new to XML/

Thanks a lot for your interest, I really appreciate it.
Steph.

Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

BJ Freeman
In reply to this post by tiffanymlk
sorry totally offbase with this answer.
but if you read your previous thread it was answered.

=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


BJ Freeman sent the following on 3/30/2010 9:19 AM:

> not sure what you mean by phases.
> if you mean the folders with basic files to work from then you can use
> ant create-project
> it will create all the folders and copy template files to them for you
> to start to work.
>
> =========================
> BJ Freeman
> http://bjfreeman.elance.com
> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> Specialtymarket.com <http://www.specialtymarket.com/>
>
> Systems Integrator-- Glad to Assist
>
> Chat  Y! messenger: bjfr33man
> Linkedin
> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>
>
> tiffanymlk sent the following on 3/30/2010 4:26 AM:
>> Hi,
>>
>> I would like to programmatically add the same phases whenever a project is
>> created. Has anyone every tried to do such a thing?
>>
>>
>> I inserted the following code in the 'createProject' method of the
>> ProjectServices.xml files.
>> <if-empty field="parameters.templateId">
>>          <set field="createProjectPhase.workEffortName" value="Phase1"/>
>>             <set field="createProjectPhase.workEffortParentId"
>> from-field="parameters.projectId"/>
>>          <call-simple-method method-name="createProjectPhase"/>
>>         </if-empty>
>>
>>
>> And this is the 'createProjectPhase' method:
>>  <simple-method method-name="createProjectPhase" short-description="Create a
>> project phase and optionally assign">
>>         <!-- create task -->
>>         <if-empty field="parameters.statusId">
>>             <set field="parameters.statusId" value="PTS_CREATED"/>
>>         </if-empty>
>>         <call-simple-method method-name="createWorkEffort"
>> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>>         <set field="parameters.workEffortId"
>> from-field="newEntity.workEffortId"/>
>>         <!-- optionally assign to party -->
>>         <if-not-empty field="parameters.partyId">
>>             <call-simple-method method-name="assignPartyToWorkEffort"
>> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>>         </if-not-empty>
>>         <!-- optionally enter estimated time and required skill -->
>>         <if-not-empty field="parameters.estimatedHours">
>>             <set field="parameters.estimatedDuration"
>> from-field="parameters.estimatedHours" type="Double"/>
>>             <if-empty field="parameters.skillTypeId">
>>                 <set field="parameters.skillTypeId" value="_NA_"/>
>>             </if-empty>
>>             <call-simple-method method-name="createWorkEffortSkillStandard"
>> xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
>>         </if-not-empty>
>>     </simple-method>
>>
>> Any help would be much appreciated, thanks
>>
>> steph.
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

isserg
hi,

i have a similar problem but i cant find where the solution is provided.
thanks alot for your help and answers.
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

tiffanymlk
In the other thread I was given this link:
http://cwiki.apache.org/confluence/display/OFBADMIN/Mailing+Lists#MailingLists-DesignanddevelopmentList:dev@ofbiz.apache.org

and I tried to find a similar solution in the Global Searchable Archives, but I couldn't find a similar thread
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

Sharan-F
In reply to this post by tiffanymlk
Hi Steph

Do you have to do this programmatically? If not then why dont you just

a) create a project as a template with the phases that you need
b) use the template as the basis for any new project created

and it will automatically include the phases defined in the project template.

Here's how to do it;

Use Project Manager to create a project with the phases you need.

1). In the Phases tab use the 'Save as Template' button to save it.
2). Create a new project and then select the template that you've just created and and all the phases in the template will be copied into the new project.

If you really need to do it programmatically then you could still use the template functionality to create a template and then program any new project to use that template.

Hope this helps.

Thanks
Sharan


Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

tiffanymlk
Yes I need to do it programmatically, but your suggestions are quite a good work around.
Thanks, I will take it into consideration.
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically create phases

BJ Freeman
In reply to this post by tiffanymlk

it would be nice if we had a repository of templates that people could
contribute to.
they would have to be massaged first use non numerical ID's so there is
no conflict.

=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Sharan-F sent the following on 3/30/2010 12:15 PM:

> Hi Steph
>
> Do you have to do this programmatically? If not then why dont you just
>
> a) create a project as a template with the phases that you need
> b) use the template as the basis for any new project created
>
> and it will automatically include the phases defined in the project
> template.
>
> Here's how to do it;
>
> Use Project Manager to create a project with the phases you need.
>
> 1). In the Phases tab use the 'Save as Template' button to save it.
> 2). Create a new project and then select the template that you've just
> created and and all the phases in the template will be copied into the new
> project.
>
> If you really need to do it programmatically then you could still use the
> template functionality to create a template and then program any new project
> to use that template.
>
> Hope this helps.
>
> Thanks
> Sharan
>
>
>