|
10 | 10 | *******************************************************************************/ |
11 | 11 | package org.obeonetwork.database.m2doc.services; |
12 | 12 |
|
| 13 | +import java.io.IOException; |
13 | 14 | import java.util.ArrayList; |
14 | 15 | import java.util.HashSet; |
15 | 16 | import java.util.List; |
16 | 17 | import java.util.Set; |
17 | 18 |
|
18 | 19 | import org.eclipse.acceleo.annotations.api.documentation.Documentation; |
19 | 20 | import org.eclipse.acceleo.annotations.api.documentation.Example; |
| 21 | +import org.eclipse.sirius.business.api.query.EObjectQuery; |
| 22 | +import org.eclipse.sirius.business.api.session.Session; |
| 23 | +import org.eclipse.sirius.ui.tools.api.actions.export.SizeTooLargeException; |
20 | 24 | import org.obeonetwork.dsl.database.AbstractTable; |
21 | 25 | import org.obeonetwork.dsl.database.DataBase; |
22 | 26 | import org.obeonetwork.dsl.database.ForeignKey; |
|
25 | 29 | import org.obeonetwork.dsl.database.Table; |
26 | 30 | import org.obeonetwork.dsl.database.TableContainer; |
27 | 31 | import org.obeonetwork.dsl.database.View; |
| 32 | +import org.obeonetwork.dsl.database.design.IDatabaseViewpointConstants; |
28 | 33 | import org.obeonetwork.dsl.database.util.DatabaseSwitch; |
29 | 34 | import org.obeonetwork.dsl.typeslibrary.NativeTypesLibrary; |
30 | 35 | import org.obeonetwork.dsl.typeslibrary.TypesLibrary; |
| 36 | +import org.obeonetwork.m2doc.element.MImage; |
| 37 | +import org.obeonetwork.m2doc.sirius.services.M2DocSiriusServices; |
31 | 38 |
|
32 | 39 | /** |
33 | 40 | * AQL Services for M2Doc. |
@@ -193,6 +200,131 @@ public List<Sequence> localSequences(DataBase db) { |
193 | 200 | return result; |
194 | 201 | } |
195 | 202 |
|
| 203 | + // @formatter:off |
| 204 | + @Documentation( |
| 205 | + comment = "{m:database.asDatabaseImage()}", |
| 206 | + value = "Returns a collection of images representing the target Database Database Diagrams.", |
| 207 | + examples = { |
| 208 | + @Example( |
| 209 | + expression = "{m:database.asDatabaseImage()}", |
| 210 | + result = "A sequence of images.") |
| 211 | + } |
| 212 | + ) |
| 213 | + // @formatter:on |
| 214 | + public List<MImage> asDatabaseImage(DataBase database) throws SizeTooLargeException, IOException { |
| 215 | + Session session = new EObjectQuery(database).getSession(); |
| 216 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 217 | + IDatabaseViewpointConstants.DATABASE_DIAGRAM_ID); |
| 218 | + |
| 219 | + return images; |
| 220 | + } |
| 221 | + |
| 222 | + // @formatter:off |
| 223 | + @Documentation( |
| 224 | + comment = "{m:database.asDatabaseImage(width)}", |
| 225 | + value = "Returns a collection of images representing the target Database Database Diagrams scaled to the given width keeping the initial image ratio.", |
| 226 | + examples = { |
| 227 | + @Example( |
| 228 | + expression = "{m:database.asDatabaseImage(400)}", |
| 229 | + result = "A sequence of images.") |
| 230 | + } |
| 231 | + ) |
| 232 | + // @formatter:on |
| 233 | + public List<MImage> asDatabaseImage(DataBase database, int width) throws SizeTooLargeException, IOException { |
| 234 | + Session session = new EObjectQuery(database).getSession(); |
| 235 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 236 | + IDatabaseViewpointConstants.DATABASE_DIAGRAM_ID); |
| 237 | + images.forEach(i -> i.conserveRatio()); |
| 238 | + images.forEach(i -> i.setWidth(width)); |
| 239 | + |
| 240 | + return images; |
| 241 | + } |
| 242 | + |
| 243 | + // @formatter:off |
| 244 | + @Documentation( |
| 245 | + comment = "{m:database.asDatabaseImage(width, height)}", |
| 246 | + value = "Returns a collection of images representing the target Database Database Diagrams scaled to the given width and heigth.", |
| 247 | + examples = { |
| 248 | + @Example( |
| 249 | + expression = "{m:database.asDatabaseImage(400, 300)}", |
| 250 | + result = "A sequence of images.") |
| 251 | + } |
| 252 | + ) |
| 253 | + // @formatter:on |
| 254 | + public List<MImage> asDatabaseImage(DataBase database, int width, int height) |
| 255 | + throws SizeTooLargeException, IOException { |
| 256 | + Session session = new EObjectQuery(database).getSession(); |
| 257 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 258 | + IDatabaseViewpointConstants.DATABASE_DIAGRAM_ID); |
| 259 | + images.forEach(i -> i.setHeight(height)); |
| 260 | + images.forEach(i -> i.setWidth(width)); |
| 261 | + |
| 262 | + return images; |
| 263 | + } |
| 264 | + |
| 265 | + // @formatter:off |
| 266 | + @Documentation( |
| 267 | + comment = "{m:database.asDatabasePartialViewImage()}", |
| 268 | + value = "Returns a collection of images representing the target Database Database Partial View Diagrams.", |
| 269 | + examples = { |
| 270 | + @Example( |
| 271 | + expression = "{m:database.asDatabasePartialViewImage()}", |
| 272 | + result = "A sequence of images.") |
| 273 | + } |
| 274 | + ) |
| 275 | + // @formatter:on |
| 276 | + public List<MImage> asDatabasePartialViewImage(DataBase database) throws SizeTooLargeException, IOException { |
| 277 | + Session session = new EObjectQuery(database).getSession(); |
| 278 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 279 | + IDatabaseViewpointConstants.DATABASE_PARTIAL_VIEW_DIAGRAM_ID); |
| 280 | + |
| 281 | + return images; |
| 282 | + } |
| 283 | + |
| 284 | + // @formatter:off |
| 285 | + @Documentation( |
| 286 | + comment = "{m:database.asDatabasePartialViewImage(width)}", |
| 287 | + value = "Returns a collection of images representing the target Database Database Partial View Diagrams scaled to the given width keeping the initial image ratio.", |
| 288 | + examples = { |
| 289 | + @Example( |
| 290 | + expression = "{m:database.asDatabasePartialViewImage(400)}", |
| 291 | + result = "A sequence of images.") |
| 292 | + } |
| 293 | + ) |
| 294 | + // @formatter:on |
| 295 | + public List<MImage> asDatabasePartialViewImage(DataBase database, int width) |
| 296 | + throws SizeTooLargeException, IOException { |
| 297 | + Session session = new EObjectQuery(database).getSession(); |
| 298 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 299 | + IDatabaseViewpointConstants.DATABASE_PARTIAL_VIEW_DIAGRAM_ID); |
| 300 | + images.forEach(i -> i.conserveRatio()); |
| 301 | + images.forEach(i -> i.setWidth(width)); |
| 302 | + |
| 303 | + return images; |
| 304 | + } |
| 305 | + |
| 306 | + // @formatter:off |
| 307 | + @Documentation( |
| 308 | + comment = "{m:database.asDatabasePartialViewImage(width, height)}", |
| 309 | + value = "Returns a collection of images representing the target Database Database Partial View Diagrams scaled to the given width and heigth.", |
| 310 | + examples = { |
| 311 | + @Example( |
| 312 | + expression = "{m:database.asDatabasePartialViewImage(400, 300)}", |
| 313 | + result = "A sequence of images.") |
| 314 | + } |
| 315 | + ) |
| 316 | + // @formatter:on |
| 317 | + public List<MImage> asDatabasePartialViewImage(DataBase database, int width, int height) |
| 318 | + throws SizeTooLargeException, IOException { |
| 319 | + Session session = new EObjectQuery(database).getSession(); |
| 320 | + List<MImage> images = new M2DocSiriusServices(session, true).asImageByRepresentationDescriptionName(database, |
| 321 | + IDatabaseViewpointConstants.DATABASE_PARTIAL_VIEW_DIAGRAM_ID); |
| 322 | + images.forEach(i -> i.setHeight(height)); |
| 323 | + images.forEach(i -> i.setWidth(width)); |
| 324 | + |
| 325 | + return images; |
| 326 | + } |
| 327 | + |
196 | 328 | /** |
197 | 329 | * Switch class used to collect the tables of a data base. |
198 | 330 | * |
|
0 commit comments