Commit 91ee5b1d authored by Noel Alonso's avatar Noel Alonso
Browse files

Elimina restos de funcionalidades obsoletas

parent 62dac4ef
Loading
Loading
Loading
Loading
+0 −94
Original line number Diff line number Diff line
package es.redmic.tasks.ingest.model.matching.series.objectcollectingseries.dto;

/*-
 * #%L
 * Tasks
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.ArrayList;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull;

import es.redmic.tasks.ingest.model.matching.common.dto.ClassificationDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemClassificationDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemCommonDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemRemarkDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.MatchingBaseDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ParameterDTO;

@JsonSchemaNotNull
public class ObjectCollectingSeriesMatching extends MatchingBaseDTO {

	@NotNull
	@Valid
	private ParameterDTO parameter;
	
	@NotNull
	@Valid
	private ClassificationDTO classifications;
	
	@Valid
	private ItemRemarkDTO remark;

	public ParameterDTO getParameter() {
		return parameter;
	}

	public void setParameter(ParameterDTO parameter) {
		this.parameter = parameter;
	}

	public ClassificationDTO getClassifications() {
		return classifications;
	}

	public void setClassifications(ClassificationDTO classifications) {
		this.classifications = classifications;
		
		for (ItemClassificationDTO item: classifications.getMatching())
			matchingColumns.addAll(item.getColumns());
	}
	
	public ItemRemarkDTO getRemark() {
		return remark;
	}

	public void setRemark(ItemRemarkDTO remark) {
		this.remark = remark;
		
		if(remark != null)
			matchingColumns.addAll(remark.getColumns());
	}
	
	@SuppressWarnings("serial")
	@JsonIgnore
	public List<ItemCommonDTO> getItemsCommon() {
		
		return new ArrayList<ItemCommonDTO>() {{
			add(getDate());
			if (getRemark() != null) add(getRemark());
			if (getQFlag() != null) add(getQFlag());
			if (getVFlag() != null) add(getVFlag());
		}};
	}
}
+0 −79
Original line number Diff line number Diff line
package es.redmic.tasks.ingest.model.matching.series.timeseries.dto;

/*-
 * #%L
 * Tasks
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.ArrayList;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull;

import es.redmic.tasks.ingest.model.matching.common.dto.ItemCommonDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemParameterDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemRemarkDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.MatchingBaseDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ParametersDTO;

@JsonSchemaNotNull
public class TimeSeriesMatching extends MatchingBaseDTO {
	
	@NotNull
	@Valid
	private ParametersDTO parameters;
	
	@Valid
	private ItemRemarkDTO remark;

	public ParametersDTO getParameters() {
		return parameters;
	}

	public void setParameters(ParametersDTO parameters) {
		this.parameters = parameters;
		for (ItemParameterDTO item : parameters.getMatching())
			matchingColumns.addAll(item.getColumns());
	}
	
	public ItemRemarkDTO getRemark() {
		return remark;
	}

	public void setRemark(ItemRemarkDTO remark) {
		this.remark = remark;
		if (remark != null)
			matchingColumns.addAll(remark.getColumns());
	}
	
	@SuppressWarnings("serial")
	@JsonIgnore
	public List<ItemCommonDTO> getItemsCommon() {
		
		return new ArrayList<ItemCommonDTO>() {{
			add(getDate());
			if (getRemark() != null) add(getRemark());
			if (getQFlag() != null) add(getQFlag());
			if (getVFlag() != null) add(getVFlag());
		}};
	}
}
+0 −79
Original line number Diff line number Diff line
package es.redmic.tasks.ingest.model.matching.tracking.dto;

/*-
 * #%L
 * Tasks
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.ArrayList;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull;

import es.redmic.tasks.ingest.model.matching.common.dto.ItemCommonDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemDeviceDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.ItemPointGeometryDTO;
import es.redmic.tasks.ingest.model.matching.common.dto.MatchingBaseDTO;

@JsonSchemaNotNull
public class TrackingMatching extends MatchingBaseDTO {
	
	@NotNull
	@Valid
	private ItemPointGeometryDTO pointGeometry;
	
	@NotNull
	@Valid
	private ItemDeviceDTO device;
	
	public TrackingMatching() {
		super();
	}

	public ItemPointGeometryDTO getPointGeometry() {
		return pointGeometry;
	}

	public void setPointGeometry(ItemPointGeometryDTO pointGeometry) {
		this.pointGeometry = pointGeometry;
		matchingColumns.addAll(pointGeometry.getColumns());
	}

	public ItemDeviceDTO getDevice() {
		return device;
	}

	public void setDevice(ItemDeviceDTO device) {
		this.device = device;
	}
	
	@SuppressWarnings("serial")
	@JsonIgnore
	public List<ItemCommonDTO> getItemsCommon() {
		
		return new ArrayList<ItemCommonDTO>() {{
			add(getDate());
			if (getQFlag() != null) add(getQFlag());
			if (getVFlag() != null) add(getVFlag());
		}};
	}
}
+0 −93
Original line number Diff line number Diff line
package es.redmic.test.tasks.unit.job.ingest.deserialize;

/*-
 * #%L
 * Tasks
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import org.junit.BeforeClass;
import org.junit.Test;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kjetland.jackson.jsonSchema.JsonSchemaGenerator;
import com.kjetland.jackson.jsonSchema.JsonSchemaResources;

import es.redmic.tasks.ingest.model.intervention.matching.RequestUserInterventionMatchingTaskDTO;
import es.redmic.tasks.ingest.model.matching.series.timeseries.dto.TimeSeriesMatching;

public class DeserializeDTOsTest {

	ObjectMapper jacksonMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

	private static Validator validator;

	static final String path = "/data/tasks/ingest/timeseries/";

	@BeforeClass
	public static void setUp() {
		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();

		validator = factory.getValidator();
	}

	@Test
	public void DeserializeIngestDataDTOToReturnOK() throws IOException {

		InputStream resource = getClass().getResource(path + "Intervention.json").openStream();

		RequestUserInterventionMatchingTaskDTO dto = jacksonMapper.readValue(resource,
				RequestUserInterventionMatchingTaskDTO.class);

		Set<ConstraintViolation<RequestUserInterventionMatchingTaskDTO>> error = validator.validate(dto);

		assertEquals(error.size(), 0);
		assertNotNull(dto.getInterventionDescription().getMatching());

		assertThat(dto, instanceOf(RequestUserInterventionMatchingTaskDTO.class));
		assertEquals(dto.getInterventionDescription().getMatching(), loadSchema(TimeSeriesMatching.class));
	}

	@SuppressWarnings("unchecked")
	protected Map<String, Object> loadSchema(Class<?> typeOfTDTO) {

		JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator(jacksonMapper,
				JsonSchemaResources.setResources(new HashMap<>()));

		JsonNode jsonSchema = jsonSchemaGenerator.generateJsonSchema(typeOfTDTO);

		return jacksonMapper.convertValue(jsonSchema, Map.class);
	}
}
+0 −17
Original line number Diff line number Diff line
Fecha;TrashType;TrashOrigin
01-01-2013;1;2
01-05-2013;0;4
01-09-2013;3;1
01-12-2013;1;1
01-01-2014;3;0
01-05-2014;0;0
01-09-2014;12;8
01-12-2014;32;0
01-01-2015;1;1
01-05-2015;3;0
01-09-2015;5;9
01-12-2015;0;7
01-01-2016;3;8
01-05-2016;1;2
01-09-2016;3;1
01-12-2016;7;7
 No newline at end of file
Loading