Skip to content

Commit

Permalink
#637 ColDP registration
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-podolskiy90 committed Nov 4, 2024
1 parent 30b48c3 commit 73cfbe3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ public class LegacyDataset extends Dataset implements LegacyEntity {
LegacyResourceConstants.MATERIAL_ENTITY_SERVICE_TYPE_1,
LegacyResourceConstants.MATERIAL_ENTITY_SERVICE_TYPE_2,
LegacyResourceConstants.SAMPLING_EVENT_SERVICE_TYPE);
private static final Set<String> DATA_PACKAGE_ENDPOINT_TYPE_ALTERNATIVES =
private static final Set<String> CAMTRAP_DP_ENDPOINT_TYPE_ALTERNATIVES =
ImmutableSet.of(
EndpointType.CAMTRAP_DP.name(), LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE);
LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE_1,
LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE_2);

/** Default constructor. */
public LegacyDataset() {
Expand Down Expand Up @@ -756,23 +757,34 @@ private void addDataPackageEndpoint() {
while (serviceTypesTokenizer.hasMoreTokens() && serviceUrlsTokenizer.hasMoreTokens()) {
String type = serviceTypesTokenizer.nextToken();
String url = serviceUrlsTokenizer.nextToken();
if (type != null && url != null && DATA_PACKAGE_ENDPOINT_TYPE_ALTERNATIVES.contains(type)) {
// create endpoint
Endpoint endpoint = createEndpoint(url, EndpointType.CAMTRAP_DP);
if (endpoint != null) {
// set it
dataPackageEndpoint = endpoint;
if (type != null && url != null) {
if (CAMTRAP_DP_ENDPOINT_TYPE_ALTERNATIVES.contains(type)) {
// create Camtrap DP endpoint
Endpoint endpoint = createEndpoint(url, EndpointType.CAMTRAP_DP);
if (endpoint != null) {
// set it
dataPackageEndpoint = endpoint;
}
// only 1 is expected
break;
} else if (LegacyResourceConstants.COLDP_SERVICE_TYPE.equals(type)) {
// create ColDP enpoint
Endpoint endpoint = createEndpoint(url, EndpointType.COLDP);
if (endpoint != null) {
// set it
dataPackageEndpoint = endpoint;
}
// only 1 is expected
break;
}
// only 1 is expected
break;
}
}
}
}

/**
* Creates a new Endpoint, or retrieves an existing Endpoint from the dataset. This method assumes
* that the dataset only has 1 endpoint for each type: EML and DWC_ARCHIVE.
* that the dataset only has 1 endpoint for each type: EML, DWC_ARCHIVE, CAMTRAP_DP or COLDP.
*
* @param url Endpoint URL
* @param type Endpoint type
Expand Down Expand Up @@ -810,11 +822,13 @@ private Endpoint createEndpoint(String url, EndpointType type) {
public DatasetType resolveType() {
if (serviceTypes != null) {
if (serviceTypes.contains(LegacyResourceConstants.CHECKLIST_SERVICE_TYPE_1)
|| serviceTypes.contains(LegacyResourceConstants.CHECKLIST_SERVICE_TYPE_2)) {
|| serviceTypes.contains(LegacyResourceConstants.CHECKLIST_SERVICE_TYPE_2)
|| serviceTypes.contains(LegacyResourceConstants.COLDP_SERVICE_TYPE)) {
return DatasetType.CHECKLIST;
} else if (serviceTypes.contains(LegacyResourceConstants.OCCURRENCE_SERVICE_TYPE_1)
|| serviceTypes.contains(LegacyResourceConstants.OCCURRENCE_SERVICE_TYPE_2)
|| serviceTypes.contains(LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE)) {
|| serviceTypes.contains(LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE_1)
|| serviceTypes.contains(LegacyResourceConstants.CAMTRAP_DP_SERVICE_TYPE_2)) {
return DatasetType.OCCURRENCE;
} else if (serviceTypes.contains(LegacyResourceConstants.MATERIAL_ENTITY_SERVICE_TYPE_1)
|| serviceTypes.contains(LegacyResourceConstants.MATERIAL_ENTITY_SERVICE_TYPE_2)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public class LegacyResourceConstants {
public static final String MATERIAL_ENTITY_SERVICE_TYPE_1 = "DWC-ARCHIVE-MATERIAL-ENTITY";
public static final String MATERIAL_ENTITY_SERVICE_TYPE_2 = "DWC_ARCHIVE_MATERIAL_ENTITY";
public static final String SAMPLING_EVENT_SERVICE_TYPE = "DWC-ARCHIVE-SAMPLING-EVENT";
public static final String CAMTRAP_DP_SERVICE_TYPE = "CAMTRAP_DP";
public static final String CAMTRAP_DP_SERVICE_TYPE_1 = "CAMTRAP_DP";
public static final String CAMTRAP_DP_SERVICE_TYPE_2 = "CAMTRAP-DP";
public static final String COLDP_SERVICE_TYPE = "COLDP";

// web service paging request size
public static final int WS_PAGE_SIZE = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ public ResponseEntity<Void> updateIpt(
/**
* Register IPT dataset, handling incoming request with path /ipt/resource. The primary contact
* and publishing organization key are mandatory. Only after both the dataset and primary contact
* have been persisted is a response with {@link HttpStatus#CREATED} returned. </br> Before being
* have been persisted is a response with {@link HttpStatus#CREATED} returned.
* <p>
* Before being
* persisted, the dataset is the UNSPECIFIED license. This will be replaced (if possible) by the
* publisher assigned license when the dataset gets crawled the first time. Since IPT 2.2, the IPT
* EML metadata document always includes a machine-readable license. See discussion at
* https://github.com/gbif/registry/issues/71
* <a href="https://github.com/gbif/registry/issues/71">GitHub</a>
*
* @param dataset LegacyDataset with HTTP form parameters
* @return {@link ResponseEntity} with {@link HttpStatus#CREATED} if successful
Expand Down

0 comments on commit 73cfbe3

Please sign in to comment.