001package org.apache.archiva.redback.rest.api.model.v2; 002/* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020import io.swagger.v3.oas.annotations.media.Schema; 021import org.apache.archiva.redback.role.model.ModelApplication; 022import org.apache.archiva.redback.role.model.ModelTemplate; 023 024import java.io.Serializable; 025 026/** 027 * @author Martin Stockhammer <martin_s@apache.org> 028 */ 029@Schema(name="roleTemplate",description = "Information about role templates") 030public class RoleTemplate implements Serializable 031{ 032 private static final long serialVersionUID = 8639174144508127048L; 033 034 private String id; 035 private String name; 036 private String description; 037 private String applicationId; 038 private boolean assignable; 039 private boolean permanent; 040 041 public static RoleTemplate of( ModelApplication application, ModelTemplate template ) { 042 RoleTemplate tmpl = new RoleTemplate( ); 043 tmpl.setApplicationId( application.getId( ) ); 044 tmpl.setId( template.getId( ) ); 045 tmpl.setName( template.getNamePrefix() ); 046 tmpl.setAssignable( template.isAssignable( ) ); 047 tmpl.setPermanent( template.isPermanent() ); 048 tmpl.setDescription( template.getDescription( ) ); 049 return tmpl; 050 } 051 052 053 @Schema(description = "The template identifier") 054 public String getId( ) 055 { 056 return id; 057 } 058 059 public void setId( String id ) 060 { 061 this.id = id; 062 } 063 064 @Schema(description = "The name of the template") 065 public String getName( ) 066 { 067 return name; 068 } 069 070 public void setName( String name ) 071 { 072 this.name = name; 073 } 074 075 @Schema(description = "The template description") 076 public String getDescription( ) 077 { 078 return description; 079 } 080 081 public void setDescription( String description ) 082 { 083 this.description = description; 084 } 085 086 @Schema(name="application_id", description = "Identifier of the application this template is part of") 087 public String getApplicationId( ) 088 { 089 return applicationId; 090 } 091 092 public void setApplicationId( String applicationId ) 093 { 094 this.applicationId = applicationId; 095 } 096 097 @Schema(description = "If a template instance can be assigned") 098 public boolean isAssignable( ) 099 { 100 return assignable; 101 } 102 103 public void setAssignable( boolean assignable ) 104 { 105 this.assignable = assignable; 106 } 107 108 @Schema(description = "If the template is permanent and cannot be deleted") 109 public boolean isPermanent( ) 110 { 111 return permanent; 112 } 113 114 public void setPermanent( boolean permanent ) 115 { 116 this.permanent = permanent; 117 } 118}