repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/model/LdapUserImportStatus.java | src/main/java/org/ohdsi/webapi/user/importer/model/LdapUserImportStatus.java | package org.ohdsi.webapi.user.importer.model;
public enum LdapUserImportStatus {
NEW_USER, MODIFIED, EXISTS
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/model/LdapObject.java | src/main/java/org/ohdsi/webapi/user/importer/model/LdapObject.java | package org.ohdsi.webapi.user.importer.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public abstract class LdapObject {
@JsonProperty("displayName")
private String displayName;
@JsonProperty("distinguishedName")
private String distinguishedName;
public LdapObject() {
}
public LdapObject(String displayName, String distinguishedName) {
this.displayName = displayName;
this.distinguishedName = distinguishedName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDistinguishedName() {
return distinguishedName;
}
public void setDistinguishedName(String distinguishedName) {
this.distinguishedName = distinguishedName;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/model/UserImportResult.java | src/main/java/org/ohdsi/webapi/user/importer/model/UserImportResult.java | package org.ohdsi.webapi.user.importer.model;
public class UserImportResult {
private int created = 0;
private int updated = 0;
public UserImportResult() {
}
public UserImportResult(int created, int updated) {
this.created = created;
this.updated = updated;
}
public int getCreated() {
return created;
}
public void setCreated(int created) {
this.created = created;
}
public int getUpdated() {
return updated;
}
public void setUpdated(int updated) {
this.updated = updated;
}
public void incCreated() {
this.created++;
}
public void incUpdated() {
this.updated++;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/exception/JobAlreadyExistException.java | src/main/java/org/ohdsi/webapi/user/importer/exception/JobAlreadyExistException.java | package org.ohdsi.webapi.user.importer.exception;
public class JobAlreadyExistException extends RuntimeException {
public JobAlreadyExistException() {
}
public JobAlreadyExistException(String message) {
super(message);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/utils/RoleGroupUtils.java | src/main/java/org/ohdsi/webapi/user/importer/utils/RoleGroupUtils.java | package org.ohdsi.webapi.user.importer.utils;
import org.ohdsi.webapi.user.importer.model.RoleGroupEntity;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class RoleGroupUtils {
public static boolean equalsRoleGroupMapping(RoleGroupEntity a, RoleGroupEntity b) {
if (Objects.isNull(a) && Objects.isNull(b)) {
return true;
}
if (Objects.nonNull(a) && Objects.nonNull(b)) {
return Objects.equals(a.getProvider(), b.getProvider())
&& Objects.equals(a.getGroupDn(), b.getGroupDn())
&& Objects.equals(a.getRole().getId(), b.getRole().getId());
}
return false;
}
public static Predicate<RoleGroupEntity> equalsPredicate(RoleGroupEntity e) {
return m -> RoleGroupUtils.equalsRoleGroupMapping(e, m);
}
public static List<RoleGroupEntity> subtract(List<RoleGroupEntity> source, List<RoleGroupEntity> target) {
return source
.stream()
.filter(m -> target.stream().noneMatch(RoleGroupUtils.equalsPredicate(m)))
.collect(Collectors.toList());
}
public static List<RoleGroupEntity> findCreated(List<RoleGroupEntity> source, List<RoleGroupEntity> target) {
return subtract(target, source);
}
public static List<RoleGroupEntity> findDeleted(List<RoleGroupEntity> source, List<RoleGroupEntity> target) {
return subtract(source, target);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/repository/UserImportJobRepository.java | src/main/java/org/ohdsi/webapi/user/importer/repository/UserImportJobRepository.java | package org.ohdsi.webapi.user.importer.repository;
import com.odysseusinc.scheduler.repository.ArachneJobRepository;
import org.ohdsi.webapi.user.importer.model.LdapProviderType;
import org.ohdsi.webapi.user.importer.model.UserImportJob;
import java.util.stream.Stream;
public interface UserImportJobRepository extends ArachneJobRepository<UserImportJob> {
UserImportJob findByProviderType(LdapProviderType providerType);
Stream<UserImportJob> findUserImportJobsBy();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/repository/UserImportJobHistoryItemRepository.java | src/main/java/org/ohdsi/webapi/user/importer/repository/UserImportJobHistoryItemRepository.java | package org.ohdsi.webapi.user.importer.repository;
import org.ohdsi.webapi.user.importer.model.LdapProviderType;
import org.ohdsi.webapi.user.importer.model.UserImportJobHistoryItem;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
import java.util.stream.Stream;
public interface UserImportJobHistoryItemRepository extends JpaRepository<UserImportJobHistoryItem, Long> {
Stream<UserImportJobHistoryItem> findByUserImportId(Long userImportId);
Optional<UserImportJobHistoryItem> findFirstByUserImportIdOrderByEndTimeDesc(Long userImportId);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/repository/RoleGroupRepository.java | src/main/java/org/ohdsi/webapi/user/importer/repository/RoleGroupRepository.java | package org.ohdsi.webapi.user.importer.repository;
import org.ohdsi.webapi.user.importer.model.RoleGroupEntity;
import org.ohdsi.webapi.user.importer.model.LdapProviderType;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface RoleGroupRepository extends JpaRepository<RoleGroupEntity, Integer> {
List<RoleGroupEntity> findByProviderAndUserImportJobNull(LdapProviderType provider);
void deleteByRoleId(Long roleId);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/repository/LdapProviderTypeConverter.java | src/main/java/org/ohdsi/webapi/user/importer/repository/LdapProviderTypeConverter.java | package org.ohdsi.webapi.user.importer.repository;
import org.ohdsi.webapi.user.importer.model.LdapProviderType;
import javax.persistence.AttributeConverter;
import java.util.Objects;
public class LdapProviderTypeConverter implements AttributeConverter<LdapProviderType, String> {
@Override
public String convertToDatabaseColumn(LdapProviderType providerType) {
return Objects.nonNull(providerType) ? providerType.getValue() : null;
}
@Override
public LdapProviderType convertToEntityAttribute(String value) {
return Objects.nonNull(value) ? LdapProviderType.fromValue(value) : null;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/providers/OhdsiLdapUtils.java | src/main/java/org/ohdsi/webapi/user/importer/providers/OhdsiLdapUtils.java | package org.ohdsi.webapi.user.importer.providers;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.ldap.filter.OrFilter;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class OhdsiLdapUtils {
public static String valueAsString(Attribute attribute) throws NamingException {
return Objects.nonNull(attribute) ? attribute.get().toString() : "";
}
public static List<String> valueAsList(Attribute attribute) throws NamingException {
List<String> result = new ArrayList<>();
if (Objects.nonNull(attribute)) {
for (int i = 0; i < attribute.size(); i++) {
result.add(attribute.get(i).toString());
}
}
return result;
}
public static OrFilter getCriteria(String attribute, Set<String> values) {
OrFilter filter = new OrFilter();
values.forEach(v -> filter.or(new EqualsFilter(attribute, v)));
return filter;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/providers/LdapProvider.java | src/main/java/org/ohdsi/webapi/user/importer/providers/LdapProvider.java | package org.ohdsi.webapi.user.importer.providers;
import org.ohdsi.webapi.user.importer.model.LdapGroup;
import org.ohdsi.webapi.user.importer.model.LdapUser;
import org.springframework.ldap.core.*;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import java.util.List;
import java.util.Set;
public interface LdapProvider {
LdapTemplate getLdapTemplate();
List<LdapGroup> getLdapGroups(Attributes attributes) throws NamingException;
SearchControls getUserSearchControls();
Set<String> getGroupClasses();
Set<String> getUserClass();
String getSearchUserFilter();
List<LdapUser> findUsers();
List<LdapGroup> findGroups(String searchStr);
String getLoginAttributeName();
String getDistinguishedAttributeName();
String getDisplayNameAttributeName();
CollectingNameClassPairCallbackHandler<LdapUser> getUserSearchCallbackHandler(AttributesMapper<LdapUser> attributesMapper);
String getPrincipal();
String getPassword();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/providers/DefaultLdapProvider.java | src/main/java/org/ohdsi/webapi/user/importer/providers/DefaultLdapProvider.java | package org.ohdsi.webapi.user.importer.providers;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.user.importer.model.LdapGroup;
import org.ohdsi.webapi.user.importer.model.LdapUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.AuthenticationSource;
import org.springframework.ldap.core.CollectingNameClassPairCallbackHandler;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.ldap.filter.OrFilter;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.naming.NameClassPair;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static org.ohdsi.webapi.user.importer.providers.OhdsiLdapUtils.getCriteria;
import static org.ohdsi.webapi.user.importer.providers.OhdsiLdapUtils.valueAsString;
@Component
@ConditionalOnProperty("security.ldap.url")
public class DefaultLdapProvider extends AbstractLdapProvider {
private static final String DN = "DN";
private static final String[] RETURNING_ATTRS = {DN, "cn", "ou"};
private static final String[] USER_ATTRIBUTES = {DN, "uid", "cn"};
@Value("${security.ldap.url}")
private String ldapUrl;
@Value("${security.ldap.baseDn}")
private String baseDn;
@Value("${security.ldap.system.username}")
private String systemUsername;
@Value("${security.ldap.referral:#{null}}")
private String referral;
@Value("${security.ldap.system.password}")
private String systemPassword;
@Value("${security.ldap.ignore.partial.result.exception:false}")
private Boolean ldapIgnorePartialResultException;
@Value("${security.ldap.userImport.loginAttr}")
private String loginAttr;
@Value("${security.ldap.userImport.usernameAttr}")
private String usernameAttr;
private String[] userAttributes;
private static final Set<String> GROUP_CLASSES = ImmutableSet.of("groupOfUniqueNames", "groupOfNames", "posixGroup");
private static final Set<String> USER_CLASSES = ImmutableSet.of("account", "person");
@PostConstruct
private void init() {
List<String> attrs = Arrays.stream(USER_ATTRIBUTES)
.collect(Collectors.toList());
attrs.add(usernameAttr);
attrs.add(loginAttr);
userAttributes = attrs.stream()
.distinct().toArray(String[]::new);
}
@Override
public LdapTemplate getLdapTemplate() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);
contextSource.setBase(baseDn);
contextSource.setUserDn(systemUsername);
contextSource.setPassword(systemPassword);
contextSource.setReferral(referral);
contextSource.setCacheEnvironmentProperties(false);
contextSource.setAuthenticationSource(new AuthenticationSource() {
@Override
public String getPrincipal() {
return systemUsername;
}
@Override
public String getCredentials() {
return systemPassword;
}
});
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(ldapIgnorePartialResultException);
return ldapTemplate;
}
@Override
public List<LdapGroup> getLdapGroups(Attributes attributes) throws NamingException {
String dn = valueAsString(attributes.get(DN));
if (StringUtils.isNotEmpty(dn)) {
LdapTemplate template = getLdapTemplate();
AndFilter filter = new AndFilter();
filter.and(getCriteria("objectclass", getGroupClasses()));
OrFilter memberFilter = new OrFilter();
memberFilter.or(new EqualsFilter("uniqueMember", dn));
memberFilter.or(new EqualsFilter("member", dn));
filter.and(memberFilter);
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchControls.setReturningAttributes(RETURNING_ATTRS);
return template.search(LdapUtils.emptyLdapName(), filter.encode(), searchControls,
(AttributesMapper<LdapGroup>) attrs -> new LdapGroup(valueAsString(attrs.get("ou")), valueAsString(attrs.get(DN))));
} else {
return new ArrayList<>();
}
}
@Override
public SearchControls getUserSearchControls() {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchControls.setReturningAttributes(userAttributes);
return searchControls;
}
@Override
public String getSearchUserFilter() {
return null;
}
@Override
public List<LdapUser> search(String filter, CollectingNameClassPairCallbackHandler<LdapUser> handler) {
getLdapTemplate().search(LdapUtils.emptyLdapName(), filter, getUserSearchControls(), handler);
return handler.getList();
}
@Override
public Set<String> getGroupClasses() {
return GROUP_CLASSES;
}
@Override
public Set<String> getUserClass() {
return USER_CLASSES;
}
@Override
public String getLoginAttributeName() {
return loginAttr;
}
@Override
public String getDistinguishedAttributeName() {
return DN;
}
@Override
public String getDisplayNameAttributeName() {
return usernameAttr;
}
@Override
public CollectingNameClassPairCallbackHandler<LdapUser> getUserSearchCallbackHandler(AttributesMapper<LdapUser> attributesMapper) {
return new OpenLdapAttributesMapper<>(attributesMapper);
}
@Override
public String getPrincipal() {
return systemUsername;
}
@Override
public String getPassword() {
return systemPassword;
}
public static class OpenLdapAttributesMapper<T> extends CollectingNameClassPairCallbackHandler<T> {
private AttributesMapper<T> mapper;
public OpenLdapAttributesMapper(AttributesMapper<T> mapper) {
this.mapper = mapper;
}
@Override
public T getObjectFromNameClassPair(NameClassPair nameClassPair) throws NamingException {
if (!(nameClassPair instanceof SearchResult)) {
throw new IllegalArgumentException("Parameter must be an instance of SearchResult");
} else {
SearchResult searchResult = (SearchResult)nameClassPair;
Attributes attributes = searchResult.getAttributes();
attributes.put(DN, searchResult.getNameInNamespace());
try {
return this.mapper.mapFromAttributes(attributes);
} catch (NamingException var5) {
throw LdapUtils.convertLdapException(var5);
}
}
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/providers/AbstractLdapProvider.java | src/main/java/org/ohdsi/webapi/user/importer/providers/AbstractLdapProvider.java | package org.ohdsi.webapi.user.importer.providers;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.user.importer.model.LdapGroup;
import org.ohdsi.webapi.user.importer.model.LdapObject;
import org.ohdsi.webapi.user.importer.model.LdapUser;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.CollectingNameClassPairCallbackHandler;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.filter.AndFilter;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.ldap.support.LdapEncoder;
import org.springframework.ldap.support.LdapUtils;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.ohdsi.webapi.user.importer.providers.OhdsiLdapUtils.getCriteria;
import static org.ohdsi.webapi.user.importer.providers.OhdsiLdapUtils.valueAsString;
public abstract class AbstractLdapProvider implements LdapProvider {
public static final String OBJECTCLASS_ATTR = "objectclass";
public static final String CN_ATTR = "cn";
@Override
public List<LdapGroup> findGroups(String searchStr) {
LdapTemplate ldapTemplate = getLdapTemplate();
return ldapTemplate.search(LdapUtils.emptyLdapName(), getFilterString(searchStr), getAttributesMapper(LdapGroup::new));
}
private String getFilterString(String searchString) {
StringBuffer buff = new StringBuffer();
buff.append('(');
buff.append(CN_ATTR).append("=").append(encodeSearchString(searchString));
buff.append(')');
return buff.toString();
}
private String encodeSearchString(String searchString) {
String wildCard = "*";
if (searchString.isEmpty() || wildCard.equals(searchString)) return searchString; // nothing to encode
List<String> tokens = Arrays.asList(StringUtils.split(searchString, wildCard));
tokens.replaceAll(LdapEncoder::filterEncode);
String encodedSearchString = (searchString.startsWith(wildCard) ? wildCard : "") +
StringUtils.join(tokens, wildCard) +
(searchString.endsWith(wildCard) ? wildCard : "");
return encodedSearchString;
}
@Override
public List<LdapUser> findUsers() {
CollectingNameClassPairCallbackHandler<LdapUser> handler = getUserSearchCallbackHandler(getUserAttributesMapper());
return search(getUserFilter(), handler);
}
abstract List<LdapUser> search(String filter, CollectingNameClassPairCallbackHandler<LdapUser> handler);
private String getUserFilter () {
if (StringUtils.isNotBlank(getSearchUserFilter())) {
return getSearchUserFilter();
}
AndFilter filter = new AndFilter();
filter.and(getCriteria(OBJECTCLASS_ATTR, getUserClass()));
return filter.encode();
}
private AttributesMapper<LdapUser> getUserAttributesMapper() {
return attributes -> {
LdapUser user = getAttributesMapper(LdapUser::new).mapFromAttributes(attributes);
user.setLogin(valueAsString(attributes.get(getLoginAttributeName())));
List<LdapGroup> groups = getLdapGroups(attributes);
user.setGroups(groups);
return user;
};
}
private <T extends LdapObject> AttributesMapper<T> getAttributesMapper(Supplier<T> supplier) {
return attributes -> {
String name = valueAsString(attributes.get(getDisplayNameAttributeName()));
String dn = valueAsString(attributes.get(getDistinguishedAttributeName()));
T object = supplier.get();
object.setDisplayName(name);
object.setDistinguishedName(dn);
return object;
};
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/providers/ActiveDirectoryProvider.java | src/main/java/org/ohdsi/webapi/user/importer/providers/ActiveDirectoryProvider.java | package org.ohdsi.webapi.user.importer.providers;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.user.importer.model.LdapGroup;
import org.ohdsi.webapi.user.importer.model.LdapUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.ldap.control.PagedResultsDirContextProcessor;
import org.springframework.ldap.core.*;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.core.support.SimpleDirContextAuthenticationStrategy;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.stereotype.Component;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.SearchControls;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.odysseusinc.arachne.commons.utils.QuoteUtils.dequote;
import static org.ohdsi.webapi.user.importer.providers.OhdsiLdapUtils.valueAsList;
@Component
@ConditionalOnProperty("security.ad.url")
public class ActiveDirectoryProvider extends AbstractLdapProvider {
@Value("${security.ad.url}")
private String adUrl;
@Value("${security.ad.searchBase}")
private String adSearchBase;
@Value("${security.ad.principalSuffix}")
private String adPrincipalSuffix;
@Value("${security.ad.system.username}")
private String adSystemUsername;
@Value("${security.ad.system.password}")
private String adSystemPassword;
@Value("${security.ad.referral:#{null}}")
private String referral;
@Value("${security.ad.ignore.partial.result.exception:false}")
private Boolean adIgnorePartialResultException;
@Value("${security.ad.result.count.limit:30000}")
private Long countLimit;
@Value("${security.ad.searchFilter}")
private String adSearchFilter;
@Value("${security.ad.userImport.loginAttr}")
private String loginAttr;
@Value("${security.ad.userImport.usernameAttr}")
private String usernameAttr;
private String[] userAttributes;
private static final Set<String> GROUP_CLASSES = ImmutableSet.of("group");
private static final Set<String> USER_CLASSES = ImmutableSet.of("user");
private static final int PAGE_SIZE = 500;
@Override
public LdapTemplate getLdapTemplate() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(dequote(adUrl));
contextSource.setBase(dequote(adSearchBase));
contextSource.setUserDn(dequote(adSystemUsername));
contextSource.setPassword(dequote(adSystemPassword));
contextSource.setCacheEnvironmentProperties(false);
contextSource.setReferral(dequote(referral));
contextSource.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
contextSource.setAuthenticationSource(new AuthenticationSource() {
@Override
public String getPrincipal() {
return ActiveDirectoryProvider.this.getPrincipal();
}
@Override
public String getCredentials() {
return ActiveDirectoryProvider.this.getPassword();
}
});
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(adIgnorePartialResultException);
return ldapTemplate;
}
@Override
public List<LdapGroup> getLdapGroups(Attributes attributes) throws NamingException {
return valueAsList(attributes.get("memberOf")).stream()
.map(v -> new LdapGroup("", v))
.collect(Collectors.toList());
}
@Override
public SearchControls getUserSearchControls() {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchControls.setCountLimit(countLimit);
return searchControls;
}
@Override
public String getSearchUserFilter() {
return adSearchFilter;
}
@Override
public List<LdapUser> search(String filter, CollectingNameClassPairCallbackHandler<LdapUser> handler) {
PagedResultsDirContextProcessor pager = new PagedResultsDirContextProcessor(PAGE_SIZE);
do {
getLdapTemplate().search(LdapUtils.emptyLdapName(), filter, getUserSearchControls(), handler, pager);
pager = new PagedResultsDirContextProcessor(PAGE_SIZE, pager.getCookie());
} while (pager.getCookie() != null && pager.getCookie().getCookie() != null
&& (countLimit == 0 || handler.getList().size() < countLimit));
return handler.getList();
}
@Override
public Set<String> getGroupClasses() {
return GROUP_CLASSES;
}
@Override
public Set<String> getUserClass() {
return USER_CLASSES;
}
@Override
public String getLoginAttributeName() {
return loginAttr;
}
@Override
public String getDistinguishedAttributeName() {
return "distinguishedName";
}
@Override
public String getDisplayNameAttributeName() {
return usernameAttr;
}
@Override
public CollectingNameClassPairCallbackHandler<LdapUser> getUserSearchCallbackHandler(AttributesMapper<LdapUser> attributesMapper) {
return new AttributesMapperCallbackHandler<>(attributesMapper);
}
@Override
public String getPrincipal() {
return StringUtils.isNotBlank(adPrincipalSuffix) ? dequote(adSystemUsername) + dequote(adPrincipalSuffix) : dequote(adSystemUsername);
}
@Override
public String getPassword() {
return dequote(adSystemPassword);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/UserImportJobDTOToUserImportJobConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/UserImportJobDTOToUserImportJobConverter.java | package org.ohdsi.webapi.user.importer.converter;
import com.cronutils.model.definition.CronDefinition;
import com.odysseusinc.scheduler.api.v1.converter.BaseArachneJobDTOToArachneJobConverter;
import org.ohdsi.webapi.user.importer.dto.UserImportJobDTO;
import org.ohdsi.webapi.user.importer.model.UserImportJob;
import org.springframework.stereotype.Component;
@Component
public class UserImportJobDTOToUserImportJobConverter extends BaseUserImportJobDTOToUserImportJobConverter<UserImportJobDTO> {
public UserImportJobDTOToUserImportJobConverter(CronDefinition cronDefinition) {
super(cronDefinition);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/JobHistoryItemToDTOConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/JobHistoryItemToDTOConverter.java | package org.ohdsi.webapi.user.importer.converter;
import org.ohdsi.webapi.user.importer.dto.JobHistoryItemDTO;
import org.ohdsi.webapi.user.importer.model.UserImportJobHistoryItem;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.stereotype.Component;
@Component
public class JobHistoryItemToDTOConverter implements Converter<UserImportJobHistoryItem, JobHistoryItemDTO> {
public JobHistoryItemToDTOConverter(GenericConversionService conversionService) {
conversionService.addConverter(this);
}
@Override
public JobHistoryItemDTO convert(UserImportJobHistoryItem source) {
JobHistoryItemDTO dto = new JobHistoryItemDTO();
dto.setId(source.getId());
dto.setAuthor(source.getAuthor());
dto.setEndTime(source.getEndTime());
dto.setExitMessage(source.getExitMessage());
dto.setJobTitle(source.getJobName());
dto.setProviderType(source.getUserImport() != null ? source.getUserImport().getProviderType() : null);
dto.setStartTime(source.getStartTime());
dto.setStatus(source.getStatus());
dto.setExitCode(source.getExitCode());
return dto;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/UserImportJobToUserImportJobDTOConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/UserImportJobToUserImportJobDTOConverter.java | package org.ohdsi.webapi.user.importer.converter;
import org.ohdsi.webapi.user.importer.dto.UserImportJobDTO;
import org.ohdsi.webapi.user.importer.model.UserImportJob;
import org.springframework.stereotype.Component;
@Component
public class UserImportJobToUserImportJobDTOConverter extends BaseUserImportJobToUserImportJobDTOConverter<UserImportJobDTO> {
@Override
protected UserImportJobDTO createResultObject(UserImportJob userImportJob) {
return new UserImportJobDTO();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/BaseUserImportJobToUserImportJobDTOConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/BaseUserImportJobToUserImportJobDTOConverter.java | package org.ohdsi.webapi.user.importer.converter;
import com.odysseusinc.scheduler.api.v1.converter.BaseArachneJobToArachneJobDTOConverter;
import org.ohdsi.webapi.user.importer.dto.UserImportJobDTO;
import org.ohdsi.webapi.user.importer.model.UserImportJob;
public abstract class BaseUserImportJobToUserImportJobDTOConverter<T extends UserImportJobDTO> extends BaseArachneJobToArachneJobDTOConverter<UserImportJob, T> {
@Override
protected void convertJob(UserImportJob source, T target) {
target.setProviderType(source.getProviderType());
target.setPreserveRoles(source.getPreserveRoles());
target.setUserRoles(source.getUserRoles());
if (source.getRoleGroupMapping() != null) {
target.setRoleGroupMapping(RoleGroupMappingConverter.convertRoleGroupMapping(source.getProviderType().getValue(),
source.getRoleGroupMapping()));
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/RoleGroupMappingConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/RoleGroupMappingConverter.java | package org.ohdsi.webapi.user.importer.converter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.ohdsi.webapi.user.Role;
import org.ohdsi.webapi.shiro.Entities.RoleEntity;
import org.ohdsi.webapi.user.importer.model.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class RoleGroupMappingConverter {
public static RoleGroupMapping convertRoleGroupMapping(String provider, List<RoleGroupEntity> mappingEntities) {
RoleGroupMapping roleGroupMapping = new RoleGroupMapping();
roleGroupMapping.setProvider(provider);
Map<Long, List<RoleGroupEntity>> entityMap = mappingEntities.stream()
.collect(Collectors.groupingBy(r -> r.getRole().getId()));
Map<Long, RoleEntity> roleMap = entityMap.entrySet().stream().map(e -> new ImmutablePair<>(e.getKey(), e.getValue().iterator().next().getRole()))
.collect(Collectors.toMap(ImmutablePair::getKey, ImmutablePair::getValue));
List<RoleGroupsMap> roleGroups = entityMap
.entrySet().stream().map(entry -> {
RoleGroupsMap roleGroupsMap = new RoleGroupsMap();
roleGroupsMap.setRole(new Role(roleMap.get(entry.getKey())));
List<LdapGroup> groups = entry
.getValue()
.stream()
.map(role -> new LdapGroup(role.getGroupName(), role.getGroupDn()))
.collect(Collectors.toList());
roleGroupsMap.setGroups(groups);
return roleGroupsMap;
}).collect(Collectors.toList());
roleGroupMapping.setRoleGroups(roleGroups);
return roleGroupMapping;
}
public static List<RoleGroupEntity> convertRoleGroupMapping(RoleGroupMapping mapping) {
final String providerTypeName = mapping.getProvider();
final LdapProviderType providerTyper = LdapProviderType.fromValue(providerTypeName);
return mapping.getRoleGroups().stream().flatMap(m -> {
RoleEntity roleEntity = convertRole(m.getRole());
return m.getGroups().stream().map(g -> {
RoleGroupEntity entity = new RoleGroupEntity();
entity.setGroupDn(g.getDistinguishedName());
entity.setGroupName(g.getDisplayName());
entity.setRole(roleEntity);
entity.setProvider(providerTyper);
return entity;
});
}).collect(Collectors.toList());
}
private static RoleEntity convertRole(Role role) {
RoleEntity roleEntity = new RoleEntity();
roleEntity.setName(role.role);
roleEntity.setId(role.id);
roleEntity.setSystemRole(role.systemRole);
return roleEntity;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/user/importer/converter/BaseUserImportJobDTOToUserImportJobConverter.java | src/main/java/org/ohdsi/webapi/user/importer/converter/BaseUserImportJobDTOToUserImportJobConverter.java | package org.ohdsi.webapi.user.importer.converter;
import com.cronutils.model.definition.CronDefinition;
import com.odysseusinc.scheduler.api.v1.converter.BaseArachneJobDTOToArachneJobConverter;
import org.ohdsi.webapi.user.importer.dto.UserImportJobDTO;
import org.ohdsi.webapi.user.importer.model.UserImportJob;
public abstract class BaseUserImportJobDTOToUserImportJobConverter<T extends UserImportJobDTO> extends BaseArachneJobDTOToArachneJobConverter<T, UserImportJob> {
protected BaseUserImportJobDTOToUserImportJobConverter(CronDefinition cronDefinition) {
super(cronDefinition);
}
@Override
protected void convertJob(T source, UserImportJob target) {
target.setProviderType(source.getProviderType());
target.setPreserveRoles(source.getPreserveRoles());
target.setUserRoles(source.getUserRoles());
if (source.getRoleGroupMapping() != null) {
target.setRoleGroupMapping(RoleGroupMappingConverter.convertRoleGroupMapping(source.getRoleGroupMapping()));
}
}
@Override
protected UserImportJob createResultObject(T userImportJobDTO) {
return new UserImportJob();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cache/ResultsCache.java | src/main/java/org/ohdsi/webapi/cache/ResultsCache.java | /*
*
* Copyright 2017 Observational Health Data Sciences and Informatics
* 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 org.ohdsi.webapi.cache;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.ohdsi.webapi.cdmresults.cache.CDMResultsCache;
/**
*
* @author fdefalco
*/
public class ResultsCache {
private static Map<String,CDMResultsCache> sourceCaches = new ConcurrentHashMap<>();
public static Map<String,CDMResultsCache> getAll() {
return sourceCaches;
}
public static CDMResultsCache get(String sourceKey) {
getAll().putIfAbsent(sourceKey, new CDMResultsCache());
return getAll().get(sourceKey);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cache/CacheInfo.java | src/main/java/org/ohdsi/webapi/cache/CacheInfo.java | /*
* Copyright 2019 cknoll1.
*
* 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 org.ohdsi.webapi.cache;
import java.io.Serializable;
import java.util.Optional;
import javax.cache.management.CacheStatisticsMXBean;
/**
*
* @author cknoll1
*/
public class CacheInfo implements Serializable{
public String cacheName;
public Long entries;
public CacheStatisticsMXBean cacheStatistics;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cache/CacheService.java | src/main/java/org/ohdsi/webapi/cache/CacheService.java | /*
* Copyright 2019 cknoll1.
*
* 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 org.ohdsi.webapi.cache;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.StreamSupport;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.ohdsi.webapi.util.CacheHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
* @author cknoll1
*/
@Path("/cache")
@Component
public class CacheService {
public static class ClearCacheResult {
public List<CacheInfo> clearedCaches;
private ClearCacheResult() {
this.clearedCaches = new ArrayList<>();
}
}
private CacheManager cacheManager;
@Autowired(required = false)
public CacheService(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
public CacheService() {
}
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<CacheInfo> getCacheInfoList() {
List<CacheInfo> caches = new ArrayList<>();
if (cacheManager == null) return caches; //caching is disabled
for (String cacheName : cacheManager.getCacheNames()) {
Cache cache = cacheManager.getCache(cacheName);
CacheInfo info = new CacheInfo();
info.cacheName = cacheName;
info.entries = StreamSupport.stream(cache.spliterator(), false).count();
info.cacheStatistics = CacheHelper.getCacheStats(cacheManager , cacheName);
caches.add(info);
}
return caches;
}
@GET
@Path("/clear")
@Produces(MediaType.APPLICATION_JSON)
public ClearCacheResult clearAll() {
ClearCacheResult result = new ClearCacheResult();
for (String cacheName : cacheManager.getCacheNames()) {
Cache cache = cacheManager.getCache(cacheName);
CacheInfo info = new CacheInfo();
info.cacheName = cacheName;
info.entries = StreamSupport.stream(cache.spliterator(), false).count();
result.clearedCaches.add(info);
cache.clear();
}
return result;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/PersonProfile.java | src/main/java/org/ohdsi/webapi/person/PersonProfile.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
/**
*
* @author fdefalco
*/
public class PersonProfile {
public ArrayList<PersonRecord> records;
public ArrayList<CohortPerson> cohorts;
public ArrayList<ObservationPeriod> observationPeriods;
public String gender;
public int yearOfBirth;
public int ageAtIndex;
public PersonProfile() {
records = new ArrayList<>();
cohorts = new ArrayList<>();
observationPeriods = new ArrayList<>();
}
@JsonProperty("recordCount")
public Integer getRecordCount() {
return this.records.size();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/Era.java | src/main/java/org/ohdsi/webapi/person/Era.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.sql.Timestamp;
/**
*
* @author fdefalco
*/
public class Era {
public Timestamp startDate;
public Timestamp endDate;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/CohortPerson.java | src/main/java/org/ohdsi/webapi/person/CohortPerson.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.sql.Timestamp;
/**
*
* @author fdefalco
*/
public class CohortPerson {
public Long personId;
public Long cohortDefinitionId;
public Timestamp startDate;
public Timestamp endDate;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/TimewaveBucket.java | src/main/java/org/ohdsi/webapi/person/TimewaveBucket.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.sql.Timestamp;
/**
*
* @author fdefalco
*/
public class TimewaveBucket {
public TimewaveBucket() {
}
public Timestamp timeIndex;
public Integer drugs = 0;
public Integer conditions = 0;
public Integer observations = 0;
public Integer getRecords() {
return drugs + conditions + observations;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/EraSet.java | src/main/java/org/ohdsi/webapi/person/EraSet.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.util.ArrayList;
/**
*
* @author fdefalco
*/
public class EraSet {
public ArrayList<Era> eras;
public Long conceptId;
public String conceptName;
public String eraType;
public EraSet() {
eras = new ArrayList<>();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/Timewave.java | src/main/java/org/ohdsi/webapi/person/Timewave.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.util.Collection;
public class Timewave {
public Timewave() {
maxEvents = 0;
}
public Collection<TimewaveBucket> buckets;
public Integer maxEvents;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/PersonRecord.java | src/main/java/org/ohdsi/webapi/person/PersonRecord.java | /*
* Copyright 2015 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.sql.Timestamp;
/**
*
* @author fdefalco
*/
public class PersonRecord {
public String domain;
public Long conceptId;
public String conceptName;
public Timestamp startDate;
public Timestamp endDate;
public int startDay;
public int endDay;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/PersonConfigurationInfo.java | src/main/java/org/ohdsi/webapi/person/PersonConfigurationInfo.java | package org.ohdsi.webapi.person;
import org.ohdsi.info.ConfigurationInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class PersonConfigurationInfo extends ConfigurationInfo {
private static final String KEY = "person";
public PersonConfigurationInfo(@Value("${person.viewDates}") Boolean viewDatesPermitted) {
properties.put("viewDatesPermitted", viewDatesPermitted);
}
@Override
public String getKey() {
return KEY;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/person/ObservationPeriod.java | src/main/java/org/ohdsi/webapi/person/ObservationPeriod.java | /*
* Copyright 2016 fdefalco.
*
* 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 org.ohdsi.webapi.person;
import java.sql.Timestamp;
/**
*
* @author fdefalco
*/
public class ObservationPeriod {
public ObservationPeriod() {
}
public long id;
public Timestamp startDate;
public Timestamp endDate;
public String type;
public int x1;
public int x2;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/PredictionAnalysis.java | src/main/java/org/ohdsi/webapi/prediction/PredictionAnalysis.java | package org.ohdsi.webapi.prediction;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.ohdsi.webapi.model.CommonEntity;
@Entity(name = "PredictionAnalysis")
@Table(name = "prediction")
public class PredictionAnalysis extends CommonEntity<Integer> {
@Id
@GenericGenerator(
name = "pred_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "prediction_seq"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "pred_generator")
@Column(name = "prediction_id")
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Lob
@Type(type = "org.hibernate.type.TextType")
private String specification;
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the specification
*/
public String getSpecification() {
return specification;
}
/**
* @param specification the specification to set
*/
public void setSpecification(String specification) {
this.specification = specification;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/PredictionService.java | src/main/java/org/ohdsi/webapi/prediction/PredictionService.java | package org.ohdsi.webapi.prediction;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.ohdsi.webapi.job.JobExecutionResource;
import org.ohdsi.webapi.prediction.domain.PredictionGenerationEntity;
import org.ohdsi.webapi.prediction.specification.PatientLevelPredictionAnalysisImpl;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
public interface PredictionService {
Iterable<PredictionAnalysis> getAnalysisList();
void delete(int id);
PredictionAnalysis createAnalysis(PredictionAnalysis pred);
PredictionAnalysis updateAnalysis(int id, PredictionAnalysis pred);
PredictionAnalysis copy(int id);
PredictionAnalysis getAnalysis(int id);
PatientLevelPredictionAnalysisImpl exportAnalysis(int id, String sourceKey);
PatientLevelPredictionAnalysisImpl exportAnalysis(int id);
PredictionAnalysis importAnalysis(PatientLevelPredictionAnalysisImpl analysis) throws Exception;
String getNameForCopy(String dtoName);
void hydrateAnalysis(PatientLevelPredictionAnalysisImpl analysis, String packageName, OutputStream out) throws JsonProcessingException;
JobExecutionResource runGeneration(PredictionAnalysis predictionAnalysis, String sourceKey) throws IOException;
PredictionGenerationEntity getGeneration(Long generationId);
List<PredictionGenerationEntity> getPredictionGenerations(Integer predictionAnalysisId);
PredictionAnalysis getById(Integer id);
int getCountPredictionWithSameName(Integer id, String name);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/PredictionServiceImpl.java | src/main/java/org/ohdsi/webapi/prediction/PredictionServiceImpl.java | package org.ohdsi.webapi.prediction;
import com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph;
import com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.analysis.Utils;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.webapi.analysis.AnalysisCohortDefinition;
import org.ohdsi.webapi.analysis.AnalysisConceptSet;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionRepository;
import org.ohdsi.webapi.common.DesignImportService;
import org.ohdsi.webapi.common.generation.AnalysisExecutionSupport;
import org.ohdsi.webapi.common.generation.GenerationUtils;
import org.ohdsi.webapi.conceptset.ConceptSetCrossReferenceImpl;
import org.ohdsi.webapi.executionengine.entity.AnalysisFile;
import org.ohdsi.webapi.featureextraction.specification.CovariateSettingsImpl;
import org.ohdsi.webapi.job.GeneratesNotification;
import org.ohdsi.webapi.job.JobExecutionResource;
import org.ohdsi.webapi.prediction.domain.PredictionGenerationEntity;
import org.ohdsi.webapi.prediction.repository.PredictionAnalysisGenerationRepository;
import org.ohdsi.webapi.prediction.repository.PredictionAnalysisRepository;
import org.ohdsi.webapi.prediction.specification.PatientLevelPredictionAnalysisImpl;
import org.ohdsi.webapi.service.ConceptSetService;
import org.ohdsi.webapi.service.JobService;
import org.ohdsi.webapi.service.VocabularyService;
import org.ohdsi.webapi.service.dto.ConceptSetDTO;
import org.ohdsi.webapi.shiro.annotations.DataSourceAccess;
import org.ohdsi.webapi.shiro.annotations.SourceKey;
import org.ohdsi.webapi.shiro.management.datasource.SourceAccessor;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceService;
import org.ohdsi.webapi.util.EntityUtils;
import org.ohdsi.webapi.util.ExportUtil;
import org.ohdsi.webapi.util.NameUtils;
import org.ohdsi.webapi.util.SessionUtils;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.Transactional;
import javax.ws.rs.InternalServerErrorException;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static org.ohdsi.webapi.Constants.GENERATE_PREDICTION_ANALYSIS;
import static org.ohdsi.webapi.Constants.Params.JOB_NAME;
import static org.ohdsi.webapi.Constants.Params.PREDICTION_ANALYSIS_ID;
import static org.ohdsi.webapi.Constants.Params.PREDICTION_SKELETON_VERSION;
@Service
@Transactional
public class PredictionServiceImpl extends AnalysisExecutionSupport implements PredictionService, GeneratesNotification {
private static final EntityGraph DEFAULT_ENTITY_GRAPH = EntityGraphUtils.fromAttributePaths("source", "analysisExecution.resultFiles");
private final EntityGraph COMMONS_ENTITY_GRAPH = EntityUtils.fromAttributePaths(
"createdBy",
"modifiedBy"
);
@Autowired
private PredictionAnalysisRepository predictionAnalysisRepository;
@PersistenceContext
protected EntityManager entityManager;
@Autowired
private ConceptSetService conceptSetService;
@Autowired
private VocabularyService vocabularyService;
@Autowired
private CohortDefinitionRepository cohortDefinitionRepository;
@Autowired
private SourceService sourceService;
@Autowired
private GenerationUtils generationUtils;
@Autowired
private JobService jobService;
@Autowired
private PredictionAnalysisGenerationRepository generationRepository;
@Autowired
private Environment env;
@Autowired
private SourceAccessor sourceAccessor;
@Autowired
private DesignImportService designImportService;
@Autowired
private ConversionService conversionService;
private final String EXEC_SCRIPT = ResourceHelper.GetResourceAsString("/resources/prediction/r/runAnalysis.R");
@Override
public Iterable<PredictionAnalysis> getAnalysisList() {
return predictionAnalysisRepository.findAll(COMMONS_ENTITY_GRAPH);
}
@Override
public int getCountPredictionWithSameName(Integer id, String name) {
return predictionAnalysisRepository.getCountPredictionWithSameName(id, name);
}
@Override
public PredictionAnalysis getById(Integer id) {
return predictionAnalysisRepository.findOne(id, COMMONS_ENTITY_GRAPH);
}
@Override
public void delete(final int id) {
this.predictionAnalysisRepository.delete(id);
}
@Override
public PredictionAnalysis createAnalysis(PredictionAnalysis pred) {
Date currentTime = Calendar.getInstance().getTime();
pred.setCreatedBy(getCurrentUser());
pred.setCreatedDate(currentTime);
// Fields with information about modifications have to be reseted
pred.setModifiedBy(null);
pred.setModifiedDate(null);
pred.setName(StringUtils.trim(pred.getName()));
return save(pred);
}
@Override
public PredictionAnalysis updateAnalysis(final int id, PredictionAnalysis pred) {
PredictionAnalysis predFromDB = getById(id);
Date currentTime = Calendar.getInstance().getTime();
pred.setModifiedBy(getCurrentUser());
pred.setModifiedDate(currentTime);
// Prevent any updates to protected fields like created/createdBy
pred.setCreatedDate(predFromDB.getCreatedDate());
pred.setCreatedBy(predFromDB.getCreatedBy());
pred.setName(StringUtils.trim(pred.getName()));
return save(pred);
}
private List<String> getNamesLike(String name) {
return predictionAnalysisRepository.findAllByNameStartsWith(name).stream().map(PredictionAnalysis::getName).collect(Collectors.toList());
}
@Override
public PredictionAnalysis copy(final int id) {
PredictionAnalysis analysis = this.predictionAnalysisRepository.findOne(id);
entityManager.detach(analysis); // Detach from the persistence context in order to save a copy
analysis.setId(null);
analysis.setName(getNameForCopy(analysis.getName()));
return this.createAnalysis(analysis);
}
@Override
public PredictionAnalysis getAnalysis(int id) {
return this.predictionAnalysisRepository.findOne(id, COMMONS_ENTITY_GRAPH);
}
@Override
public PatientLevelPredictionAnalysisImpl exportAnalysis(int id) {
return exportAnalysis(id, sourceService.getPriorityVocabularySource().getSourceKey());
}
@Override
public PatientLevelPredictionAnalysisImpl exportAnalysis(int id, String sourceKey) {
PredictionAnalysis pred = predictionAnalysisRepository.findOne(id);
PatientLevelPredictionAnalysisImpl expression;
try {
expression = Utils.deserialize(pred.getSpecification(), PatientLevelPredictionAnalysisImpl.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
// Set the root properties
expression.setId(pred.getId());
expression.setName(StringUtils.trim(pred.getName()));
expression.setDescription(pred.getDescription());
expression.setOrganizationName(env.getRequiredProperty("organization.name"));
expression.setSkeletonVersion(PREDICTION_SKELETON_VERSION);
// Retrieve the cohort definition details
ArrayList<AnalysisCohortDefinition> detailedList = new ArrayList<>();
for (AnalysisCohortDefinition c : expression.getCohortDefinitions()) {
CohortDefinition cd = cohortDefinitionRepository.findOneWithDetail(c.getId());
detailedList.add(new AnalysisCohortDefinition(cd));
}
expression.setCohortDefinitions(detailedList);
// Retrieve the concept set expressions
ArrayList<AnalysisConceptSet> pcsList = new ArrayList<>();
HashMap<Integer, ArrayList<Long>> conceptIdentifiers = new HashMap<>();
for (AnalysisConceptSet pcs : expression.getConceptSets()) {
pcs.expression = conceptSetService.getConceptSetExpression(pcs.id, sourceKey);
pcsList.add(pcs);
conceptIdentifiers.put(pcs.id, new ArrayList<>(vocabularyService.resolveConceptSetExpression(pcs.expression)));
}
expression.setConceptSets(pcsList);
// Resolve all ConceptSetCrossReferences
for (ConceptSetCrossReferenceImpl xref : expression.getConceptSetCrossReference()) {
if (xref.getTargetName().equalsIgnoreCase("covariateSettings")) {
if (xref.getPropertyName().equalsIgnoreCase("includedCovariateConceptIds")) {
expression.getCovariateSettings().get(xref.getTargetIndex()).setIncludedCovariateConceptIds(conceptIdentifiers.get(xref.getConceptSetId()));
} else if (xref.getPropertyName().equalsIgnoreCase("excludedCovariateConceptIds")) {
expression.getCovariateSettings().get(xref.getTargetIndex()).setExcludedCovariateConceptIds(conceptIdentifiers.get(xref.getConceptSetId()));
}
}
}
ExportUtil.clearCreateAndUpdateInfo(expression);
return expression;
}
@Override
public PredictionAnalysis importAnalysis(PatientLevelPredictionAnalysisImpl analysis) throws Exception {
try {
if (Objects.isNull(analysis.getCohortDefinitions()) || Objects.isNull(analysis.getCovariateSettings())) {
log.error("Failed to import Prediction. Invalid source JSON.");
throw new InternalServerErrorException();
}
// Create all of the cohort definitions
// and map the IDs from old -> new
List<BigDecimal> newTargetIds = new ArrayList<>();
List<BigDecimal> newOutcomeIds = new ArrayList<>();
analysis.getCohortDefinitions().forEach((analysisCohortDefinition) -> {
BigDecimal oldId = new BigDecimal(analysisCohortDefinition.getId());
analysisCohortDefinition.setId(null);
CohortDefinition cd = designImportService.persistCohortOrGetExisting(conversionService.convert(analysisCohortDefinition, CohortDefinition.class), true);
if (analysis.getTargetIds().contains(oldId)) {
newTargetIds.add(new BigDecimal(cd.getId()));
}
if (analysis.getOutcomeIds().contains(oldId)) {
newOutcomeIds.add(new BigDecimal(cd.getId()));
}
analysisCohortDefinition.setId(cd.getId());
analysisCohortDefinition.setName(cd.getName());
});
// Create all of the concept sets and map
// the IDs from old -> new
Map<Integer, Integer> conceptSetIdMap = new HashMap<>();
analysis.getConceptSets().forEach((pcs) -> {
int oldId = pcs.id;
ConceptSetDTO cs = designImportService.persistConceptSet(pcs);
pcs.id = cs.getId();
pcs.name = cs.getName();
conceptSetIdMap.put(oldId, cs.getId());
});
// Replace all of the cohort definitions
analysis.setTargetIds(newTargetIds);
analysis.setOutcomeIds(newOutcomeIds);
// Replace all of the concept sets
analysis.getConceptSetCrossReference().forEach((ConceptSetCrossReferenceImpl xref) -> {
Integer newConceptSetId = conceptSetIdMap.get(xref.getConceptSetId());
xref.setConceptSetId(newConceptSetId);
});
// Clear all of the concept IDs from the covariate settings
analysis.getCovariateSettings().forEach((CovariateSettingsImpl cs) -> {
cs.setIncludedCovariateConceptIds(new ArrayList<>());
cs.setExcludedCovariateConceptIds(new ArrayList<>());
});
// Remove the ID
analysis.setId(null);
// Create the prediction analysis
PredictionAnalysis pa = new PredictionAnalysis();
pa.setDescription(analysis.getDescription());
pa.setSpecification(Utils.serialize(analysis));
pa.setName(NameUtils.getNameWithSuffix(analysis.getName(), this::getNamesLike));
PredictionAnalysis savedAnalysis = this.createAnalysis(pa);
return predictionAnalysisRepository.findOne(savedAnalysis.getId(), COMMONS_ENTITY_GRAPH);
} catch (Exception e) {
log.debug("Error while importing prediction analysis: " + e.getMessage());
throw e;
}
}
@Override
public String getNameForCopy(String dtoName) {
return NameUtils.getNameForCopy(dtoName, this::getNamesLike, predictionAnalysisRepository.findByName(dtoName));
}
@Override
public void hydrateAnalysis(PatientLevelPredictionAnalysisImpl analysis, String packageName, OutputStream out) throws JsonProcessingException {
if (packageName == null || !Utils.isAlphaNumeric(packageName)) {
throw new IllegalArgumentException("The package name must be alphanumeric only.");
}
analysis.setSkeletonVersion(PREDICTION_SKELETON_VERSION);
analysis.setPackageName(packageName);
super.hydrateAnalysis(analysis, out);
}
@Override
@DataSourceAccess
public JobExecutionResource runGeneration(final PredictionAnalysis predictionAnalysis,
@SourceKey final String sourceKey) throws IOException {
final Source source = sourceService.findBySourceKey(sourceKey);
final Integer predictionAnalysisId = predictionAnalysis.getId();
String packageName = String.format("PredictionAnalysis.%s", SessionUtils.sessionId());
String packageFilename = String.format("prediction_study_%d.zip", predictionAnalysisId);
List<AnalysisFile> analysisFiles = new ArrayList<>();
AnalysisFile analysisFile = new AnalysisFile();
analysisFile.setFileName(packageFilename);
try(ByteArrayOutputStream out = new ByteArrayOutputStream()) {
PatientLevelPredictionAnalysisImpl analysis = exportAnalysis(predictionAnalysisId, sourceKey);
hydrateAnalysis(analysis, packageName, out);
analysisFile.setContents(out.toByteArray());
}
analysisFiles.add(analysisFile);
analysisFiles.add(prepareAnalysisExecution(packageName, packageFilename, predictionAnalysisId));
JobParametersBuilder builder = prepareJobParametersBuilder(source, predictionAnalysisId, packageName, packageFilename)
.addString(PREDICTION_ANALYSIS_ID, predictionAnalysisId.toString())
.addString(JOB_NAME, String.format("Generating Prediction Analysis %d using %s (%s)", predictionAnalysisId, source.getSourceName(), source.getSourceKey()));
Job generateAnalysisJob = generationUtils.buildJobForExecutionEngineBasedAnalysisTasklet(
GENERATE_PREDICTION_ANALYSIS,
source,
builder,
analysisFiles
).build();
return jobService.runJob(generateAnalysisJob, builder.toJobParameters());
}
@Override
protected String getExecutionScript() {
return EXEC_SCRIPT;
}
@Override
public List<PredictionGenerationEntity> getPredictionGenerations(Integer predictionAnalysisId) {
return generationRepository
.findByPredictionAnalysisId(predictionAnalysisId, DEFAULT_ENTITY_GRAPH)
.stream()
.filter(gen -> sourceAccessor.hasAccess(gen.getSource()))
.collect(Collectors.toList());
}
@Override
public PredictionGenerationEntity getGeneration(Long generationId) {
return generationRepository.findOne(generationId, DEFAULT_ENTITY_GRAPH);
}
private PredictionAnalysis save(PredictionAnalysis analysis) {
analysis = predictionAnalysisRepository.saveAndFlush(analysis);
entityManager.refresh(analysis);
analysis = getById(analysis.getId());
return analysis;
}
@Override
public String getJobName() {
return GENERATE_PREDICTION_ANALYSIS;
}
@Override
public String getExecutionFoldingKey() {
return PREDICTION_ANALYSIS_ID;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/PredictionController.java | src/main/java/org/ohdsi/webapi/prediction/PredictionController.java | package org.ohdsi.webapi.prediction;
import com.odysseusinc.arachne.commons.utils.ConverterUtils;
import org.ohdsi.analysis.Utils;
import org.ohdsi.webapi.Constants;
import org.ohdsi.webapi.check.CheckResult;
import org.ohdsi.webapi.check.checker.prediction.PredictionChecker;
import org.ohdsi.webapi.common.SourceMapKey;
import org.ohdsi.webapi.common.analyses.CommonAnalysisDTO;
import org.ohdsi.webapi.common.generation.ExecutionBasedGenerationDTO;
import org.ohdsi.webapi.common.sensitiveinfo.CommonGenerationSensitiveInfoService;
import org.ohdsi.webapi.executionengine.service.ScriptExecutionService;
import org.ohdsi.webapi.job.JobExecutionResource;
import org.ohdsi.webapi.prediction.domain.PredictionGenerationEntity;
import org.ohdsi.webapi.prediction.dto.PredictionAnalysisDTO;
import org.ohdsi.webapi.prediction.specification.PatientLevelPredictionAnalysisImpl;
import org.ohdsi.webapi.security.PermissionService;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceService;
import org.ohdsi.webapi.util.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.stereotype.Controller;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
/**
* Provides REST services for working with
* patient-level prediction designs.
*
* @summary Prediction
*/
@Controller
@Path("/prediction/")
public class PredictionController {
private static final Logger LOGGER = LoggerFactory.getLogger(PredictionController.class);
private static final String NO_PREDICTION_ANALYSIS_MESSAGE = "There is no prediction analysis with id = %d.";
private static final String NO_GENERATION_MESSAGE = "There is no generation with id = %d";
private final PredictionService service;
private final GenericConversionService conversionService;
private final ConverterUtils converterUtils;
private final CommonGenerationSensitiveInfoService<ExecutionBasedGenerationDTO> sensitiveInfoService;
private final SourceService sourceService;
private final ScriptExecutionService executionService;
private final PredictionChecker checker;
private PermissionService permissionService;
@Value("${security.defaultGlobalReadPermissions}")
private boolean defaultGlobalReadPermissions;
@Autowired
public PredictionController(PredictionService service,
GenericConversionService conversionService,
ConverterUtils converterUtils,
CommonGenerationSensitiveInfoService sensitiveInfoService,
SourceService sourceService,
ScriptExecutionService executionService, PredictionChecker checker,
PermissionService permissionService) {
this.service = service;
this.conversionService = conversionService;
this.converterUtils = converterUtils;
this.sensitiveInfoService = sensitiveInfoService;
this.sourceService = sourceService;
this.executionService = executionService;
this.checker = checker;
this.permissionService = permissionService;
}
/**
* Used to retrieve all prediction designs in the WebAPI database.
* @summary Get all prediction designs
* @return A list of all prediction design names and identifiers
*/
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<CommonAnalysisDTO> getAnalysisList() {
return StreamSupport
.stream(service.getAnalysisList().spliterator(), false)
.filter(!defaultGlobalReadPermissions ? entity -> permissionService.hasReadAccess(entity) : entity -> true)
.map(analysis -> {
CommonAnalysisDTO dto = conversionService.convert(analysis, CommonAnalysisDTO.class);
permissionService.fillWriteAccess(analysis, dto);
permissionService.fillReadAccess(analysis, dto);
return dto;
})
.collect(Collectors.toList());
}
/**
* Check to see if a prediction design exists by name
*
* @summary Prediction design exists by name
* @param id The prediction design id
* @param name The prediction design name
* @return 1 if a prediction design with the given name and id exist in WebAPI
* and 0 otherwise
*/
@GET
@Path("/{id}/exists")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public int getCountPredictionWithSameName(@PathParam("id") @DefaultValue("0") final int id, @QueryParam("name") String name) {
return service.getCountPredictionWithSameName(id, name);
}
/**
* Used to delete a selected prediction design by ID.
*
* @summary Delete a prediction designs
* @param id The identifier of the prediction design
* @return None
*/
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public void delete(@PathParam("id") int id) {
service.delete(id);
}
/**
* Used to add a new prediction design to the database
*
* @summary Save a new prediction design
* @param est The prediction design object
* @return An PredictionAnalysisDTO which contains the identifier assigned to the prediction design.
*/
@POST
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public PredictionAnalysisDTO createAnalysis(PredictionAnalysis pred) {
PredictionAnalysis analysis = service.createAnalysis(pred);
return reloadAndConvert(analysis.getId());
}
/**
* Used to save changes to an existing prediction design by ID.
*
* @summary Update a prediction design
* @param id The ID of the prediction design
* @param est The prediction design object
* @return An PredictionAnalysisDTO which contains the updated prediction design.
*/
@PUT
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public PredictionAnalysisDTO updateAnalysis(@PathParam("id") int id, PredictionAnalysis pred) {
service.updateAnalysis(id, pred);
return reloadAndConvert(id);
}
/**
* Used to create a copy of an existing existing prediction design by ID.
*
* @summary Copy a prediction design
* @param id The ID of the prediction design
* @return An PredictionAnalysisDTO which contains the newly copied prediction design.
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/copy")
public PredictionAnalysisDTO copy(@PathParam("id") int id) {
PredictionAnalysis analysis = service.copy(id);
return reloadAndConvert(analysis.getId());
}
/**
* Used to retrieve an existing existing prediction design by ID.
*
* @summary Get a prediction design by ID
* @param id The ID of the prediction design
* @return An EstimationDTO which contains the prediction design.
*/
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public PredictionAnalysisDTO getAnalysis(@PathParam("id") int id) {
PredictionAnalysis analysis = service.getAnalysis(id);
ExceptionUtils.throwNotFoundExceptionIfNull(analysis, String.format(NO_PREDICTION_ANALYSIS_MESSAGE, id));
return conversionService.convert(analysis, PredictionAnalysisDTO.class);
}
/**
* Used to export an existing existing prediction design by ID. This is used
* when transferring the object outside of WebAPI.
*
* @summary Export a prediction design
* @param id The ID of the prediction design
* @return An EstimationAnalysisImpl which resolves all references to cohorts, concept sets, etc
* and contains the full prediction design for export.
*/
@GET
@Path("{id}/export")
@Produces(MediaType.APPLICATION_JSON)
public PatientLevelPredictionAnalysisImpl exportAnalysis(@PathParam("id") int id) {
return service.exportAnalysis(id);
}
/**
* Import a full prediction design
*
* @summary Import a prediction design
* @param analysis The full prediction design
* @return The newly imported prediction
*/
@POST
@Path("import")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public PredictionAnalysisDTO importAnalysis(PatientLevelPredictionAnalysisImpl analysis) throws Exception {
if (Objects.isNull(analysis)) {
LOGGER.error("Failed to import Prediction, empty or not valid source JSON");
throw new InternalServerErrorException();
}
PredictionAnalysis importedAnalysis = service.importAnalysis(analysis);
return reloadAndConvert(importedAnalysis.getId());
}
/**
* Download an R package to execute the prediction study
*
* @summary Download a prediction R package
* @param id The id for the prediction study
* @param packageName The R package name for the study
* @return Binary zip file containing the full R package
* @throws IOException
*/
@GET
@Path("{id}/download")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadPackage(@PathParam("id") int id, @QueryParam("packageName") String packageName) throws IOException {
if (packageName == null) {
packageName = "prediction" + String.valueOf(id);
}
if (!Utils.isAlphaNumeric(packageName)) {
throw new IllegalArgumentException("The package name must be alphanumeric only.");
}
PatientLevelPredictionAnalysisImpl plpa = service.exportAnalysis(id);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
service.hydrateAnalysis(plpa, packageName, baos);
Response response = Response
.ok(baos)
.type(MediaType.APPLICATION_OCTET_STREAM)
.header("Content-Disposition", String.format("attachment; filename=\"prediction_study_%d_export.zip\"", id))
.build();
return response;
}
/**
* Generate a prediction design by ID on a specific sourceKey. Please note
* this requires configuration of the Arachne Execution Engine.
*
* @summary Generate a prediction on a selected source
* @param id The id for the prediction study
* @param sourceKey The CDM source key
* @return JobExecutionResource The job information
* @throws IOException
*/
@POST
@Path("{id}/generation/{sourceKey}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public JobExecutionResource runGeneration(@PathParam("id") Integer predictionAnalysisId,
@PathParam("sourceKey") String sourceKey) throws IOException {
PredictionAnalysis predictionAnalysis = service.getAnalysis(predictionAnalysisId);
ExceptionUtils.throwNotFoundExceptionIfNull(predictionAnalysis, String.format(NO_PREDICTION_ANALYSIS_MESSAGE, predictionAnalysisId));
PredictionAnalysisDTO predictionAnalysisDTO = conversionService.convert(predictionAnalysis, PredictionAnalysisDTO.class);
CheckResult checkResult = runDiagnostics(predictionAnalysisDTO);
if (checkResult.hasCriticalErrors()) {
throw new RuntimeException("Cannot be generated due to critical errors in design. Call 'check' service for further details");
}
return service.runGeneration(predictionAnalysis, sourceKey);
}
/**
* Get a list of generations for the selected prediction design.
*
* @summary Get generations for a prediction design
* @param id The id for the prediction design
* @return List<ExecutionBasedGenerationDTO> The list of generations
*/
@GET
@Path("{id}/generation")
@Produces(MediaType.APPLICATION_JSON)
public List<ExecutionBasedGenerationDTO> getGenerations(@PathParam("id") Integer predictionAnalysisId) {
Map<String, Source> sourcesMap = sourceService.getSourcesMap(SourceMapKey.BY_SOURCE_KEY);
List<PredictionGenerationEntity> predictionGenerations = service.getPredictionGenerations(predictionAnalysisId);
List<ExecutionBasedGenerationDTO> dtos = converterUtils.convertList(predictionGenerations, ExecutionBasedGenerationDTO.class);
return sensitiveInfoService.filterSensitiveInfo(dtos, info -> Collections.singletonMap(Constants.Variables.SOURCE, sourcesMap.get(info.getSourceKey())));
}
/**
* Get a prediction design generation info.
*
* @summary Get prediction design generation info
* @param generationId The id for the prediction generation
* @return ExecutionBasedGenerationDTO The generation information
*/
@GET
@Path("/generation/{generationId}")
@Produces(MediaType.APPLICATION_JSON)
public ExecutionBasedGenerationDTO getGeneration(@PathParam("generationId") Long generationId) {
PredictionGenerationEntity generationEntity = service.getGeneration(generationId);
ExceptionUtils.throwNotFoundExceptionIfNull(generationEntity, String.format(NO_GENERATION_MESSAGE, generationId));
return sensitiveInfoService.filterSensitiveInfo(conversionService.convert(generationEntity, ExecutionBasedGenerationDTO.class),
Collections.singletonMap(Constants.Variables.SOURCE, generationEntity.getSource()));
}
/**
* Get a prediction design generation result.
*
* @summary Get prediction design generation result
* @param generationId The id for the prediction generation
* @return Response Streams a binary ZIP file with the results
*/
@GET
@Path("/generation/{generationId}/result")
@Produces("application/zip")
public Response downloadResults(@PathParam("generationId") Long generationId) throws IOException {
File archive = executionService.getExecutionResult(generationId);
return Response.ok(archive)
.header("Content-type", "application/zip")
.header("Content-Disposition", "attachment; filename=\"" + archive.getName() + "\"")
.build();
}
private PredictionAnalysisDTO reloadAndConvert(Integer id) {
// Before conversion entity must be refreshed to apply entity graphs
PredictionAnalysis analysis = service.getById(id);
return conversionService.convert(analysis, PredictionAnalysisDTO.class);
}
/**
* Performs a series of checks of the prediction design to ensure it will
* properly execute.
*
* @summary Check a prediction design for logic flaws
* @param PredictionAnalysisDTO The prediction design
* @return CheckResult The results of performing all checks
*/
@POST
@Path("/check")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public CheckResult runDiagnostics(PredictionAnalysisDTO predictionAnalysisDTO){
return new CheckResult(checker.check(predictionAnalysisDTO));
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/dto/PredictionAnalysisDTO.java | src/main/java/org/ohdsi/webapi/prediction/dto/PredictionAnalysisDTO.java | package org.ohdsi.webapi.prediction.dto;
import org.ohdsi.webapi.common.analyses.CommonAnalysisDTO;
public class PredictionAnalysisDTO extends CommonAnalysisDTO {
private String specification;
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/domain/PredictionGenerationEntity.java | src/main/java/org/ohdsi/webapi/prediction/domain/PredictionGenerationEntity.java | package org.ohdsi.webapi.prediction.domain;
import org.ohdsi.webapi.executionengine.entity.ExecutionEngineGenerationEntity;
import org.ohdsi.webapi.prediction.PredictionAnalysis;
import javax.persistence.*;
@Entity
@Table(name = "prediction_analysis_generation")
public class PredictionGenerationEntity extends ExecutionEngineGenerationEntity {
@ManyToOne(targetEntity = PredictionAnalysis.class, fetch = FetchType.LAZY)
@JoinColumn(name = "prediction_id")
private PredictionAnalysis predictionAnalysis;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/repository/PredictionAnalysisGenerationRepository.java | src/main/java/org/ohdsi/webapi/prediction/repository/PredictionAnalysisGenerationRepository.java | package org.ohdsi.webapi.prediction.repository;
import com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph;
import com.cosium.spring.data.jpa.entity.graph.repository.EntityGraphJpaRepository;
import org.ohdsi.webapi.prediction.domain.PredictionGenerationEntity;
import java.util.List;
public interface PredictionAnalysisGenerationRepository extends EntityGraphJpaRepository<PredictionGenerationEntity, Long> {
List<PredictionGenerationEntity> findByPredictionAnalysisId(Integer predictionAnalysisId, EntityGraph entityGraph);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/repository/PredictionAnalysisRepository.java | src/main/java/org/ohdsi/webapi/prediction/repository/PredictionAnalysisRepository.java | package org.ohdsi.webapi.prediction.repository;
import com.cosium.spring.data.jpa.entity.graph.repository.EntityGraphJpaRepository;
import org.ohdsi.webapi.prediction.PredictionAnalysis;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface PredictionAnalysisRepository extends EntityGraphJpaRepository<PredictionAnalysis, Integer> {
@Query("SELECT pa FROM PredictionAnalysis pa WHERE pa.name LIKE ?1 ESCAPE '\\'")
List<PredictionAnalysis> findAllByNameStartsWith(String pattern);
Optional<PredictionAnalysis> findByName(String name);
@Query("SELECT COUNT(pa) FROM PredictionAnalysis pa WHERE pa.name = :name and pa.id <> :id")
int getCountPredictionWithSameName(@Param("id") Integer id, @Param("name") String name);
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/converter/PredictionGenerationToCommonGenerationDtoConverter.java | src/main/java/org/ohdsi/webapi/prediction/converter/PredictionGenerationToCommonGenerationDtoConverter.java | package org.ohdsi.webapi.prediction.converter;
import org.ohdsi.webapi.common.generation.ExecutionEngineGenerationEntityToDtoConverter;
import org.ohdsi.webapi.prediction.domain.PredictionGenerationEntity;
import org.springframework.stereotype.Component;
@Component
public class PredictionGenerationToCommonGenerationDtoConverter extends ExecutionEngineGenerationEntityToDtoConverter<PredictionGenerationEntity> {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/converter/PredictionAnalysisToPredictionAnalysisDTOConverter.java | src/main/java/org/ohdsi/webapi/prediction/converter/PredictionAnalysisToPredictionAnalysisDTOConverter.java | package org.ohdsi.webapi.prediction.converter;
import org.ohdsi.webapi.prediction.PredictionAnalysis;
import org.ohdsi.webapi.prediction.dto.PredictionAnalysisDTO;
import org.springframework.stereotype.Component;
@Component
public class PredictionAnalysisToPredictionAnalysisDTOConverter extends PredictionAnalysisToCommonAnalysisDTOConverter<PredictionAnalysisDTO> {
@Override
protected PredictionAnalysisDTO createResultObject() {
return new PredictionAnalysisDTO();
}
@Override
public void doConvert(PredictionAnalysis source, PredictionAnalysisDTO target) {
super.doConvert(source, target);
target.setSpecification(source.getSpecification());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/converter/PredictionAnalysisToCommonAnalysisDTOConverter.java | src/main/java/org/ohdsi/webapi/prediction/converter/PredictionAnalysisToCommonAnalysisDTOConverter.java | package org.ohdsi.webapi.prediction.converter;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.common.analyses.CommonAnalysisDTO;
import org.ohdsi.webapi.prediction.PredictionAnalysis;
import org.ohdsi.webapi.service.converters.BaseCommonEntityToDTOConverter;
import org.springframework.stereotype.Component;
@Component
public class PredictionAnalysisToCommonAnalysisDTOConverter <T extends CommonAnalysisDTO>
extends BaseCommonEntityToDTOConverter<PredictionAnalysis, T> {
@Override
protected T createResultObject() {
return (T) new CommonAnalysisDTO();
}
@Override
public void doConvert(PredictionAnalysis source, T target) {
target.setId(source.getId());
target.setName(StringUtils.trim(source.getName()));
target.setDescription(source.getDescription());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/MLPSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/MLPSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import org.ohdsi.analysis.prediction.design.MLPSettings;
/**
*
* @author asena5
*/
public class MLPSettingsImpl extends SeedSettingsImpl implements MLPSettings {
private List<Integer> size = new ArrayList<>(Arrays.asList(4));
private List<BigDecimal> alpha = new ArrayList<>(Arrays.asList(BigDecimal.valueOf(0.000010f)));
/**
* The number of hidden nodes
*
* @return size
*
*/
@Override
public List<Integer> getSize() {
return size;
}
/**
*
* @param size
*/
public void setSize(Object size) {
if (size != null) {
if (size instanceof ArrayList) {
this.size = (ArrayList<Integer>) size;
} else if (size instanceof Integer) {
this.size = new ArrayList<>(Arrays.asList((Integer) size));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.size = null;
}
}
/**
* The L2 regularisation
*
* @return alpha
*
*/
@Override
public List<BigDecimal> getAlpha() {
return alpha;
}
/**
*
* @param alpha
*/
public void setAlpha(Object alpha) {
if (alpha != null) {
if (alpha instanceof ArrayList) {
this.alpha = (ArrayList<BigDecimal>) alpha;
} else if (alpha instanceof Float) {
this.alpha = new ArrayList<>(Arrays.asList(new BigDecimal((Float) alpha)));
} else {
throw new InputMismatchException("Expected ArrayList<BigDecimal> or Float");
}
} else {
this.alpha = null;
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/RandomForestSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/RandomForestSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import org.ohdsi.analysis.prediction.design.RandomForestSettings;
/**
*
* @author asena5
*/
public class RandomForestSettingsImpl extends SeedSettingsImpl implements RandomForestSettings {
private List<Integer> mtries = new ArrayList<>(Arrays.asList(-1));
private List<Integer> ntrees = new ArrayList<>(Arrays.asList(500));
private List<Integer> maxDepth = null;
private List<Boolean> varImp = new ArrayList<>(Arrays.asList(true));
/**
* The number of features to include in each tree (-1 defaults to square
* root of total features)
*
* @return mtries
*
*/
@Override
public List<Integer> getMtries() {
return mtries;
}
/**
*
* @param mtries
*/
public void setMtries(Object mtries) {
if (mtries != null) {
if (mtries instanceof ArrayList) {
this.mtries = (ArrayList<Integer>) mtries;
} else if (mtries instanceof Integer) {
this.mtries = new ArrayList<>(Arrays.asList((Integer) mtries));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.mtries = null;
}
}
/**
* The number of trees to build
*
* @return ntrees
*
*/
@Override
public List<Integer> getNtrees() {
return ntrees;
}
/**
*
* @param ntrees
*/
public void setNtrees(Object ntrees) {
if (ntrees != null) {
if (ntrees instanceof ArrayList) {
this.ntrees = (ArrayList<Integer>) ntrees;
} else if (ntrees instanceof Integer) {
this.ntrees = new ArrayList<>(Arrays.asList((Integer) ntrees));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.ntrees = null;
}
}
/**
* Maximum number of interactions - a large value will lead to slow model
* training
*
* @return maxDepth
*
*/
@Override
public List<Integer> getMaxDepth() {
return maxDepth;
}
/**
*
* @param maxDepth
*/
public void setMaxDepth(List<Object> maxDepth) {
if (maxDepth != null) {
if (this.maxDepth == null)
this.maxDepth = new ArrayList<>();
maxDepth.forEach((o) -> {
if (o instanceof BigDecimal) {
this.maxDepth.add(((BigDecimal) o).intValue());
} else if (o instanceof Integer) {
this.maxDepth.add((Integer) o);
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or ArrayList<BigDecimal>");
}
});
} else {
this.maxDepth = null;
}
}
/**
* Perform an initial variable selection prior to fitting the model to
* select the useful variables
*
* @return varImp
*
*/
@Override
public List<Boolean> getVarImp() {
return varImp;
}
/**
*
* @param varImp
*/
public void setVarImp(Object varImp) {
if (varImp != null) {
if (varImp instanceof ArrayList) {
this.varImp = (ArrayList<Boolean>) varImp;
} else if (varImp instanceof Boolean) {
this.varImp = new ArrayList<>(Arrays.asList((Boolean) varImp));
} else {
throw new InputMismatchException("Expected ArrayList<Boolean> or Boolean");
}
} else {
this.varImp = null;
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/AdaBoostSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/AdaBoostSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import org.ohdsi.analysis.prediction.design.AdaBoostSettings;
/**
* Specification for a Ada Boost Model
*/
public class AdaBoostSettingsImpl extends SeedSettingsImpl implements AdaBoostSettings {
private List<Integer> nEstimators = new ArrayList<>(Arrays.asList(50));
private List<BigDecimal> learningRate = new ArrayList<>(Arrays.asList(new BigDecimal(1)));
/**
* The maximum number of estimators at which boosting is terminated
*
* @return nEstimators
*
*/
@Override
public List<Integer> getNEstimators() {
return nEstimators;
}
/**
*
* @param nEstimators
*/
public void setNEstimators(Object nEstimators) {
if (nEstimators != null) {
if (nEstimators instanceof ArrayList) {
this.nEstimators = (ArrayList<Integer>) nEstimators;
} else if (nEstimators instanceof Integer) {
this.nEstimators = new ArrayList<>(Arrays.asList((Integer) nEstimators));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.nEstimators = null;
}
}
/**
* Learning rate shrinks the contribution of each classifier by
* learningRate. There is a trade-off between learningRate and nEstimators .
*
* @return learningRate
*
*/
@Override
public List<BigDecimal> getLearningRate() {
return learningRate;
}
/**
* Set the learning rate
*
* @param learningRate
*/
public void setLearningRate(Object learningRate) {
if (learningRate != null) {
if (learningRate instanceof ArrayList) {
this.learningRate = (ArrayList<BigDecimal>) learningRate;
} else if (learningRate instanceof Integer) {
this.learningRate = new ArrayList<>(Arrays.asList(new BigDecimal((Integer) learningRate)));
} else {
throw new InputMismatchException("Expected ArrayList<BigDecimal> or Integer");
}
} else {
this.learningRate = null;
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/CreateStudyPopulationArgsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/CreateStudyPopulationArgsImpl.java | package org.ohdsi.webapi.prediction.specification;
import org.ohdsi.analysis.prediction.design.CreateStudyPopulationArgs;
import org.ohdsi.webapi.RLangClassImpl;
/**
* Create a parameter object for the function createStudyPopulation
*/
public class CreateStudyPopulationArgsImpl extends RLangClassImpl implements CreateStudyPopulationArgs {
private Boolean binary = true;
private Boolean includeAllOutcomes = true;
private Boolean firstExposureOnly = false;
private Integer washoutPeriod = 0;
private Boolean removeSubjectsWithPriorOutcome = false;
private Integer priorOutcomeLookback = 99999;
private Boolean requireTimeAtRisk = true;
private Integer minTimeAtRisk = 365;
private Integer riskWindowStart = 0;
private Boolean addExposureDaysToStart = false;
private Integer riskWindowEnd = 365;
private Boolean addExposureDaysToEnd = true;
private String popAttrClass = "populationSettings";
/**
* Forces the outcomeCount to be 0 or 1 (use for binary prediction problems)
* @return binary
**/
@Override
public Boolean getBinary() {
return binary;
}
/**
*
* @param binary
*/
public void setBinary(Boolean binary) {
this.binary = binary;
}
/**
* (binary) indicating whether to include people with outcomes who are not observed for the whole at risk period
* @return includeAllOutcomes
**/
@Override
public Boolean getIncludeAllOutcomes() {
return includeAllOutcomes;
}
/**
*
* @param includeAllOutcomes
*/
public void setIncludeAllOutcomes(Boolean includeAllOutcomes) {
this.includeAllOutcomes = includeAllOutcomes;
}
/**
* Should only the first exposure per subject be included? Note that this is typically done in the createStudyPopulation function
* @return firstExposureOnly
**/
@Override
public Boolean getFirstExposureOnly() {
return firstExposureOnly;
}
/**
*
* @param firstExposureOnly
*/
public void setFirstExposureOnly(Boolean firstExposureOnly) {
this.firstExposureOnly = firstExposureOnly;
}
/**
* The minimum required continuous observation time prior to index date for a person to be included in the cohort.
* @return washoutPeriod
**/
@Override
public Integer getWashoutPeriod() {
return washoutPeriod;
}
/**
*
* @param washoutPeriod
*/
public void setWashoutPeriod(Integer washoutPeriod) {
this.washoutPeriod = washoutPeriod;
}
/**
* Remove subjects that have the outcome prior to the risk window start?
* @return removeSubjectsWithPriorOutcome
**/
@Override
public Boolean getRemoveSubjectsWithPriorOutcome() {
return removeSubjectsWithPriorOutcome;
}
/**
*
* @param removeSubjectsWithPriorOutcome
*/
public void setRemoveSubjectsWithPriorOutcome(Boolean removeSubjectsWithPriorOutcome) {
this.removeSubjectsWithPriorOutcome = removeSubjectsWithPriorOutcome;
}
/**
* How many days should we look back when identifying prior outcomes?
* @return priorOutcomeLookback
**/
@Override
public Integer getPriorOutcomeLookback() {
return priorOutcomeLookback;
}
/**
*
* @param priorOutcomeLookback
*/
public void setPriorOutcomeLookback(Integer priorOutcomeLookback) {
this.priorOutcomeLookback = priorOutcomeLookback;
}
/**
* Should subjects without time at risk be removed?
* @return requireTimeAtRisk
**/
@Override
public Boolean getRequireTimeAtRisk() {
return requireTimeAtRisk;
}
/**
*
* @param requireTimeAtRisk
*/
public void setRequireTimeAtRisk(Boolean requireTimeAtRisk) {
this.requireTimeAtRisk = requireTimeAtRisk;
}
/**
* The miminum time at risk in days
* @return minTimeAtRisk
**/
@Override
public Integer getMinTimeAtRisk() {
return minTimeAtRisk;
}
/**
*
* @param minTimeAtRisk
*/
public void setMinTimeAtRisk(Integer minTimeAtRisk) {
this.minTimeAtRisk = minTimeAtRisk;
}
/**
* The start of the risk window (in days) relative to the indexdate (+ days of exposure if theaddExposureDaysToStart parameter is specified).
* @return riskWindowStart
**/
@Override
public Integer getRiskWindowStart() {
return riskWindowStart;
}
/**
*
* @param riskWindowStart
*/
public void setRiskWindowStart(Integer riskWindowStart) {
this.riskWindowStart = riskWindowStart;
}
/**
* Add the length of exposure the start of the risk window?
* @return addExposureDaysToStart
**/
@Override
public Boolean getAddExposureDaysToStart() {
return addExposureDaysToStart;
}
/**
*
* @param addExposureDaysToStart
*/
public void setAddExposureDaysToStart(Boolean addExposureDaysToStart) {
this.addExposureDaysToStart = addExposureDaysToStart;
}
/**
* The end of the risk window (in days) relative to the index date (+ days of exposure if the addExposureDaysToEnd parameter is specified).
* @return riskWindowEnd
**/
@Override
public Integer getRiskWindowEnd() {
return riskWindowEnd;
}
/**
*
* @param riskWindowEnd
*/
public void setRiskWindowEnd(Integer riskWindowEnd) {
this.riskWindowEnd = riskWindowEnd;
}
/**
* Add the length of exposure the risk window?
* @return addExposureDaysToEnd
**/
@Override
public Boolean getAddExposureDaysToEnd() {
return addExposureDaysToEnd;
}
/**
*
* @param addExposureDaysToEnd
*/
public void setAddExposureDaysToEnd(Boolean addExposureDaysToEnd) {
this.addExposureDaysToEnd = addExposureDaysToEnd;
}
/**
* Get popAttrClass
* @return popAttrClass
**/
@Override
public String getAttrClass() {
return popAttrClass;
}
/**
*
* @param attrClass
*/
@Override
public void setAttrClass(String attrClass) {
this.popAttrClass = attrClass;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/KNNSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/KNNSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import org.ohdsi.analysis.prediction.design.KNNSettings;
/**
*
* @author asena5
*/
public class KNNSettingsImpl extends ModelSettingsImpl implements KNNSettings {
private Integer k = 1000;
/**
* The number of neighbors to consider
* @return k
**/
@Override
public Integer getK() {
return k;
}
/**
*
* @param k
*/
public void setK(Integer k) {
this.k = k;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/SeedSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/SeedSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.ohdsi.analysis.prediction.design.SeedSettings;
/**
*
* @author asena5
*/
public class SeedSettingsImpl extends ModelSettingsImpl implements SeedSettings {
/**
*
*/
protected Integer seed = null;
/**
*
* @return
*/
@JsonProperty("seed")
@Override
public Integer getSeed() {
return seed;
}
/**
*
* @param seed
*/
public void setSeed(Integer seed) {
this.seed = seed;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/RunPlpArgsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/RunPlpArgsImpl.java | package org.ohdsi.webapi.prediction.specification;
import org.ohdsi.analysis.prediction.design.RunPlpArgs;
import org.ohdsi.analysis.prediction.design.TestSplitEnum;
/**
*
* @author asena5
*/
public class RunPlpArgsImpl implements RunPlpArgs {
private Float minCovariateFraction = 0.001f;
private Boolean normalizeData = true;
private TestSplitEnum testSplit = TestSplitEnum.TIME;
private Float testFraction = 0.25f;
private Float splitSeed = null;
private Integer nfold = 3;
/**
* The minimum fraction of target population who must have a covariate for it to be included in the model training
* @return minCovariateFraction
**/
@Override
public Float getMinCovariateFraction() {
return minCovariateFraction;
}
/**
*
* @param minCovariateFraction
*/
public void setMinCovariateFraction(Float minCovariateFraction) {
this.minCovariateFraction = minCovariateFraction;
}
/**
* Whether to normalise the covariates before training
* @return normalizeData
**/
@Override
public Boolean getNormalizeData() {
return normalizeData;
}
/**
*
* @param normalizeData
*/
public void setNormalizeData(Boolean normalizeData) {
this.normalizeData = normalizeData;
}
/**
* Either 'person' or 'time' specifying the type of evaluation used. 'time' find the date where testFraction of patients had an index after the date and assigns patients with an index prior to this date into the training set and post the date into the test set 'person' splits the data into test (1-testFraction of the data) and train (validationFraction of the data) sets. The split is stratified by the class label.
* @return testSplit
**/
@Override
public TestSplitEnum getTestSplit() {
return testSplit;
}
/**
*
* @param testSplit
*/
public void setTestSplit(TestSplitEnum testSplit) {
this.testSplit = testSplit;
}
/**
* The fraction of the data to be used as the test set in the patient split evaluation
* @return testFraction
**/
@Override
public Float getTestFraction() {
return testFraction;
}
/**
*
* @param testFraction
*/
public void setTestFraction(Float testFraction) {
this.testFraction = testFraction;
}
/**
* The seed used to split the test/train set when using a person type testSplit
* @return splitSeed
**/
@Override
public Float getSplitSeed() {
return splitSeed;
}
/**
*
* @param splitSeed
*/
public void setSplitSeed(Float splitSeed) {
this.splitSeed = splitSeed;
}
/**
* The number of folds used in the cross validation
* @return nfold
**/
@Override
public Integer getNfold() {
return nfold;
}
/**
*
* @param nfold
*/
public void setNfold(Integer nfold) {
this.nfold = nfold;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/PatientLevelPredictionAnalysisImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/PatientLevelPredictionAnalysisImpl.java | package org.ohdsi.webapi.prediction.specification;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.ohdsi.analysis.prediction.design.PatientLevelPredictionAnalysis;
import org.ohdsi.analysis.hydra.design.SkeletonTypeEnum;
import org.ohdsi.webapi.CommonDTO;
import org.ohdsi.webapi.analysis.AnalysisCohortDefinition;
import org.ohdsi.webapi.analysis.AnalysisConceptSet;
import org.ohdsi.webapi.conceptset.ConceptSetCrossReferenceImpl;
import org.ohdsi.webapi.featureextraction.specification.CovariateSettingsImpl;
import static org.ohdsi.webapi.Constants.Params.PREDICTION_SKELETON_VERSION;
/**
*
* @author asena5
*/
@JsonIgnoreProperties(ignoreUnknown=true, value = {"createdBy", "createdDate", "modifiedBy", "modifiedDate"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PatientLevelPredictionAnalysisImpl implements PatientLevelPredictionAnalysis, CommonDTO {
private Integer id = null;
private String name = null;
private String description = null;
private String version = null;
private String organizationName = null;
private String packageName = null;
private SkeletonTypeEnum skeletonType = SkeletonTypeEnum.PATIENT_LEVEL_PREDICTION_STUDY;
private String skeletonVersion = PREDICTION_SKELETON_VERSION;
private String createdBy = null;
private String createdDate = null;
private String modifiedBy = null;
private String modifiedDate = null;
private List<AnalysisCohortDefinition> cohortDefinitions = null;
private List<AnalysisConceptSet> conceptSets = null;
private List<ConceptSetCrossReferenceImpl> conceptSetCrossReference = null;
private List<BigDecimal> targetIds = null;
private List<BigDecimal> outcomeIds = null;
private List<CovariateSettingsImpl> covariateSettings = null;
private List<CreateStudyPopulationArgsImpl> populationSettings = null;
private List<ModelSettingsImpl> modelSettings = null;
private GetDbPLPDataArgsImpl getPlpDataArgs = null;
private RunPlpArgsImpl runPlpArgs = null;
/**
* Identifier for the PLP specification
* @return id
**/
@Override
public Integer getId() {
return id;
}
/**
*
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Name for the PLP specification
* @return name
**/
@Override
public String getName() {
return name;
}
/**
*
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* The description of the study
* @return description
**/
@Override
public String getDescription() {
return description;
}
/**
*
* @param description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Version number of the specification for use by the hydration package
* @return version
**/
@Override
public String getVersion() {
return version;
}
/**
*
* @param version
*/
public void setVersion(String version) {
this.version = version;
}
/**
* The organization that produced the specification
* @return organizationName
**/
@Override
public String getOrganizationName() {
return organizationName;
}
/**
*
* @param organizationName
*/
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
/**
* The name of the R Package for execution
* @return packageName
**/
@Override
public String getPackageName() {
return packageName;
}
/**
*
* @param packageName
*/
public void setPackageName(String packageName) {
this.packageName = packageName;
}
/**
* The base skeleton R package
* @return skeletonType
**/
@Override
public SkeletonTypeEnum getSkeletonType() {
return skeletonType;
}
/**
*
* @param skeletonType
*/
public void setSkeletonType(SkeletonTypeEnum skeletonType) {
this.skeletonType = skeletonType;
}
/**
* The corresponding skeleton version to use
* @return skeletonVersion
**/
@Override
public String getSkeletonVersion() {
return skeletonVersion;
}
/**
*
* @param skeletonVersion
*/
public void setSkeletonVersion(String skeletonVersion) {
this.skeletonVersion = skeletonVersion;
}
/**
* The person who created the analysis
* @return createdBy
**/
@Override
public String getCreatedBy() {
return createdBy;
}
/**
*
* @param createdBy
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
* The date and time the estimation was first saved
* @return createdDate
**/
@Override
public String getCreatedDate() {
return createdDate;
}
/**
*
* @param createdDate
*/
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
/**
* The last person to modify the analysis
* @return modifiedBy
**/
@Override
public String getModifiedBy() {
return modifiedBy;
}
/**
*
* @param modifiedBy
*/
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
/**
* The date and time the estimation was last saved
* @return modifiedDate
**/
@Override
public String getModifiedDate() {
return modifiedDate;
}
/**
*
* @param modifiedDate
*/
public void setModifiedDate(String modifiedDate) {
this.modifiedDate = modifiedDate;
}
/**
*
* @param cohortDefinitionsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addCohortDefinitionsItem(AnalysisCohortDefinition cohortDefinitionsItem) {
if (this.cohortDefinitions == null) {
this.cohortDefinitions = new ArrayList<>();
}
this.cohortDefinitions.add(cohortDefinitionsItem);
return this;
}
/**
* Get cohortDefinitions
* @return cohortDefinitions
**/
@Override
public List<AnalysisCohortDefinition> getCohortDefinitions() {
return cohortDefinitions;
}
/**
*
* @param cohortDefinitions
*/
public void setCohortDefinitions(List<AnalysisCohortDefinition> cohortDefinitions) {
this.cohortDefinitions = cohortDefinitions;
}
/**
*
* @param conceptSetsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addConceptSetsItem(AnalysisConceptSet conceptSetsItem) {
if (this.conceptSets == null) {
this.conceptSets = new ArrayList<>();
}
this.conceptSets.add(conceptSetsItem);
return this;
}
/**
* Get conceptSets
* @return conceptSets
**/
@Override
public List<AnalysisConceptSet> getConceptSets() {
return conceptSets;
}
/**
*
* @param conceptSets
*/
public void setConceptSets(List<AnalysisConceptSet> conceptSets) {
this.conceptSets = conceptSets;
}
/**
* Get conceptSetCrossReference
* @return conceptSetCrossReference
**/
@Override
public List<ConceptSetCrossReferenceImpl> getConceptSetCrossReference() {
return conceptSetCrossReference;
}
/**
*
* @param conceptSetCrossReference
*/
public void setConceptSetCrossReference(List<ConceptSetCrossReferenceImpl> conceptSetCrossReference) {
this.conceptSetCrossReference = conceptSetCrossReference;
}
/**
*
* @param targetIdsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addTargetIdsItem(BigDecimal targetIdsItem) {
if (this.targetIds == null) {
this.targetIds = new ArrayList<>();
}
this.targetIds.add(targetIdsItem);
return this;
}
/**
* A list of the cohort IDs from the cohortDefinition collection for use as targets in the prediction
* @return targetIds
**/
@Override
public List<BigDecimal> getTargetIds() {
return targetIds;
}
/**
*
* @param targetIds
*/
public void setTargetIds(List<BigDecimal> targetIds) {
this.targetIds = targetIds;
}
/**
*
* @param outcomeIdsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addOutcomeIdsItem(BigDecimal outcomeIdsItem) {
if (this.outcomeIds == null) {
this.outcomeIds = new ArrayList<>();
}
this.outcomeIds.add(outcomeIdsItem);
return this;
}
/**
* A list of the cohort IDs from the cohortDefinition collection for use as outcomes in the prediction
* @return outcomeIds
**/
@Override
public List<BigDecimal> getOutcomeIds() {
return outcomeIds;
}
/**
*
* @param outcomeIds
*/
public void setOutcomeIds(List<BigDecimal> outcomeIds) {
this.outcomeIds = outcomeIds;
}
/**
*
* @param covariateSettingsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addCovariateSettingsItem(CovariateSettingsImpl covariateSettingsItem) {
if (this.covariateSettings == null) {
this.covariateSettings = new ArrayList<>();
}
this.covariateSettings.add(covariateSettingsItem);
return this;
}
/**
* Get covariateSettings
* @return covariateSettings
**/
@Override
public List<CovariateSettingsImpl> getCovariateSettings() {
return covariateSettings;
}
/**
*
* @param covariateSettings
*/
public void setCovariateSettings(List<CovariateSettingsImpl> covariateSettings) {
this.covariateSettings = covariateSettings;
}
/**
*
* @param populationSettingsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addPopulationSettingsItem(CreateStudyPopulationArgsImpl populationSettingsItem) {
if (this.populationSettings == null) {
this.populationSettings = new ArrayList<>();
}
this.populationSettings.add(populationSettingsItem);
return this;
}
/**
* Get populationSettings
* @return populationSettings
**/
@Override
public List<CreateStudyPopulationArgsImpl> getPopulationSettings() {
return populationSettings;
}
/**
*
* @param populationSettings
*/
public void setPopulationSettings(List<CreateStudyPopulationArgsImpl> populationSettings) {
this.populationSettings = populationSettings;
}
/**
*
* @param modelSettingsItem
* @return
*/
public PatientLevelPredictionAnalysisImpl addModelSettingsItem(ModelSettingsImpl modelSettingsItem) {
if (this.modelSettings == null) {
this.modelSettings = new ArrayList<>();
}
this.modelSettings.add(modelSettingsItem);
return this;
}
/**
* Get modelSettings
* @return modelSettings
**/
@Override
public List<ModelSettingsImpl> getModelSettings() {
return modelSettings;
}
/**
*
* @param modelSettings
*/
public void setModelSettings(List<ModelSettingsImpl> modelSettings) {
this.modelSettings = modelSettings;
}
/**
* Get getPlpDataArgs
* @return getPlpDataArgs
**/
@Override
public GetDbPLPDataArgsImpl getPlpDataArgs() {
return getPlpDataArgs;
}
/**
*
* @param getPlpDataArgs
*/
public void setGetPlpDataArgs(GetDbPLPDataArgsImpl getPlpDataArgs) {
this.getPlpDataArgs = getPlpDataArgs;
}
/**
* Get runPlpArgs
* @return runPlpArgs
**/
@Override
public RunPlpArgsImpl getRunPlpArgs() {
return runPlpArgs;
}
/**
*
* @param runPlpArgs
*/
public void setRunPlpArgs(RunPlpArgsImpl runPlpArgs) {
this.runPlpArgs = runPlpArgs;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/DecisionTreeSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/DecisionTreeSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import org.ohdsi.analysis.prediction.design.ClassWeightEnum;
import org.ohdsi.analysis.prediction.design.DecisionTreeSettings;
/**
* Specification for a Decision Tree Model
*/
public class DecisionTreeSettingsImpl extends SeedSettingsImpl implements DecisionTreeSettings {
private List<Integer> maxDepth = new ArrayList<>(Arrays.asList(10));
private List<Integer> minSamplesSplit = new ArrayList<>(Arrays.asList(2));
private List<Integer> minSamplesLeaf = new ArrayList<>(Arrays.asList(10));
private List<BigDecimal> minImpurityDecrease = new ArrayList<>(Arrays.asList(BigDecimal.valueOf(1.0E-7f)));
private List<ClassWeightEnum> classWeight = new ArrayList<>(Arrays.asList(ClassWeightEnum.NONE));
private Boolean plot = false;
/**
* The maximum depth of the tree
*
* @return maxDepth
*
*/
@Override
public List<Integer> getMaxDepth() {
return maxDepth;
}
/**
*
* @param maxDepth
*/
public void setMaxDepth(Object maxDepth) {
if (maxDepth != null) {
if (maxDepth instanceof ArrayList) {
this.maxDepth = (ArrayList<Integer>) maxDepth;
} else if (maxDepth instanceof Integer) {
this.maxDepth = new ArrayList<>(Arrays.asList((Integer) maxDepth));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.maxDepth = null;
}
}
/**
* The minimum samples per split
*
* @return minSamplesSplit
*
*/
@Override
public List<Integer> getMinSamplesSplit() {
return minSamplesSplit;
}
/**
*
* @param minSamplesSplit
*/
public void setMinSamplesSplit(Object minSamplesSplit) {
if (minSamplesSplit != null) {
if (minSamplesSplit instanceof ArrayList) {
this.minSamplesSplit = (ArrayList<Integer>) minSamplesSplit;
} else if (minSamplesSplit instanceof Integer) {
this.minSamplesSplit = new ArrayList<>(Arrays.asList((Integer) minSamplesSplit));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.minSamplesSplit = null;
}
}
/**
* The minimum number of samples per leaf
*
* @return minSampleLeaf
*
*/
@Override
public List<Integer> getMinSamplesLeaf() {
return minSamplesLeaf;
}
/**
*
* @param minSamplesLeaf
*/
public void setMinSamplesLeaf(Object minSamplesLeaf) {
if (minSamplesLeaf != null) {
if (minSamplesLeaf instanceof ArrayList) {
this.minSamplesLeaf = (ArrayList<Integer>) minSamplesLeaf;
} else if (minSamplesLeaf instanceof Integer) {
this.minSamplesLeaf = new ArrayList<>(Arrays.asList((Integer) minSamplesLeaf));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.minSamplesLeaf = null;
}
}
/**
* Threshold for early stopping in tree growth. A node will split if its
* impurity is above the threshold, otherwise it is a leaf.
*
* @return minImpurityDecrease
*
*/
@Override
public List<BigDecimal> getMinImpurityDecrease() {
return minImpurityDecrease;
}
/**
*
* @param minImpurityDecrease
*/
public void setMinImpurityDecrease(Object minImpurityDecrease) {
if (minImpurityDecrease != null) {
if (minImpurityDecrease instanceof ArrayList) {
this.minImpurityDecrease = (List<BigDecimal>) minImpurityDecrease;
} else if (minImpurityDecrease instanceof Float) {
this.minImpurityDecrease = new ArrayList<>(Arrays.asList(new BigDecimal((Float) minImpurityDecrease)));
} else {
throw new InputMismatchException("Expected ArrayList<BigDecimal> or Float");
}
} else {
this.minImpurityDecrease = null;
}
}
/**
* Balance or None
*
* @return classWeight
*
*/
@Override
public List<ClassWeightEnum> getClassWeight() {
return classWeight;
}
/**
*
* @param classWeight
*/
public void setClassWeight(List<ClassWeightEnum> classWeight) {
this.classWeight = classWeight;
}
/**
* Boolean whether to plot the tree (requires python pydotplus module)
*
* @return plot
*
*/
@Override
public Boolean getPlot() {
return plot;
}
/**
*
* @param plot
*/
public void setPlot(Boolean plot) {
this.plot = plot;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/LassoLogisticRegressionSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/LassoLogisticRegressionSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import org.ohdsi.analysis.prediction.design.LassoLogisticRegressionSettings;
/**
*
* @author asena5
*/
public class LassoLogisticRegressionSettingsImpl extends SeedSettingsImpl implements LassoLogisticRegressionSettings {
private BigDecimal variance = BigDecimal.valueOf(0.01);
/**
* A single value used as the starting value for the automatic lambda search
* @return variance
**/
@Override
public BigDecimal getVariance() {
return variance;
}
/**
*
* @param variance
*/
public void setVariance(BigDecimal variance) {
this.variance = variance;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/NaiveBayesSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/NaiveBayesSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import org.ohdsi.analysis.prediction.design.NaiveBayesSettings;
/**
*
* @author asena5
*/
public class NaiveBayesSettingsImpl extends ModelSettingsImpl implements NaiveBayesSettings {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/ModelSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/ModelSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import org.ohdsi.analysis.prediction.design.ModelSettings;
import org.ohdsi.analysis.prediction.design.ModelSettingsConst;
/**
*
* @author asena5
*/
@JsonSubTypes({
@JsonSubTypes.Type(value = AdaBoostSettingsImpl.class, name = ModelSettingsConst.ADA_BOOST),
@JsonSubTypes.Type(value = DecisionTreeSettingsImpl.class, name = ModelSettingsConst.DECISION_TREE),
@JsonSubTypes.Type(value = GradientBoostingMachineSettingsImpl.class, name = ModelSettingsConst.GRADIENT_BOOSTING_MACHINE),
@JsonSubTypes.Type(value = KNNSettingsImpl.class, name = ModelSettingsConst.KNN),
@JsonSubTypes.Type(value = LassoLogisticRegressionSettingsImpl.class, name = ModelSettingsConst.LASSO_LOGISTIC_REGRESSION),
@JsonSubTypes.Type(value = MLPSettingsImpl.class, name = ModelSettingsConst.MLP),
@JsonSubTypes.Type(value = NaiveBayesSettingsImpl.class, name = ModelSettingsConst.NAIVE_BAYES),
@JsonSubTypes.Type(value = RandomForestSettingsImpl.class, name = ModelSettingsConst.RANDOM_FOREST)
})
public class ModelSettingsImpl implements ModelSettings {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/GetDbPLPDataArgsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/GetDbPLPDataArgsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import org.ohdsi.analysis.prediction.design.GetDbPLPDataArgs;
/**
*
* @author asena5
*/
public class GetDbPLPDataArgsImpl implements GetDbPLPDataArgs {
private BigDecimal maxSampleSize = null;
private Integer washoutPeriod = 0;
/**
* Max sample size
* @return maxSampleSize
**/
@Override
public BigDecimal getMaxSampleSize() {
return maxSampleSize;
}
/**
*
* @param maxSampleSize
*/
public void setMaxSampleSize(BigDecimal maxSampleSize) {
this.maxSampleSize = maxSampleSize;
}
/**
* The mininum required continuous observation time prior to index date for a person to be included in the cohort. Note that this is typically done in the createStudyPopulation function,but can already be done here for efficiency reasons.
* @return washoutPeriod
**/
@Override
public Integer getWashoutPeriod() {
return washoutPeriod;
}
/**
*
* @param washoutPeriod
*/
public void setWashoutPeriod(Integer washoutPeriod) {
this.washoutPeriod = washoutPeriod;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/prediction/specification/GradientBoostingMachineSettingsImpl.java | src/main/java/org/ohdsi/webapi/prediction/specification/GradientBoostingMachineSettingsImpl.java | package org.ohdsi.webapi.prediction.specification;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import org.ohdsi.analysis.prediction.design.GradientBoostingMachineSettings;
/**
*
* @author asena5
*/
public class GradientBoostingMachineSettingsImpl extends SeedSettingsImpl implements GradientBoostingMachineSettings {
private List<Integer> nTrees = null;
private Integer nthread = 20;
private List<Integer> maxDepth = null;
private List<Integer> minRows = new ArrayList<>(Arrays.asList(20));
private List<BigDecimal> learnRate = null;
/**
* The number of trees to build
*
* @return nTrees
*
*/
@Override
public List<Integer> getNTrees() {
return nTrees;
}
/**
*
* @param nTrees
*/
public void setNTrees(List<Object> nTrees) {
if (nTrees != null) {
if (this.nTrees == null)
this.nTrees = new ArrayList<>();
nTrees.forEach((o) -> {
if (o instanceof BigDecimal) {
this.nTrees.add(((BigDecimal) o).intValue());
} else if (o instanceof Integer) {
this.nTrees.add((Integer) o);
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or ArrayList<BigDecimal>");
}
});
} else {
this.nTrees = null;
}
}
/**
* The number of computer threads to (how many cores do you have?)
*
* @return nthread
*
*/
@Override
public Integer getNThread() {
return nthread;
}
/**
*
* @param nthread
*/
public void setNthread(Integer nthread) {
this.nthread = nthread;
}
/**
* Maximum number of interactions - a large value will lead to slow model
* training
*
* @return maxDepth
*
*/
@Override
public List<Integer> getMaxDepth() {
return maxDepth;
}
/**
*
* @param maxDepth
*/
public void setMaxDepth(Object maxDepth) {
if (maxDepth != null) {
if (maxDepth instanceof ArrayList) {
this.maxDepth = (ArrayList<Integer>) maxDepth;
} else if (maxDepth instanceof Integer) {
this.maxDepth = new ArrayList<>(Arrays.asList((Integer) maxDepth));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.maxDepth = null;
}
}
/**
* The minimum number of rows required at each end node of the tree
*
* @return minRows
*
*/
@Override
public List<Integer> getMinRows() {
return minRows;
}
/**
*
* @param minRows
*/
public void setMinRows(Object minRows) {
if (minRows != null) {
if (minRows instanceof ArrayList) {
this.minRows = (ArrayList<Integer>) minRows;
} else if (minRows instanceof Integer) {
this.minRows = new ArrayList<>(Arrays.asList((Integer) minRows));
} else {
throw new InputMismatchException("Expected ArrayList<Integer> or Integer");
}
} else {
this.minRows = null;
}
}
/**
* The boosting learn rate
*
* @return learnRate
*
*/
@Override
public List<BigDecimal> getLearnRate() {
return learnRate;
}
/**
*
* @param learnRate
*/
public void setLearnRate(List<BigDecimal> learnRate) {
this.learnRate = learnRate;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/package-info.java | src/main/java/org/ohdsi/webapi/model/package-info.java | /**
* This package corresponds to model objects in the CDM schema
*/
package org.ohdsi.webapi.model; | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/CohortAttribute.java | src/main/java/org/ohdsi/webapi/model/CohortAttribute.java | package org.ohdsi.webapi.model;
import java.util.Date;
public class CohortAttribute {
public static final String COHORT_DEFINITION_ID = "COHORT_DEFINITION_ID";
public static final String COHORT_START_DATE = "COHORT_START_DATE";
public static final String COHORT_END_DATE = "COHORT_END_DATE";
public static final String SUBJECT_ID = "SUBJECT_ID";
public static final String ATTRIBUTE_DEFINITION_ID = "ATTRIBUTE_DEFINITION_ID";
public static final String VALUE_AS_NUMBER = "VALUE_AS_NUMBER";
public static final String VALUE_AS_CONCEPT_ID = "VALUE_AS_CONCEPT_ID";
private int cohortDefinitionId;
private Date cohortStartDate;
private Date cohortEndDate;
private int subjectId;
private int attributeDefinitionId;
private double valueAsNumber;
private int valueAsConceptId;
public int getCohortDefinitionId() {
return cohortDefinitionId;
}
public void setCohortDefinitionId(int cohortDefinitionId) {
this.cohortDefinitionId = cohortDefinitionId;
}
public Date getCohortStartDate() {
return cohortStartDate;
}
public void setCohortStartDate(Date cohortStartDate) {
this.cohortStartDate = cohortStartDate;
}
public Date getCohortEndDate() {
return cohortEndDate;
}
public void setCohortEndDate(Date cohrotEndDate) {
this.cohortEndDate = cohrotEndDate;
}
public int getSubjectId() {
return subjectId;
}
public void setSubjectId(int subjectId) {
this.subjectId = subjectId;
}
public int getAttributeDefinitionId() {
return attributeDefinitionId;
}
public void setAttributeDefinitionId(int attributeDefinitionId) {
this.attributeDefinitionId = attributeDefinitionId;
}
public double getValueAsNumber() {
return valueAsNumber;
}
public void setValueAsNumber(double valueAsNumber) {
this.valueAsNumber = valueAsNumber;
}
public int getValueAsConceptId() {
return valueAsConceptId;
}
public void setValueAsConceptId(int valueAsConceptId) {
this.valueAsConceptId = valueAsConceptId;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/CommonEntity.java | src/main/java/org/ohdsi/webapi/model/CommonEntity.java | package org.ohdsi.webapi.model;
import org.ohdsi.analysis.WithId;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@MappedSuperclass
public abstract class CommonEntity<T extends Number> implements Serializable, WithId<T> {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "created_by_id", updatable = false)
private UserEntity createdBy;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modified_by_id")
private UserEntity modifiedBy;
@Column(name = "created_date", updatable = false)
private Date createdDate;
@Column(name = "modified_date")
private Date modifiedDate;
public UserEntity getCreatedBy() {
return createdBy;
}
public void setCreatedBy(UserEntity createdBy) {
this.createdBy = createdBy;
}
public UserEntity getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(UserEntity modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Date getModifiedDate() {
return modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
this.modifiedDate = modifiedDate;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/Cohort.java | src/main/java/org/ohdsi/webapi/model/Cohort.java | package org.ohdsi.webapi.model;
import java.util.Date;
public class Cohort {
public static final String COHORT_DEFINITION_ID = "COHORT_DEFINITION_ID";
public static final String SUBJECT_ID = "SUBJECT_ID";
public static final String COHORT_START_DATE = "COHORT_START_DATE";
public static final String COHORT_END_DATE = "COHORT_END_DATE";
private int cohortDefinitionId;
private int subjectId;
private Date cohortStartDate;
private Date cohortEndDate;
public int getCohortDefinitionId() {
return cohortDefinitionId;
}
public void setCohortDefinitionId(int cohortDefinitionId) {
this.cohortDefinitionId = cohortDefinitionId;
}
public int getSubjectId() {
return subjectId;
}
public void setSubjectId(int subjectId) {
this.subjectId = subjectId;
}
public Date getCohortStartDate() {
return cohortStartDate;
}
public void setCohortStartDate(Date cohortStartDate) {
this.cohortStartDate = cohortStartDate;
}
public Date getCohortEndDate() {
return cohortEndDate;
}
public void setCohortEndDate(Date cohortEndDate) {
this.cohortEndDate = cohortEndDate;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/CommonEntityExt.java | src/main/java/org/ohdsi/webapi/model/CommonEntityExt.java | package org.ohdsi.webapi.model;
import org.ohdsi.webapi.tag.domain.Tag;
import javax.persistence.MappedSuperclass;
import java.util.List;
import java.util.Set;
@MappedSuperclass
public abstract class CommonEntityExt<T extends Number> extends CommonEntity<T> {
public abstract Set<Tag> getTags();
public abstract void setTags(Set<Tag> tags);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/CohortDefinition.java | src/main/java/org/ohdsi/webapi/model/CohortDefinition.java | package org.ohdsi.webapi.model;
import java.util.Date;
public class CohortDefinition {
public static final String COHORT_DEFINITION_ID = "COHORT_DEFINITION_ID";
public static final String COHORT_DEFINITION_NAME = "COHORT_DEFINITION_NAME";
public static final String COHORT_DEFINITION_DESCRIPTION = "COHORT_DEFINITION_DESCRIPTION";
public static final String DEFINITION_TYPE_CONCEPT_ID = "DEFINITION_TYPE_CONCEPT_ID";
public static final String COHORT_DEFINITION_SYNTAX = "COHORT_DEFINITION_SYNTAX";
public static final String SUBJECT_CONCEPT_ID = "SUBJECT_CONCEPT_ID";
public static final String COHORT_INITIATION_DATE = "COHORT_INITIATION_DATE";
private int cohortDefinitionId;
private String cohortDefinitionName;
private String cohortDefinitionDescription;
private int definitionTypeConceptId;
private String cohortDefinitionSyntax;
private int subjectConceptId;
private Date cohortInitiationDate;
public int getCohortDefinitionId() {
return cohortDefinitionId;
}
public void setCohortDefinitionId(int cohortDefinitionId) {
this.cohortDefinitionId = cohortDefinitionId;
}
public String getCohortDefinitionName() {
return cohortDefinitionName;
}
public void setCohortDefinitionName(String cohortDefinitionName) {
this.cohortDefinitionName = cohortDefinitionName;
}
public String getCohortDefinitionDescription() {
return cohortDefinitionDescription;
}
public void setCohortDefinitionDescription(String cohortDefinitionDescription) {
this.cohortDefinitionDescription = cohortDefinitionDescription;
}
public int getDefinitionTypeConceptId() {
return definitionTypeConceptId;
}
public void setDefinitionTypeConceptId(int definitionTypeConceptId) {
this.definitionTypeConceptId = definitionTypeConceptId;
}
public String getCohortDefinitionSyntax() {
return cohortDefinitionSyntax;
}
public void setCohortDefinitionSyntax(String cohortDefinitionSyntax) {
this.cohortDefinitionSyntax = cohortDefinitionSyntax;
}
public int getSubjectConceptId() {
return subjectConceptId;
}
public void setSubjectConceptId(int subjectConceptId) {
this.subjectConceptId = subjectConceptId;
}
public Date getCohortInitiationDate() {
return cohortInitiationDate;
}
public void setCohortInitiationDate(Date cohortInitiationDate) {
this.cohortInitiationDate = cohortInitiationDate;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/results/package-info.java | src/main/java/org/ohdsi/webapi/model/results/package-info.java | /**
* This package corresponds to model objects in the Results (also named OHDSI) schema
*/
package org.ohdsi.webapi.model.results; | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/results/Analysis.java | src/main/java/org/ohdsi/webapi/model/results/Analysis.java | package org.ohdsi.webapi.model.results;
/**
*
* For OHDSI implementations, this corresponds to the HERACLES_ANALYSIS table
*
*/
public class Analysis {
public static final String ANALYSIS_ID = "ANALYSIS_ID";
public static final String ANALYSIS_NAME = "ANALYSIS_NAME";
public static final String STRATUM_1_NAME = "STRATUM_1_NAME";
public static final String STRATUM_2_NAME = "STRATUM_2_NAME";
public static final String STRATUM_3_NAME = "STRATUM_3_NAME";
public static final String STRATUM_4_NAME = "STRATUM_4_NAME";
public static final String STRATUM_5_NAME = "STRATUM_5_NAME";
public static final String ANALYSIS_TYPE = "ANALYSIS_TYPE";
private int analysisId;
private String analysisName;
private String stratum1Name;
private String stratum2Name;
private String stratum3Name;
private String stratum4Name;
private String stratum5Name;
private String analysisType;
public int getAnalysisId() {
return analysisId;
}
public void setAnalysisId(int analysisId) {
this.analysisId = analysisId;
}
public String getAnalysisName() {
return analysisName;
}
public void setAnalysisName(String analysisName) {
this.analysisName = analysisName;
}
public String getStratum1Name() {
return stratum1Name;
}
public void setStratum1Name(String stratum1Name) {
this.stratum1Name = stratum1Name;
}
public String getStratum2Name() {
return stratum2Name;
}
public void setStratum2Name(String stratum2Name) {
this.stratum2Name = stratum2Name;
}
public String getStratum3Name() {
return stratum3Name;
}
public void setStratum3Name(String stratum3Name) {
this.stratum3Name = stratum3Name;
}
public String getStratum4Name() {
return stratum4Name;
}
public void setStratum4Name(String stratum4Name) {
this.stratum4Name = stratum4Name;
}
public String getStratum5Name() {
return stratum5Name;
}
public void setStratum5Name(String stratum5Name) {
this.stratum5Name = stratum5Name;
}
/**
* @return the analysisType
*/
public String getAnalysisType() {
return analysisType;
}
/**
* @param analysisType the analysisType to set
*/
public void setAnalysisType(String analysisType) {
this.analysisType = analysisType;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/results/AnalysisResultsDist.java | src/main/java/org/ohdsi/webapi/model/results/AnalysisResultsDist.java | package org.ohdsi.webapi.model.results;
/**
*
* For OHDSI implementations, this corresponds to the HERACLES_RESULTS_DIST table
*
*/
public class AnalysisResultsDist extends AnalysisResults {
public static final String MIN_VALUE = "MIN_VALUE";
public static final String MAX_VALUE = "MAX_VALUE";
public static final String AVG_VALUE = "AVG_VALUE";
public static final String STDEV_VALUE = "STDEV_VALUE";
public static final String MEDIAN_VALUE = "MEDIAN_VALUE";
public static final String P10_VALUE = "P10_VALUE";
public static final String P25_VALUE = "P25_VALUE";
public static final String P75_VALUE = "P75_VALUE";
public static final String P90_VALUE = "P90_VALUE";
private double minValue;
private double maxValue;
private double avgValue;
private double stdevValue;
private double medianValue;
private double p10Value;
private double p25Value;
private double p75Value;
private double p90Value
;
public double getMinValue() {
return minValue;
}
public void setMinValue(double minValue) {
this.minValue = minValue;
}
public double getMaxValue() {
return maxValue;
}
public void setMaxValue(double maxValue) {
this.maxValue = maxValue;
}
public double getAvgValue() {
return avgValue;
}
public void setAvgValue(double avgValue) {
this.avgValue = avgValue;
}
public double getStdevValue() {
return stdevValue;
}
public void setStdevValue(double stdevValue) {
this.stdevValue = stdevValue;
}
public double getMedianValue() {
return medianValue;
}
public void setMedianValue(double medianValue) {
this.medianValue = medianValue;
}
public double getP10Value() {
return p10Value;
}
public void setP10Value(double p10Value) {
this.p10Value = p10Value;
}
public double getP25Value() {
return p25Value;
}
public void setP25Value(double p25Value) {
this.p25Value = p25Value;
}
public double getP75Value() {
return p75Value;
}
public void setP75Value(double p75Value) {
this.p75Value = p75Value;
}
public double getP90Value() {
return p90Value;
}
public void setP90Value(double p90Value) {
this.p90Value = p90Value;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/model/results/AnalysisResults.java | src/main/java/org/ohdsi/webapi/model/results/AnalysisResults.java | package org.ohdsi.webapi.model.results;
/**
*
* For OHDSI implementations, this corresponds to the HERACLES_RESULTS table
*
*/
public class AnalysisResults {
public static final String COHORT_DEFINITION_ID = "COHORT_DEFINITION_ID";
public static final String ANALYSIS_ID = "ANALYSIS_ID";
public static final String STRATUM_1 = "STRATUM_1";
public static final String STRATUM_2 = "STRATUM_2";
public static final String STRATUM_3 = "STRATUM_3";
public static final String STRATUM_4 = "STRATUM_4";
public static final String STRATUM_5 = "STRATUM_5";
public static final String COUNT_VALUE = "COUNT_VALUE";
private int cohortDefinitionId;
private int analysisId;
private String stratum1;
private String stratum2;
private String stratum3;
private String stratum4;
private String stratum5;
private int countValue;
public int getCohortDefinitionId() {
return cohortDefinitionId;
}
public void setCohortDefinitionId(int cohortDefinitionId) {
this.cohortDefinitionId = cohortDefinitionId;
}
public int getAnalysisId() {
return analysisId;
}
public void setAnalysisId(int analysisId) {
this.analysisId = analysisId;
}
public String getStratum1() {
return stratum1;
}
public void setStratum1(String stratum1) {
this.stratum1 = stratum1;
}
public String getStratum2() {
return stratum2;
}
public void setStratum2(String stratum2) {
this.stratum2 = stratum2;
}
public String getStratum3() {
return stratum3;
}
public void setStratum3(String stratum3) {
this.stratum3 = stratum3;
}
public String getStratum4() {
return stratum4;
}
public void setStratum4(String stratum4) {
this.stratum4 = stratum4;
}
public String getStratum5() {
return stratum5;
}
public void setStratum5(String stratum5) {
this.stratum5 = stratum5;
}
public int getCountValue() {
return countValue;
}
public void setCountValue(int countValue) {
this.countValue = countValue;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/featureextraction/specification/CovariateSettingsImpl.java | src/main/java/org/ohdsi/webapi/featureextraction/specification/CovariateSettingsImpl.java | package org.ohdsi.webapi.featureextraction.specification;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.ArrayList;
import java.util.List;
import org.ohdsi.analysis.featureextraction.design.*;
import org.ohdsi.webapi.RLangClassImpl;
/**
*
* @author asena5
*/
@JsonIgnoreProperties(ignoreUnknown=true)
public class CovariateSettingsImpl extends RLangClassImpl implements CovariateSettings {
private Boolean temporal = false;
private Boolean demographicsGender = false;
private Boolean demographicsAge = false;
private Boolean demographicsAgeGroup = false;
private Boolean demographicsRace = false;
private Boolean demographicsEthnicity = false;
private Boolean demographicsIndexYear = false;
private Boolean demographicsIndexMonth = false;
private Boolean demographicsPriorObservationTime = false;
private Boolean demographicsPostObservationTime = false;
private Boolean demographicsTimeInCohort = false;
private Boolean demographicsIndexYearMonth = false;
private Boolean conditionOccurrenceAnyTimePrior = false;
private Boolean conditionOccurrenceLongTerm = false;
private Boolean conditionOccurrenceMediumTerm = false;
private Boolean conditionOccurrenceShortTerm = false;
private Boolean conditionOccurrencePrimaryInpatientAnyTimePrior = false;
private Boolean conditionOccurrencePrimaryInpatientLongTerm = false;
private Boolean conditionOccurrencePrimaryInpatientMediumTerm = false;
private Boolean conditionOccurrencePrimaryInpatientShortTerm = false;
private Boolean conditionEraAnyTimePrior = false;
private Boolean conditionEraLongTerm = false;
private Boolean conditionEraMediumTerm = false;
private Boolean conditionEraShortTerm = false;
private Boolean conditionEraOverlapping = false;
private Boolean conditionEraStartLongTerm = false;
private Boolean conditionEraStartMediumTerm = false;
private Boolean conditionEraStartShortTerm = false;
private Boolean conditionGroupEraAnyTimePrior = false;
private Boolean conditionGroupEraLongTerm = false;
private Boolean conditionGroupEraMediumTerm = false;
private Boolean conditionGroupEraShortTerm = false;
private Boolean conditionGroupEraOverlapping = false;
private Boolean conditionGroupEraStartLongTerm = false;
private Boolean conditionGroupEraStartMediumTerm = false;
private Boolean conditionGroupEraStartShortTerm = false;
private Boolean drugExposureAnyTimePrior = false;
private Boolean drugExposureLongTerm = false;
private Boolean drugExposureMediumTerm = false;
private Boolean drugExposureShortTerm = false;
private Boolean drugEraAnyTimePrior = false;
private Boolean drugEraLongTerm = false;
private Boolean drugEraMediumTerm = false;
private Boolean drugEraShortTerm = false;
private Boolean drugEraOverlapping = false;
private Boolean drugEraStartLongTerm = false;
private Boolean drugEraStartMediumTerm = false;
private Boolean drugEraStartShortTerm = false;
private Boolean drugGroupEraAnyTimePrior = false;
private Boolean drugGroupEraLongTerm = false;
private Boolean drugGroupEraMediumTerm = false;
private Boolean drugGroupEraShortTerm = false;
private Boolean drugGroupEraOverlapping = false;
private Boolean drugGroupEraStartLongTerm = false;
private Boolean drugGroupEraStartMediumTerm = false;
private Boolean drugGroupEraStartShortTerm = false;
private Boolean procedureOccurrenceAnyTimePrior = false;
private Boolean procedureOccurrenceLongTerm = false;
private Boolean procedureOccurrenceMediumTerm = false;
private Boolean procedureOccurrenceShortTerm = false;
private Boolean deviceExposureAnyTimePrior = false;
private Boolean deviceExposureLongTerm = false;
private Boolean deviceExposureMediumTerm = false;
private Boolean deviceExposureShortTerm = false;
private Boolean measurementAnyTimePrior = false;
private Boolean measurementLongTerm = false;
private Boolean measurementMediumTerm = false;
private Boolean measurementShortTerm = false;
private Boolean measurementValueAnyTimePrior = false;
private Boolean measurementValueLongTerm = false;
private Boolean measurementValueMediumTerm = false;
private Boolean measurementValueShortTerm = false;
private Boolean measurementRangeGroupAnyTimePrior = false;
private Boolean measurementRangeGroupLongTerm = false;
private Boolean measurementRangeGroupMediumTerm = false;
private Boolean measurementRangeGroupShortTerm = false;
private Boolean observationAnyTimePrior = false;
private Boolean observationLongTerm = false;
private Boolean observationMediumTerm = false;
private Boolean observationShortTerm = false;
private Boolean charlsonIndex = false;
private Boolean dcsi = false;
private Boolean chads2 = false;
private Boolean chads2Vasc = false;
private Boolean distinctConditionCountLongTerm = false;
private Boolean distinctConditionCountMediumTerm = false;
private Boolean distinctConditionCountShortTerm = false;
private Boolean distinctIngredientCountLongTerm = false;
private Boolean distinctIngredientCountMediumTerm = false;
private Boolean distinctIngredientCountShortTerm = false;
private Boolean distinctProcedureCountLongTerm = false;
private Boolean distinctProcedureCountMediumTerm = false;
private Boolean distinctProcedureCountShortTerm = false;
private Boolean distinctMeasurementCountLongTerm = false;
private Boolean distinctMeasurementCountMediumTerm = false;
private Boolean distinctMeasurementCountShortTerm = false;
private Boolean distinctObservationCountLongTerm = false;
private Boolean distinctObservationCountMediumTerm = false;
private Boolean distinctObservationCountShortTerm = false;
private Boolean visitCountLongTerm = false;
private Boolean visitCountMediumTerm = false;
private Boolean visitCountShortTerm = false;
private Boolean visitConceptCountLongTerm = false;
private Boolean visitConceptCountMediumTerm = false;
private Boolean visitConceptCountShortTerm = false;
private Integer longTermStartDays = -365;
private Integer mediumTermStartDays = -180;
private Integer shortTermStartDays = -30;
private Integer endDays = 0;
private List<Long> includedCovariateConceptIds = null;
private Boolean addDescendantsToInclude = false;
private List<Long> excludedCovariateConceptIds = null;
private Boolean addDescendantsToExclude = false;
private List<Long> includedCovariateIds = null;
private String attrFun = "getDbDefaultCovariateData";
private String csAttrClass = "covariateSettings";
/**
* Construct temporal covariates
* @return temporal
**/
@Override
public Boolean getTemporal() {
return temporal;
}
/**
*
* @param temporal
*/
public void setTemporal(Boolean temporal) {
this.temporal = temporal;
}
/**
* Gender of the subject. (analysis ID 1)
* @return demographicsGender
**/
@Override
public Boolean getDemographicsGender() {
return demographicsGender;
}
/**
*
* @param demographicsGender
*/
public void setDemographicsGender(Boolean demographicsGender) {
this.demographicsGender = demographicsGender;
}
/**
* Age of the subject on the index date (in years). (analysis ID 2)
* @return demographicsAge
**/
@Override
public Boolean getDemographicsAge() {
return demographicsAge;
}
/**
*
* @param demographicsAge
*/
public void setDemographicsAge(Boolean demographicsAge) {
this.demographicsAge = demographicsAge;
}
/**
* Age of the subject on the index date (in 5 year age groups) (analysis ID 3)
* @return demographicsAgeGroup
**/
@Override
public Boolean getDemographicsAgeGroup() {
return demographicsAgeGroup;
}
/**
*
* @param demographicsAgeGroup
*/
public void setDemographicsAgeGroup(Boolean demographicsAgeGroup) {
this.demographicsAgeGroup = demographicsAgeGroup;
}
/**
* Race of the subject. (analysis ID 4)
* @return demographicsRace
**/
@Override
public Boolean getDemographicsRace() {
return demographicsRace;
}
/**
*
* @param demographicsRace
*/
public void setDemographicsRace(Boolean demographicsRace) {
this.demographicsRace = demographicsRace;
}
/**
* Ethnicity of the subject. (analysis ID 5)
* @return demographicsEthnicity
**/
@Override
public Boolean getDemographicsEthnicity() {
return demographicsEthnicity;
}
/**
*
* @param demographicsEthnicity
*/
public void setDemographicsEthnicity(Boolean demographicsEthnicity) {
this.demographicsEthnicity = demographicsEthnicity;
}
/**
* Year of the index date. (analysis ID 6)
* @return demographicsIndexYear
**/
@Override
public Boolean getDemographicsIndexYear() {
return demographicsIndexYear;
}
/**
*
* @param demographicsIndexYear
*/
public void setDemographicsIndexYear(Boolean demographicsIndexYear) {
this.demographicsIndexYear = demographicsIndexYear;
}
/**
* Month of the index date. (analysis ID 7)
* @return demographicsIndexMonth
**/
@Override
public Boolean getDemographicsIndexMonth() {
return demographicsIndexMonth;
}
/**
*
* @param demographicsIndexMonth
*/
public void setDemographicsIndexMonth(Boolean demographicsIndexMonth) {
this.demographicsIndexMonth = demographicsIndexMonth;
}
/**
* Number of continuous days of observation time preceding the index date. (analysis ID 8)
* @return demographicsPriorObservationTime
**/
@Override
public Boolean getDemographicsPriorObservationTime() {
return demographicsPriorObservationTime;
}
/**
*
* @param demographicsPriorObservationTime
*/
public void setDemographicsPriorObservationTime(Boolean demographicsPriorObservationTime) {
this.demographicsPriorObservationTime = demographicsPriorObservationTime;
}
/**
* Number of continuous days of observation time following the index date. (analysis ID 9)
* @return demographicsPostObservationTime
**/
@Override
public Boolean getDemographicsPostObservationTime() {
return demographicsPostObservationTime;
}
/**
*
* @param demographicsPostObservationTime
*/
public void setDemographicsPostObservationTime(Boolean demographicsPostObservationTime) {
this.demographicsPostObservationTime = demographicsPostObservationTime;
}
/**
* Number of days of observation time during cohort period. (analysis ID 10)
* @return demographicsTimeInCohort
**/
@Override
public Boolean getDemographicsTimeInCohort() {
return demographicsTimeInCohort;
}
/**
*
* @param demographicsTimeInCohort
*/
public void setDemographicsTimeInCohort(Boolean demographicsTimeInCohort) {
this.demographicsTimeInCohort = demographicsTimeInCohort;
}
/**
* Both calendar year and month of the index date in a single variable. (analysis ID 11)
* @return demographicsIndexYearMonth
**/
@Override
public Boolean getDemographicsIndexYearMonth() {
return demographicsIndexYearMonth;
}
/**
*
* @param demographicsIndexYearMonth
*/
public void setDemographicsIndexYearMonth(Boolean demographicsIndexYearMonth) {
this.demographicsIndexYearMonth = demographicsIndexYearMonth;
}
/**
* One covariate per condition in the condition_occurrence table starting any time prior to index. (analysis ID 101)
* @return conditionOccurrenceAnyTimePrior
**/
@Override
public Boolean getConditionOccurrenceAnyTimePrior() {
return conditionOccurrenceAnyTimePrior;
}
/**
*
* @param conditionOccurrenceAnyTimePrior
*/
public void setConditionOccurrenceAnyTimePrior(Boolean conditionOccurrenceAnyTimePrior) {
this.conditionOccurrenceAnyTimePrior = conditionOccurrenceAnyTimePrior;
}
/**
* One covariate per condition in the condition_occurrence table starting in the long term window. (analysis ID 102)
* @return conditionOccurrenceLongTerm
**/
@Override
public Boolean getConditionOccurrenceLongTerm() {
return conditionOccurrenceLongTerm;
}
/**
*
* @param conditionOccurrenceLongTerm
*/
public void setConditionOccurrenceLongTerm(Boolean conditionOccurrenceLongTerm) {
this.conditionOccurrenceLongTerm = conditionOccurrenceLongTerm;
}
/**
* One covariate per condition in the condition_occurrence table starting in the medium term window. (analysis ID 103)
* @return conditionOccurrenceMediumTerm
**/
@Override
public Boolean getConditionOccurrenceMediumTerm() {
return conditionOccurrenceMediumTerm;
}
/**
*
* @param conditionOccurrenceMediumTerm
*/
public void setConditionOccurrenceMediumTerm(Boolean conditionOccurrenceMediumTerm) {
this.conditionOccurrenceMediumTerm = conditionOccurrenceMediumTerm;
}
/**
* One covariate per condition in the condition_occurrence table starting in the short term window. (analysis ID 104)
* @return conditionOccurrenceShortTerm
**/
@Override
public Boolean getConditionOccurrenceShortTerm() {
return conditionOccurrenceShortTerm;
}
/**
*
* @param conditionOccurrenceShortTerm
*/
public void setConditionOccurrenceShortTerm(Boolean conditionOccurrenceShortTerm) {
this.conditionOccurrenceShortTerm = conditionOccurrenceShortTerm;
}
/**
* One covariate per condition observed in an inpatient setting in the condition_occurrence table starting any time prior to index. (analysis ID 105)
* @return conditionOccurrencePrimaryInpatientAnyTimePrior
**/
@Override
public Boolean getConditionOccurrencePrimaryInpatientAnyTimePrior() {
return conditionOccurrencePrimaryInpatientAnyTimePrior;
}
/**
*
* @param conditionOccurrencePrimaryInpatientAnyTimePrior
*/
public void setConditionOccurrencePrimaryInpatientAnyTimePrior(Boolean conditionOccurrencePrimaryInpatientAnyTimePrior) {
this.conditionOccurrencePrimaryInpatientAnyTimePrior = conditionOccurrencePrimaryInpatientAnyTimePrior;
}
/**
* One covariate per condition observed in an inpatient setting in the condition_occurrence table starting in the long term window. (analysis ID 106)
* @return conditionOccurrencePrimaryInpatientLongTerm
**/
@Override
public Boolean getConditionOccurrencePrimaryInpatientLongTerm() {
return conditionOccurrencePrimaryInpatientLongTerm;
}
/**
*
* @param conditionOccurrencePrimaryInpatientLongTerm
*/
public void setConditionOccurrencePrimaryInpatientLongTerm(Boolean conditionOccurrencePrimaryInpatientLongTerm) {
this.conditionOccurrencePrimaryInpatientLongTerm = conditionOccurrencePrimaryInpatientLongTerm;
}
/**
* One covariate per condition observed in an inpatient setting in the condition_occurrence table starting in the medium term window. (analysis ID 107)
* @return conditionOccurrencePrimaryInpatientMediumTerm
**/
@Override
public Boolean getConditionOccurrencePrimaryInpatientMediumTerm() {
return conditionOccurrencePrimaryInpatientMediumTerm;
}
/**
*
* @param conditionOccurrencePrimaryInpatientMediumTerm
*/
public void setConditionOccurrencePrimaryInpatientMediumTerm(Boolean conditionOccurrencePrimaryInpatientMediumTerm) {
this.conditionOccurrencePrimaryInpatientMediumTerm = conditionOccurrencePrimaryInpatientMediumTerm;
}
/**
* One covariate per condition observed in an inpatient setting in the condition_occurrence table starting in the short term window. (analysis ID 108)
* @return conditionOccurrencePrimaryInpatientShortTerm
**/
@Override
public Boolean getConditionOccurrencePrimaryInpatientShortTerm() {
return conditionOccurrencePrimaryInpatientShortTerm;
}
/**
*
* @param conditionOccurrencePrimaryInpatientShortTerm
*/
public void setConditionOccurrencePrimaryInpatientShortTerm(Boolean conditionOccurrencePrimaryInpatientShortTerm) {
this.conditionOccurrencePrimaryInpatientShortTerm = conditionOccurrencePrimaryInpatientShortTerm;
}
/**
* One covariate per condition in the condition_era table overlapping with any time prior to index. (analysis ID 201)
* @return conditionEraAnyTimePrior
**/
@Override
public Boolean getConditionEraAnyTimePrior() {
return conditionEraAnyTimePrior;
}
/**
*
* @param conditionEraAnyTimePrior
*/
public void setConditionEraAnyTimePrior(Boolean conditionEraAnyTimePrior) {
this.conditionEraAnyTimePrior = conditionEraAnyTimePrior;
}
/**
* One covariate per condition in the condition_era table overlapping with any part of the long term window. (analysis ID 202)
* @return conditionEraLongTerm
**/
@Override
public Boolean getConditionEraLongTerm() {
return conditionEraLongTerm;
}
/**
*
* @param conditionEraLongTerm
*/
public void setConditionEraLongTerm(Boolean conditionEraLongTerm) {
this.conditionEraLongTerm = conditionEraLongTerm;
}
/**
* One covariate per condition in the condition_era table overlapping with any part of the medium term window. (analysis ID 203)
* @return conditionEraMediumTerm
**/
@Override
public Boolean getConditionEraMediumTerm() {
return conditionEraMediumTerm;
}
/**
*
* @param conditionEraMediumTerm
*/
public void setConditionEraMediumTerm(Boolean conditionEraMediumTerm) {
this.conditionEraMediumTerm = conditionEraMediumTerm;
}
/**
* One covariate per condition in the condition_era table overlapping with any part of the short term window. (analysis ID 204)
* @return conditionEraShortTerm
**/
@Override
public Boolean getConditionEraShortTerm() {
return conditionEraShortTerm;
}
/**
*
* @param conditionEraShortTerm
*/
public void setConditionEraShortTerm(Boolean conditionEraShortTerm) {
this.conditionEraShortTerm = conditionEraShortTerm;
}
/**
* One covariate per condition in the condition_era table overlapping with the end of the risk window. (analysis ID 205)
* @return conditionEraOverlapping
**/
public Boolean getConditionEraOverlapping() {
return conditionEraOverlapping;
}
/**
*
* @param conditionEraOverlapping
*/
public void setConditionEraOverlapping(Boolean conditionEraOverlapping) {
this.conditionEraOverlapping = conditionEraOverlapping;
}
/**
* One covariate per condition in the condition_era table starting in the long term window. (analysis ID 206)
* @return conditionEraStartLongTerm
**/
@Override
public Boolean getConditionEraStartLongTerm() {
return conditionEraStartLongTerm;
}
/**
*
* @param conditionEraStartLongTerm
*/
public void setConditionEraStartLongTerm(Boolean conditionEraStartLongTerm) {
this.conditionEraStartLongTerm = conditionEraStartLongTerm;
}
/**
* One covariate per condition in the condition_era table starting in the medium term window. (analysis ID 207)
* @return conditionEraStartMediumTerm
**/
@Override
public Boolean getConditionEraStartMediumTerm() {
return conditionEraStartMediumTerm;
}
/**
*
* @param conditionEraStartMediumTerm
*/
public void setConditionEraStartMediumTerm(Boolean conditionEraStartMediumTerm) {
this.conditionEraStartMediumTerm = conditionEraStartMediumTerm;
}
/**
* One covariate per condition in the condition_era table starting in the short term window. (analysis ID 208)
* @return conditionEraStartShortTerm
**/
@Override
public Boolean getConditionEraStartShortTerm() {
return conditionEraStartShortTerm;
}
/**
*
* @param conditionEraStartShortTerm
*/
public void setConditionEraStartShortTerm(Boolean conditionEraStartShortTerm) {
this.conditionEraStartShortTerm = conditionEraStartShortTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table overlapping with any time prior to index. (analysis ID 209)
* @return conditionGroupEraAnyTimePrior
**/
@Override
public Boolean getConditionGroupEraAnyTimePrior() {
return conditionGroupEraAnyTimePrior;
}
/**
*
* @param conditionGroupEraAnyTimePrior
*/
public void setConditionGroupEraAnyTimePrior(Boolean conditionGroupEraAnyTimePrior) {
this.conditionGroupEraAnyTimePrior = conditionGroupEraAnyTimePrior;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table overlapping with any part of the long term window. (analysis ID 210)
* @return conditionGroupEraLongTerm
**/
@Override
public Boolean getConditionGroupEraLongTerm() {
return conditionGroupEraLongTerm;
}
/**
*
* @param conditionGroupEraLongTerm
*/
public void setConditionGroupEraLongTerm(Boolean conditionGroupEraLongTerm) {
this.conditionGroupEraLongTerm = conditionGroupEraLongTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table overlapping with any part of the medium term window. (analysis ID 211)
* @return conditionGroupEraMediumTerm
**/
@Override
public Boolean getConditionGroupEraMediumTerm() {
return conditionGroupEraMediumTerm;
}
/**
*
* @param conditionGroupEraMediumTerm
*/
public void setConditionGroupEraMediumTerm(Boolean conditionGroupEraMediumTerm) {
this.conditionGroupEraMediumTerm = conditionGroupEraMediumTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table overlapping with any part of the short term window. (analysis ID 212)
* @return conditionGroupEraShortTerm
**/
@Override
public Boolean getConditionGroupEraShortTerm() {
return conditionGroupEraShortTerm;
}
/**
*
* @param conditionGroupEraShortTerm
*/
public void setConditionGroupEraShortTerm(Boolean conditionGroupEraShortTerm) {
this.conditionGroupEraShortTerm = conditionGroupEraShortTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table overlapping with the end of the risk window. (analysis ID 213)
* @return conditionGroupEraOverlapping
**/
@Override
public Boolean getConditionGroupEraOverlapping() {
return conditionGroupEraOverlapping;
}
/**
*
* @param conditionGroupEraOverlapping
*/
public void setConditionGroupEraOverlapping(Boolean conditionGroupEraOverlapping) {
this.conditionGroupEraOverlapping = conditionGroupEraOverlapping;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table starting in the long term window. (analysis ID 214)
* @return conditionGroupEraStartLongTerm
**/
@Override
public Boolean getConditionGroupEraStartLongTerm() {
return conditionGroupEraStartLongTerm;
}
/**
*
* @param conditionGroupEraStartLongTerm
*/
public void setConditionGroupEraStartLongTerm(Boolean conditionGroupEraStartLongTerm) {
this.conditionGroupEraStartLongTerm = conditionGroupEraStartLongTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table starting in the medium term window. (analysis ID 215)
* @return conditionGroupEraStartMediumTerm
**/
@Override
public Boolean getConditionGroupEraStartMediumTerm() {
return conditionGroupEraStartMediumTerm;
}
/**
*
* @param conditionGroupEraStartMediumTerm
*/
public void setConditionGroupEraStartMediumTerm(Boolean conditionGroupEraStartMediumTerm) {
this.conditionGroupEraStartMediumTerm = conditionGroupEraStartMediumTerm;
}
/**
* One covariate per condition era rolled up to groups in the condition_era table starting in the short term window. (analysis ID 216)
* @return conditionGroupEraStartShortTerm
**/
@Override
public Boolean getConditionGroupEraStartShortTerm() {
return conditionGroupEraStartShortTerm;
}
/**
*
* @param conditionGroupEraStartShortTerm
*/
public void setConditionGroupEraStartShortTerm(Boolean conditionGroupEraStartShortTerm) {
this.conditionGroupEraStartShortTerm = conditionGroupEraStartShortTerm;
}
/**
* One covariate per drug in the drug_exposure table starting any time prior to index. (analysis ID 301)
* @return drugExposureAnyTimePrior
**/
@Override
public Boolean getDrugExposureAnyTimePrior() {
return drugExposureAnyTimePrior;
}
/**
*
* @param drugExposureAnyTimePrior
*/
public void setDrugExposureAnyTimePrior(Boolean drugExposureAnyTimePrior) {
this.drugExposureAnyTimePrior = drugExposureAnyTimePrior;
}
/**
* One covariate per drug in the drug_exposure table starting in the long term window. (analysis ID 302)
* @return drugExposureLongTerm
**/
@Override
public Boolean getDrugExposureLongTerm() {
return drugExposureLongTerm;
}
/**
*
* @param drugExposureLongTerm
*/
public void setDrugExposureLongTerm(Boolean drugExposureLongTerm) {
this.drugExposureLongTerm = drugExposureLongTerm;
}
/**
* One covariate per drug in the drug_exposure table starting in the medium term window. (analysis ID 303)
* @return drugExposureMediumTerm
**/
@Override
public Boolean getDrugExposureMediumTerm() {
return drugExposureMediumTerm;
}
/**
*
* @param drugExposureMediumTerm
*/
public void setDrugExposureMediumTerm(Boolean drugExposureMediumTerm) {
this.drugExposureMediumTerm = drugExposureMediumTerm;
}
/**
* One covariate per drug in the drug_exposure table starting in the short term window. (analysis ID 304)
* @return drugExposureShortTerm
**/
@Override
public Boolean getDrugExposureShortTerm() {
return drugExposureShortTerm;
}
/**
*
* @param drugExposureShortTerm
*/
public void setDrugExposureShortTerm(Boolean drugExposureShortTerm) {
this.drugExposureShortTerm = drugExposureShortTerm;
}
/**
* One covariate per drug in the drug_era table overlapping with any time prior to index. (analysis ID 401)
* @return drugEraAnyTimePrior
**/
@Override
public Boolean getDrugEraAnyTimePrior() {
return drugEraAnyTimePrior;
}
/**
*
* @param drugEraAnyTimePrior
*/
public void setDrugEraAnyTimePrior(Boolean drugEraAnyTimePrior) {
this.drugEraAnyTimePrior = drugEraAnyTimePrior;
}
/**
* One covariate per drug in the drug_era table overlapping with any part of the long term window. (analysis ID 402)
* @return drugEraLongTerm
**/
@Override
public Boolean getDrugEraLongTerm() {
return drugEraLongTerm;
}
/**
*
* @param drugEraLongTerm
*/
public void setDrugEraLongTerm(Boolean drugEraLongTerm) {
this.drugEraLongTerm = drugEraLongTerm;
}
/**
* One covariate per drug in the drug_era table overlapping with any part of the medium term window. (analysis ID 403)
* @return drugEraMediumTerm
**/
@Override
public Boolean getDrugEraMediumTerm() {
return drugEraMediumTerm;
}
/**
*
* @param drugEraMediumTerm
*/
public void setDrugEraMediumTerm(Boolean drugEraMediumTerm) {
this.drugEraMediumTerm = drugEraMediumTerm;
}
/**
* One covariate per drug in the drug_era table overlapping with any part of the short window. (analysis ID 404)
* @return drugEraShortTerm
**/
@Override
public Boolean getDrugEraShortTerm() {
return drugEraShortTerm;
}
/**
*
* @param drugEraShortTerm
*/
public void setDrugEraShortTerm(Boolean drugEraShortTerm) {
this.drugEraShortTerm = drugEraShortTerm;
}
/**
* One covariate per drug in the drug_era table overlapping with the end of the risk window. (analysis ID 405)
* @return drugEraOverlapping
**/
@Override
public Boolean getDrugEraOverlapping() {
return drugEraOverlapping;
}
/**
*
* @param drugEraOverlapping
*/
public void setDrugEraOverlapping(Boolean drugEraOverlapping) {
this.drugEraOverlapping = drugEraOverlapping;
}
/**
* One covariate per drug in the drug_era table starting in the long term window. (analysis ID 406)
* @return drugEraStartLongTerm
**/
@Override
public Boolean getDrugEraStartLongTerm() {
return drugEraStartLongTerm;
}
/**
*
* @param drugEraStartLongTerm
*/
public void setDrugEraStartLongTerm(Boolean drugEraStartLongTerm) {
this.drugEraStartLongTerm = drugEraStartLongTerm;
}
/**
* One covariate per drug in the drug_era table starting in the medium term window. (analysis ID 407)
* @return drugEraStartMediumTerm
**/
@Override
public Boolean getDrugEraStartMediumTerm() {
return drugEraStartMediumTerm;
}
/**
*
* @param drugEraStartMediumTerm
*/
public void setDrugEraStartMediumTerm(Boolean drugEraStartMediumTerm) {
this.drugEraStartMediumTerm = drugEraStartMediumTerm;
}
/**
* One covariate per drug in the drug_era table starting in the long short window. (analysis ID 408)
* @return drugEraStartShortTerm
**/
@Override
public Boolean getDrugEraStartShortTerm() {
return drugEraStartShortTerm;
}
/**
*
* @param drugEraStartShortTerm
*/
public void setDrugEraStartShortTerm(Boolean drugEraStartShortTerm) {
this.drugEraStartShortTerm = drugEraStartShortTerm;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table overlapping with any time prior to index. (analysis ID 409)
* @return drugGroupEraAnyTimePrior
**/
@Override
public Boolean getDrugGroupEraAnyTimePrior() {
return drugGroupEraAnyTimePrior;
}
/**
*
* @param drugGroupEraAnyTimePrior
*/
public void setDrugGroupEraAnyTimePrior(Boolean drugGroupEraAnyTimePrior) {
this.drugGroupEraAnyTimePrior = drugGroupEraAnyTimePrior;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table overlapping with any part of the long term window. (analysis ID 410)
* @return drugGroupEraLongTerm
**/
@Override
public Boolean getDrugGroupEraLongTerm() {
return drugGroupEraLongTerm;
}
/**
*
* @param drugGroupEraLongTerm
*/
public void setDrugGroupEraLongTerm(Boolean drugGroupEraLongTerm) {
this.drugGroupEraLongTerm = drugGroupEraLongTerm;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table overlapping with any part of the medium term window. (analysis ID 411)
* @return drugGroupEraMediumTerm
**/
@Override
public Boolean getDrugGroupEraMediumTerm() {
return drugGroupEraMediumTerm;
}
/**
*
* @param drugGroupEraMediumTerm
*/
public void setDrugGroupEraMediumTerm(Boolean drugGroupEraMediumTerm) {
this.drugGroupEraMediumTerm = drugGroupEraMediumTerm;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table overlapping with any part of the short term window. (analysis ID 412)
* @return drugGroupEraShortTerm
**/
@Override
public Boolean getDrugGroupEraShortTerm() {
return drugGroupEraShortTerm;
}
/**
*
* @param drugGroupEraShortTerm
*/
public void setDrugGroupEraShortTerm(Boolean drugGroupEraShortTerm) {
this.drugGroupEraShortTerm = drugGroupEraShortTerm;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table overlapping with the end of the risk window. (analysis ID 413)
* @return drugGroupEraOverlapping
**/
@Override
public Boolean getDrugGroupEraOverlapping() {
return drugGroupEraOverlapping;
}
/**
*
* @param drugGroupEraOverlapping
*/
public void setDrugGroupEraOverlapping(Boolean drugGroupEraOverlapping) {
this.drugGroupEraOverlapping = drugGroupEraOverlapping;
}
/**
* One covariate per drug rolled up to ATC groups in the drug_era table starting in the long term window. (analysis ID 414)
* @return drugGroupEraStartLongTerm
**/
@Override
public Boolean getDrugGroupEraStartLongTerm() {
return drugGroupEraStartLongTerm;
}
/**
*
* @param drugGroupEraStartLongTerm
*/
public void setDrugGroupEraStartLongTerm(Boolean drugGroupEraStartLongTerm) {
this.drugGroupEraStartLongTerm = drugGroupEraStartLongTerm;
}
/**
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | true |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/dto/VersionDTO.java | src/main/java/org/ohdsi/webapi/versioning/dto/VersionDTO.java | package org.ohdsi.webapi.versioning.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.ohdsi.webapi.user.dto.UserDTO;
import java.util.Date;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VersionDTO {
@JsonProperty
private Long assetId;
@JsonProperty
private String comment;
@JsonProperty
private int version;
@JsonProperty
private boolean archived;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private UserDTO createdBy;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Date createdDate;
public Long getAssetId() {
return assetId;
}
public void setAssetId(Long assetId) {
this.assetId = assetId;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public UserDTO getCreatedBy() {
return createdBy;
}
public void setCreatedBy(UserDTO createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public boolean isArchived() {
return archived;
}
public void setArchived(boolean archived) {
this.archived = archived;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/dto/VersionUpdateDTO.java | src/main/java/org/ohdsi/webapi/versioning/dto/VersionUpdateDTO.java | package org.ohdsi.webapi.versioning.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.ohdsi.webapi.versioning.domain.VersionPK;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VersionUpdateDTO {
@JsonProperty
private Long assetId;
@JsonProperty
private int version;
@JsonProperty
private String comment;
@JsonProperty
private boolean archived;
public Long getAssetId() {
return assetId;
}
public void setAssetId(long assetId) {
this.assetId = assetId;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public boolean isArchived() {
return archived;
}
public void setArchived(boolean archived) {
this.archived = archived;
}
public VersionPK getVersionPk() {
return new VersionPK(assetId, version);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/dto/VersionFullDTO.java | src/main/java/org/ohdsi/webapi/versioning/dto/VersionFullDTO.java | package org.ohdsi.webapi.versioning.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VersionFullDTO<T> {
private T entityDTO;
private VersionDTO versionDTO;
public T getEntityDTO() {
return entityDTO;
}
public void setEntityDTO(T entityDTO) {
this.entityDTO = entityDTO;
}
public VersionDTO getVersionDTO() {
return versionDTO;
}
public void setVersionDTO(VersionDTO versionDTO) {
this.versionDTO = versionDTO;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/service/VersionService.java | src/main/java/org/ohdsi/webapi/versioning/service/VersionService.java | package org.ohdsi.webapi.versioning.service;
import org.ohdsi.webapi.exception.AtlasException;
import org.ohdsi.webapi.service.AbstractDaoService;
import org.ohdsi.webapi.versioning.domain.Version;
import org.ohdsi.webapi.versioning.domain.VersionBase;
import org.ohdsi.webapi.versioning.domain.VersionPK;
import org.ohdsi.webapi.versioning.domain.VersionType;
import org.ohdsi.webapi.versioning.dto.VersionUpdateDTO;
import org.ohdsi.webapi.versioning.repository.CharacterizationVersionRepository;
import org.ohdsi.webapi.versioning.repository.CohortVersionRepository;
import org.ohdsi.webapi.versioning.repository.ConceptSetVersionRepository;
import org.ohdsi.webapi.versioning.repository.IrVersionRepository;
import org.ohdsi.webapi.versioning.repository.PathwayVersionRepository;
import org.ohdsi.webapi.versioning.repository.ReusableVersionRepository;
import org.ohdsi.webapi.versioning.repository.VersionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.ws.rs.NotFoundException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
@Transactional
public class VersionService<T extends Version> extends AbstractDaoService {
@Value("${versioning.maxAttempt}")
private int maxAttempt;
private static final Logger logger = LoggerFactory.getLogger(VersionService.class);
private final EntityManager entityManager;
private final Map<VersionType, VersionRepository<T>> repositoryMap;
@Autowired
private VersionService<T> versionService;
@Autowired
public VersionService(
EntityManager entityManager,
CohortVersionRepository cohortRepository,
ConceptSetVersionRepository conceptSetVersionRepository,
CharacterizationVersionRepository characterizationVersionRepository,
IrVersionRepository irRepository,
PathwayVersionRepository pathwayRepository,
ReusableVersionRepository reusableRepository) {
this.entityManager = entityManager;
this.repositoryMap = new HashMap<>();
this.repositoryMap.put(VersionType.COHORT, (VersionRepository<T>) cohortRepository);
this.repositoryMap.put(VersionType.CONCEPT_SET, (VersionRepository<T>) conceptSetVersionRepository);
this.repositoryMap.put(VersionType.CHARACTERIZATION, (VersionRepository<T>) characterizationVersionRepository);
this.repositoryMap.put(VersionType.INCIDENCE_RATE, (VersionRepository<T>) irRepository);
this.repositoryMap.put(VersionType.PATHWAY, (VersionRepository<T>) pathwayRepository);
this.repositoryMap.put(VersionType.REUSABLE, (VersionRepository<T>) reusableRepository);
}
private VersionRepository<T> getRepository(VersionType type) {
return repositoryMap.get(type);
}
public List<VersionBase> getVersions(VersionType type, long assetId) {
return getRepository(type).findAllVersions(assetId);
}
public T create(VersionType type, T assetVersion) {
int attemptsCounter = 0;
boolean saved = false;
// Trying to save current version. Current version is selected from database
// If current version number is already used - get latest version from database again and try to save.
while (!saved && attemptsCounter < maxAttempt) {
attemptsCounter++;
Integer latestVersion = getRepository(type).getLatestVersion(assetVersion.getAssetId());
if (Objects.nonNull(latestVersion)) {
assetVersion.setVersion(latestVersion + 1);
} else {
assetVersion.setVersion(1);
}
try {
assetVersion = versionService.save(type, assetVersion);
saved = true;
} catch (PersistenceException e) {
logger.warn("Error during saving version", e);
}
}
if (!saved) {
log.error("Error during saving version");
throw new AtlasException("Error during saving version");
}
return assetVersion;
}
public T update(VersionType type, VersionUpdateDTO updateDTO) {
T currentVersion = getRepository(type).findOne(updateDTO.getVersionPk());
if (Objects.isNull(currentVersion)) {
throw new NotFoundException("Version not found");
}
currentVersion.setComment(updateDTO.getComment());
currentVersion.setArchived(updateDTO.isArchived());
return save(type, currentVersion);
}
public void delete(VersionType type, long assetId, int version) {
VersionPK pk = new VersionPK(assetId, version);
T currentVersion = getRepository(type).getOne(pk);
if (Objects.isNull(currentVersion)) {
throw new NotFoundException("Version not found");
}
currentVersion.setArchived(true);
}
public T getById(VersionType type, long assetId, int version) {
VersionPK pk = new VersionPK(assetId, version);
return getRepository(type).findOne(pk);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public T save(VersionType type, T version) {
version = getRepository(type).saveAndFlush(version);
entityManager.refresh(version);
return getRepository(type).getOne(version.getPk());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/VersionType.java | src/main/java/org/ohdsi/webapi/versioning/domain/VersionType.java | package org.ohdsi.webapi.versioning.domain;
public enum VersionType {
CONCEPT_SET, COHORT, CHARACTERIZATION, INCIDENCE_RATE, PATHWAY, REUSABLE
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/ConceptSetVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/ConceptSetVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "concept_set_version")
public class ConceptSetVersion extends Version {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/Version.java | src/main/java/org/ohdsi/webapi/versioning/domain/Version.java | package org.ohdsi.webapi.versioning.domain;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import java.util.Date;
import java.util.Objects;
@MappedSuperclass
public abstract class Version {
@EmbeddedId
private VersionPK pk;
@Column(name = "comment")
private String comment;
@Column(name = "archived")
private boolean archived;
@Column(name = "asset_json")
private String assetJson;
@Column(name = "created_date", updatable = false)
private Date createdDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "created_by_id", updatable = false)
private UserEntity createdBy;
public VersionPK getPk() {
return pk;
}
public void setPk(VersionPK pk) {
this.pk = pk;
}
public String getComment() {
return comment;
}
public void setComment(String description) {
this.comment = description;
}
public boolean isArchived() {
return archived;
}
public void setArchived(boolean archived) {
this.archived = archived;
}
public String getAssetJson() {
return assetJson;
}
public void setAssetJson(String assetJson) {
this.assetJson = assetJson;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public UserEntity getCreatedBy() {
return createdBy;
}
public void setCreatedBy(UserEntity createdBy) {
this.createdBy = createdBy;
}
private VersionPK doGetPK() {
if (Objects.isNull(getPk())) {
setPk(new VersionPK());
}
return getPk();
}
public Long getAssetId() {
return doGetPK().getAssetId();
}
public void setAssetId(long assetId) {
doGetPK().setAssetId(assetId);
}
public int getVersion() {
return doGetPK().getVersion();
}
public void setVersion(int version) {
this.doGetPK().setVersion(version);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/PathwayVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/PathwayVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "pathway_version")
public class PathwayVersion extends Version {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/CohortVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/CohortVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity(name = "CohortVersion")
@Table(name = "cohort_version")
public class CohortVersion extends Version {
@Column(name = "description")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/VersionPK.java | src/main/java/org/ohdsi/webapi/versioning/domain/VersionPK.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;
@Embeddable
public class VersionPK implements Serializable {
@Column(name = "asset_id")
private long assetId;
@Column(name = "version")
private int version;
public VersionPK() {
}
public VersionPK(long assetId, int version) {
this.assetId = assetId;
this.version = version;
}
public Long getAssetId() {
return assetId;
}
public void setAssetId(long assetId) {
this.assetId = assetId;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VersionPK that = (VersionPK) o;
return assetId == that.assetId && version == that.version;
}
@Override
public int hashCode() {
return Objects.hash(assetId, version);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/CharacterizationVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/CharacterizationVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "cohort_characterization_version")
public class CharacterizationVersion extends Version {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/IRVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/IRVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "ir_version")
public class IRVersion extends Version {
@Column(name = "description")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/VersionBase.java | src/main/java/org/ohdsi/webapi/versioning/domain/VersionBase.java | package org.ohdsi.webapi.versioning.domain;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
import java.util.Date;
// Projection class
public class VersionBase {
private Long assetId;
private String comment;
private int version;
private UserEntity createdBy;
private Date createdDate;
private boolean archived;
public VersionBase(long assetId, String comment, int version, UserEntity createdBy, Date createdDate, boolean archived) {
this.assetId = assetId;
this.comment = comment;
this.version = version;
this.createdBy = createdBy;
this.createdDate = createdDate;
this.archived = archived;
}
public Long getAssetId() {
return assetId;
}
public String getComment() {
return comment;
}
public int getVersion() {
return version;
}
public UserEntity getCreatedBy() {
return createdBy;
}
public Date getCreatedDate() {
return createdDate;
}
public boolean isArchived() {
return archived;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/domain/ReusableVersion.java | src/main/java/org/ohdsi/webapi/versioning/domain/ReusableVersion.java | package org.ohdsi.webapi.versioning.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "reusable_version")
public class ReusableVersion extends Version {
@Column(name = "description")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/CohortVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/CohortVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.CohortVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface CohortVersionRepository extends VersionRepository<CohortVersion> {
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/IrVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/IrVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.IRVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface IrVersionRepository extends VersionRepository<IRVersion> {
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/CharacterizationVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/CharacterizationVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.CharacterizationVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface CharacterizationVersionRepository extends VersionRepository<CharacterizationVersion> {
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/ReusableVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/ReusableVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.ReusableVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface ReusableVersionRepository extends VersionRepository<ReusableVersion> {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/VersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/VersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.Version;
import org.ohdsi.webapi.versioning.domain.VersionBase;
import org.ohdsi.webapi.versioning.domain.VersionPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.NoRepositoryBean;
import java.util.List;
@NoRepositoryBean
public interface VersionRepository<T extends Version> extends JpaRepository<T, VersionPK> {
@Query("SELECT max(v.pk.version) from #{#entityName} v WHERE v.pk.assetId = ?1")
Integer getLatestVersion(long assetId);
@Query("SELECT new org.ohdsi.webapi.versioning.domain.VersionBase(v.pk.assetId, v.comment, " +
"v.pk.version, uc, v.createdDate, v.archived) " +
"FROM #{#entityName} v " +
"LEFT JOIN UserEntity uc " +
"ON uc = v.createdBy " +
"WHERE v.pk.assetId = ?1")
List<VersionBase> findAllVersions(long assetId);
@Query("SELECT v from #{#entityName} v WHERE v.pk.assetId = ?1")
List<T> findAll(int assetId);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/ConceptSetVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/ConceptSetVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.ConceptSetVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface ConceptSetVersionRepository extends VersionRepository<ConceptSetVersion> {
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/repository/PathwayVersionRepository.java | src/main/java/org/ohdsi/webapi/versioning/repository/PathwayVersionRepository.java | package org.ohdsi.webapi.versioning.repository;
import org.ohdsi.webapi.versioning.domain.PathwayVersion;
import org.springframework.stereotype.Repository;
@Repository
public interface PathwayVersionRepository extends VersionRepository<PathwayVersion> {
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/converter/VersionToVersionDTOConverter.java | src/main/java/org/ohdsi/webapi/versioning/converter/VersionToVersionDTOConverter.java | package org.ohdsi.webapi.versioning.converter;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.user.dto.UserDTO;
import org.ohdsi.webapi.versioning.domain.Version;
import org.ohdsi.webapi.versioning.dto.VersionDTO;
import org.springframework.stereotype.Component;
@Component
public class VersionToVersionDTOConverter extends BaseConversionServiceAwareConverter<Version, VersionDTO> {
@Override
public VersionDTO convert(Version source) {
VersionDTO target = new VersionDTO();
target.setComment(source.getComment());
target.setAssetId(source.getAssetId());
target.setVersion(source.getVersion());
target.setArchived(source.isArchived());
target.setCreatedBy(conversionService.convert(source.getCreatedBy(), UserDTO.class));
target.setCreatedDate(source.getCreatedDate());
return target;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/versioning/converter/VersionBaseToVersionDTOConverter.java | src/main/java/org/ohdsi/webapi/versioning/converter/VersionBaseToVersionDTOConverter.java | package org.ohdsi.webapi.versioning.converter;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.user.dto.UserDTO;
import org.ohdsi.webapi.versioning.domain.VersionBase;
import org.ohdsi.webapi.versioning.dto.VersionDTO;
import org.springframework.stereotype.Component;
@Component
public class VersionBaseToVersionDTOConverter extends BaseConversionServiceAwareConverter<VersionBase, VersionDTO> {
@Override
public VersionDTO convert(VersionBase source) {
VersionDTO target = new VersionDTO();
target.setComment(source.getComment());
target.setAssetId(source.getAssetId());
target.setVersion(source.getVersion());
target.setArchived(source.isArchived());
target.setCreatedBy(conversionService.convert(source.getCreatedBy(), UserDTO.class));
target.setCreatedDate(source.getCreatedDate());
return target;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/db/migartion/V2_7_2_20190515164044__hideSensitiveInfo.java | src/main/java/org/ohdsi/webapi/db/migartion/V2_7_2_20190515164044__hideSensitiveInfo.java | package org.ohdsi.webapi.db.migartion;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringMigration;
import org.apache.commons.collections.map.HashedMap;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.executionengine.entity.AnalysisResultFile;
import org.ohdsi.webapi.executionengine.entity.AnalysisResultFileContent;
import org.ohdsi.webapi.executionengine.entity.AnalysisResultFileContentList;
import org.ohdsi.webapi.executionengine.service.AnalysisResultFileContentSensitiveInfoService;
import org.ohdsi.webapi.service.AbstractDaoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import static org.ohdsi.webapi.Constants.Variables.SOURCE;
@Component
public class V2_7_2_20190515164044__hideSensitiveInfo implements ApplicationContextAwareSpringMigration {
private final Logger log = LoggerFactory.getLogger(V2_7_2_20190515164044__hideSensitiveInfo.class);
private final static String SQL_PATH = "/db/migration/java/V2_7_2_20190515164044__hideSensitiveInfo/";
@Autowired
private Environment env;
@Autowired
private MigrationDAO migrationDAO;
@Autowired
private AnalysisResultFileContentSensitiveInfoService sensitiveInfoService;
@Override
public void migrate() throws Exception {
String webAPISchema = this.env.getProperty("spring.jpa.properties.hibernate.default_schema");
try {
Map<Integer, Source> sourceMap = migrationDAO.getSourceData(webAPISchema);
List<ExecutionData> executions = migrationDAO.getExecutions(webAPISchema);
for (ExecutionData execution : executions) {
Source source = sourceMap.get(execution.executionId);
// Variables must contain field "sourceName". See sensitive_filters.csv
Map<String, Object> variables = Collections.singletonMap(SOURCE, source);
AnalysisResultFileContentList contentList = new AnalysisResultFileContentList();
for(OutputFile outputFile: execution.files) {
byte[] content = migrationDAO.getFileContent(webAPISchema, outputFile.id);
// Before changing implementaion of AnalysisResultFile or AnalysisResultFileContent check which fields are used in
// sensitive info filter (AnalysisResultFileContentSensitiveInfoServiceImpl)
AnalysisResultFile resultFile = new AnalysisResultFile();
resultFile.setFileName(outputFile.filename);
resultFile.setId(outputFile.id);
AnalysisResultFileContent resultFileContent = new AnalysisResultFileContent();
resultFileContent.setAnalysisResultFile(resultFile);
resultFileContent.setContents(content);
contentList.getFiles().add(resultFileContent);
}
// We have to filter all files for current execution because of possibility of archives split into volumes
// Volumes will be removed during decompressing and compressing
contentList = sensitiveInfoService.filterSensitiveInfo(contentList, variables);
// Update content of files only if all files were processed successfully
if(contentList.isSuccessfullyFiltered()) {
for (AnalysisResultFileContent resultFileContent : contentList.getFiles()) {
try {
migrationDAO.updateFileContent(webAPISchema, resultFileContent.getAnalysisResultFile().getId(), resultFileContent.getContents());
} catch (Exception e) {
log.error("Error updating file content for file with id: {}", resultFileContent.getAnalysisResultFile().getId(), e);
}
}
// Get list of ids of files (archive volumes) that are not used anymore
// and delete them from database
Set<Long> rowIds = contentList.getFiles().stream()
.map(file -> file.getAnalysisResultFile().getId())
.collect(Collectors.toSet());
execution.files.stream()
.filter(file -> !rowIds.contains(file.id))
.forEach(file -> {
try {
migrationDAO.deleteFileAndContent(webAPISchema, file.id);
} catch (Exception e) {
log.error("Error deleting file content for file with id: {}", file.id, e);
}
});
} else {
log.error("Error migrating file content. See errors above");
}
}
} catch (Exception e) {
log.error("Error migrating file content", e);
}
}
@Service
public static class MigrationDAO extends AbstractDaoService{
public List<ExecutionData> getExecutions(String webAPISchema) {
String[] params = new String[]{"webapi_schema"};
String[] values = new String[]{webAPISchema};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "getOutputFilesData.sql"), params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
Map<Integer, ExecutionData> executionMap = new HashMap<>();
return getJdbcTemplate().query(translatedSql, rs -> {
while (rs.next()) {
OutputFile outputFile = new OutputFile();
outputFile.filename = rs.getString("file_name");
outputFile.id = rs.getLong("id");
int executionId = rs.getInt("execution_id");
ExecutionData execution = executionMap.get(executionId);
if(execution == null) {
execution = new ExecutionData();
execution.executionId = executionId;
executionMap.put(executionId, execution);
}
execution.files.add(outputFile);
}
return new ArrayList<>(executionMap.values());
});
}
public Map<Integer, Source> getSourceData(String webAPISchema) {
String[] params = new String[]{"webapi_schema"};
String[] values = new String[]{webAPISchema};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "getSourceData.sql"), params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
return getJdbcTemplate().query(translatedSql, rs -> {
Map<Integer, Source> result = new HashedMap();
while (rs.next()) {
Source source = new Source();
source.sourceName = rs.getString("source_name");
int executionId = rs.getInt("execution_id");
result.put(executionId, source);
}
return result;
});
}
public byte[] getFileContent(String webAPISchema, long id) {
String[] params = new String[]{"webapi_schema", "id"};
String[] values = new String[]{webAPISchema, String.valueOf(id)};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "getOutputFileContent.sql"), params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
return getJdbcTemplate().query(translatedSql, rs -> {
while (rs.next()) {
return rs.getBytes("file_contents");
}
return null;
});
}
public void updateFileContent(String webAPISchema, long id, byte[] content) {
String[] params = new String[]{"webapi_schema"};
String[] values = new String[]{webAPISchema};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "updateFileContent.sql"), params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
Object[] psValues = new Object[] {content, id};
getJdbcTemplate().update(translatedSql, psValues);
}
public void deleteFileAndContent(String webAPISchema, Long id) {
String[] params = new String[]{"webapi_schema"};
String[] values = new String[]{webAPISchema};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "deleteFileContent.sql"), params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
Object[] psValues = new Object[] {id};
getJdbcTemplate().update(translatedSql, psValues);
generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "deleteFile.sql"), params, values);
translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, getDialect());
getJdbcTemplate().update(translatedSql, psValues);
}
}
private static class ExecutionData {
public int executionId;
public List<OutputFile> files = new ArrayList<>();
}
private static class OutputFile {
public long id;
public String filename;
}
private static class Source {
public String sourceName;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20191106092815__migrateEventFAType.java | src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20191106092815__migrateEventFAType.java | package org.ohdsi.webapi.db.migartion;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringMigration;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlSplit;
import org.ohdsi.webapi.service.AbstractDaoService;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceDaimon;
import org.ohdsi.webapi.source.SourceRepository;
import org.ohdsi.webapi.util.CancelableJdbcTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.List;
@Component
public class V2_8_0_20191106092815__migrateEventFAType implements ApplicationContextAwareSpringMigration {
private final static String UPDATE_VALUE_SQL = ResourceHelper.GetResourceAsString(
"/db/migration/java/V2_8_0_20191106092815__migrateEventFAType/updateFaType.sql");
private final static String UPDATE_VALUE_IMPALA_SQL = ResourceHelper.GetResourceAsString(
"/db/migration/java/V2_8_0_20191106092815__migrateEventFAType/updateFaTypeImpala.sql");
private static final Logger log = LoggerFactory.getLogger(V2_8_0_20191106092815__migrateEventFAType.class);
private final SourceRepository sourceRepository;
private final V2_8_0_20191106092815__migrateEventFAType.MigrationDAO migrationDAO;
@Autowired
public V2_8_0_20191106092815__migrateEventFAType(final SourceRepository sourceRepository,
final V2_8_0_20191106092815__migrateEventFAType.MigrationDAO migrationDAO) {
this.sourceRepository = sourceRepository;
this.migrationDAO = migrationDAO;
}
@Override
public void migrate() throws Exception {
List<Source> sources = sourceRepository.findAll();
sources.stream()
.filter(source -> source.getTableQualifierOrNull(SourceDaimon.DaimonType.Results) != null)
.forEach(source -> {
try {
CancelableJdbcTemplate jdbcTemplate = migrationDAO.getSourceJdbcTemplate(source);
this.migrationDAO.updateColumnValue(source, jdbcTemplate);
} catch (Exception e) {
log.error(String.format("Failed to update fa type value for source: %s (%s)", source.getSourceName(), source.getSourceKey()));
throw e;
}
});
}
@Service
public static class MigrationDAO extends AbstractDaoService {
public void updateColumnValue(Source source, CancelableJdbcTemplate jdbcTemplate) {
String resultsSchema = source.getTableQualifier(SourceDaimon.DaimonType.Results);
String[] params = new String[]{"results_schema"};
String[] values = new String[]{resultsSchema};
String translatedSql;
// Impala can't update non-kudu tables, so use special script with temp table
if (Source.IMPALA_DATASOURCE.equals(source.getSourceDialect())) {
translatedSql = SqlRender.renderSql(UPDATE_VALUE_IMPALA_SQL, params, values);
} else {
translatedSql = SqlRender.renderSql(UPDATE_VALUE_SQL, params, values);
}
for (String sql: SqlSplit.splitSql(translatedSql)) {
jdbcTemplate.execute(sql);
}
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20190410103000__migratePathwayResults.java | src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20190410103000__migratePathwayResults.java | package org.ohdsi.webapi.db.migartion;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringMigration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONObject;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlSplit;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.service.AbstractDaoService;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceDaimon;
import org.ohdsi.webapi.source.SourceRepository;
import org.ohdsi.webapi.util.CancelableJdbcTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import static org.ohdsi.webapi.Constants.Params.GENERATION_ID;
@Component
public class V2_8_0_20190410103000__migratePathwayResults implements ApplicationContextAwareSpringMigration {
private final static String SQL_PATH = "/db/migration/java/V2_8_0_20190410103000__migratePathwayResults/";
private static final Logger log = LoggerFactory.getLogger(V2_8_0_20190410103000__migratePathwayResults.class);
private final SourceRepository sourceRepository;
private final MigrationDAO migrationDAO;
private final Environment env;
@Service
public static class MigrationDAO extends AbstractDaoService {
public void savePathwayCodes(List<Object[]> pathwayCodes, Source source, CancelableJdbcTemplate jdbcTemplate) {
String resultsSchema = source.getTableQualifier(SourceDaimon.DaimonType.Results);
String[] params;
String[] values;
List<PreparedStatementCreator> creators = new ArrayList<>();
// clear existing results to prevent double-inserts
params = new String[]{"results_schema"};
values = new String[]{resultsSchema};
// delete only codes that belongs current Atlas instance
List<Object[]> executionIdAndCodes = pathwayCodes.stream().map(v -> new Object[]{ v[0], v[1] }).collect(Collectors.toList());
String deleteSql = SqlRender.renderSql("DELETE FROM @results_schema.pathway_analysis_codes WHERE pathway_analysis_generation_id = ? AND code = ?", params, values);
String translatedSql = SqlTranslate.translateSingleStatementSql(deleteSql, source.getSourceDialect());
jdbcTemplate.batchUpdate(translatedSql, executionIdAndCodes);
String saveCodesSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "saveCodes.sql"), params, values);
saveCodesSql = SqlTranslate.translateSingleStatementSql(saveCodesSql, source.getSourceDialect());
jdbcTemplate.batchUpdate(saveCodesSql, pathwayCodes);
}
}
private static class EventCohort {
public int cohortId;
public String name;
}
@Autowired
public V2_8_0_20190410103000__migratePathwayResults(final SourceRepository sourceRepository,
final MigrationDAO migrationDAO,
final Environment env) {
this.sourceRepository = sourceRepository;
this.migrationDAO = migrationDAO;
this.env = env;
}
@Override
public void migrate() throws JsonProcessingException {
String webAPISchema = this.env.getProperty("spring.jpa.properties.hibernate.default_schema");
sourceRepository.findAll().forEach(source -> {
try {
String[] params;
String[] values;
String translatedSql;
String resultsSchema = source.getTableQualifierOrNull(SourceDaimon.DaimonType.Results);
if (resultsSchema == null) {
return; // no results in this source
}
CancelableJdbcTemplate jdbcTemplate = migrationDAO.getSourceJdbcTemplate(source);
// step 1: ensure tables are created and have correct columns
params = new String[]{"results_schema"};
values = new String[]{source.getTableQualifier(SourceDaimon.DaimonType.Results)};
String ensureTablesSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "ensureTables.sql"), params, values);
translatedSql = SqlTranslate.translateSql(ensureTablesSql, source.getSourceDialect());
Arrays.asList(SqlSplit.splitSql(translatedSql)).forEach(jdbcTemplate::execute);
// step 2: populate pathway_analysis_paths
params = new String[]{"results_schema"};
values = new String[]{source.getTableQualifier(SourceDaimon.DaimonType.Results)};
String savePathwaysSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "migratePathwayResults.sql"), params, values);
translatedSql = SqlTranslate.translateSql(savePathwaysSql, source.getSourceDialect());
Arrays.asList(SqlSplit.splitSql(translatedSql)).forEach(jdbcTemplate::execute);
// step 3: populate pathway_analysis_codes from each generated design for the given source
// load the generated designs
params = new String[]{"webapi_schema", "source_id"};
values = new String[]{webAPISchema, Integer.toString(source.getSourceId())};
String generatedDesignSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "getPathwayGeneratedDesigns.sql"), params, values);
translatedSql = SqlTranslate.translateSingleStatementSql(generatedDesignSql, this.migrationDAO.getDialect());
Map<Long, List<EventCohort>> designEventCohorts = migrationDAO.getJdbcTemplate().query(translatedSql, rs -> {
Map<Long, List<EventCohort>> result = new HashMap<>();
while (rs.next()) {
String design = rs.getString("design");
JSONObject jsonObject = new JSONObject(design);
// parse design and fetch list of event cohorts
List<EventCohort> eventCohorts = jsonObject.getJSONArray("eventCohorts").toList()
.stream().map(obj -> {
Map ecJson = (Map) obj;
EventCohort c = new EventCohort();
c.name = String.valueOf(ecJson.get("name"));
return c;
})
.sorted(Comparator.comparing(d -> d.name))
.collect(Collectors.toList());
int index = 0;
for (EventCohort ec : eventCohorts) {
ec.cohortId = (int) Math.pow(2, index++); // assign each cohort an ID based on their name-sort order, as a power of 2
}
result.put(rs.getLong(GENERATION_ID), eventCohorts);
}
return result;
});
//fetch the distinct generation_id, combo_id from the source
params = new String[]{"results_schema"};
values = new String[]{resultsSchema};
String distinctGenerationComboIdsSql = SqlRender.renderSql(ResourceHelper.GetResourceAsString(SQL_PATH + "getPathwayGeneratedCodes.sql"), params, values);
translatedSql = SqlTranslate.translateSingleStatementSql(distinctGenerationComboIdsSql, source.getSourceDialect());
// retrieve list of generation-comboId-Name-isCombo values
List<Object[]> generatedComboNames = jdbcTemplate.query(translatedSql, (rs) -> {
// values of String[] are: "generation_id", "code", "name", "is_combo"
List<Object[]> result = new ArrayList<>();
while (rs.next()) {
Long generationId = rs.getLong("pathway_analysis_generation_id");
Long comboId = rs.getLong("combo_id");
if (!designEventCohorts.containsKey(generationId)) {
continue; // skip this record, since we do not have a design for it
}
List<EventCohort> eventCohorts = designEventCohorts.get(generationId);
List<EventCohort> comboCohorts = eventCohorts.stream().filter(ec -> (ec.cohortId & comboId) > 0).collect(Collectors.toList());
String names = comboCohorts.stream()
.map(c -> c.name)
.collect(Collectors.joining(","));
result.add(new Object[]{generationId, comboId, names, comboCohorts.size() > 1 ? 1 : 0});
}
return result;
});
this.migrationDAO.savePathwayCodes(generatedComboNames, source, jdbcTemplate);
}
catch(Exception e) {
log.error(String.format("Failed to migration pathways for source: %s (%s)", source.getSourceName(), source.getSourceKey()));
}
});
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20190520171430__cohortExpressionHashCode.java | src/main/java/org/ohdsi/webapi/db/migartion/V2_8_0_20190520171430__cohortExpressionHashCode.java | package org.ohdsi.webapi.db.migartion;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringMigration;
import org.ohdsi.analysis.Utils;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetails;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetailsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class V2_8_0_20190520171430__cohortExpressionHashCode implements ApplicationContextAwareSpringMigration {
private CohortDefinitionDetailsRepository detailsRepository;
@Autowired
public V2_8_0_20190520171430__cohortExpressionHashCode(CohortDefinitionDetailsRepository detailsRepository){
this.detailsRepository = detailsRepository;
}
@Override
public void migrate() throws Exception {
List<CohortDefinitionDetails> allDetails = detailsRepository.findAll();
for (CohortDefinitionDetails details: allDetails) {
//after deserialization the field "cdmVersionRange" is added and default value for it is set
CohortExpression expression = Utils.deserialize(details.getExpression(), CohortExpression.class);
details.setExpression(Utils.serialize(expression));
details.updateHashCode();
detailsRepository.save(details);
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/db/migartion/V2_6_0_20180807192421__cohortDetailsHashcodes.java | src/main/java/org/ohdsi/webapi/db/migartion/V2_6_0_20180807192421__cohortDetailsHashcodes.java | package org.ohdsi.webapi.db.migartion;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringMigration;
import java.util.List;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetails;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetailsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class V2_6_0_20180807192421__cohortDetailsHashcodes implements ApplicationContextAwareSpringMigration {
private CohortDefinitionDetailsRepository detailsRepository;
@Autowired
public V2_6_0_20180807192421__cohortDetailsHashcodes(final CohortDefinitionDetailsRepository detailsRepository) {
this.detailsRepository = detailsRepository;
}
@Override
public void migrate() throws JsonProcessingException {
final List<CohortDefinitionDetails> allDetails = detailsRepository.findAll();
for (CohortDefinitionDetails details: allDetails) {
details.updateHashCode();
detailsRepository.save(details);
}
}
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/configuration/JacksonConfiguration.java | src/main/java/org/ohdsi/webapi/configuration/JacksonConfiguration.java | package org.ohdsi.webapi.configuration;
import org.ohdsi.analysis.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.SpringHandlerInstantiator;
import javax.annotation.PostConstruct;
@Configuration
public class JacksonConfiguration {
@Autowired
private ApplicationContext applicationContext;
@PostConstruct
public void configureUtilsMapper() {
Utils.setObjectMapperHandlerInstantiator(new SpringHandlerInstantiator(this.applicationContext.getAutowireCapableBeanFactory()));
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/exception/SourceDuplicateKeyException.java | src/main/java/org/ohdsi/webapi/exception/SourceDuplicateKeyException.java | package org.ohdsi.webapi.exception;
public class SourceDuplicateKeyException extends UserException {
public SourceDuplicateKeyException(String message, Throwable cause) {
super(message, cause);
}
public SourceDuplicateKeyException(String message) {
super(message);
}
public SourceDuplicateKeyException(Throwable ex) {
super(ex);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/exception/ConceptNotExistException.java | src/main/java/org/ohdsi/webapi/exception/ConceptNotExistException.java | package org.ohdsi.webapi.exception;
public class ConceptNotExistException extends RuntimeException {
public ConceptNotExistException(String message) {
super(message);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/exception/ConversionAtlasException.java | src/main/java/org/ohdsi/webapi/exception/ConversionAtlasException.java | package org.ohdsi.webapi.exception;
import org.springframework.core.convert.ConversionFailedException;
public class ConversionAtlasException extends ConversionFailedException {
private String message;
public ConversionAtlasException(String message) {
super(null, null, null, null);
this.message = message;
}
@Override
public String getMessage() {
return this.message;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.