-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from ALNAUA/candidateWorkHistoryRestTrigger
added CandidateWorkHistoryRestTrigger support
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/client/core/base/model/helper/impl/CandidateWorkHistoryTriggerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.client.core.base.model.helper.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateWorkHistory; | ||
import com.client.core.base.model.helper.AbstractTriggerHelper; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.model.relatedentity.CandidateWorkHistoryRelatedEntity; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public abstract class CandidateWorkHistoryTriggerHelper extends AbstractTriggerHelper<CandidateWorkHistory> { | ||
|
||
public CandidateWorkHistoryTriggerHelper(Integer updatingUserID, Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(updatingUserID, CandidateWorkHistory.class, CandidateWorkHistoryRelatedEntity.CANDIDATE_WORK_HISTORY, relatedEntityFields); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...esttrigger/controller/candidateworkhistory/CandidateWorkHistoryRestTriggerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.client.core.resttrigger.controller.candidateworkhistory; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateWorkHistory; | ||
import com.client.core.base.model.relatedentity.CandidateWorkHistoryRelatedEntity; | ||
import com.client.core.base.workflow.node.TriggerValidator; | ||
import com.client.core.resttrigger.controller.AbstractRestTriggerController; | ||
import com.client.core.resttrigger.model.api.RestTriggerRequest; | ||
import com.client.core.resttrigger.model.api.RestTriggerResponse; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateWorkHistoryRestTriggerHelper; | ||
import com.client.core.resttrigger.workflow.traversing.CandidateWorkHistoryRestTriggerTraverser; | ||
import org.apache.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@Controller | ||
@RequestMapping("/resttrigger/candidateworkhistory/*") | ||
public class CandidateWorkHistoryRestTriggerController extends AbstractRestTriggerController<CandidateWorkHistory, CandidateWorkHistoryRestTriggerHelper, CandidateWorkHistoryRestTriggerTraverser> { | ||
|
||
private final Logger log = Logger.getLogger(CandidateWorkHistoryRestTriggerController.class); | ||
|
||
@Autowired | ||
public CandidateWorkHistoryRestTriggerController(Optional<List<TriggerValidator<CandidateWorkHistory, CandidateWorkHistoryRestTriggerHelper, CandidateWorkHistoryRestTriggerTraverser>>> triggerValidators) { | ||
super(CandidateWorkHistory.class, triggerValidators, CandidateWorkHistoryRelatedEntity.values()); | ||
} | ||
|
||
/** | ||
* Called when candidate is added | ||
* | ||
* @param body | ||
* | ||
* @return the json parsed form response message | ||
*/ | ||
@RequestMapping(value = { "add" }, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) | ||
@ResponseBody | ||
public RestTriggerResponse addEntity(@RequestBody String body) { | ||
log.info("---------------------------- Starting Candidate Work History Add Validation Process From Rest Trigger ----------------------------------------"); | ||
|
||
Map<String, Object> valuesChanges = (Map<String, Object>) convertToMap(body).get("data"); | ||
|
||
RestTriggerRequest<CandidateWorkHistory> restTriggerRequest = convertToObject(body); | ||
|
||
Integer entityID = restTriggerRequest.getMeta().getEntityId(); | ||
Integer updatingUserID = restTriggerRequest.getMeta().getUserId(); | ||
|
||
CandidateWorkHistoryRestTriggerTraverser traverser = new CandidateWorkHistoryRestTriggerTraverser(entityID, valuesChanges, updatingUserID, false, getRelatedEntityFields()); | ||
|
||
return handleRequest(traverser, valuesChanges); | ||
} | ||
|
||
/** | ||
* Called when candidate is edited | ||
* | ||
* @param body | ||
* | ||
* @return the json parsed form response message | ||
*/ | ||
@RequestMapping(value = { "edit" }, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }) | ||
@ResponseBody | ||
public RestTriggerResponse editEntity(@RequestBody String body) { | ||
log.info("---------------------------- Starting Candidate Work History Edit Validation Process From Rest Trigger ----------------------------------------"); | ||
|
||
Map<String, Object> valuesChanges = (Map<String, Object>) convertToMap(body).get("data"); | ||
|
||
RestTriggerRequest<CandidateWorkHistory> restTriggerRequest = convertToObject(body); | ||
|
||
Integer entityID = restTriggerRequest.getMeta().getEntityId(); | ||
Integer updatingUserID = restTriggerRequest.getMeta().getUserId(); | ||
|
||
CandidateWorkHistoryRestTriggerTraverser traverser = new CandidateWorkHistoryRestTriggerTraverser(entityID, valuesChanges, updatingUserID, true, getRelatedEntityFields()); | ||
|
||
return handleRequest(traverser, valuesChanges); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
.../com/client/core/resttrigger/model/helper/impl/CandidateWorkHistoryRestTriggerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.client.core.resttrigger.model.helper.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateWorkHistory; | ||
import com.client.core.base.model.helper.impl.CandidateWorkHistoryTriggerHelper; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.model.relatedentity.CandidateWorkHistoryRelatedEntity; | ||
import com.client.core.base.util.TriggerUtil; | ||
import com.client.core.resttrigger.model.helper.RestTriggerHelper; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class CandidateWorkHistoryRestTriggerHelper extends CandidateWorkHistoryTriggerHelper implements RestTriggerHelper<CandidateWorkHistory> { | ||
|
||
private final Integer entityID; | ||
private final Map<String, Object> valuesChanged; | ||
|
||
public CandidateWorkHistoryRestTriggerHelper(Integer entityID, Map<String, Object> valuesChanged, Integer updatingUserID, | ||
Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(updatingUserID, relatedEntityFields); | ||
this.entityID = entityID; | ||
this.valuesChanged = valuesChanged; | ||
} | ||
|
||
@Override | ||
public Set<String> getPopulatedFields() { | ||
return valuesChanged.keySet(); | ||
} | ||
|
||
@Override | ||
public Integer getEntityID() { | ||
return entityID; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getValuesChanged() { | ||
return valuesChanged; | ||
} | ||
|
||
@Override | ||
protected CandidateWorkHistory instantiateNewEntity() { | ||
return TriggerUtil.populateEntity(entityID, CandidateWorkHistory.class, valuesChanged, CandidateWorkHistory::new, getFields(CandidateWorkHistoryRelatedEntity.CANDIDATE_WORK_HISTORY)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../client/core/resttrigger/workflow/node/impl/CandidateWorkHistoryRestTriggerValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.client.core.resttrigger.workflow.node.impl; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateWorkHistory; | ||
import com.client.core.base.model.relatedentity.CandidateWorkHistoryRelatedEntity; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateWorkHistoryRestTriggerHelper; | ||
import com.client.core.resttrigger.workflow.traversing.CandidateWorkHistoryRestTriggerTraverser; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public abstract class CandidateWorkHistoryRestTriggerValidator extends AbstractRestTriggerValidator<CandidateWorkHistory, CandidateWorkHistoryRestTriggerHelper, CandidateWorkHistoryRestTriggerTraverser> { | ||
|
||
public CandidateWorkHistoryRestTriggerValidator(Integer order, Map<CandidateWorkHistoryRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(order, relatedEntityFields); | ||
} | ||
|
||
public CandidateWorkHistoryRestTriggerValidator(Map<CandidateWorkHistoryRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(relatedEntityFields); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...client/core/resttrigger/workflow/traversing/CandidateWorkHistoryRestTriggerTraverser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.client.core.resttrigger.workflow.traversing; | ||
|
||
import com.bullhornsdk.data.model.entity.core.standard.CandidateWorkHistory; | ||
import com.client.core.base.model.relatedentity.BullhornRelatedEntity; | ||
import com.client.core.base.workflow.traversing.AbstractTriggerTraverser; | ||
import com.client.core.resttrigger.model.helper.impl.CandidateWorkHistoryRestTriggerHelper; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class CandidateWorkHistoryRestTriggerTraverser extends AbstractTriggerTraverser<CandidateWorkHistory, CandidateWorkHistoryRestTriggerHelper> { | ||
|
||
public CandidateWorkHistoryRestTriggerTraverser(Integer entityID, Map<String, Object> valuesChanged, Integer updatingUserID, boolean edit, | ||
Map<? extends BullhornRelatedEntity, Set<String>> relatedEntityFields) { | ||
super(new CandidateWorkHistoryRestTriggerHelper(entityID, valuesChanged, updatingUserID, relatedEntityFields), edit); | ||
} | ||
|
||
} |