Module: Mrdf_Model

Defined in:
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/main.rb,
lib/ontomde-uml2-struts/footer.rb,
lib/ontomde-uml2-struts/header.rb,
lib/ontomde-uml2-struts/spring.rb,
lib/ontomde-uml2-struts/webXml.rb,
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/jsp_index.rb,
lib/ontomde-uml2-struts/validator.rb,
lib/ontomde-uml2-struts/validation.rb,
lib/ontomde-uml2-struts/header_link.rb,
lib/ontomde-uml2-struts/localeAction.rb,
lib/ontomde-uml2-struts/reloadAction.rb,
lib/ontomde-uml2-struts/struts-config.rb,
lib/ontomde-uml2-struts/mappingToJavaHierarchy.rb

Overview

Helpers to add Reload action

Constant Summary collapse

STRUTS_WEBXML_HEAD =

HEADER of generated web.xml

<<ENDHEAD
<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">

<!-- Generated by XMDA -->

<web-app>
	<display-name>Struts Examples Application</display-name>
ENDHEAD
STRUTS_WEBXML_FOOT =

Footer of generated web.xml

<<ENDFOOT
	<!-- Standard Action Servlet Configuration (with debugging) -->
	<servlet>
		<servlet-name>action</servlet-name>
		<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
		<!-- Default -->
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>debug</param-name>
			<param-value>2</param-value>
		</init-param>
		<init-param>
			<param-name>detail</param-name>
			<param-value>2</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>

	<!-- Standard Action Servlet Mapping -->
	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>

	<!-- The Usual Welcome File List -->
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>index.html</welcome-file>
		<welcome-file>upload.jsp</welcome-file>
	</welcome-file-list>

	<error-page>
		<error-code>500</error-code>
		<location>/errorPage.jsp</location>
	</error-page>

	<error-page>
		<exception-type>java.lang.Exception</exception-type>
		<location>/errorPage.jsp</location>
	</error-page>
</web-app>
ENDFOOT
STRUTS_WEBXML_ACEGI_FILTER =

ACEGI STRUTS FILTER definition

<<ENDSEC
       <filter>
		<filter-name>Acegi Filter Chain Proxy</filter-name>
		<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
		<init-param>
			<param-name>targetClass</param-name>
			<param-value>xmda.security.FilterChainProxyTrigger</param-value>
		</init-param>
	</filter>
ENDSEC
STRUTS_WEBXML_ACEGI_MAPPING =
<<ENDMAP
  	<filter-mapping>
          <filter-name>Acegi Filter Chain Proxy</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
ENDMAP
STRUTS_WEBXML_XMDA_FILTER =

WEBXML filter for xmda actions

<<ENDMAP
  	<filter-mapping>
          <filter-name>XmdaFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
ENDMAP
STRUTS_SPRING_LISTENER =
<<END11
    <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <!-- Charge par le Struts Plugin -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <!-- end of spring section -->
END11
STRUTS_SESSION_TIMEOUT_IN_MINUTES_RES =
"server.session.timeout.minutes"
STRUTS_VALIDATOR_NAMES =

list of validator names defined

Array.new
STRUTS_RES_DIRECTORY =
"res"
STRUTS_ACTION_LOCALE_FORM =
"xmda.struts.ActionLocaleForm"
STRUTS_ACTION_LOCALE_PATH =
"/setLocale"
STRUTS_ACTION_LOCALE_URL =
"#{STRUTS_ACTION_LOCALE_PATH}.do"

Instance Method Summary collapse

Instance Method Details

#css_color_classObject



28
29
30
# File 'lib/ontomde-uml2-struts/header_link.rb', line 28

def css_color_class
  return  "orange"
end

#css_path_modelObject



24
25
26
# File 'lib/ontomde-uml2-struts/header_link.rb', line 24

def css_path_model
  return  "#{STRUTS_RES_DIRECTORY}/"
end

#eachStrutsBeanObject



36
37
38
39
40
41
42
43
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 36

def eachStrutsBean
  uml_Class_all.each { |c|
    next if c.kind_of?(Muml_Enumeration)
    next if c.kind_of?(Muml_Interface)
    next if c.java_ignoreMe?
    yield(c)
  }
end

#eachStrutsFormsetObject



45
46
47
48
49
50
51
52
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 45

def eachStrutsFormset
  uml_Class_all.each { |c|
    next if c.kind_of?(Muml_Enumeration)
    next if c.kind_of?(Muml_Interface)
    next if c.java_ignoreMe?
    yield(c)
  }
end

#struts_ActionLocaleWriteActionBeanObject



27
28
29
# File 'lib/ontomde-uml2-struts/localeAction.rb', line 27

def struts_ActionLocaleWriteActionBean
  write  %{<form-bean name="#{STRUTS_ACTION_LOCALE_FORM}" type="#{STRUTS_ACTION_LOCALE_FORM}"/>\n}
end

#struts_ActionLocaleWriteActionPathObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ontomde-uml2-struts/localeAction.rb', line 16

def struts_ActionLocaleWriteActionPath
  write(%{
 <action path="#{STRUTS_ACTION_LOCALE_PATH}"
  type="org.apache.struts.actions.LocaleAction"
  name="#{STRUTS_ACTION_LOCALE_FORM}"
  scope="session"
  validate="false"
  cancellable="true"
  />
    })
end

#struts_addActionLocaleForm!Object



9
10
11
12
13
14
15
# File 'lib/ontomde-uml2-struts/localeAction.rb', line 9

def struts_addActionLocaleForm!
  each { |k,c|
    next unless c.kind_of?(::Muml_Model)
    c.struts_addActionLocaleForm!
    break
  }
end

#struts_addPerClassElement!Object



47
48
49
50
51
52
53
54
55
# File 'lib/ontomde-uml2-struts/main.rb', line 47

def struts_addPerClassElement!
	struts_viewableClassifier.each { |c|
		c.struts_addActionForm!
	}
	struts_viewableClassifier.each { |c|
		next if c.struts_actionForm_one0.nil?
		c.struts_addAction!
	}
end

#struts_addReloadDefinitionsAction(uri = "/admin/reload") ⇒ Object

Calling this method will setup a struts reload action. This action will be accessible with a browser using the provided uri. Calling the action will trigger a struts configuration reload, usefull for developpment.

Note: *This method should be called before code generation and before setup generation. *Action is extracted from ruby *Thanks to Stephane Coutant for pointing out this feature.



15
16
17
# File 'lib/ontomde-uml2-struts/reloadAction.rb', line 15

def struts_addReloadDefinitionsAction(uri="/admin/reload")
	self.struts_reloadDefinitionsActionUri=uri
end

#struts_addValidator(name) ⇒ Object

declare a new validator return name for easy insertion in templates



14
15
16
17
# File 'lib/ontomde-uml2-struts/validator.rb', line 14

def struts_addValidator(name)
	STRUTS_VALIDATOR_NAMES << name.to_s
	return name
end

#struts_allInOneGenerateObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ontomde-uml2-struts/main.rb', line 57

def struts_allInOneGenerate
	struts_generate_webxml
	struts_struts_config_generate
	struts_validator_generate
	struts_validation_generate
	struts_copyReloadDefinitionsActionClass

	struts_index_generate
	struts_edit_generate

	java_generate
	struts_messageResources_generate
	#struts_servlet_generate
	#umlx_getOrCreateClass("org.apache.struts.action.ActionForm")
	#struts_servlet_generate

	db_generateConfiguration
	struts_messageResources_generate
end

#struts_allInOneTransform!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ontomde-uml2-struts/main.rb', line 4

def struts_allInOneTransform!
	umlx_autoImplementProperty! if context[:withAutoImplementProperty]
	umlx_autoImplementOperation! if context[:withAutoImplementOperation]
        java_addEnumAssignable! if context[:withEnumAssignable]
	#
	#Usefull in case of Flex integration
	java_addEnumCompatibilityLayerProperties! if context[:withEnumAsString]
	umlx_MarkAllAsbusinessMethod!

	umlx_makeCompositionNavigable!
	struts_addReloadDefinitionsAction
	struts_addAllOperationAggregateParameterClass!
	java_transform!
	db_addPersistence!
	struts_addActionLocaleForm!
	struts_addPerClassElement!


	db_addTestImplementations! if context[:simulateNotImplementedMethods]
	struts_messageCheck if context[:messageCheck]
end

#struts_copyReloadDefinitionsActionClassObject

internal use copys required java source files to project



21
22
23
24
# File 'lib/ontomde-uml2-struts/reloadAction.rb', line 21

def struts_copyReloadDefinitionsActionClass()
	#return if self.struts_reloadDefinitionsActionUri.empty?
	#FileUtils.cp("#{File.dirname(__FILE__)}/ReloadDefinitionsAction.java","#{context[:build]}/WEB-INF/src/java/xmda/struts/ReloadDefinitionsAction.java")
end

#struts_createDataTypeHelpers!Object



4
5
6
7
8
# File 'lib/ontomde-uml2-struts/mappingToJavaHierarchy.rb', line 4

def struts_createDataTypeHelpers!
	JavaMapping.instance.getMappings.each { |m|
		m.struts_generateHelper(self)
	}
end

#struts_edit_generateObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 54

def struts_edit_generate
  uml_Class_all.each { |c|
    next if c.kind_of?(Muml_Enumeration)
    next if c.kind_of?(Muml_Interface)
    next if c.java_ignoreMe?
    #next if c.db_isTransient?
    c.struts_edit_generate
    c.struts_row_generate
  }
end

#struts_encloseWrite(before, after, &block) ⇒ Object



20
21
22
23
24
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 20

def struts_encloseWrite(before,after,&block)
  write(before)
  yield
  write(after)
end


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ontomde-uml2-struts/footer.rb', line 5

def struts_footer_generate
  write <<END
<!-- **********************************
************  BAS DE PAGE   ***********
************************************ -->
<SCRIPT>
function #{::Muml_Class::STRUTS_SETLOCALE_ACTION}(lang) {
 document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{::Muml_Class::STRUTS_SETLOCALE_ACTION}";
 document.forms[0].#{Muml_Class::STRUTS_SETLOCALE_LANGUAGE_FIELD}.value=lang;
 document.forms[0].submit();
 }
function #{::Muml_Class::STRUTS_SETTIMEZONE_ACTION}(tz) {
 document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{::Muml_Class::STRUTS_SETTIMEZONE_ACTION}";
 document.forms[0].#{Muml_Class::STRUTS_SETTIMEZONE_FIELD}.value=tz;
 document.forms[0].submit();
 }
function #{::Muml_Class::STRUTS_SETSKIN_ACTION}(skin) {
 alert("!!");
 document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{::Muml_Class::STRUTS_SETSKIN_ACTION}";
 document.forms[0].#{Muml_Class::STRUTS_SETSKIN_FIELD}.value=skin;
 document.forms[0].submit();
 }
 function #{::Muml_Class::STRUTS_SWITH_TO_FLEX_ACTION}() {
 document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{::Muml_Class::STRUTS_SWITH_TO_FLEX_ACTION}";
 document.forms[0].submit();
 }

</SCRIPT>
<br/>
<table>
	<tr>
<td>
	<img  onClick="switchToFlex();" src="#{css_path_model}/#{css_color_class}/image/logoFrancetelecom.gif"  border="0" alt=""/>
</td>
<td width="100%">
</td>
<td>
	<a href="#">
		<img  onClick="#{::Muml_Class::STRUTS_SWITH_TO_FLEX_ACTION}();" src="#{css_path_model}/#{css_color_class}/image/btnFX.gif" width="28" height="25" border="0" alt=""/>
	</a>
</td>
<td>
		<a href="#">
			<img src="#{css_path_model}/#{css_color_class}/image/btnSend.gif" width="25" height="25" border="0" alt="" />
		</a>
	</td>
                      <td>
		<a href="#">
			<img src="#{css_path_model}/#{css_color_class}/image/btnUp.gif" width="25" height="25" border="0" alt=""/>
		</a>
	</td>
                      <td>
		<img src="#{css_path_model}/#{css_color_class}/image/imgSprtr.gif" width="1" height="30" border="0" alt="" />
	</td>
                      <td>
		<a href="#">
			<img  onclick="setLocale('fr');" src="#{css_path_model}/#{css_color_class}/image/btnLanguage_Fr.gif" width="24" height="19" border="0"     alt="" />
		</a>
	</td>
                      <td>
		<a href="#">
			<img onclick="setLocale('en');" src="#{css_path_model}/#{css_color_class}/image/btnLanguage_Eng.gif" width="24" height="19" border="0" alt="" />
		</a>
	</td>
                      <td>
		<a href="#">
			<img onclick="setLocale('de');" src="#{css_path_model}/#{css_color_class}/image/btnLanguage_Dch.gif" width="24" height="19" border="0" alt="" />
		</a>
	</td>
                        <td>
		<img src="#{css_path_model}/#{css_color_class}/image/imgSprtr.gif" width="1" height="30" border="0" alt="" />
	</td>
                      <td>
<html:hidden property="#{::Muml_Class::STRUTS_SETLOCALE_LANGUAGE_FIELD}"/>
<input type="hidden" name="#{::Muml_Class::STRUTS_SETSKIN_FIELD}"/>
END



  write(struts_getTimeZoneSelect())

  write %{
	</td>
	<td>
  }
  struts_writeTimeoutIndicator()

  if context[:security]
    # DISPLAY A WARNING IN WEB PAGE IF SERVER SECURITY IS DISABLED
    write <<SECWARN
<%= 
xmda.security.ProviderImpl.getSecurityIsDisabled()
? "<span style=\\"background-color:red; text-color:black\\" bgcolor=\\"black\\">ACCESS<br>CONTROL<br>DISABLED</span>" 
: "" 
%>
SECWARN
  
 
  
    #cf: j_acegi_logout is handled in Application-security.xml
    write <<END2
   <td><html:link page="/j_acegi_logout" title="Logout"><img src="res/orange/image/exit.gif" width="25" height="25" border="0" alt="exit"/></html:link></td>
END2
  end
 
 
  write <<END

	</td>
    </tr>
              </table>




END
end

#struts_generate_webxmlObject



4
5
6
7
8
# File 'lib/ontomde-uml2-struts/webXml.rb', line 4

def struts_generate_webxml
  mtk_writeSession("#{context[:webContentDir]}/WEB-INF/web.xml") {
    struts_webxml_write
  }
end

#struts_generateSpringApplicationContextObject



5
6
7
8
9
10
# File 'lib/ontomde-uml2-struts/spring.rb', line 5

def struts_generateSpringApplicationContext
	return unless context[:struts_useSpring]
	mtk_writeSession("#{context[:webContentDir]}/WEB-INF/applicationContext.xml") {
		struts_writeSpringApplicationContext
	}
end

#struts_getReloadDefinitionsActionConfigObject

internal use inserts required configuration item in struts configuration file.



28
29
30
31
# File 'lib/ontomde-uml2-struts/reloadAction.rb', line 28

def struts_getReloadDefinitionsActionConfig
	return "<!-- no reload definition action -->" if struts_reloadDefinitionsActionUri.empty?
	return %{<action path="#{struts_reloadDefinitionsActionUri}" type="org.apache.struts.tiles.actions.ReloadDefinitionsAction"/>}
end

#struts_header_generateObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ontomde-uml2-struts/header.rb', line 3

def struts_header_generate
  write <<END
	<%-- ********  ENTETE ****************** --%>
<div class="cadre">
	<div class="AgLeft">
<a href="https://rubyforge.org/">
	<img src="#{css_path_model}/#{css_color_class}/image/logoMDE.gif" border="0"  alt="Home"/>
</a>
	</div>
      <div class="AgCenter">
<img src="#{css_path_model}/#{css_color_class}/image/bienvenue.gif" border="0"  alt="will be delete"/>
      </div>
	<div class="AgRight">
	<a href="javascript:window.print();">
	<img src="#{css_path_model}/#{css_color_class}/image/btnPrint.gif" width="25" height="25" border="0" alt="Print"/>
</a>
<html:link page="/Welcome.do"title="Retour a l'accueil">
	<img src="#{css_path_model}/#{css_color_class}/image/btnPosition.gif" width="25" height="25" border="0" alt="Position"/>
</html:link>
<a href="#">
	<img src="#{css_path_model}/#{css_color_class}/image/btnHelp.gif" width="25" height="25" border="0" alt="Help"/>
</a>
	</div>
</div>
	<%-- ********  USER CONTEXT ************* --%>
END
end


32
33
34
35
36
37
# File 'lib/ontomde-uml2-struts/header_link.rb', line 32

def struts_header_link_generate(sourcePage)
  rel=Pathname.new(".").relative_path_from(Pathname.new(File.dirname(sourcePage)))
  write <<END
<jsp:include page="#{rel}/res/orange/include/include_head.jsp" flush="false"/>
END
end

#struts_index_generateObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/ontomde-uml2-struts/jsp_index.rb', line 3

def struts_index_generate

	mtk_writeSession( %{#{context[:webContentDir]}/index.jsp} ) {
		mtk_context( :struts_curClass => self) {
			write <<END
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@ page contentType="text/html;charset=ISO8859-1" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html:html>
<head>
<script src="res//orange/script/initialization.js" type="text/javascript"></script>
<script src="res//orange/script/main.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="res//orange/css/layout.css"/>
<link rel="stylesheet" type="text/css" href="res//orange/css/content.css"/>
<link rel="stylesheet" type="text/css" media="print" href="res//orange/css/print.css"/>
<script type="text/javascript" language="Javascript" src="res//orange/script/fonctionsJS-archimede.js"></script>

<title>Index -- Generated with XMDA</title>
</head>
<body >

<html:form action="#{STRUTS_ACTION_LOCALE_URL}">
<%-- not necessary in jsp_index debug form --%>
<input type="hidden" name="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}" />

<logic:messagesPresent>
  <bean:message key="errors.header"/>
  <ul>
  <html:messages id="error">
     <li><bean:write name="error"/></li>
  </html:messages>
  </ul><hr />
</logic:messagesPresent>
<center>

END

			struts_header_generate
			write <<END
	<!-- **************************************
	************  CORPS DE PAGE  **************
	**************************************** -->
			<center>
   	<div class="milieu">
		<div class="contenusansMenu">
			<!-- Indicateur Hi�rarchique -->
			<div class="indicateur"><h1>Accueil</h1></div>
			<a name="contenu"></a>
			<!-- Corps de Page -->
			<h2 style="font-size:120%">Generated with XMDA</h2>
			<ul>
END
pkg=Hash.new
uml_Class_all.each {|c|
	next if c.kind_of?(Muml_Enumeration)
	next if c.kind_of?(Muml_Class)&& !c.umlx_isReallyAClass?
	next if c.java_ignoreMe?
	#puts "JSP_INDEX #{c}::#{c.class.name} #{c.db_isTransient?}"
	#next if c.db_isTransient?
	#next if c.java_DAOClass.empty?
	next if c.struts_action.empty?
	p=c.uml_ownedMember_inv_one
	pkg[p]=Array.new if pkg[p].nil?
	pkg[p] << c
	}
write %{<table border="1" style="border-style: ; border: gray; border-spacing:0px">}
write %{<tr bgcolor="#EEEEEE" width="10%"><td valign="center"><a name="index"/><h3>Package index</h3></td><td><ul>}
pkg.keys.sort {|a,b| a.java_qualifiedName.to_s <=> b.java_qualifiedName.to_s }.each { |p|
	write %{<li><a href="##{p.java_qualifiedName}">#{p.java_qualifiedName}</a></li>  }
	}
write "</ul></td></tr>"
pkg.keys.sort {|a,b| a.uml_name.to_s <=> b.uml_name.to_s }.each { |p|
	write %{<tr><td valign="center"><h3><a name="#{p.java_qualifiedName}"/><a href="#index">#{p.java_qualifiedName.gsub(/\./," .")}</a></h3></td><td><ul>}
	pkg[p].sort { |a,b| a.uml_name.to_s <=> b.uml_name.to_s }.each {|c|
		write <<END
			#{if (!c.uml_isAbstract?)
				%{<li>#{c.uml_name}: <html:link page="/#{c.java_Name}-new.do?doWhat=newa">new</html:link> #{%{ (transient)} if c.db_isTransient? }
#{ %{
<%
for (java.util.Iterator<?> iter = #{c.db_getFindAllCall}.iterator(); iter.hasNext();) {
	#{c.java_qualifiedName} c=(#{c.java_qualifiedName})iter.next();

	out.println(", <a href=\\"#{c.java_Name}-new.do?doWhat=sgbd_read&id="+c.getId()+"\\">"+c.getId()+"</a>");
}
%>
} unless (c.db_isTransient? || c.java_DAOClass.empty?) }

			</li>}
			else
				%{}
			end
			}
END
				}


	write("</ul></td></tr>")
	}
write <<END
	</table>
</span>

		</div>
	</div>
<%-- TODO: html:xxx --%>
<div class="bodyBottom"></div>
<input type="hidden" name="page" value="/Welcome.do"/>
END

			struts_footer_generate
			write <<END
	</div>



</center>
</html:form>

</body>
</html:html>
END
		}
	}
end

#struts_installRessourcesObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ontomde-uml2-struts/main.rb', line 77

def struts_installRessources
	log.info "struts_installRessources disabled"
	return
	mtk_writeSession("#{context[:targetDir]}/.ontomde_java_res") {
		write("ontomde_java_res=#{Mrdf_Model::JAVALIB_DIR.gsub(/\\/,'/')}\n")
	}
	return
	build=context[:webContentDir]
	zipdir=Mrdf_Model::JAVALIB_DIR
	src1="#{zipdir}/JavaProject-WEB-INF.zip"
	tg1="#{context[:webContentDir]}/WEB-INF/"
	cmd1="unzip -q -n #{src1} -d #{tg1}"

	tg2="#{context[:webContentDir]}"
	src2="#{zipdir}/JavaProject-WebContent.zip"
	cmd2="unzip -q -n #{src2} -d #{tg2}/ "

	tg3="#{context[:javaDir]}"
	src3="#{zipdir}/JavaProject-java.zip"
	cmd3="unzip -q -n #{src3} -d #{tg3} "

	tg4="#{context[:javaDir]}"
	src4="#{zipdir}/rootZip.zip"
	cmd4="unzip -q -n #{src4} -d #{tg4} "


	if (! File.exists?(src1))
		log.info("libraries not included in this distribution. You will have to download and unzip this file in the webapp directory (#{src1},#{src2},#{src3} )")
		return
	end


	if File.exists?("#{build}/WEB-INF/lib/")
		log.info "UNZIP skipped"
	else
		FileUtils.mkdir_p(build)
		if(context[:useUnzip,false])
			log.info "UNZIP !!!"
			[cmd1,cmd2,cmd3].each { |cmd|
				raise "****\nERROR running unzip\n#{cmd}\n*****" unless system(cmd)
			}
		else
			#no unzip
			log.info "copy #{src1} to #{tg1}"
			FileUtils.cp(src1,tg1)
			log.info "copy #{src2} to #{tg2}"
			FileUtils.cp(src2,tg2)
			log.info "copy #{src3} to #{tg3}"
			FileUtils.cp(src3,tg3)
			log.info "copy #{src4} to #{tg4}"
			FileUtils.cp(src4,tg4)
			puts("************")
			puts("************")
			puts("PLEASE UNZIP #{tg1}/#{File.basename(src1)}")
			puts("PLEASE UNZIP #{tg2}/#{File.basename(src2)}")
			puts("PLEASE UNZIP #{tg3}/#{File.basename(src3)}")
			puts("PLEASE UNZIP #{tg4}/#{File.basename(src4)}")
			puts("************")
			puts("************")
		end
	end
end

#struts_springIgnore(b) ⇒ Object



41
42
43
44
45
# File 'lib/ontomde-uml2-struts/spring.rb', line 41

def struts_springIgnore(b)
	return true if b.struts_action_one0.nil?
	#return true if b.java_DAOClass_one0.nil?
	return false
end

#struts_struts_config_generateObject



17
18
19
20
21
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 17

def struts_struts_config_generate
	mtk_writeSession("#{context[:webContentDir]}/WEB-INF/struts-config.xml") {
		struts_struts_config_writeFile
	}
end

#struts_struts_config_writeFileObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 26

def struts_struts_config_writeFile
# CAUTION no CR befor <?xml> instruction
	before=<<END
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE struts-config PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
        "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
END
	after=<<END
 <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
  <set-property property="pathnames" value="/WEB-INF/validation.xml, /WEB-INF/validator-rules.xml"/>
  <set-property property="stopOnFirstError" value="true"/>
 </plug-in>
</struts-config>
END

#<!ELEMENT struts-config (data-sources?, form-beans?, global-exceptions?, global-forwards?, action-mappings?, controller?, message-resources*, plug-in*)>

	encloseWrite(before,after) {
 		struts_write_struts_config_form_beans
		struts_struts_config_writeFile_GlobalException
		struts_struts_config_writeFile_GlobalForwards
		struts_write_struts_config_action_mappings
		struts_writeSpringRequestProcess_controller
 		write(%{<!-- Message are in /WEB-INF/classes/ApplicationResources*.properties -->\n})
		write(%{<message-resources parameter="MessageResources"/>\n})
		struts_writeSpringRequestProcess_plugin
	}
end

#struts_struts_config_writeFile_GlobalExceptionObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 60

def struts_struts_config_writeFile_GlobalException
	before="<global-exceptions>"
	after="</global-exceptions>"
	encloseWrite(before,after) {
			write <<ENDEXCEPTION
	<exception
		key="errors.ioException"
		type="#{struts_getFunctionalException.java_qualifiedName}"
		path="errorPage.jsp"
		handler="#{struts_getExceptionHandlerClass.java_qualifiedName}"
	 />
ENDEXCEPTION
		}
end

#struts_struts_config_writeFile_GlobalForwardsObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 75

def struts_struts_config_writeFile_GlobalForwards
	before=<<END
<global-forwards>
	<forward name="#{Muml_Class::STRUTS_SWITCH_TO_FLEX_FORWARD}" path="#{Muml_Class::FLEX_SWITCH_TO_JSP_PATH}" />
	<forward name="#{Muml_Class::NOGIF_FORWARD}" path="/res/orange/image/noImage.gif" />
END
	after=<<END
</global-forwards>
END
	encloseWrite(before,after) {
#<!--
# <global-forwards type="org.apache.struts.webapp.examples.CustomActionForward">
#  <forward name="welcome" path="/welcome.do">
#   <set-property property="example" value="EXAMPLE"/>
#  </forward>
# </global-forwards>
#-->
		struts_struts_config_writeFile_GlobalForwards_editAction
	}
end

#struts_struts_config_writeFile_GlobalForwards_editActionObject



95
96
97
98
99
100
101
102
103
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 95

def struts_struts_config_writeFile_GlobalForwards_editAction
	eachStrutsBean { |c|
		b=c.struts_actionFormSrc_one0
		next if b.nil?
		write(%{<forward path="/#{b.java_Name}-new.do?#{Muml_Classifier::STRUTS_DISPATCH_FIELD_NAME}=#{Muml_Classifier::STRUTS_ACTION_STARTEDIT}"
			name="#{b.struts_editForwardName}" redirect="false" />\n})
	}

end

#struts_struts_config_writeFile_struts_configObject



57
58
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 57

def struts_struts_config_writeFile_struts_config
end

#struts_validation_generateObject



4
5
6
7
8
# File 'lib/ontomde-uml2-struts/validation.rb', line 4

def struts_validation_generate
	mtk_writeSession("#{context[:webContentDir]}/WEB-INF/validation.xml") {
		struts_validation_writeFile
	}
end

#struts_validation_writeFileObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ontomde-uml2-struts/validation.rb', line 10

def struts_validation_writeFile

# CAUTION no CR befor <?xml> instruction
write <<END
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE form-validation PUBLIC
     "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
     "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">

<!-- Generated by XMDA -->

<form-validation>

<!--
     This is a minimal Validator form file with a couple of examples.
-->
END

	struts_write_validation_formset
	write %{</form-validation>\n}
end

#struts_validator_generateObject



4
5
6
7
8
# File 'lib/ontomde-uml2-struts/validator.rb', line 4

def struts_validator_generate
	mtk_writeSession("#{context[:webContentDir]}/WEB-INF/validator-rules.xml") {
		struts_validator_write
	}
end

#struts_validator_writeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/ontomde-uml2-struts/validator.rb', line 22

def struts_validator_write
write <<END
<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<!--
  $Id: validator-rules.xml,v 1.1 2006/07/21 12:40:26 nacid Exp $

   This file contains the default Struts Validator pluggable validator
   definitions.  It should be placed somewhere under /WEB-INF and
   referenced in the struts-config.xml under the plug-in element
   for the ValidatorPlugIn.

      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
                                                  /WEB-INF/validation.xml"/>
      </plug-in>

   These are the default error messages associated with
   each validator defined in this file.  They should be
   added to your projects ApplicationResources.properties
   file or you can associate new ones by modifying the
   pluggable validators msg attributes in this file.

   # Struts Validator Error Messages
   errors.required={0} is required.
   errors.minlength={0} can not be less than {1} characters.
   errors.maxlength={0} can not be greater than {1} characters.
   errors.invalid={0} is invalid.

   errors.byte={0} must be a byte.
   errors.short={0} must be a short.
   errors.integer={0} must be an integer.
   errors.long={0} must be a long.
   errors.float={0} must be a float.
   errors.double={0} must be a double.

   errors.date={0} is not a date.
   errors.range={0} is not in the range {1} through {2}.
   errors.creditcard={0} is an invalid credit card number.
   errors.email={0} is an invalid e-mail address.

   Note: Starting in Struts 1.2.0 the default javascript definitions have
         been consolidated to commons-validator. The default can be overridden
         by supplying a <javascript> element with a CDATA section, just as
         in struts 1.1.

-->

<form-validation>

   <global>

      <validator name="#{struts_addValidator("required")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateRequired"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
                  msg="errors.required"/>

      <validator name="#{struts_addValidator("requiredif")}"
                 classname="org.apache.struts.validator.FieldChecks"
                 method="validateRequiredIf"
                 methodParams="java.lang.Object,
                               org.apache.commons.validator.ValidatorAction,
                               org.apache.commons.validator.Field,
                               org.apache.struts.action.ActionMessages,
                               org.apache.commons.validator.Validator,
                               javax.servlet.http.HttpServletRequest"
                 msg="errors.required"/>

      <validator name="#{struts_addValidator("validwhen")}"
          msg="errors.required"
                 classname="org.apache.struts.validator.validwhen.ValidWhen"
                 method="validateValidWhen"
                 methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"/>


      <validator name="#{struts_addValidator("minlength")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMinLength"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.minlength"
           jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>


      <validator name="#{struts_addValidator("maxlength")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMaxLength"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.maxlength"
           jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>



      <validator name="#{struts_addValidator("mask")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMask"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.invalid"/>


      <validator name="#{struts_addValidator("byte")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateByte"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.byte"
       jsFunctionName="ByteValidations"/>


      <validator name="#{struts_addValidator("short")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateShort"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.short"
       jsFunctionName="ShortValidations"/>


      <validator name="#{struts_addValidator("integer")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateInteger"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.integer"
       jsFunctionName="IntegerValidations"/>



      <validator name="#{struts_addValidator("long")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateLong"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.long"/>


      <validator name="#{struts_addValidator("float")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateFloat"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.float"
       jsFunctionName="FloatValidations"/>

      <validator name="#{struts_addValidator("double")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateDouble"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.double"/>


      <validator name="#{struts_addValidator("date")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateDate"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.date"
       jsFunctionName="DateValidations"/>


      <validator name="#{struts_addValidator("intRange")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateIntRange"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends="integer"
                  msg="errors.range"/>


      <validator name="#{struts_addValidator("floatRange")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateFloatRange"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends="float"
                  msg="errors.range"/>

      <validator name="#{struts_addValidator("doubleRange")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateDoubleRange"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends="double"
                  msg="errors.range"/>


      <validator name="#{struts_addValidator("creditCard")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateCreditCard"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.creditcard"/>


      <validator name="#{struts_addValidator("email")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateEmail"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.email"/>

      <validator name="#{struts_addValidator("url")}"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateUrl"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.url"/>

     <!--
       This simply allows struts to include the validateUtilities into a page, it should
       not be used as a validation rule.
     -->
     <validator name="includeJavaScriptUtilities"
            classname=""
               method=""
         methodParams=""
              depends=""
                  msg=""
           jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>

   </global>

</form-validation>

END
end

#struts_validatorExists?(name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ontomde-uml2-struts/validator.rb', line 18

def struts_validatorExists?(name)
	return STRUTS_VALIDATOR_NAMES.include?(name.to_s)
end

#struts_viewableClassifier(ignoreAbstract = true) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ontomde-uml2-struts/main.rb', line 26

def struts_viewableClassifier(ignoreAbstract=true)
		ret=Array.new
		uml_Class_all.each { |c|
			next unless (c.kind_of?(Muml_Class) && c.umlx_isReallyAClass?) #TODO: for jdo || c.kind_of?(Muml_Interface)
			next if c.java_ignoreMe?
			next if c.struts_isForm?
			#next if c.java_isATestFile?

      #TODO: Hack for  human task (bug if MPC in name)!
      if context[:db_useStereotypeMarker] && !"#{c.uml_name}".include?("MPC")
         next if c.db_isTransient?
      end

			next if c.db_isDAO?
			next unless c.umlx_businessMethod?
			#no struts for abstract classes
			next if c.uml_isAbstract? && ignoreAbstract
			ret<< c
		}
		return ret
end

#struts_webxml_writeObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/ontomde-uml2-struts/webXml.rb', line 122

def struts_webxml_write
  encloseWrite(STRUTS_WEBXML_HEAD,STRUTS_WEBXML_FOOT) {
    struts_writeSpringWebApplicationContext
    write <<ENDXFILTER
	<filter>
<filter-name>XmdaFilter</filter-name>
<filter-class>#{viewFilter}</filter-class>
	</filter>    
ENDXFILTER
    write STRUTS_WEBXML_ACEGI_FILTER if context[:security]  
    write STRUTS_WEBXML_XMDA_FILTER
    write STRUTS_WEBXML_ACEGI_MAPPING if context[:security]
    struts_writeSpringWebApplicationListener
  }
end

#struts_write_struts_config_action_mappingsObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 143

def struts_write_struts_config_action_mappings
#write(%{<action-mappings type="org.apache.struts.webapp.examples.CustomActionMapping"> \n})
	before=%{ <action-mappings> \n}
	after=<<END
   <action path="/Welcome" forward="/index.jsp" />
 </action-mappings>
END

      	encloseWrite(before,after) {
		write(%{#{struts_getReloadDefinitionsActionConfig}\n})
		struts_ActionLocaleWriteActionPath
		eachStrutsBean { |b|
			b.struts_write_struts_config_action_mapping
		}
	}
end

#struts_write_struts_config_form_beansObject



105
106
107
108
109
110
111
112
113
114
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 105

def struts_write_struts_config_form_beans
	write %{ <form-beans>\n}

	struts_ActionLocaleWriteActionBean

	eachStrutsBean { |b|
		b.struts_write_struts_config_form_bean
	}
    write %{ </form-beans>\n}
end

#struts_write_validation_formsetObject



32
33
34
35
36
37
38
# File 'lib/ontomde-uml2-struts/validation.rb', line 32

def struts_write_validation_formset
	write %{	<formset>\n}
	eachStrutsFormset { |b|
		b.struts_write_validation_config_formset
	}
    write %{	</formset>\n}
end

#struts_writeSpringApplicationContextObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ontomde-uml2-struts/spring.rb', line 12

def struts_writeSpringApplicationContext

write <<END
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

	<!-- ===========================actions struts ================================ -->

	#{mtk_stss { struts_writeSpringStrutsBean }}

	<!-- ============================================ DAO beans =================================== -->

	#{mtk_stss { struts_writeSpringBean }}

	<!-- scope="prototype" because PersistenceContextType is extended and thus not thread safe. We need to have a single private PersistenceContext for the duration of the transaction. We need EXTENTED because SGBD need to be accessed read-only from JSPs, after transaction has been committed -->
	<bean id="#{Muml_Class::DB_Context.gsub(/^.*\./,'')}" class="#{Muml_Class::DB_Context}" scope="prototype" />
	<bean class="#{Muml_Class::DB_Context}$#{Muml_Class::DB_Context.gsub(/^.*\./,'')}SpringContext" />
</beans>
END

end

#struts_writeSpringBeanObject



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ontomde-uml2-struts/spring.rb', line 75

def struts_writeSpringBean
	# beans are no longer spring beans
	return
	eachStrutsBean { |b|
		next if struts_springIgnore(b)
		dao=b.java_DAOClass_one
		if b.uml_isAbstract?
			write("<!-- ignore abstract : #{b.java_Name} -->\n")
		else
			write %{<bean id="#{dao.java_Name}" class="#{dao.java_qualifiedName}" />\n}
		end
	}
end

#struts_writeSpringRequestProcess_controllerObject

struts-config configuration for spring



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 117

def struts_writeSpringRequestProcess_controller
	return unless context[:struts_useSpring]
	write <<END
<controller>
  <set-property
     property="processorClass"
     value="org.springframework.web.struts.DelegatingRequestProcessor"
  />
</controller>
END
end

#struts_writeSpringRequestProcess_pluginObject



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/ontomde-uml2-struts/struts-config.rb', line 129

def struts_writeSpringRequestProcess_plugin
  return
	return unless context[:struts_useSpring]
	write <<END
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property
     property="contextConfigLocation"
     value="/WEB-INF/applicationContext.xml, /WEB-INF/applicationContext-jpa.xml"
  />
</plug-in>
END
end

#struts_writeSpringStrutsBeanObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ontomde-uml2-struts/spring.rb', line 46

def struts_writeSpringStrutsBean
	eachStrutsBean { |b|
		next if struts_springIgnore(b)
		#puts "b=#{b.java_qualifiedName}"

		if b.struts_action_one.nil?
			#puts "!!!! #{b} n'a pas de struts_action"
			next
		end
	suffixes=["-new"]
	b.struts_ownedTab.each {|tab|
		idOnglet=tab.java_Name_one
		suffixes<< "#{idOnglet}-submit"
		}
	suffixes.each { |suffix|
	if b.uml_isAbstract?
		write("<!-- ignore abstract : #{b.java_Name} -->\n")
	else
		write <<END
	<bean	name="/#{b.java_Name}#{suffix}"
		parent="txProxyTemplate"
		scope="session">
		<property name="target"><bean class="#{b.struts_action_one.java_qualifiedName}"/></property>
	</bean>
END
		end
	}}
end

#struts_writeSpringWebApplicationContextObject



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ontomde-uml2-struts/webXml.rb', line 138

def struts_writeSpringWebApplicationContext
  return unless context[:struts_useSpring]
  
  write <<END12
	<!-- begin of spring section -->
	<context-param>
<param-name>webAppRootKey</param-name>
<param-value>xmda-struts.root</param-value>
	</context-param>
	<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
	</context-param>
	<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml, /WEB-INF/applicationContext-jpa.xml
#{ %{, /WEB-INF/applicationContext-security.xml} if context[:security] }
  </param-value>
  </context-param>
END12
end

#struts_writeSpringWebApplicationListenerObject



160
161
162
163
# File 'lib/ontomde-uml2-struts/webXml.rb', line 160

def struts_writeSpringWebApplicationListener
  return unless context[:struts_useSpring]
  write STRUTS_SPRING_LISTENER 
end

#viewFilterObject



10
11
12
13
14
15
16
# File 'lib/ontomde-uml2-struts/webXml.rb', line 10

def viewFilter
  if context[:struts_useSpring]
    return "xmda.jpa.OpenDbContextInViewFilter"
  else
    return "xmda.jpa.OpenJEEDbContextInViewFilter"
  end
end