Top Level Namespace

Defined Under Namespace

Modules: Ontomde

Constant Summary collapse

RSM6_PLUGIN_VERSION =
Ontomde::Plugin::Rsm6::VERSION

Instance Method Summary collapse

Instance Method Details

#plugin_install(rsm_plugin) ⇒ Object



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
# File 'lib/ontomde-plugin-rsm6.rb', line 139

def plugin_install(rsm_plugin)
	s="************************************************"
	puts s

	zip_file="#{File.dirname(__FILE__)}/../dist/fr.ft.emf2rdf_#{RSM6_PLUGIN_VERSION}/"
	#puts ">Performing internal check."
	if !File.exists?(zip_file+"/plugin.xml")
		puts s
		puts "** Internal error : missing plugin file version #{RSM6_PLUGIN_VERSION}."
		puts "#{zip_file}"
		puts s
		exit 1
	end

	puts "unziping plugin to :\n   \"#{rsm_plugin}\""
	cp_r(zip_file,rsm_plugin)

	#File.chdir "#{zip_file}/../"
	#FileList["fr.ft.emf2rdf_#{RSM6_PLUGIN_VERSION}/**/*" ].each { |f|
	#	puts "installing #{f}"
	#	.copy("#{f}","c:/tmp/#{f}")
	#}


	puts "checking installation"
	plugin_file=rsm_plugin+"/fr.ft.emf2rdf_#{RSM6_PLUGIN_VERSION}/plugin.xml"

	if !File.exists?(plugin_file)
		puts s
		puts "** Internal error during installation."
		puts s
		puts "diagnostic:"
		puts "  RSM_HOME=\"#{rsm_home}\""
		puts s
		exit(1)
	end 

	puts ""
	puts s
	puts "** installation successful. Restart RSM."
	puts s

end

#rsm6_install_plugin(scriptName) ⇒ Object



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
131
132
133
134
135
136
137
138
# File 'lib/ontomde-plugin-rsm6.rb', line 8

def rsm6_install_plugin(scriptName)
	s="************************************************"
	puts s
	puts "** Installation program for RSM rdfmda plugin v:#{RSM6_PLUGIN_VERSION} **"
	puts s
	puts ""
  options = {}
  options[:rsm]=nil

  #cf: http://www.ruby-doc.org/core/classes/OptionParser.html
  OptionParser.new do |opts|
    opts.banner =<<ENDHELP 
Usage: #{scriptName} [options]
------------------------------------------------------
#{scriptName} converts a UML2/RDF model file 
into a protege 2000 knowledge base.

Example:
  $ #{scriptName} --rsm6 myUmlModel.emx.nt
  will generate these Protege files:
     * myUmlModel.emx.nt_kb.pprj
     * myUmlModel.emx.nt_kb.rdf
     * myUmlModel.emx.nt_kb.rdfs
------------------------------------------------------
ENDHELP

    opts.on("-v", "--[no|-verbose", "Run in verbose mode") do |v|
      options[:verbose] = v
    end

    opts.on("-r","--rsm DIRECTORY",Array,"RSM 6 Directory") do |v|
      options[:rsm]=v
    end

    opts.on("-n","--no_default","Do not use default settings","option used primarily used for testing") do |v|
      options[:no_default]=v
    end

    opts.separator ""
    opts.separator "Common options:"

    # No argument, shows at tail.  This will print an options summary.
    # Try it and see!
    opts.on_tail("-h", "--help", "Show this message") do
        puts opts
        exit
    end

  end.parse!
["RSM6_HOME", "RSM_HOME"].each { |v|
	if options[:rsm].nil? && !ENV[v].nil?
		puts "NOTE: using environment variable #{v}"
		puts "#{v}=#{ENV[v]}"
		puts ""
		options[:rsm]=[ENV[v]]
	end
}	
if options[:rsm].nil? && !options[:no_default]
	puts "NOTE: using default RSM6 installation directory"
	options[:rsm]=[".","C:\\Program Files\\IBM\\Rational\\SDP\\6.0"]
end

if ARGV.length > 0
   puts "Incorrect syntax used"
   puts "parameter #{ARGV} was not understood"
   puts "Please refer to documentation with :"
   puts "> #{scripName} --help"

end

[:rsm].each { |p|
	puts "--#{p}=#{options[p]}" if options[:verbose]
	next unless options[p].nil? 
	m="--#{p} parameter is mandatory"
	puts("")
	puts(m)
	puts("For command syntax :")
	puts("#{File.basename(__FILE__)} --help")
	puts("")
        raise Exception.new(m)
}


options[:rsm].each { |rsm_home|
	tab="   "
	puts "looking for IBM RSM in directory :\n\"#{rsm_home}\"."
	if !File.exist?(rsm_home)
		puts "ERROR: \"#{rsm_home}\" is not a directory."
		next
	end
	rsm_plugin=rsm_home+'/radrsm_shared/eclipse/plugins/'
	#puts "STEP 2: looking for plugin directory: #{rsm_plugin}"
	if !File.exist?(rsm_plugin)
		#puts "#{tab}Plugin directory not found in \"#{rsm_home}\""
		puts "ERROR: \"#{rsm_home}\" is not a rsm6 directory ."
		next
	end

	plugin_install(rsm_plugin)
	puts "done !" 
	exit(0)
}

	puts <<END
RSM directory was not found.
Please provide #{scriptName} the correct RSM6 installation directory.

Option 1) Use RSM6_HOME environnement variable.
> #{scriptName}

Option 2) Provide RSM directory on the command line. 
> #{scriptName} --rsm6 "C:\\Program Files\\IBM\\Rational\\SDP\\6.0"

Option 3) Launch #{scriptName} from RSM6 directory
> cd <RSM6 DIRECTORY>
> #{scriptName}

NOTE: The root directory of RSM is the directory 
      containing the following folders:
      * radrsm_shared
      * rsm_prod
      * setup
      * ...
END

	puts "*******************************************"
	puts "Plugin installation was **not** successful."
	puts "*******************************************"
	exit

end