View Javadoc
1   package fr.paris.lutece.plugins.appcenter.modules.fastdeployapplication.service.ansible;
2   
3   import java.util.Locale;
4   import java.util.regex.Matcher;
5   import java.util.regex.Pattern;
6   
7   import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8   
9   // TODO: Auto-generated Javadoc
10  /**
11   * The Class AWXHost.
12   */
13  @JsonIgnoreProperties( ignoreUnknown = true )
14  public class AWXHost
15  {
16  
17      /** The id. */
18      private String id;
19    
20      /** The name. */
21      private String name;
22      
23      /** The variables. */
24      private AWXHostVariable variables;
25  
26      /**
27       * Gets the id.
28       *
29       * @return the id
30       */
31      public String getId( )
32      {
33          return id;
34      }
35  
36      /**
37       * Sets the id.
38       *
39       * @param id the new id
40       */
41      public void setId( String id )
42      {
43          this.id = id;
44      }
45  
46    
47  
48    
49      /**
50       * Gets the name.
51       *
52       * @return the name
53       */
54      public String getName( )
55      {
56          return name;
57      }
58  
59      /**
60       * Sets the name.
61       *
62       * @param name the new name
63       */
64      public void setName( String name )
65      {
66          this.name = name;
67      }
68  
69      /**
70       * Gets the variables.
71       *
72       * @return the variables
73       */
74      public AWXHostVariable getVariables( )
75      {
76          return variables;
77      }
78  
79      /**
80       * Sets the variables.
81       *
82       * @param variables the new variables
83       */
84      public void setVariables( AWXHostVariable variables )
85      {
86          this.variables = variables;
87      }
88      
89      
90      /**
91       * Gets the code environment.
92       *
93       * @return the code environment
94       */
95      public String getCodeEnvironment()
96      {
97          
98              String[] tabName= this.getName( ).split( "-" );
99              return (tabName[2]+"."+tabName[1]).toLowerCase( Locale.FRENCH );
100     }
101     
102     /**
103      * Gets the code type.
104      *
105      * @return the code type
106      */
107     public String getCodeType()
108     {
109         String[] tabName= this.getName( ).split( "-" );
110         Pattern pattern = Pattern.compile("(.*?)(\\d+)(.*)");
111         Matcher matcher = pattern.matcher(tabName[3]);
112         if(matcher.find( ))
113         {
114             return matcher.group(1).toUpperCase( Locale.FRENCH ); 
115         }
116         return null;
117     }
118     
119     /**
120      * Gets the code instance.
121      *
122      * @return the code instance
123      */
124     public String getCodeInstance()
125     {
126         String[] tabName= this.getName( ).split( "-" );
127         Pattern pattern = Pattern.compile("(.*?)(\\d+)(.*)");
128         Matcher matcher = pattern.matcher(tabName[3]);
129         if(matcher.find( ))
130         {
131             return matcher.group(2); 
132         }
133         return null;
134     }
135     
136     
137     
138     
139     
140 
141 }