Skip to content

Commit

Permalink
[FEATURE]-Bulk uploading for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
ndasanayaka committed Jul 3, 2024
1 parent 529f7b6 commit c825b15
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<dependency org="com.google.inject.extensions" name="guice-servlet" rev="4.1.0" />

<!--<dependency org="jakarta-regexp" name="jakarta-regexp" rev="1.4" />-->
<!-- <dependency org="org.apache.poi" name="poi-ooxml" rev="4.1.0" /> -->
<dependency org="org.apache.lucene" name="lucene-core" rev="6.3.0" />
<dependency org="org.apache.lucene" name="lucene-queryparser" rev="6.3.0" />
<dependency org="org.apache.lucene" name="lucene-queries" rev="6.3.0" />
Expand Down Expand Up @@ -58,6 +59,9 @@
<dependency org="org.hibernate" name="hibernate-core" rev="5.2.6.Final" />

<dependency org="com.github.dfabulich" name="sitemapgen4j" rev="1.0.6"/>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency org="org.springframework" name="spring-web" rev="5.0.3.RELEASE"/>


<exclude org="org.apache.james" module="apache-mime4j-core"/>
<exclude org="org.apache.james" module="apache-mime4j-dom"/>
Expand Down
153 changes: 153 additions & 0 deletions src/net/qldarch/archobj/ProjectObj.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package net.qldarch.archobj;

import java.sql.Date;
import com.fasterxml.jackson.annotation.JsonProperty;

public class ProjectObj {

@JsonProperty("australian")
private boolean australian;

@JsonProperty("demolished")
private boolean demolished;

@JsonProperty("label")
private String label;

@JsonProperty("location")
private String location;

@JsonProperty("latitude")
private double latitude;

@JsonProperty("longitude")
private double longitude;

@JsonProperty("completion")
private Date completion;

@JsonProperty("summary")
private String summary;

@JsonProperty("typologies")
private String typologies;

@JsonProperty("associateArchitect")
private Associate associateArchitect;

@JsonProperty("associateFirm")
private Associate associateFirm;

@JsonProperty("row")
private int row;

@JsonProperty("index")
private int index;

public boolean getAustralian() {
return australian;
}
public void setAustralian(boolean australian ) {
this.australian = australian;
}
public boolean getDemolished() {
return demolished;
}
public void setDemolished(boolean demolished ) {
this.demolished = demolished;
}
public String getLabel() {
return label;
}
public void setLabel(String label ) {
this.label = label;
}
public String getLocation() {
return location;
}
public void setLocation(String location ) {
this.location = location;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude ) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude ) {
this.longitude = longitude;
}
public Date getCompletion() {
return completion;
}
public void setCompletion(Date completion ) {
this.completion = completion;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary ) {
this.summary = summary;
}
public String getTypologies() {
return typologies;
}
public void setTypologies(String typologies ) {
this.typologies = typologies;
}
public void setAssociateArchitect(Associate associateArchitect ) {
this.associateArchitect = associateArchitect;
}
public Associate getAssociateArchitect() {
return associateArchitect;
}
public void setAssociateFirm(Associate associateFirm ) {
this.associateFirm = associateFirm;
}
public Associate getAssociateFirm() {
return associateFirm;
}
public int getRow(){
return row;
}
public void setRow(int row ) {
this.row = row;
}
public int getIndex(){
return index;
}
public void setIndex(int index ) {
this.index = index;
}

public static class Associate {
private int id;
private String label;
private String type;

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}



}
29 changes: 29 additions & 0 deletions src/net/qldarch/archobj/WsArchObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,33 @@ public Response get(@PathParam("id") Long id) throws Exception {
return Response.status(404).entity(M.of("msg", "Archive object not found")).build();
}
}

@GET
@Path("/byname/{label}")
@Produces(ContentType.JSON)
@JsonSkipField(type=Media.class, field="depicts")
@JsonSerializer(type=Utterance.class, serializer=InterviewUtteranceSerializer.class)
@JsonSerializer(path="$.precededby", serializer=SimpleArchObjSerializer.class)
@JsonSerializer(path="$.succeededby", serializer=SimpleArchObjSerializer.class)
@JsonSerializer(path="$.interviews", serializer=CollectionRemoveNullsSerializer.class)
@JsonSerializer(path="$.interviews.*", serializer=IdArchObjSerializer.class)
@JsonSerializer(path="$.interviewer.*", serializer=SimpleArchObjSerializer.class)
@JsonSerializer(path="$.interviewee.*", serializer=SimpleArchObjSerializer.class)
public Response getByLabel(@PathParam("label") String label) throws Exception {

String sql_exact = "SELECT id,label,type FROM archobj WHERE label='"+label+"'LIMIT 1";
List<Map<String, Object>> results_exact = db.executeQuery(sql_exact, Rsc::fetchAll);
if (!results_exact.isEmpty()) {
return Response.ok().entity(results_exact).build();
} else {
String sql_similar = "SELECT id,label,type FROM archobj WHERE type IN ('firm','person') AND SIMILARITY(label,'"+label+"') > 0.4";
List<Map<String, Object>> results_similar = db.executeQuery(sql_similar, Rsc::fetchAll);
if (!results_similar.isEmpty()) {
return Response.ok().entity(results_similar).build();
} else {
return Response.status(401).entity(M.of("msg", "No records found")).build();
}

}
}
}
Loading

0 comments on commit c825b15

Please sign in to comment.