Skip to content

Commit

Permalink
Merge pull request #418 from bullhorn/f/java17
Browse files Browse the repository at this point in the history
Bullhorn REST SDK v2.0
  • Loading branch information
johnsully83 authored Jun 1, 2023
2 parents 1838858 + de3dad0 commit deb29ad
Show file tree
Hide file tree
Showing 205 changed files with 11,195 additions and 7,346 deletions.
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
language: java

install: mvn install -DskipTests=true -Dgpg.skip=true
before_install:
- nvm install $NODE_VERSION
- curl -s "https://get.sdkman.io" | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk install java 17.0.5-oracle
- sdk use java 17.0.5-oracle

install:
- mvn install -DskipTests=true -Dgpg.skip=true
- npm install

dist: trusty

jdk:
- oraclejdk8
#jdk:
# - oraclejdk8

env:
- NODE_VERSION="5.12.0"
Expand All @@ -14,12 +23,6 @@ cache:
directories:
- node_modules

before_install:
- nvm install $NODE_VERSION

install:
- npm install

after_success:
- mvn test jacoco:report coveralls:report
- test $TRAVIS_BRANCH = "master" && npm run galaxy -- $FIREBASE_URL $SLACK_WEB_HOOK $SLACK_CHANNEL
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ A Java client library for working with the Bullhorn REST API. Handles authentica
<version>1.0</version>
</dependency>
```
Note, as of version 2.0.0 the SDK is built using Java 17 so the default binaries are not compatible with <17 versioned applications.
If you'd like to use JRE 8 compatible binaries, add the `<classifier>` tag in your dependency:

```xml

<dependency>
<groupId>com.bullhorn</groupId>
<artifactId>sdk-rest</artifactId>
<version>2.0.0</version>
<classifier>jdk8</classifier>
</dependency>
```

Omission of the `<classifier>` tag will result in Maven downloading the JRE 17 binaries.

## Basic setup:

Expand Down
150 changes: 119 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bullhorn</groupId>
<artifactId>sdk-rest</artifactId>
<version>1.4.61</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>Bullhorn REST SDK</name>
Expand Down Expand Up @@ -42,7 +42,8 @@
<org.springframework.version>4.2.6.RELEASE</org.springframework.version>
<additionalparam>-Xdoclint:none</additionalparam>
<coveralls-version>4.2.0</coveralls-version>
<jacoco-version>0.7.7.201606060606</jacoco-version>
<jacoco-version>0.8.8</jacoco-version>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
Expand Down Expand Up @@ -145,7 +146,7 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.4.5</version>
<version>3.0.14</version>
</dependency>

<dependency>
Expand All @@ -167,16 +168,34 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.17.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.7-groovy-2.0</version>
<version>2.0-M2-groovy-3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -199,6 +218,17 @@
<version>2.2</version>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>

<distributionManagement>
Expand All @@ -212,6 +242,13 @@
</repository>
</distributionManagement>

<pluginRepositories>
<pluginRepository>
<id>groovy-plugins-release</id>
<url>https://groovy.jfrog.io/artifactory/plugins-release</url>
</pluginRepository>
</pluginRepositories>

<build>
<testResources>
<testResource>
Expand All @@ -221,34 +258,12 @@
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.8</source>
<target>1.8</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.3.4-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<version>2.22.2</version>
<configuration>
<argLine>${argLine} -Xms512m -Xmx1024m -XX:MaxPermSize=512m</argLine>
<argLine>${argLine} -Xms512m -Xmx1024m -XX:MaxMetaspaceSize=512m</argLine>
<includes>
<include>**/Test*.java</include>
<include>**/*Spec.*</include>
Expand All @@ -268,6 +283,79 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<executions>
<execution>
<id>compile-java8</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>8</release>
<fork>true</fork>
<outputDirectory>${project.build.outputDirectory}_jdk8</outputDirectory>
</configuration>
</execution>
<execution>
<id>compile-java17</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>17</release>
<fork>true</fork>
<outputDirectory>${project.build.outputDirectory}_jdk17</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.6.0-03</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.9-03</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>jar-jdk8</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>jdk8</classifier>
<classesDirectory>${project.build.outputDirectory}_jdk8</classesDirectory>
</configuration>
</execution>
<execution>
<id>jar-jdk17</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>jdk17</classifier>
<classesDirectory>${project.build.outputDirectory}_jdk17</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ public class MockBullhornData implements BullhornData {
return (C) response;
}

@Override
public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity, Set<String> nullBypassFields) {

CrudResponse response = null;

response = mockDataHandler.updateEntity(entity, nullBypassFields);

return (C) response;
}

@Override
public <C extends CrudResponse, T extends UpdateEntity> List<C> updateMultipleEntities(List<T> entityList) {
List<C> responseList = new ArrayList<C>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,17 @@ public class MockDataHandler {
return (C) response;
}

public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity) {
return updateEntity(entity, Collections.emptySet());
}

/**
* Updates the entity.
*
* @param entity
* @return
*/
public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity) {
public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity, Set<String> nullBypassFields) {
Map<Integer, T> currentValues = (Map<Integer, T>) restEntityMap.get(entity.getClass());
CrudResponse response = new UpdateResponse();
response.setChangedEntityId(entity.getId());
Expand All @@ -231,7 +235,7 @@ public class MockDataHandler {
throw new RestApiException("No entity of type "+entity.getClass().getSimpleName()+" with id "+entity.getId()+" exists.");
}
try {
updateExistingEntityWithNewNonNullValues(entity, existingEntity);
updateExistingEntityWithNewNonNullOrBypassedValues(entity, existingEntity, nullBypassFields);
} catch (Exception e) {
String message = "Error updating entity of type: " + entity.getClass().getSimpleName() + " with id: " + entity.getId();
response.setErrorCode("500");
Expand Down Expand Up @@ -1053,7 +1057,7 @@ public class MockDataHandler {
*
*/

private <M> void updateExistingEntityWithNewNonNullValues(M from, M to) throws Exception {
private <M> void updateExistingEntityWithNewNonNullOrBypassedValues(M from, M to, Set<String> fieldsToBypass) throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(to.getClass());

// Iterate over all the attributes
Expand All @@ -1063,8 +1067,9 @@ public class MockDataHandler {
if (descriptor.getWriteMethod() != null) {

Object newValue = descriptor.getReadMethod().invoke(from);
if (newValue != null && !"id".equals(descriptor.getName())) {
descriptor.getWriteMethod().invoke(to, newValue);
if ((newValue != null || fieldsToBypass.contains(descriptor.getName())) && !"id".equals(descriptor.getName())) {
// Pass array to invoke method to allow null values
descriptor.getWriteMethod().invoke(to, [newValue] as Object[]);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ public class MockDataLoader {
entityFiles.put(CandidateCertification.class, "candidatecertification-data.txt");
entityFiles.put(CandidateEducation.class, "candidateeducation-data.txt");
entityFiles.put(CandidateReference.class, "candidatereference-data.txt");
entityFiles.put(CandidateSource.class, "candidatesource-data.txt");
entityFiles.put(CandidateWorkHistory.class, "candidateworkhistory-data.txt");
entityFiles.put(Category.class, "category-data.txt");
entityFiles.put(Certification.class, "certification-data.txt");
Expand All @@ -444,12 +445,14 @@ public class MockDataLoader {
entityFiles.put(ClientCorporationCertification.class, "clientcorporationcertification-data.txt");
entityFiles.put(CorporateUser.class, "corporateuser-data.txt");
entityFiles.put(CorporationDepartment.class, "corporationdepartment-data.txt");
entityFiles.put(Corporation.class, "corporation-data.txt");
entityFiles.put(Country.class, "country-data.txt");
entityFiles.put(Department.class, "department-data.txt");
entityFiles.put(DistributionList.class, "distributionlist-data.txt");
entityFiles.put(File.class, "file-data.txt");
entityFiles.put(GoalTarget.class, "goaltarget-data.txt");
entityFiles.put(HousingComplex.class, "housingcomplex-data.txt");
entityFiles.put(HousingComplexAmenity.class, "housingcomplexamenity-data.txt");
entityFiles.put(HousingComplexUnit.class, "housingcomplexunit-data.txt");
entityFiles.put(HousingComplexFurnitureDelivery.class, "housingcomplexfurnituredelivery-data.txt");
entityFiles.put(HousingComplexUtilityAccount.class, "housingcomplexutilityaccount-data.txt");
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/bullhornsdk/data/api/BullhornData.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,20 @@ public <T extends QueryEntity & AllRecordsEntity, L extends ListWrapper<T>> L qu

public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity);

/**
* Updates an UpdateEntity that is a sub type of BullhornEntity and returns a CrudResponse with info on the update, such as warnings, errors
* and validation errors. Additionally, a set of fields can be passed in order to include them into the payload regardless of whether they have
* null values.
*
* Please note, the id of the passed in entity cannot be null.
*
* @param entity the entity to update, must have the id field set.
* @param nullBypassFields name of fields that should be included in the payload regardless of whether they have null values
*
* @return an UpdateResponse with updated entity information
*/
public <C extends CrudResponse, T extends UpdateEntity> C updateEntity(T entity, Set<String> nullBypassFields);

/**
* Same as updateEntity, but handles a list of entities to update.
*
Expand Down
Loading

0 comments on commit deb29ad

Please sign in to comment.