Skip to content
Snippets Groups Projects

Tag meta geo histo models

Merged Stian Fjæran Mogen requested to merge tag-meta-geo-histo-models into dev
2 unresolved threads

Added models for Tag, Metadata, Geolocation and Histogram. Not sure if the relations between models are excatly how we want them, but feel free to request improvements and changes. xoxo

Merge request reports

Pipeline #75864 passed

Pipeline passed for f425ceb3 on tag-meta-geo-histo-models

Approval is optional

Merged by Eirik SteiraEirik Steira 5 years ago (Mar 20, 2020 5:59pm UTC)

Merge details

  • Changes merged into dev with b323c9d3 (commits were squashed).
  • Deleted the source branch.

Pipeline #76035 passed

Pipeline passed for b323c9d3 on dev

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Eirik Steira
  • Eirik Steira
  • 14
    15 @Entity
    16 @Table(name = "Tag")
    17 public class Tag {
    18
    19 /*
    20 Defines the tag-id, this cannot be blank
    21 */
    22
    23
    24 @Id @NotBlank(message = "Tag-Id may not be blank")
    25 @GeneratedValue(strategy = GenerationType.AUTO)
    26 private int tagId;
    27
    28 @Id @NotBlank(message = "Image-Id may not be blank")
    29 private int imageId;
  • This is complex stuff and you have done a good job defining the relationships. However, there are some minor flaws when in comes to which column a foreign key should join on which is why I left some comments.

    Other than that there is a couple of things that should be looked into:

    1. The code fails to run once the entity classes are registered (point 3). You can test the implementation by adding this to App.main() and then compile and run it.
    EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("ImageApplication");
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    1. Proper JavaDoc. The JavaDoc should be on the form /**

    */ and no spacing preceding what is to be documented.

    Read more here: https://www.oracle.com/technetwork/java/javase/documentation/index-137868.html

    1. Add entity classes to src/main/java/resources/META-INF/persistence.xml and to the test file src/test/java/resources/META-INF/persistence.xml to register the entities and create the tables.
    Edited by Eirik Steira
  • added 1 commit

    Compare with previous version

  • added 2 commits

    Compare with previous version

  • 20 private int metadataId;
    21
    22 /**
    23 * One to one relation joining imageId
    24 * on image_id column in image
    25 */
    26
    27 @OneToOne
    28 @JoinColumn(name = "image_id")
    29 private Image image;
    30
    31 @NotBlank (message = "GeolocationId may not be blank")
    32 private int geoLocationId;
    33
    34 @NotBlank (message = "HistogramId may not be blank")
    35 private int histogramId;
    • Since these are declared and the metadata model should know about the geolocation and histogram, the relationship should be declared here as well.

      Also, to keep the code as standardized as possible, we try to use a primitive wrapper type for id fields, ie Long instead of long. This goes for all id fields :)

    • Please register or sign in to reply
  • merged

  • Eirik Steira mentioned in commit b323c9d3

    mentioned in commit b323c9d3

  • Please register or sign in to reply
    Loading