Commit 91e65868 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Refactoring: simplification of application architecture (removed dependencies...

Refactoring: simplification of application architecture (removed dependencies to Jersey and AngularJS, managed all operations using JSF and JavaScript onevent functions)
parent 5a297385
Loading
Loading
Loading
Loading
+1 −28
Original line number Diff line number Diff line
@@ -14,18 +14,6 @@
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>    
        
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>2.6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <dependency>
            <groupId>it.inaf.oats.ia2</groupId>
@@ -45,21 +33,6 @@
            <type>jar</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.flipkart.zjsonpatch</groupId>
            <artifactId>zjsonpatch</artifactId>
            <version>0.2.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
+50 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ import java.io.Serializable;
 */
public class Column extends EntityWrapper<ColumnEntity> implements Serializable {

    private static final long serialVersionUID = 2835969352471501746L;

    public static final String UTYPE = "utype";
    public static final String UCD = "ucd";
    public static final String UNIT = "unit";
@@ -94,4 +96,52 @@ public class Column extends EntityWrapper<ColumnEntity> implements Serializable
    public boolean isIndexed() {
        return indexed;
    }

    public boolean getStd() {
        return getValue(STD).equals("1");
    }

    public void setStd(boolean std) {
        setValue(STD, std ? "1" : "0");
    }

    public boolean getPrincipal() {
        return getValue(PRINCIPAL).equals("1");
    }

    public void setPrincipal(boolean principal) {
        setValue(PRINCIPAL, principal ? "1" : "0");
    }

    public String getUcd() {
        return getValue(UCD);
    }

    public void setUcd(String ucd) {
        setValue(UCD, ucd);
    }

    public String getUtype() {
        return getValue(UTYPE);
    }

    public void setUtype(String utype) {
        setValue(UTYPE, utype);
    }

    public String getUnit() {
        return getValue(UNIT);
    }

    public void setUnit(String unit) {
        setValue(UNIT, unit);
    }

    public String getDescription() {
        return getValue(DESCRIPTION);
    }

    public void setDescription(String description) {
        setValue(DESCRIPTION, description);
    }
}
+13 −4
Original line number Diff line number Diff line
@@ -13,17 +13,22 @@ import java.util.Map;
 */
public abstract class EntityWrapper<T extends TapSchemaEntity> {

    private final T entity;
    private T entity;
    private final Map<String, String> originalValues;
    private final Map<String, String> editedValues;
    private final List<String> supportedKeys;
    private List<String> supportedKeys;
    private Status status;

    // Only for deserialization
    protected EntityWrapper() {
        originalValues = new HashMap<String, String>();
        editedValues = new HashMap<String, String>();
    }
    
    public EntityWrapper(T entity, String... supportedKeys) {
        this();
        this.entity = entity;
        this.supportedKeys = Arrays.asList(supportedKeys);
        originalValues = new HashMap<String, String>();
        editedValues = new HashMap<String, String>();
    }

    public List<String> getSupportedKeys() {
@@ -101,4 +106,8 @@ public abstract class EntityWrapper<T extends TapSchemaEntity> {
    protected void undoChanges() {
        editedValues.clear();
    }
    
    public boolean isToRemove() {
        return status == Status.TO_REMOVE;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ public interface EntityWrapperContainer<T extends EntityWrapper> {
    
    public List<String> getAddables();

    public List<T> getAllEntityWrappers();
    public <T> List<T> getAllEntityWrappers();

    public void addEntityWrapper(String name) throws SQLException;

+49 −9
Original line number Diff line number Diff line
@@ -17,13 +17,20 @@ import java.util.TreeMap;
 */
public class Schema extends EntityWrapper<SchemaEntity> implements EntityWrapperContainer<Table>, Serializable {

    private static final long serialVersionUID = -1564499229970697945L;

    public static final String UTYPE = "utype";
    public static final String DESCRIPTION = "description";

    private final TapSchemaHandler tapSchemaHandler;
    private TapSchemaHandler tapSchemaHandler;

    private String selectedTable;
    private final Map<String, Table> tables;
    private Map<String, Table> tables;

    // Only for deserialization
    protected Schema() {
        super();
    }

    public Schema(TapSchemaHandler tapSchemaHandler, SchemaEntity schemaEntity) throws SQLException {
        super(schemaEntity, UTYPE, DESCRIPTION);
@@ -83,15 +90,32 @@ public class Schema extends EntityWrapper<SchemaEntity> implements EntityWrapper

    @Override
    public void removeEntityWrapper(String name) {
        Table table = tables.get(name);
        String previousTable = null;
        boolean changeSelection = false;
        TableEntity tableEntity = null;
        for (Table table : tables.values()) {
            if (table.getName().equals(name)) {
                if (table.getStatus() == Status.ADDED_NOT_PERSISTED) {
                    tables.remove(name);
                    changeSelection = true;
                } else {
                    table.setStatus(Status.TO_REMOVE);
                }
        selectedTable = tables.isEmpty() ? null : tables.keySet().iterator().next();
                tableEntity = table.getEntity();
                break;
            }
            previousTable = table.getName();
        }

        if (changeSelection) {
            if (tables.isEmpty()) {
                selectedTable = null;
            } else {
                selectedTable = previousTable == null ? tables.keySet().iterator().next() : previousTable;
            }
        }

        tapSchemaHandler.removeTable(getEntity(), table.getEntity());
        tapSchemaHandler.removeTable(getEntity(), tableEntity);
    }

    @Override
@@ -137,4 +161,20 @@ public class Schema extends EntityWrapper<SchemaEntity> implements EntityWrapper
    public Table getSelectedEntity() {
        return selectedTable == null ? null : tables.get(selectedTable);
    }

    public String getUtype() {
        return getValue(UTYPE);
    }

    public void setUtype(String utype) {
        setValue(UTYPE, utype);
    }

    public String getDescription() {
        return getValue(DESCRIPTION);
    }

    public void setDescription(String description) {
        setValue(DESCRIPTION, description);
    }
}
Loading