Commit 127afc04 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added comments, refactoring, improved testing

parent 0527414f
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -20,6 +20,11 @@
            <artifactId>TapSchemaManagerDL</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>ari.ucd</groupId>
            <artifactId>ucdvalidator</artifactId>
            <version>1.0beta</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
@@ -53,8 +58,8 @@
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
+22 −15
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ import java.io.Serializable;

/**
 *
 * @author Sonia Zorba <zorba at oats.inaf.it>
 * @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
 */
public class Column extends EntityWrapper<ColumnEntity> implements Serializable {

@@ -28,10 +28,10 @@ public class Column extends EntityWrapper<ColumnEntity> implements Serializable

    private boolean hidden;

    public Column(TapSchemaHandler tapSchemaHandler, ColumnEntity columnEntity, boolean primaryKey) {
    public Column(TapSchemaHandler tapSchemaHandler, ColumnEntity columnEntity) {
        super(columnEntity, UTYPE, UCD, UNIT, DESCRIPTION, STD, PRINCIPAL);
        hidden = true;
        this.primaryKey = primaryKey;
        this.primaryKey = columnEntity.isPrimaryKey();
        this.datatype = columnEntity.getDatatype();
        this.size = columnEntity.getSize();
        this.indexed = columnEntity.getIndexed() == 1;
@@ -51,18 +51,25 @@ public class Column extends EntityWrapper<ColumnEntity> implements Serializable
    @Override
    protected void afterSetValue(String key, String value) {
        ColumnEntity columnEntity = getEntity();
        if (key.equals(UTYPE)) {
        switch (key) {
            case UTYPE:
                columnEntity.setUtype(value);
        } else if (key.equals(UCD)) {
                break;
            case UCD:
                columnEntity.setUcd(value);
        } else if (key.equals(UNIT)) {
                break;
            case UNIT:
                columnEntity.setUnit(value);
        } else if (key.equals(DESCRIPTION)) {
                break;
            case DESCRIPTION:
                columnEntity.setDescription(value);
        } else if (key.equals(STD)) {
                break;
            case STD:
                columnEntity.setStd(Integer.parseInt(value));
        } else if (key.equals(PRINCIPAL)) {
                break;
            case PRINCIPAL:
                columnEntity.setPrincipal(Integer.parseInt(value));
                break;
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Sonia Zorba <zorba at oats.inaf.it>
 * @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
 */
@XmlRootElement(name = "credentials-config")
public class CredentialsConfiguration {
@@ -20,7 +20,7 @@ public class CredentialsConfiguration {
    private List<Object> credentialsInfo;

    public CredentialsConfiguration() {
        credentialsInfo = new ArrayList<Object>();
        credentialsInfo = new ArrayList<>();
    }

    public void addCredentials(Credentials credentials) {
+0 −14
Original line number Diff line number Diff line
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.inaf.oats.ia2.tapschemamanager.businesslayer;

/**
 *
 * @author Sonia Zorba <zorba at oats.inaf.it>
 */
public class CredentialsConfigurationBean {
    
}
+4 −4
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import java.util.Map;

/**
 *
 * @author Sonia Zorba <zorba at oats.inaf.it>
 * @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
 * @param <T>
 */
public abstract class EntityWrapper<T extends TapSchemaEntity> implements Serializable {
@@ -23,8 +23,8 @@ public abstract class EntityWrapper<T extends TapSchemaEntity> implements Serial
    private Status status;

    public EntityWrapper(T entity, String... supportedKeys) {
        originalValues = new HashMap<String, String>();
        editedValues = new HashMap<String, String>();
        originalValues = new HashMap<>();
        editedValues = new HashMap<>();
        this.entity = entity;
        this.supportedKeys = Arrays.asList(supportedKeys);
    }
@@ -48,7 +48,7 @@ public abstract class EntityWrapper<T extends TapSchemaEntity> implements Serial
    protected abstract void afterSetValue(String key, String value);

    public final void setValue(String key, String value) {
        if (originalValues.get(key) == null && value.equals("")) {
        if (originalValues.get(key) == null && value.isEmpty()) {
            value = null;
        }
        editedValues.put(key, value);
Loading