Compare commits

...

6 Commits

5 changed files with 100 additions and 120 deletions

View File

@ -21,6 +21,8 @@ Run the `run.sh`
Assuming you're running the server locally, go to [http://localhost:8080/core/2.0.0/$metadata](http://localhost:8080/core/2.0.0/$metadata)\
Otherwise, you will have to replace `localhost` with the IP of your Docker machine.
![](https://cdn.ossez.com/discourse-uploads/optimized/2X/8/881469dc9b204975de209b56f0d897ba8b782347_2_690x439.png)
## Running with a different database
If you set the `SQL_HOST` Environment Variable, then the build script will not build the test database.

View File

@ -11,14 +11,14 @@ plugins {
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
url = uri('https://repo.ossez.com/repository/maven-public/')
}
}
dependencies {
implementation 'org.postgresql:postgresql:42.2.23'
implementation 'org.apache.olingo:odata-server-api:4.8.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'org.apache.olingo:odata-commons-api:4.8.0'
implementation 'org.apache.olingo:odata-commons-core:4.8.0'
implementation 'org.slf4j:slf4j-api:1.7.11'

View File

@ -1,11 +1,11 @@
FROM ubuntu:20.10
FROM ubuntu:22.04
WORKDIR /usr/src/app
# Comment next line out for Windows builds
ARG DEBIAN_FRONTEND=noninteractive
#ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y wget openjdk-8-jdk curl pip maven docker-compose
# Needed for Windows builds
#RUN update-java-alternatives -s java-1.8.0-openjdk-amd64
RUN update-java-alternatives -s java-1.8.0-openjdk-amd64
CMD sh /usr/src/app/docker/scripts/build.sh

View File

@ -11,8 +11,8 @@
<packaging>war</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<junit.version>5.7.0</junit.version>
<javax.version>2.5</javax.version>
<odata.version>4.8.0</odata.version>

View File

@ -17,8 +17,7 @@ import java.util.HashMap;
import static org.reso.service.servlet.RESOservlet.resourceLookup;
import static org.reso.service.servlet.RESOservlet.getConnection;
public class EnumFieldInfo extends FieldInfo
{
public class EnumFieldInfo extends FieldInfo {
private String lookupName;
private final ArrayList<EnumValueInfo> values = new ArrayList<>();
private final HashMap<String, Object> valueLookup = new HashMap<>();
@ -29,25 +28,20 @@ public class EnumFieldInfo extends FieldInfo
private static final String LOOKUP_COLUMN_NAME = "LookupValue";
public EnumFieldInfo(String fieldName, FullQualifiedName type)
{
public EnumFieldInfo(String fieldName, FullQualifiedName type) {
super(fieldName, type);
}
public void addValue(EnumValueInfo value)
{
public void addValue(EnumValueInfo value) {
values.add(value);
}
private void loadValues()
{
private void loadValues() {
ResourceInfo resource = resourceLookup.get("Lookup");
if (resource!=null)
{
if (resource != null) {
Connection connect = getConnection();
String queryString = null;
try
{
try {
Statement statement = connect.createStatement();
HashMap<String, Boolean> selectLookup = new HashMap<>();
selectLookup.put(LOOKUP_COLUMN_NAME, true);
@ -56,26 +50,21 @@ public class EnumFieldInfo extends FieldInfo
LOG.debug("Query: " + queryString);
ResultSet resultSet = statement.executeQuery(queryString);
while (resultSet.next())
{
while (resultSet.next()) {
Entity ent = CommonDataProcessing.getEntityFromRow(resultSet, resource, selectLookup);
Property property = ent.getProperty(LOOKUP_COLUMN_NAME);
String val = property.getValue().toString();
values.add(new EnumValueInfo(val));
}
}
catch (Exception e)
{
} catch (Exception e) {
LOG.info("Query: " + queryString);
LOG.error("Error in finding Lookup values for " + lookupName + ": " + e.getMessage());
}
}
}
public ArrayList<EnumValueInfo> getValues()
{
if (values.size()==0)
{
public ArrayList<EnumValueInfo> getValues() {
if (values.size() == 0) {
EnumValueInfo sampleValue = new EnumValueInfo("Sample" + lookupName + "EnumValue");
values.add(sampleValue);
}
@ -83,16 +72,15 @@ public class EnumFieldInfo extends FieldInfo
return values;
}
public void setLookupName(String name) { lookupName=name; }
public void setLookupName(String name) {
lookupName = name;
}
public FullQualifiedName getType()
{
if (values.size()==0)
{
public FullQualifiedName getType() {
if (values.size() == 0) {
getValues();
}
if (values.size()>0)
{
if (values.size() > 0) {
return new FullQualifiedName("org.reso.metadata.enums." + lookupName);
}
@ -102,49 +90,39 @@ public class EnumFieldInfo extends FieldInfo
/**
* Accessor for lookupName
*
* @return
*/
public String getLookupName()
{
public String getLookupName() {
return lookupName;
}
public boolean isCollection()
{
public boolean isCollection() {
return isCollection;
}
public void setCollection()
{
public void setCollection() {
isCollection = true;
}
public void setFlags()
{
public void setFlags() {
isFlags = true;
}
public boolean isFlags()
{
public boolean isFlags() {
return isFlags;
}
public Object getValueOf(String enumStringValue)
{
public Object getValueOf(String enumStringValue) {
Object value = valueLookup.get(enumStringValue);
if (value==null)
{
if (value == null) {
long bitValue = 1;
for (EnumValueInfo val: values)
{
for (EnumValueInfo val : values) {
valueLookup.put(val.getValue(), bitValue);
if (isFlags)
{
if (isFlags) {
bitValue = bitValue * 2;
}
else
{
} else {
bitValue = bitValue + 1;
}
}