/*
 * Copyright 2021 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * 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 com.b2international.snowowl.core.codesystem;

import java.io.Serializable;
import java.util.List;

import com.b2international.index.revision.RevisionBranch.BranchState;
import com.b2international.snowowl.core.branch.BranchInfo;
import com.b2international.snowowl.core.uri.CodeSystemURI;

/**
 * @since 7.17.0
 */
public final class UpgradeInfo implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	BranchInfo upgradeOfBranchInfo;
	List<BranchInfo> versionBranchInfos;
	List<CodeSystemURI> availableVersions;
	
	public UpgradeInfo(BranchInfo upgradeOfBranchInfo, List<BranchInfo> versionBranchInfos, List<CodeSystemURI> availableVersions) {
		this.upgradeOfBranchInfo = upgradeOfBranchInfo;
		this.versionBranchInfos = versionBranchInfos;
		this.availableVersions = availableVersions;
	}
	
	// returns the BranchInfo of the upgradeOf Code System's HEAD
	public BranchInfo getUpgradeOfBranchInfo() {
		return upgradeOfBranchInfo;
	}
	
	public List<BranchInfo> getVersionBranchInfos() {
		return versionBranchInfos;
	}
	
	public List<CodeSystemURI> getAvailableVersions() {
		return availableVersions;
	}
	
	public boolean isBlocked() {
		return upgradeOfBranchInfo.getState()  == BranchState.DIVERGED || upgradeOfBranchInfo.getState()  == BranchState.BEHIND;
	}
	
}

@@ -910,16 +910,175 @@
 stemURI;
+%0Aimport com.fasterxml.jackson.annotation.JsonCreator;%0Aimport com.fasterxml.jackson.annotation.JsonIgnore;%0Aimport com.fasterxml.jackson.annotation.JsonProperty;
 %0A%0A/**%0A *
@@ -1320,16 +1320,30 @@
 ions;%0A%09%0A
+%09@JsonCreator%0A
 %09public 
@@ -1358,76 +1358,196 @@
 nfo(
-BranchInfo upgradeOfBranchInfo, List%3CBranchInfo%3E versionBranchInfos,
+%0A%09%09%09@JsonProperty(%22upgradeOfBranchInfo%22) BranchInfo upgradeOfBranchInfo, %0A%09%09%09@JsonProperty(%22versionBranchInfos%22) List%3CBranchInfo%3E versionBranchInfos, %0A%09%09%09@JsonProperty(%22availableVersions%22)
  Lis
@@ -2042,26 +2042,39 @@
 ersions;%0A%09%7D%0A
-
 %09%0A
+%09@JsonIgnore%0A
 %09public bool

add annotation for rest service test