diff --git a/.gitignore b/.gitignore index 8d3e714262..59480b08f4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ build/ # Marquez configuration config.yml +/.metadata/ diff --git a/src/main/java/marquez/api/mappers/NamespaceApiMapper.java b/src/main/java/marquez/api/mappers/NamespaceApiMapper.java index 1377405650..4f14fb7f6d 100644 --- a/src/main/java/marquez/api/mappers/NamespaceApiMapper.java +++ b/src/main/java/marquez/api/mappers/NamespaceApiMapper.java @@ -21,6 +21,7 @@ import marquez.service.models.Namespace; public class NamespaceApiMapper extends Mapper { + public Namespace map(NamespaceResponse namespace) { requireNonNull(namespace, "namespace must not be null"); return new Namespace( diff --git a/src/main/java/marquez/api/mappers/NamespaceMapper.java b/src/main/java/marquez/api/mappers/NamespaceMapper.java new file mode 100644 index 0000000000..2373c68919 --- /dev/null +++ b/src/main/java/marquez/api/mappers/NamespaceMapper.java @@ -0,0 +1,30 @@ +/* + * 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 marquez.api.mappers; + +import lombok.NonNull; +import marquez.api.models.NamespaceRequest; +import marquez.common.models.NamespaceName; +import marquez.service.models.Namespace; + +public final class NamespaceMapper { + private NamespaceMapper() {} + + public static Namespace map( + @NonNull NamespaceName namespaceName, @NonNull NamespaceRequest request) { + return new Namespace( + namespaceName.getValue(), request.getOwner(), request.getDescription().orElse(null)); + } +} diff --git a/src/main/java/marquez/service/models/Namespace.java b/src/main/java/marquez/service/models/Namespace.java index ac7340048c..a3b24aaec6 100644 --- a/src/main/java/marquez/service/models/Namespace.java +++ b/src/main/java/marquez/service/models/Namespace.java @@ -43,4 +43,12 @@ public Namespace( this.ownerName = ownerName; this.description = description; } + + public Namespace(String name, String ownerName, String description) { + this.guid = null; + this.name = name; + this.createdAt = null; + this.ownerName = ownerName; + this.description = description; + } }