-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
1,531 additions
and
391 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,16 +1,8 @@ | ||
-- Data for testing locally | ||
-- *** DO NOT DEPLOY TO UAT OR OPS *** | ||
|
||
INSERT INTO "Users" ("id", "username") VALUES ('fee1dc78-0604-4fa6-adae-0b4b55440e7d', '[email protected]'); | ||
|
||
INSERT INTO "RasterDefinitions" ( | ||
"outputGranuleExtentFlag", "outputSamplingGridType", "rasterResolution", "utmZoneAdjust", "mgrsBandAdjust" | ||
) VALUES ( | ||
TRUE, 'UTM', 1000, 1, -1 | ||
); | ||
|
||
INSERT INTO "RasterDefinitions" ( | ||
"outputGranuleExtentFlag", "outputSamplingGridType", "rasterResolution" | ||
INSERT INTO "Users" ( | ||
"id", "username", "email", "firstName", "lastName" | ||
) VALUES ( | ||
TRUE, 'GEO', 3 | ||
'fee1dc78-0604-4fa6-adae-0b4b55440e7d', 'test-user', 'test@localhost', 'First', 'Last' | ||
); |
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 |
---|---|---|
@@ -1,41 +1,59 @@ | ||
-- Create tables | ||
CREATE TABLE "Users" ( | ||
"id" uuid DEFAULT gen_random_uuid() PRIMARY KEY, | ||
"username" varchar UNIQUE NOT NULL | ||
"username" varchar UNIQUE NOT NULL, | ||
"email" varchar NOT NULL, | ||
"firstName" varchar NOT NULL, | ||
"lastName" varchar NOT NULL | ||
); | ||
|
||
CREATE TABLE "RasterDefinitions" ( | ||
"id" uuid DEFAULT gen_random_uuid() PRIMARY KEY, | ||
"userId" uuid NOT NULL, | ||
"name" varchar NOT NULL, | ||
"outputGranuleExtentFlag" boolean NOT NULL, | ||
"outputSamplingGridType" varchar NOT NULL, | ||
"rasterResolution" int NOT NULL, | ||
"utmZoneAdjust" int, | ||
"mgrsBandAdjust" int | ||
"mgrsBandAdjust" int, | ||
FOREIGN KEY ("userId") REFERENCES "Users" ("id") | ||
); | ||
|
||
CREATE TABLE "L2RasterProducts" ( | ||
"id" uuid DEFAULT gen_random_uuid() PRIMARY KEY, | ||
"definitionID" uuid NOT NULL, | ||
"timestamp" timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
"cycle" int NOT NULL, | ||
"pass" int NOT NULL, | ||
"scene" int NOT NULL, | ||
FOREIGN KEY ("definitionID") REFERENCES "RasterDefinitions" ("id") | ||
"outputGranuleExtentFlag" boolean NOT NULL, | ||
"outputSamplingGridType" varchar NOT NULL, | ||
"rasterResolution" int NOT NULL, | ||
"utmZoneAdjust" int, | ||
"mgrsBandAdjust" int | ||
); | ||
|
||
CREATE TABLE "Granules" ( | ||
"id" uuid DEFAULT gen_random_uuid() PRIMARY KEY, | ||
"productId" uuid NOT NULL, | ||
"timestamp" timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
"uri" varchar NOT NULL, | ||
FOREIGN KEY ("productId") REFERENCES "L2RasterProducts" ("id") | ||
); | ||
|
||
CREATE TABLE "ProductHistory" ( | ||
"requestedByID" uuid, | ||
"rasterProductID" uuid, | ||
"requestedById" uuid, | ||
"rasterProductId" uuid, | ||
"timestamp" timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
PRIMARY KEY ("requestedByID", "rasterProductID"), | ||
FOREIGN KEY ("requestedByID") REFERENCES "Users" ("id"), | ||
FOREIGN KEY ("rasterProductID") REFERENCES "L2RasterProducts" ("id") ON DELETE CASCADE | ||
PRIMARY KEY ("requestedById", "rasterProductId"), | ||
FOREIGN KEY ("requestedById") REFERENCES "Users" ("id"), | ||
FOREIGN KEY ("rasterProductId") REFERENCES "L2RasterProducts" ("id") ON DELETE CASCADE | ||
); | ||
|
||
CREATE TABLE "Status" ( | ||
"id" uuid DEFAULT gen_random_uuid() PRIMARY KEY, | ||
"productID" uuid NOT NULL, | ||
"productId" uuid NOT NULL, | ||
"timestamp" timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
"state" varchar NOT NULL, | ||
"reason" text, | ||
FOREIGN KEY ("productID") REFERENCES "L2RasterProducts" ("id") ON DELETE CASCADE | ||
FOREIGN KEY ("productId") REFERENCES "L2RasterProducts" ("id") ON DELETE CASCADE | ||
); |
12 changes: 12 additions & 0 deletions
12
src/main/java/gov/nasa/podaac/swodlr/SwodlrProperties.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,12 @@ | ||
package gov.nasa.podaac.swodlr; | ||
|
||
import java.util.Map; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
@ConfigurationProperties("swodlr") | ||
@ConstructorBinding | ||
public record SwodlrProperties( | ||
Map<String, String> teaMapping, | ||
String productCreateQueueUrl | ||
) { } |
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
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,71 @@ | ||
package gov.nasa.podaac.swodlr.granule; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import gov.nasa.podaac.swodlr.Utils; | ||
import gov.nasa.podaac.swodlr.l2rasterproduct.L2RasterProduct; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
import org.hibernate.validator.constraints.URL; | ||
|
||
@Entity | ||
@Table(name = "Granules") | ||
public class Granule { | ||
@Id | ||
private UUID id; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "productId", nullable = false) | ||
private L2RasterProduct product; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime timestamp; | ||
|
||
@Column(nullable = false) | ||
private String uri; | ||
|
||
Granule() { } | ||
|
||
public Granule(L2RasterProduct product, String uri) { | ||
this.id = UUID.randomUUID(); | ||
this.timestamp = LocalDateTime.now(); | ||
this.product = product; | ||
this.uri = uri; | ||
} | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public L2RasterProduct getProduct() { | ||
return product; | ||
} | ||
|
||
public LocalDateTime getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
@JsonIgnore | ||
public String getS3Uri() { | ||
return uri; | ||
} | ||
|
||
public String getUri() { | ||
try { | ||
return Utils | ||
.applicationContext() | ||
.getBean(TeaMapper.class) | ||
.convertS3Uri(URI.create(uri)) | ||
.toString(); | ||
} catch (URISyntaxException ex) { } | ||
|
||
return null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/gov/nasa/podaac/swodlr/granule/GranuleController.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,19 @@ | ||
package gov.nasa.podaac.swodlr.granule; | ||
|
||
import java.util.Set; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.graphql.data.method.annotation.SchemaMapping; | ||
import org.springframework.stereotype.Controller; | ||
import gov.nasa.podaac.swodlr.l2rasterproduct.L2RasterProduct; | ||
|
||
@Controller | ||
public class GranuleController { | ||
@Autowired | ||
private GranuleRepository granuleRepository; | ||
|
||
@SchemaMapping(typeName = "L2RasterProduct", field = "granules") | ||
public Set<Granule> getGranulesForProduct(L2RasterProduct product) { | ||
return granuleRepository.findByProduct(product); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/gov/nasa/podaac/swodlr/granule/GranuleRepository.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,10 @@ | ||
package gov.nasa.podaac.swodlr.granule; | ||
|
||
import gov.nasa.podaac.swodlr.l2rasterproduct.L2RasterProduct; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface GranuleRepository extends JpaRepository<Granule, UUID> { | ||
Set<Granule> findByProduct(L2RasterProduct product); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/gov/nasa/podaac/swodlr/granule/TeaMapper.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,22 @@ | ||
package gov.nasa.podaac.swodlr.granule; | ||
|
||
import gov.nasa.podaac.swodlr.SwodlrProperties; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TeaMapper { | ||
@Autowired | ||
private SwodlrProperties swodlrProperties; | ||
|
||
public URI convertS3Uri(URI s3Uri) throws URISyntaxException{ | ||
String bucketName = s3Uri.getAuthority(); | ||
String teaHost = swodlrProperties.teaMapping().get(bucketName); | ||
String path = "/" + bucketName + s3Uri.getPath(); | ||
|
||
URI teaUri = new URI("https", teaHost, path, null); | ||
return teaUri; | ||
} | ||
} |
Oops, something went wrong.