use of org.karnak.backend.enums.ProfileItemType in project karnak by OsiriX-Foundation.
the class Profile method getProfileItems.
public static List<ProfileItem> getProfileItems(ProfileEntity profileEntity) {
final Set<ProfileElementEntity> listProfileElementEntity = profileEntity.getProfileElementEntities();
List<ProfileItem> profileItems = new ArrayList<>();
for (ProfileElementEntity profileElementEntity : listProfileElementEntity) {
ProfileItemType t = ProfileItemType.getType(profileElementEntity.getCodename());
if (t == null) {
LOGGER.error("Cannot find the profile codename: {}", profileElementEntity.getCodename());
} else {
Object instanceProfileItem;
try {
instanceProfileItem = t.getProfileClass().getConstructor(ProfileElementEntity.class).newInstance(profileElementEntity);
profileItems.add((ProfileItem) instanceProfileItem);
} catch (Exception e) {
LOGGER.error("Cannot build the profile: {}", t.getProfileClass().getName(), e);
}
}
}
profileItems.sort(Comparator.comparing(ProfileItem::getPosition));
return profileItems;
}
use of org.karnak.backend.enums.ProfileItemType in project karnak by OsiriX-Foundation.
the class ProfilePipeService method validateProfile.
public ArrayList<ProfileError> validateProfile(ProfilePipeBody profilePipeYml) {
ProfileEntity newProfileEntity = createNewProfile(profilePipeYml, false);
ArrayList<ProfileError> profileErrors = new ArrayList<>();
for (ProfileElementEntity profileElementEntity : newProfileEntity.getProfileElementEntities()) {
ProfileError profileError = new ProfileError(profileElementEntity);
profileErrors.add(profileError);
ProfileItemType t = ProfileItemType.getType(profileElementEntity.getCodename());
if (t == null) {
profileError.setError("Cannot find the profile codename: " + profileElementEntity.getCodename());
} else {
try {
t.getProfileClass().getConstructor(ProfileElementEntity.class).newInstance(profileElementEntity);
} catch (Exception e) {
profileError.setError(e.getCause().getMessage());
continue;
}
}
}
return profileErrors;
}
Aggregations