Skip to content

Commit

Permalink
feat(Workers Comp): Enable Create and Update for Workers Comp and Wor… (
Browse files Browse the repository at this point in the history
#416)

Also bypassing private label lookup by provided id for workers compensation rate
  • Loading branch information
monroepe authored Nov 9, 2023
1 parent 960b2be commit 8c2cb69
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dataloader.iml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
<configuration />
</facet>
</component>
</module>
</module>
1 change: 1 addition & 0 deletions dataloader.properties
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ loginUrl=https://rest.bullhornstaffing.com/rest-services/login
#stateTaxFormExistField=customText1
#taskExistField=taskUUID
#tearsheetExistField=name
#workersCompensationExistField=name

#clientCorporationCustomObjectInstance1ExistField=clientCorporation.externalID,text1
#clientCorporationCustomObjectInstance2ExistField=clientCorporation.externalID,text1
Expand Down
4 changes: 4 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ These example CSV files reference several reference only entities that must exis
* Invoice Statement Template
* Ensure at least one Invoice Statement Template exists: https://confluence.bullhorn.com/display/WFR/Invoice+Template+Setup

* WorkersCompensationRate
* workersCompensation-ext-1 WorkersCompensation
* PrivateLabel ID

* Corp Settings
* Enable Lead And Opportunity Enabled
* Enable Novo Tax Info Tab Enabled
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dependency>
<groupId>com.bullhorn</groupId>
<artifactId>sdk-rest</artifactId>
<version>2.2.0</version>
<version>2.2.2</version>
<classifier>jdk8</classifier>
</dependency>

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/bullhorn/dataloader/enums/EntityInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public enum EntityInfo {
GENERAL_LEDGER_SEGMENT_5(BullhornEntityInfo.GENERAL_LEDGER_SEGMENT_5, 60),
GENERAL_LEDGER_SERVICE_CODE(BullhornEntityInfo.GENERAL_LEDGER_SERVICE_CODE, 70),
INVOICE_STATEMENT_MESSAGE_TEMPLATE(BullhornEntityInfo.INVOICE_STATEMENT_MESSAGE_TEMPLATE, 80),
WORKERS_COMPENSATION(BullhornEntityInfo.WORKERS_COMPENSATION, 90),

// Entities that reference other entities, in load order
CLIENT_CORPORATION(BullhornEntityInfo.CLIENT_CORPORATION, 100),
Expand Down Expand Up @@ -68,6 +69,7 @@ public enum EntityInfo {
PLACEMENT_CHANGE_REQUEST(BullhornEntityInfo.PLACEMENT_CHANGE_REQUEST, 320),
INVOICE_TERM(BullhornEntityInfo.INVOICE_TERM, 330),
BILLING_PROFILE(BullhornEntityInfo.BILLING_PROFILE, 340),
WORKERS_COMPENSATION_RATE(BullhornEntityInfo.WORKERS_COMPENSATION_RATE, 350),

// Custom Objects
CLIENT_CORPORATION_CUSTOM_OBJECT_INSTANCE_1(BullhornEntityInfo.CLIENT_CORPORATION_CUSTOM_OBJECT_INSTANCE_1, 1000),
Expand Down Expand Up @@ -185,12 +187,11 @@ public enum EntityInfo {
INVOICE_STATEMENT_TEMPLATE(BullhornEntityInfo.INVOICE_STATEMENT_TEMPLATE, 2010),
JOB_SUBMISSION_HISTORY(BullhornEntityInfo.JOB_SUBMISSION_HISTORY, 2011),
PERSON(BullhornEntityInfo.PERSON, 2012),
SKILL(BullhornEntityInfo.SKILL, 2013),
SPECIALTY(BullhornEntityInfo.SPECIALTY, 2014),
STATE(BullhornEntityInfo.STATE, 2015),
TIME_UNIT(BullhornEntityInfo.TIME_UNIT, 2016),
WORKERS_COMPENSATION(BullhornEntityInfo.WORKERS_COMPENSATION, 2017),
WORKERS_COMPENSATION_RATE(BullhornEntityInfo.WORKERS_COMPENSATION_RATE, 2018),
PRIVATE_LABEL(BullhornEntityInfo.PRIVATE_LABEL, 2013),
SKILL(BullhornEntityInfo.SKILL, 2014),
SPECIALTY(BullhornEntityInfo.SPECIALTY, 2015),
STATE(BullhornEntityInfo.STATE, 2016),
TIME_UNIT(BullhornEntityInfo.TIME_UNIT, 2017),
;

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/bullhorn/dataloader/rest/RestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public <T extends QueryEntity> List<T> queryForList(Class<T> type,
String where,
Set<String> fieldSet,
QueryParams params) {
List<T> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(type, where, fieldSet);
if (privateLabelList != null) {
return privateLabelList;
}
Set<String> correctedFieldSet = FindUtil.getCorrectedFieldSet(fieldSet);
printUtil.log(Level.DEBUG, "Find(" + type.getSimpleName() + " Query): " + where
+ ", fields: " + correctedFieldSet.stream().sorted().collect(Collectors.toList()));
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/bullhorn/dataloader/rest/RestApiExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.bullhornsdk.data.exception.RestApiException;
import com.bullhornsdk.data.model.entity.core.standard.JobSubmission;
import com.bullhornsdk.data.model.entity.core.standard.JobSubmissionHistory;
import com.bullhornsdk.data.model.entity.core.standard.PrivateLabel;
import com.bullhornsdk.data.model.entity.core.type.QueryEntity;
import com.bullhornsdk.data.model.entity.core.type.SearchEntity;
import com.bullhornsdk.data.model.parameter.standard.ParamFactory;
import com.bullhornsdk.data.model.response.crud.CrudResponse;
Expand Down Expand Up @@ -76,6 +78,26 @@ <S extends SearchEntity> SearchResult<S> getByExternalId(RestApi restApi, Class<
return searchResult;
}

/**
* Bypass the fast fail of verifying if an entity is already in the system. If we have an internal id, then skip the
* lookup, since the rest call itself will verify the id upon creation/update.
*/
<T extends QueryEntity> List<T> bypassPrivateLabelLookupById(Class<T> type, String where, Set<String> fieldSet) {
List<T> list = null;
if (type.equals(PrivateLabel.class)
&& where.startsWith(StringConsts.ID + "=")
&& !fieldSet.isEmpty()
&& fieldSet.stream().findFirst().get().equals(StringConsts.ID)
) {
list = new ArrayList<>();
PrivateLabel privateLabel = new PrivateLabel();
Integer id = Integer.valueOf(where.substring(3));
privateLabel.setId(id);
list.add((T)privateLabel);
}
return list;
}

/**
* Internal method that performs the search by externalID and returns the resulting list of entities
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public void testIsLoadable() {
Assert.assertTrue(EntityInfo.PLACEMENT_CUSTOM_OBJECT_INSTANCE_1.isLoadable());
Assert.assertFalse(EntityInfo.SKILL.isLoadable());
Assert.assertFalse(EntityInfo.BUSINESS_SECTOR.isLoadable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION.isLoadable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION_RATE.isLoadable());
}

@Test
Expand All @@ -32,6 +34,8 @@ public void testIsInsertable() {
Assert.assertTrue(EntityInfo.PLACEMENT_CUSTOM_OBJECT_INSTANCE_10.isInsertable());
Assert.assertFalse(EntityInfo.SKILL.isInsertable());
Assert.assertFalse(EntityInfo.BUSINESS_SECTOR.isInsertable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION.isInsertable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION_RATE.isInsertable());
}

@Test
Expand All @@ -41,6 +45,8 @@ public void testIsUpdatable() {
Assert.assertTrue(EntityInfo.PLACEMENT_CUSTOM_OBJECT_INSTANCE_1.isUpdatable());
Assert.assertFalse(EntityInfo.SKILL.isUpdatable());
Assert.assertFalse(EntityInfo.BUSINESS_SECTOR.isUpdatable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION.isUpdatable());
Assert.assertTrue(EntityInfo.WORKERS_COMPENSATION_RATE.isUpdatable());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ public void testIntegration() throws IOException {
skipInserts = false;
skipDeletes = false;

skipDeletes = true;
runAllCommandsAgainstDirectory(TestUtils.getResourceFilePath("skipUpdatesEntitiesPart1"));
skipUpdates = true;
skipExports = true;
runAllCommandsAgainstDirectory(TestUtils.getResourceFilePath("skipUpdatesEntitiesPart2"));
skipUpdates = false;
skipDeletes = false;
skipExports = false;

// Run the full test of all example files
runAllCommandsAgainstDirectory("examples/load");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import com.bullhorn.dataloader.util.PrintUtil;
import com.bullhornsdk.data.exception.RestApiException;
import com.bullhornsdk.data.model.entity.core.standard.Candidate;
import com.bullhornsdk.data.model.entity.core.standard.ClientCorporation;
import com.bullhornsdk.data.model.entity.core.standard.JobSubmissionHistory;
import com.bullhornsdk.data.model.entity.core.standard.PrivateLabel;
import com.bullhornsdk.data.model.enums.ChangeType;
import com.bullhornsdk.data.model.response.crud.CrudResponse;
import com.bullhornsdk.data.model.response.crud.DeleteResponse;
Expand Down Expand Up @@ -187,6 +189,61 @@ public void testGetByExternalIdFailure() {
verify(restApiMock, times(2)).performGetRequest(any(), any(), any());
}

@Test
public void testBypassPrivateLabelLookupById() {
Set<String> fieldSet = new HashSet<>();
fieldSet.add("id");

List<PrivateLabel> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(
PrivateLabel.class, "id=123", fieldSet);

Assert.assertNotNull(privateLabelList);
Assert.assertEquals(privateLabelList.get(0).getId(), Integer.valueOf(123));
}

@Test
public void testBypassPrivateLabelLookupByIdNonPrivateLabelFailure() {
Set<String> fieldSet = new HashSet<>();
fieldSet.add("id");

List<ClientCorporation> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(
ClientCorporation.class, "id=123", fieldSet);

Assert.assertNull(privateLabelList);
}

@Test
public void testBypassPrivateLabelLookupByIdWhereClauseFailure() {
Set<String> fieldSet = new HashSet<>();
fieldSet.add("id");

List<PrivateLabel> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(
PrivateLabel.class, "name=PL1", fieldSet);

Assert.assertNull(privateLabelList);
}

@Test
public void testBypassPrivateLabelLookupByIdEmptyFieldSetFailure() {
Set<String> fieldSet = new HashSet<>();

List<PrivateLabel> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(
PrivateLabel.class, "id=123", fieldSet);

Assert.assertNull(privateLabelList);
}

@Test
public void testBypassPrivateLabelLookupByIdNonIdFieldSetFailure() {
Set<String> fieldSet = new HashSet<>();
fieldSet.add("name");

List<PrivateLabel> privateLabelList = restApiExtension.bypassPrivateLabelLookupById(
PrivateLabel.class, "id=123", fieldSet);

Assert.assertNull(privateLabelList);
}

@Test
public void testPostDeleteJobSubmission() throws InstantiationException, IllegalAccessException {
// When soft-deleting a JobSubmission, JobSubmissionHistory records should also be hard-deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void setup() {
new AbstractCrudResponse(), new AbstractCrudResponse(), new AbstractCrudResponse(), new AbstractCrudResponse());
when(bullhornDataMock.disassociateWithEntity(any(), any(), any(), any())).thenReturn(
new AbstractCrudResponse(), new AbstractCrudResponse(), new AbstractCrudResponse(), new AbstractCrudResponse());
when(restApiExtensionMock.bypassPrivateLabelLookupById(any(), any(), any())).thenReturn(null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sendoutExistField=migrateGUID
stateTaxFormExistField=customText1
taskExistField=taskUUID
tearsheetExistField=name
workersCompensationExistField=name

clientCorporationCustomObjectInstance1ExistField=clientCorporation.externalID,text1
clientCorporationCustomObjectInstance2ExistField=clientCorporation.externalID,text1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
code ,name ,state,description
WC-Code1,workersCompensation-ext-1,IL ,WC Description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
compensation.name ,rate,startDate ,endDate ,privateLabel.id
workersCompensation-ext-1,1.12,9/8/2023 12:00,9/8/2024 12:00,47583

0 comments on commit 8c2cb69

Please sign in to comment.