Skip to content

Commit

Permalink
Add Component Property API
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Kesterson <rkesters@gmail.com>
  • Loading branch information
rkesters committed Jul 28, 2023
1 parent 924a007 commit ed3bd00
Show file tree
Hide file tree
Showing 9 changed files with 866 additions and 75 deletions.
1 change: 1 addition & 0 deletions cp.txt

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions src/main/java/org/dependencytrack/model/ComponentProperty.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* This file is part of Dependency-Track.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Steve Springett. All Rights Reserved.
*/
package org.dependencytrack.model;

import alpine.model.IConfigProperty;
import alpine.server.json.TrimmedStringDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
* User-defined key/value model for individual projects.
*
* @author Steve Springett
* @since 3.0.0
*/
@PersistenceCapable(table = "COMPONENT_PROPERTY")
@Unique(name="COMPONENT_PROPERTY_KEYS_IDX", members={"component", "groupName", "propertyName"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ComponentProperty implements IConfigProperty, Serializable {

private static final long serialVersionUID = -6728711858486727102L;

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE)
@JsonIgnore
private long id;

@Persistent
@Column(name = "COMPONENT_ID", allowsNull = "false")
private Component component;

@Persistent
@Column(name = "GROUPNAME", allowsNull = "false")
@NotBlank
@Size(min = 1, max = 255)
@JsonDeserialize(using = TrimmedStringDeserializer.class)
@Pattern(regexp = "[\\P{Cc}]+", message = "The groupName must not contain control characters")
private String groupName;

@Persistent
@Column(name = "PROPERTYNAME", allowsNull = "false")
@NotBlank
@Size(min = 1, max = 255)
@JsonDeserialize(using = TrimmedStringDeserializer.class)
@Pattern(regexp = "[\\P{Cc}]+", message = "The propertyName must not contain control characters")
private String propertyName;

@Persistent
@Column(name = "PROPERTYVALUE", length = 1024)
@Size(min = 0, max = 1024)
@JsonDeserialize(using = TrimmedStringDeserializer.class)
@Pattern(regexp = "[\\P{Cc}]+", message = "The propertyValue must not contain control characters")
private String propertyValue;

@Persistent
@Column(name = "PROPERTYTYPE", jdbcType = "VARCHAR", allowsNull = "false")
@NotNull
private PropertyType propertyType;

@Persistent
@Column(name = "DESCRIPTION")
@Size(max = 255)
@JsonDeserialize(using = TrimmedStringDeserializer.class)
@Pattern(regexp = "[\\P{Cc}]+", message = "The description must not contain control characters")
private String description;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public Component getComponent() {
return component;
}

public void setComponent(Component component) {
this.component = component;
}

public String getGroupName() {
return groupName;
}

public void setGroupName(String groupName) {
this.groupName = groupName;
}

public String getPropertyName() {
return propertyName;
}

public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}

public String getPropertyValue() {
return propertyValue;
}

public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}

public PropertyType getPropertyType() {
return propertyType;
}

public void setPropertyType(PropertyType propertyType) {
this.propertyType = propertyType;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

}
Loading

0 comments on commit ed3bd00

Please sign in to comment.