From 0c0fcde6f66752bb806f6ece04a9e38f99d83d26 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 13 Dec 2017 07:26:44 +0000 Subject: [PATCH] SSDM-5773: Refactoring AbstractCreateEntityTypeExecutor by extracting CreatePropertyAssignmentsExecutor SVN: 39033 --- .../v3/helper/entity/EntityTypeUtils.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/entity/EntityTypeUtils.java diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/entity/EntityTypeUtils.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/entity/EntityTypeUtils.java new file mode 100644 index 00000000000..7e988389b87 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/entity/EntityTypeUtils.java @@ -0,0 +1,48 @@ +/* + * Copyright 2017 ETH Zuerich, SIS + * + * 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. + */ + +package ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity; + +import java.util.Collection; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.create.PropertyAssignmentCreation; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class EntityTypeUtils +{ + public static void checkPropertyAssignmentCreations(Collection<PropertyAssignmentCreation> propertyAssignments) + { + if (propertyAssignments != null) + { + for (PropertyAssignmentCreation assignmentCreation : propertyAssignments) + { + if (assignmentCreation.getPropertyTypeId() == null) + { + throw new UserFailureException("PropertyTypeId cannot be null."); + } + if (assignmentCreation.getOrdinal() != null && assignmentCreation.getOrdinal() <= 0) + { + throw new UserFailureException("Ordinal cannot be <= 0."); + } + } + } + } +} -- GitLab