Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ mvn test jacoco:report
public class User {
@ObjectId
private String id;

private String name;
private String email;

@Internal
private Address address; // Embedded document

@Reference
private List<Order> orders; // Referenced documents

// Default constructor required
public User() {}

// Getters and setters...
}
```
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ jobs:
test:
name: Test and Analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Run tests and generate coverage
run: mvn clean verify

- name: Run SonarCloud analysis
if: env.SONAR_TOKEN != ''
run: mvn sonar:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Upload coverage to Codecov
if: env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v3
Expand All @@ -60,7 +60,7 @@ jobs:
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Archive test results
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -77,26 +77,26 @@ jobs:
name: Build and Package
needs: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build package
run: mvn clean package -DskipTests

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,50 @@ env:
jobs:
validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Run tests
run: mvn clean test

- name: Generate test coverage report
run: mvn jacoco:report

- name: Run checkstyle
run: mvn checkstyle:check
continue-on-error: true

- name: Run PMD
run: mvn pmd:check
continue-on-error: true

- name: Run SpotBugs
run: mvn spotbugs:check
continue-on-error: true

- name: Check code formatting with Spotless
run: mvn spotless:check
continue-on-error: true

- name: Build package
run: mvn clean package -DskipTests

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand All @@ -79,7 +79,7 @@ jobs:
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Archive test results
uses: actions/upload-artifact@v4
if: always()
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ import com.arquivolivre.mongocom.annotations.*;
public class Contact {
@ObjectId
private String id;

private String name;
private String email;
private ContactType type;

@Internal // Embedded documents
private List<Phone> phones;

@Reference // Reference to another document
private Contact company;

// Constructors, getters and setters...
public Contact() {}

public Contact(String name) {
this.name = name;
}

// ... other methods
}
```
Expand All @@ -98,16 +98,16 @@ public class Phone {
private int countryCode;
private int areaCode;
private int phoneNumber;

public Phone() {} // Required default constructor

public Phone(PhoneType type, int country, int area, int number) {
this.phoneType = type;
this.countryCode = country;
this.areaCode = area;
this.phoneNumber = number;
}

// ... getters and setters
}
```
Expand All @@ -121,22 +121,22 @@ public class Example {
public static void main(String[] args) {
// Create collection manager
CollectionManager cm = CollectionManagerFactory.createCollectionManager();

// Create a new contact
Contact contact = new Contact("John Doe");
contact.setEmail("john@example.com");
contact.addPhone(new Phone(PhoneType.MOBILE, 1, 555, 1234567));

// Insert into database
String id = cm.insert(contact);
System.out.println("Inserted with ID: " + id);

// Query the database
Contact found = cm.findOne(Contact.class, new MongoQuery("name", "John Doe"));
if (found != null) {
System.out.println("Found: " + found.getName());
}

// Close connection
cm.close();
}
Expand Down Expand Up @@ -238,16 +238,16 @@ CollectionManager cm = CollectionManagerFactory.setup(servletContext);
public class Order {
@ObjectId
private String id;

private String orderNumber;
private Date orderDate;

@Internal
private List<OrderItem> items;

@Internal
private Address shippingAddress;

// ... constructors, getters, setters
}

Expand All @@ -256,7 +256,7 @@ public class OrderItem {
private String productName;
private int quantity;
private double price;

// ... constructors, getters, setters
}
```
Expand All @@ -269,10 +269,10 @@ public class User {
@ObjectId
private String id;
private String username;

@Reference
private Profile profile; // Reference to another document

// ... other fields and methods
}

Expand All @@ -282,7 +282,7 @@ public class Profile {
private String id;
private String firstName;
private String lastName;

// ... other fields and methods
}
```
Expand Down
4 changes: 2 additions & 2 deletions examples/src/com/example/collections/Address.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@

/**
*
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*/
@Internal
public class Address {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/com/example/collections/Contact.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@

/**
*
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*/
@Document //this represents the structure of a document of the collection contact
public class Contact {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/com/example/collections/Phone.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@

/**
*
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>.
* @author Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*/
@Internal
public class Phone {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/com/example/collections/types/ContactType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>..
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,5 +22,5 @@
public enum ContactType {

PERSON, COMPANY

}
4 changes: 2 additions & 2 deletions examples/src/com/example/collections/types/PhoneType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br>..
* Copyright 2014 Thiago da Silva Gonzaga <thiagosg@sjrp.unesp.br&gt;.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,5 +22,5 @@
public enum PhoneType {

HOME, MOBILE, COMPANY

}
Loading
Loading