[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.mpilib;
|
---|
| 6 |
|
---|
| 7 | import java.util.ArrayList;
|
---|
| 8 | import org.apache.commons.logging.Log;
|
---|
| 9 | import org.apache.commons.logging.LogFactory;
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | *
|
---|
| 13 | * @author rayj
|
---|
| 14 | */
|
---|
| 15 | public class Identifiers extends ArrayList<Identifier> implements java.io.Serializable {
|
---|
| 16 | private static Log log = LogFactory.getLog(Identifiers.class);
|
---|
| 17 | static final long serialVersionUID = -917875998116976597L;
|
---|
| 18 |
|
---|
| 19 | public Identifiers() {
|
---|
| 20 | log.info("Identifiers Initiated..");
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public boolean add(Identifiers identifiers) {
|
---|
| 24 | for (Identifier identifier : identifiers) {
|
---|
| 25 | add(identifier);
|
---|
| 26 | }
|
---|
| 27 | return true;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | @Override
|
---|
| 31 | public boolean add(Identifier identifier) {
|
---|
| 32 | //check to see if this id already exists
|
---|
| 33 | Identifier myIdentifier = null;
|
---|
| 34 |
|
---|
| 35 | if (!doesIdentifierExist(identifier) ) {
|
---|
| 36 | myIdentifier = new Identifier(identifier.getId(), identifier.getOrganizationId());
|
---|
| 37 | super.add(myIdentifier);
|
---|
| 38 | }
|
---|
| 39 | return true;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | private boolean doesIdentifierExist(Identifier identifier) {
|
---|
| 43 | boolean found = false;
|
---|
| 44 | for (Identifier existingId : this) {
|
---|
| 45 | if ((existingId.getOrganizationId().contentEquals(identifier.getOrganizationId()) && (existingId.getId().contentEquals(identifier.getId())))) {
|
---|
| 46 | found = true;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 | return found;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public boolean add(String id, String organization) {
|
---|
| 53 | return add(new Identifier(id, organization));
|
---|
| 54 | }
|
---|
| 55 | }
|
---|