1 | package org.apache.maven.continuum.web.action; |
2 | |
3 | /* |
4 | * Licensed to the Apache Software Foundation (ASF) under one |
5 | * or more contributor license agreements. See the NOTICE file |
6 | * distributed with this work for additional information |
7 | * regarding copyright ownership. The ASF licenses this file |
8 | * to you under the Apache License, Version 2.0 (the |
9 | * "License"); you may not use this file except in compliance |
10 | * with the License. You may obtain a copy of the License at |
11 | * |
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | * |
14 | * Unless required by applicable law or agreed to in writing, |
15 | * software distributed under the License is distributed on an |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
17 | * KIND, either express or implied. See the License for the |
18 | * specific language governing permissions and limitations |
19 | * under the License. |
20 | */ |
21 | |
22 | import org.apache.maven.continuum.model.project.BuildDefinition; |
23 | import org.apache.maven.continuum.web.model.BuildDefinitionSummary; |
24 | |
25 | import java.util.LinkedList; |
26 | import java.util.List; |
27 | |
28 | /** |
29 | * @author <a href="mailto:olamy@apache.org">olamy</a> |
30 | * @version $Id: AbstractBuildDefinitionAction.java 752008 2009-03-10 07:28:33Z ctan $ |
31 | * @since 16 sept. 07 |
32 | */ |
33 | public abstract class AbstractBuildDefinitionAction |
34 | extends ContinuumConfirmAction |
35 | { |
36 | |
37 | protected BuildDefinitionSummary generateBuildDefinitionSummary( BuildDefinition buildDefinition ) |
38 | { |
39 | BuildDefinitionSummary bds = new BuildDefinitionSummary(); |
40 | |
41 | bds.setGoals( buildDefinition.getGoals() ); |
42 | bds.setId( buildDefinition.getId() ); |
43 | bds.setArguments( buildDefinition.getArguments() ); |
44 | bds.setBuildFile( buildDefinition.getBuildFile() ); |
45 | bds.setScheduleId( buildDefinition.getSchedule().getId() ); |
46 | bds.setScheduleName( buildDefinition.getSchedule().getName() ); |
47 | bds.setIsDefault( buildDefinition.isDefaultForProject() ); |
48 | bds.setIsBuildFresh( buildDefinition.isBuildFresh() ); |
49 | if ( buildDefinition.getProfile() != null ) |
50 | { |
51 | bds.setProfileName( buildDefinition.getProfile().getName() ); |
52 | bds.setProfileId( buildDefinition.getProfile().getId() ); |
53 | } |
54 | bds.setDescription( buildDefinition.getDescription() ); |
55 | bds.setType( buildDefinition.getType() ); |
56 | bds.setAlwaysBuild( buildDefinition.isBuildFresh() || buildDefinition.isAlwaysBuild() ); |
57 | return bds; |
58 | } |
59 | |
60 | protected List<BuildDefinitionSummary> generateBuildDefinitionSummaries( List<BuildDefinition> buildDefinitions ) |
61 | { |
62 | List<BuildDefinitionSummary> buildDefinitionSummaries = new LinkedList<BuildDefinitionSummary>(); |
63 | for ( BuildDefinition buildDefinition : buildDefinitions ) |
64 | { |
65 | buildDefinitionSummaries.add( generateBuildDefinitionSummary( buildDefinition ) ); |
66 | } |
67 | return buildDefinitionSummaries; |
68 | } |
69 | } |