com.adaptrex.core.persistence.PersistenceTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adaptrex-core Show documentation
Show all versions of adaptrex-core Show documentation
The Core Adaptrex Framework
/*
* Copyright 2012 Adaptrex, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.adaptrex.core.persistence;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import com.adaptrex.core.ext.ExtConfig;
import com.adaptrex.core.security.SecurityModel;
import com.fasterxml.jackson.databind.ObjectMapper;
public class PersistenceTools {
public static List getIncludes(ExtConfig config, String nodePath) {
return getListAtPath(config, nodePath, config.getIncludes());
}
public static List getExcludes(ExtConfig config, String nodePath) {
return getListAtPath(config, nodePath, config.getExcludes());
}
public static List getJoins(ExtConfig config, String nodePath) {
return getListAtPath(config, nodePath, config.getAssociations());
}
private static List getListAtPath(ExtConfig config, String nodePath, List fullList) {
List list = new ArrayList();
for (String item : fullList) {
if (config.getModelName().equals(nodePath)) {
if (!item.contains(".")) list.add(item);
} else {
if (item.contains(nodePath + ".")) list.add(item.split("\\.")[1]);
}
}
return list;
}
public static SecurityModel getSecurityModel() throws Exception {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream stream = loader.getResourceAsStream("adaptrex.security");
if (stream == null) return null;
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(stream,SecurityModel.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy