Add login page.
[demoscenemusic.git] / src / main / java / net / pterodactylus / demoscenemusic / data / DataManager.java
1 /*
2  * DemosceneMusic - DataManager.java - Copyright © 2012 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.demoscenemusic.data;
19
20 import java.sql.ResultSet;
21 import java.sql.SQLException;
22 import java.util.Collection;
23 import java.util.EnumMap;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.concurrent.Callable;
28
29 import net.pterodactylus.demoscenemusic.data.Track.Relationship;
30 import net.pterodactylus.util.collection.Memoizer;
31 import net.pterodactylus.util.database.Database;
32 import net.pterodactylus.util.database.DatabaseException;
33 import net.pterodactylus.util.database.Field;
34 import net.pterodactylus.util.database.Join;
35 import net.pterodactylus.util.database.Join.JoinType;
36 import net.pterodactylus.util.database.ObjectCreator;
37 import net.pterodactylus.util.database.ObjectCreator.StringCreator;
38 import net.pterodactylus.util.database.OrderField;
39 import net.pterodactylus.util.database.Parameter.StringParameter;
40 import net.pterodactylus.util.database.Query;
41 import net.pterodactylus.util.database.Query.Type;
42 import net.pterodactylus.util.database.ResultProcessor;
43 import net.pterodactylus.util.database.ValueField;
44 import net.pterodactylus.util.database.ValueFieldWhereClause;
45
46 /**
47  * Interface between the database and the application.
48  *
49  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
50  */
51 public class DataManager {
52
53         /** The artist object creator. */
54         @SuppressWarnings("synthetic-access")
55         private final ObjectCreator<Artist> artistCreator = new ArtistCreator();
56
57         /** The group object creator. */
58         @SuppressWarnings("synthetic-access")
59         private final ObjectCreator<Group> groupCreator = new GroupCreator();
60
61         /** The track object creator. */
62         @SuppressWarnings("synthetic-access")
63         private final ObjectCreator<Track> trackCreator = new TrackCreator();
64
65         /** The style object creator. */
66         @SuppressWarnings("synthetic-access")
67         private final ObjectCreator<Style> styleCreator = new StyleCreator();
68
69         /** The {@link User} object creator. */
70         @SuppressWarnings("synthetic-access")
71         private final ObjectCreator<User> userCreator = new UserCreator();
72
73         /** The database. */
74         private final Database database;
75
76         /**
77          * Creates a new data manager.
78          *
79          * @param database
80          *            The database to operate on
81          */
82         public DataManager(Database database) {
83                 this.database = database;
84         }
85
86         /**
87          * Returns all artists.
88          *
89          * @return All artists
90          * @throws DatabaseException
91          *             if a database error occurs
92          */
93         public Collection<Artist> getAllArtists() throws DatabaseException {
94                 Query query = new Query(Type.SELECT, "ARTISTS");
95                 query.addField(new Field("ARTISTS.*"));
96                 return database.getMultiple(query, artistCreator);
97         }
98
99         /**
100          * Returns the artist with the given ID.
101          *
102          * @param id
103          *            The ID of the artist
104          * @return The artist with the given ID, or {@code null} if there is no
105          *         artist with the given ID
106          * @throws DatabaseException
107          *             if a database error occurs
108          */
109         public Artist getArtistById(String id) throws DatabaseException {
110                 Query query = new Query(Type.SELECT, "ARTISTS");
111                 query.addField(new Field("ARTISTS.*"));
112                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("ARTISTS.ID", new StringParameter(id))));
113                 return database.getSingle(query, artistCreator);
114         }
115
116         /**
117          * Returns all artists that belong to the group with the given ID.
118          *
119          * @param groupId
120          *            The ID of the group
121          * @return All artists belonging to the given group
122          * @throws DatabaseException
123          *             if a database error occurs
124          */
125         public Collection<Artist> getArtistsByGroup(String groupId) throws DatabaseException {
126                 Query query = new Query(Type.SELECT, "ARTISTS");
127                 query.addField(new Field("ARTISTS.*"));
128                 query.addJoin(new Join(JoinType.INNER, "GROUP_ARTISTS", new Field("ARTISTS.ID"), new Field("GROUP_ARTISTS.ARTIST")));
129                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("GROUP_ARTISTS.GROUP_", new StringParameter(groupId))));
130                 return database.getMultiple(query, artistCreator);
131         }
132
133         /**
134          * Returns all artists involved in the track with the given ID.
135          *
136          * @param trackId
137          *            The ID of the track
138          * @return All artists involved in the track, in preferred order
139          * @throws DatabaseException
140          *             if a database error occurs
141          */
142         public List<Artist> getArtistsByTrack(String trackId) throws DatabaseException {
143                 Query query = new Query(Type.SELECT, "ARTISTS");
144                 query.addField(new Field("ARTISTS.*"));
145                 query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACK_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
146                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.TRACK", new StringParameter(trackId))));
147                 query.addOrderField(new OrderField(new Field("TRACK_ARTISTS.DISPLAY_ORDER")));
148                 return database.getMultiple(query, artistCreator);
149         }
150
151         /**
152          * Returns all remix artists involved in the track with the given ID.
153          *
154          * @param trackId
155          *            The ID of the track
156          * @return All remix artists involved in the track, in preferred order
157          * @throws DatabaseException
158          *             if a database error occurs
159          */
160         public List<Artist> getRemixArtistsByTrack(String trackId) throws DatabaseException {
161                 Query query = new Query(Type.SELECT, "ARTISTS");
162                 query.addField(new Field("ARTISTS.*"));
163                 query.addJoin(new Join(JoinType.INNER, "TRACK_REMIX_ARTISTS", new Field("TRACK_REMIX_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
164                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_REMIX_ARTISTS.TRACK", new StringParameter(trackId))));
165                 query.addOrderField(new OrderField(new Field("TRACK_REMIX_ARTISTS.DISPLAY_ORDER")));
166                 return database.getMultiple(query, artistCreator);
167         }
168
169         /**
170          * Returns all related tracks for the track with the given ID.
171          *
172          * @param trackId
173          *            The ID of the tracks
174          * @return A mapping from relationship to all tracks that match the relation
175          * @throws DatabaseException
176          *             if a database error occurs
177          */
178         public Map<Relationship, Collection<Track>> getRelatedTracksByTrack(String trackId) throws DatabaseException {
179                 Query query = new Query(Type.SELECT, "TRACKS");
180                 query.addField(new Field("TRACKS.*"));
181                 query.addField(new Field("TRACK_RELATIONS.*"));
182                 query.addJoin(new Join(JoinType.INNER, "TRACK_RELATIONS", new Field("TRACK_RELATIONS.TRACK"), new Field("TRACK_RELATIONS.RELATED_TRACK")));
183                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_RELATIONS.TRACK", new StringParameter(trackId))));
184                 final Map<Relationship, Collection<Track>> relatedTracks = new EnumMap<Relationship, Collection<Track>>(Relationship.class);
185                 database.process(query, new ResultProcessor() {
186
187                         @Override
188                         @SuppressWarnings("synthetic-access")
189                         public void processResult(ResultSet resultSet) throws SQLException {
190                                 Track track = trackCreator.createObject(resultSet);
191                                 Relationship relationship = Relationship.valueOf(resultSet.getString("TRACK_RELATIONS.RELATIONSHIP"));
192                                 if (!relatedTracks.containsKey(relationship)) {
193                                         relatedTracks.put(relationship, new HashSet<Track>());
194                                 }
195                                 relatedTracks.get(relationship).add(track);
196                         }
197                 });
198                 return relatedTracks;
199         }
200
201         /**
202          * Returns the track with the given ID.
203          *
204          * @param id
205          *            The ID of the track
206          * @return The track with the given ID, or {@code null} if there is no such
207          *         track
208          * @throws DatabaseException
209          *             if a database error occurs
210          */
211         public Track getTrackById(String id) throws DatabaseException {
212                 Query query = new Query(Type.SELECT, "TRACKS");
213                 query.addField(new Field("TRACKS.*"));
214                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACKS.ID", new StringParameter(id))));
215                 return database.getSingle(query, trackCreator);
216         }
217
218         /**
219          * Returns all tracks by the artist with the given ID.
220          *
221          * @param artistId
222          *            The ID of the artist
223          * @return All tracks by the given artist
224          * @throws DatabaseException
225          *             if a database error occurs
226          */
227         public Collection<Track> getTracksByArtist(String artistId) throws DatabaseException {
228                 Query query = new Query(Type.SELECT, "TRACKS");
229                 query.addField(new Field("TRACKS.*"));
230                 query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACKS.ID"), new Field("TRACK_ARTISTS.TRACK")));
231                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.ARTIST", new StringParameter(artistId))));
232                 return database.getMultiple(query, trackCreator);
233         }
234
235         /**
236          * Returns all groups the artist with the given ID belongs to.
237          *
238          * @param artistId
239          *            The ID of the artist
240          * @return All groups the artist belongs to
241          * @throws DatabaseException
242          *             if a database error occurs
243          */
244         public Collection<Group> getGroupsByArtist(String artistId) throws DatabaseException {
245                 Query query = new Query(Type.SELECT, "GROUPS");
246                 query.addField(new Field("GROUPS.*"));
247                 query.addJoin(new Join(JoinType.INNER, "GROUP_ARTISTS", new Field("GROUPS.ID"), new Field("GROUP_ARTISTS.GROUP_")));
248                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("GROUP_ARTISTS.ARTIST", new StringParameter(artistId))));
249                 return database.getMultiple(query, groupCreator);
250         }
251
252         /**
253          * Returns all styles for the track with the given ID.
254          *
255          * @param trackId
256          *            The ID of the track
257          * @return All styles for the given track
258          * @throws DatabaseException
259          *             if a database error occurs
260          */
261         public Collection<Style> getStylesByTrack(String trackId) throws DatabaseException {
262                 Query query = new Query(Type.SELECT, "STYLES");
263                 query.addField(new Field("STYLES.*"));
264                 query.addJoin(new Join(JoinType.INNER, "TRACK_STYLES", new Field("STYLES.ID"), new Field("TRACK_STYLES.STYLE")));
265                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_STYLES.TRACK", new StringParameter(trackId))));
266                 return database.getMultiple(query, styleCreator);
267         }
268
269         /**
270          * Returns the user with the given name.
271          *
272          * @param username
273          *            The name of the user
274          * @return The user, or {@code null} if the user does not exist
275          * @throws DatabaseException
276          *             if a database error occurs
277          */
278         public User getUserByName(String username) throws DatabaseException {
279                 Query query = new Query(Type.SELECT, "USERS");
280                 query.addField(new Field("USERS.*"));
281                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("USERS.NAME", new StringParameter(username))));
282                 return database.getSingle(query, userCreator);
283         }
284
285         /**
286          * Returns the user connected with the given OpenID.
287          *
288          * @param openId
289          *            The OpenID to find the user for
290          * @return The user connected with the given OpenID, or {@code null} if
291          *         there is no such user
292          * @throws DatabaseException
293          *             if a database error occurs
294          */
295         public User getUserByOpenId(String openId) throws DatabaseException {
296                 Query query = new Query(Type.SELECT, "USERS");
297                 query.addField(new Field("USERS.*"));
298                 query.addJoin(new Join(JoinType.INNER, "USER_OPENIDS", new Field("USER_OPENIDS.USER"), new Field("USERS.ID")));
299                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("USER_OPENIDS.OPENID", new StringParameter(openId))));
300                 return database.getSingle(query, userCreator);
301         }
302
303         /**
304          * Returns all OpenIDs connected with the user with the given ID.
305          *
306          * @param userId
307          *            The ID of the user
308          * @return All OpenIDs connected with the given user
309          * @throws DatabaseException
310          *             if a database error occurs
311          */
312         public Collection<String> getOpenIdsByUser(String userId) throws DatabaseException {
313                 Query query = new Query(Type.SELECT, "USER_OPENIDS");
314                 query.addField(new Field("USER_OPENIDS.*"));
315                 query.addWhereClause(new ValueFieldWhereClause(new ValueField("USER_OPENIDS.USER", new StringParameter(userId))));
316                 return database.getMultiple(query, new StringCreator("USER_OPENIDS.OPENID"));
317         }
318
319         /**
320          * {@link Artist} implementation that retrieves some attributes (such as
321          * {@link #getGroups()}, and {@link #getTracks()}) from the
322          * {@link DataManager} on demand.
323          *
324          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
325          */
326         private class LazyArtist extends DefaultArtist {
327
328                 /** Memoizer for the tracks by this artist. */
329                 private final Memoizer<Void> tracksMemoizer = new Memoizer<Void>(new Callable<Void>() {
330                         @Override
331                         public Void call() throws DatabaseException {
332                                 if (!hasValue("tracks")) {
333                                         getValue("tracks", Collection.class).set(getTracksByArtist(getId()));
334                                 }
335                                 return null;
336                         }
337                 });
338
339                 /** Memoizer for the groups of this artist. */
340                 private final Memoizer<Void> groupsMemoizer = new Memoizer<Void>(new Callable<Void>() {
341
342                         @Override
343                         public Void call() throws Exception {
344                                 if (!hasValue("groups")) {
345                                         getValue("groups", Collection.class).set(getGroupsByArtist(getId()));
346                                 }
347                                 return null;
348                         }
349
350                 });
351
352                 /**
353                  * Creates a new lazy artist.
354                  *
355                  * @param id
356                  *            The ID of the artist
357                  */
358                 public LazyArtist(String id) {
359                         super(id);
360                 }
361
362                 //
363                 // DEFAULTARTIST METHODS
364                 //
365
366                 /**
367                  * {@inheritDoc}
368                  */
369                 @Override
370                 public Collection<Group> getGroups() {
371                         groupsMemoizer.get();
372                         return super.getGroups();
373                 }
374
375                 /**
376                  * {@inheritDoc}
377                  */
378                 @Override
379                 public Collection<Track> getTracks() {
380                         tracksMemoizer.get();
381                         return super.getTracks();
382                 }
383
384         }
385
386         /**
387          * {@link ObjectCreator} implementation that can create {@link Artist}
388          * objects. This specific class actually creates {@link LazyArtist}
389          * instances.
390          *
391          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
392          */
393         private class ArtistCreator implements ObjectCreator<Artist> {
394
395                 /**
396                  * {@inheritDoc}
397                  */
398                 @Override
399                 public Artist createObject(ResultSet resultSet) throws SQLException {
400                         return new LazyArtist(resultSet.getString("ARTISTS.ID")).setName(resultSet.getString("ARTISTS.NAME"));
401                 }
402
403         }
404
405         /**
406          * {@link Group} implementation that retrieves some attributes (such as
407          * {@link #getArtists()}) from the {@link DataManager} on demand.
408          *
409          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
410          */
411         private class LazyGroup extends DefaultGroup {
412
413                 /** Memoizer for the artist. */
414                 private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
415
416                         @Override
417                         public Void call() throws Exception {
418                                 if (!hasValue("artists")) {
419                                         getValue("artists", Collection.class).set(getArtistsByGroup(getId()));
420                                 }
421                                 return null;
422                         }
423
424                 });
425
426                 /**
427                  * Creates a new lazy group.
428                  *
429                  * @param id
430                  *            The ID of the group
431                  */
432                 public LazyGroup(String id) {
433                         super(id);
434                 }
435
436                 //
437                 // DEFAULTGROUP METHODS
438                 //
439
440                 /**
441                  * {@inheritDoc}
442                  */
443                 @Override
444                 public Collection<Artist> getArtists() {
445                         artistsMemoizer.get();
446                         return super.getArtists();
447                 }
448
449         }
450
451         /**
452          * {@link ObjectCreator} implementation that can create {@link Group}
453          * objects. This specific implementation creates {@link LazyGroup}
454          * instances.
455          *
456          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
457          */
458         private class GroupCreator implements ObjectCreator<Group> {
459
460                 /**
461                  * {@inheritDoc}
462                  */
463                 @Override
464                 public Group createObject(ResultSet resultSet) throws SQLException {
465                         return new LazyGroup(resultSet.getString("GROUPS.ID")).setName(resultSet.getString("GROUPS.NAME")).setUrl(resultSet.getString("GROUPS.URL"));
466                 }
467
468         }
469
470         /**
471          * {@link Track} implementation that retrieves some attributes (such as
472          * {@link #getArtists()}, and {@link #getStyles()}) from the
473          * {@link DataManager} on demand.
474          *
475          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
476          */
477         private class LazyTrack extends DefaultTrack {
478
479                 /** Memoizer for the artists. */
480                 private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
481
482                         @Override
483                         public Void call() throws Exception {
484                                 if (!hasValue("artists")) {
485                                         getValue("artists", List.class).set(getArtistsByTrack(getId()));
486                                 }
487                                 return null;
488                         }
489
490                 });
491
492                 /** Memoizer for the styles. */
493                 private final Memoizer<Void> stylesMemoizer = new Memoizer<Void>(new Callable<Void>() {
494
495                         @Override
496                         public Void call() throws Exception {
497                                 if (!hasValue("styles")) {
498                                         getValue("styles", Collection.class).set(getStylesByTrack(getId()));
499                                 }
500                                 return null;
501                         }
502
503                 });
504
505                 /** Memoizer for the remix artists. */
506                 private final Memoizer<Void> remixArtistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
507
508                         @Override
509                         public Void call() throws Exception {
510                                 if (!hasValue("remixArtists")) {
511                                         getValue("remixArtists", List.class).set(getRemixArtistsByTrack(getId()));
512                                 }
513                                 return null;
514                         }
515
516                 });
517
518                 /** Memoizer for the related tracks. */
519                 private final Memoizer<Void> relatedTracksMemoizer = new Memoizer<Void>(new Callable<Void>() {
520
521                         @Override
522                         public Void call() throws Exception {
523                                 if (!hasValue("relatedTracks")) {
524                                         getValue("relatedTracks", Map.class).set(getRelatedTracksByTrack(getId()));
525                                 }
526                                 return null;
527                         }
528                 });
529
530                 /**
531                  * Creates a new track.
532                  *
533                  * @param id
534                  *            The ID of the track
535                  */
536                 public LazyTrack(String id) {
537                         super(id);
538                 }
539
540                 //
541                 // DEFAULTTRACK METHODS
542                 //
543
544                 /**
545                  * {@inheritDoc}
546                  */
547                 @Override
548                 public List<Artist> getArtists() {
549                         artistsMemoizer.get();
550                         return super.getArtists();
551                 }
552
553                 /**
554                  * {@inheritDoc}
555                  */
556                 @Override
557                 public Collection<Style> getStyles() {
558                         stylesMemoizer.get();
559                         return super.getStyles();
560                 }
561
562                 /**
563                  * {@inheritDoc}
564                  */
565                 @Override
566                 public List<Artist> getRemixArtists() {
567                         remixArtistsMemoizer.get();
568                         return super.getRemixArtists();
569                 }
570
571                 /**
572                  * {@inheritDoc}
573                  */
574                 @Override
575                 public Map<Relationship, Collection<Track>> getRelatedTracks() {
576                         relatedTracksMemoizer.get();
577                         return super.getRelatedTracks();
578                 }
579
580         }
581
582         /**
583          * {@link ObjectCreator} implementation that can create {@link Track}
584          * objects. This specific implementation creates {@link LazyTrack}
585          * instances.
586          *
587          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
588          */
589         private class TrackCreator implements ObjectCreator<Track> {
590
591                 /**
592                  * {@inheritDoc}
593                  */
594                 @Override
595                 public Track createObject(ResultSet resultSet) throws SQLException {
596                         return new LazyTrack(resultSet.getString("TRACKS.ID")).setName(resultSet.getString("TRACKS.NAME")).setRemix(resultSet.getString("TRACKS.REMIX"));
597                 }
598
599         }
600
601         /**
602          * {@link ObjectCreator} implementation that can create {@link Style}
603          * objects.
604          *
605          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
606          */
607         private class StyleCreator implements ObjectCreator<Style> {
608
609                 /**
610                  * {@inheritDoc}
611                  */
612                 @Override
613                 public Style createObject(ResultSet resultSet) throws SQLException {
614                         return new DefaultStyle(resultSet.getString("STYLES.ID")).setName(resultSet.getString("STYLES.NAME"));
615                 }
616
617         }
618
619         /**
620          * {@link User} implementation that retrieves some attributes (such as
621          * {@link #getOpenIds()}) from the {@link DataManager} on demand.
622          *
623          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
624          */
625         private class LazyUser extends DefaultUser {
626
627                 /** Memoizer for a user’s OpenIDs. */
628                 private final Memoizer<Void> openIdMemoizer = new Memoizer<Void>(new Callable<Void>() {
629
630                         @Override
631                         public Void call() throws Exception {
632                                 if (!hasValue("openIds")) {
633                                         getValue("openIds", Collection.class).set(getOpenIdsByUser(getId()));
634                                 }
635                                 return null;
636                         }
637                 });
638
639                 /**
640                  * Creates a new user.
641                  *
642                  * @param id
643                  *            The ID of the user
644                  */
645                 public LazyUser(String id) {
646                         super(id);
647                 }
648
649                 /**
650                  * {@inheritDoc}
651                  */
652                 @Override
653                 public Collection<String> getOpenIds() {
654                         openIdMemoizer.get();
655                         return super.getOpenIds();
656                 }
657
658         }
659
660         /**
661          * {@link ObjectCreator} implementation that can create {@link User}
662          * objects. This specific implementation creates {@link LazyUser} instances.
663          *
664          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
665          */
666         private class UserCreator implements ObjectCreator<User> {
667
668                 /**
669                  * {@inheritDoc}
670                  */
671                 @Override
672                 public User createObject(ResultSet resultSet) throws SQLException {
673                         return new LazyUser(resultSet.getString("USERS.ID")).setName(resultSet.getString("USERS.NAME")).setPasswordHash(resultSet.getString("USERS.PASSWORD")).setLevel(resultSet.getInt("USERS.LEVEL"));
674                 }
675
676         }
677
678 }