本文整理汇总了Java中org.cpsolver.ifs.util.DataProperties.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java DataProperties.setProperty方法的具体用法?Java DataProperties.setProperty怎么用?Java DataProperties.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cpsolver.ifs.util.DataProperties
的用法示例。
在下文中一共展示了DataProperties.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSolver
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public StudentSolverProxy createSolver(DataProperties properties) {
try {
if (!sessionContext.isAuthenticated() || sessionContext.getUser().getCurrentAcademicSessionId() == null) return null;
removeSolver();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.OwnerPuid", sessionContext.getUser().getExternalUserId());
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String host = properties.getProperty("General.Host");
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
StudentSolverProxy solver = solverServerService.createStudentSolver(host, sessionContext.getUser().getExternalUserId(), properties);
solver.load(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to start the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例2: reload
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public StudentSolverProxy reload(DataProperties properties) {
try {
StudentSolverProxy solver = getSolver();
if (solver == null) return createSolver(properties);
DataProperties oldProperties = solver.getProperties();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.OwnerPuid", oldProperties.getProperty("General.OwnerPuid"));
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
solver.reload(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to reload the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例3: createSolver
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public ExamSolverProxy createSolver(DataProperties properties) {
try {
if (!sessionContext.isAuthenticated() || sessionContext.getUser().getCurrentAcademicSessionId() == null) return null;
removeSolver();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.OwnerPuid", sessionContext.getUser().getExternalUserId());
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String host = properties.getProperty("General.Host");
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
ExamSolverProxy solver = solverServerService.createExamSolver(host, sessionContext.getUser().getExternalUserId(), properties);
solver.load(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to start the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例4: reload
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public ExamSolverProxy reload(DataProperties properties) {
try {
ExamSolverProxy solver = getSolver();
if (solver == null) return createSolver(properties);
DataProperties oldProperties = solver.getProperties();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("Exam.Type",oldProperties.getProperty("Exam.Type"));
properties.setProperty("General.OwnerPuid", oldProperties.getProperty("General.OwnerPuid"));
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
solver.reload(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to reload the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例5: createSolver
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public InstructorSchedulingProxy createSolver(DataProperties properties) {
try {
if (!sessionContext.isAuthenticated() || sessionContext.getUser().getCurrentAcademicSessionId() == null) return null;
removeSolver();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.OwnerPuid", sessionContext.getUser().getExternalUserId());
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String host = properties.getProperty("General.Host");
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
InstructorSchedulingProxy solver = solverServerService.createInstructorScheduling(host, sessionContext.getUser().getExternalUserId(), properties);
solver.load(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to start the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例6: reload
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public InstructorSchedulingProxy reload(DataProperties properties) {
try {
InstructorSchedulingProxy solver = getSolver();
if (solver == null) return createSolver(properties);
DataProperties oldProperties = solver.getProperties();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.OwnerPuid", oldProperties.getProperty("General.OwnerPuid"));
properties.setProperty("General.SolverGroupId",oldProperties.getProperty("General.SolverGroupId"));
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
solver.reload(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to reload the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例7: getInfoOfASolution
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static HashMap<String, String> getInfoOfASolution(File file) {
try {
DataProperties properties = new DataProperties();
properties.setProperty("General.Input", file.getPath());
TimetableXMLLoader loader = new TimetableXMLLoader(new TimetableModel(properties), new DefaultSingleAssignment<Lecture, Placement>());
loader.load();
File newOutputFile = new File(file.getParentFile(), "new-output.csv");
Test.saveOutputCSV(new Solution<Lecture, Placement>(loader.getModel(), loader.getAssignment()), newOutputFile);
Progress.removeInstance(loader.getModel());
System.out.println(" Reading " + newOutputFile + " ...");
HashMap<String, String> info = getInfo(newOutputFile);
File outputFile = new File(file.getParentFile(), "output.csv");
if (outputFile.exists()) {
System.out.println(" Reading " + outputFile + " ...");
HashMap<String, String> info2 = getInfo(outputFile);
if (info2.containsKey("000.002 Time [sec]"))
info.put("000.002 Time [sec]", info2.get("000.002 Time [sec]"));
}
return info;
} catch (Exception e) {
System.err.println("Error reading info, message: " + e.getMessage());
e.printStackTrace();
return null;
}
}
示例8: main
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Progress.getInstance().addProgressListener(new ProgressWriter(System.out));
File inputCfg = new File(args[0]);
DataProperties properties = ToolBox.loadProperties(inputCfg);
if (properties.getProperty("INCLUDE_REGEXP") != null) {
test(inputCfg, null, null, properties.getProperty("INCLUDE_REGEXP"), (args.length > 1 ? args[1] : null));
} else {
String outDir = properties.getProperty("General.Output", ".") + File.separator
+ inputCfg.getName().substring(0, inputCfg.getName().lastIndexOf('.')) + File.separator
+ sDateFormat.format(new Date());
if (args.length > 1)
outDir = args[1] + File.separator + (sDateFormat.format(new Date()));
properties.setProperty("General.Output", outDir.toString());
System.out.println("Output folder: " + properties.getProperty("General.Output"));
(new File(outDir)).mkdirs();
ToolBox.configureLogging(outDir, null);
test(properties);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: createSolver
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public SolverProxy createSolver(DataProperties properties) {
try {
if (!sessionContext.isAuthenticated() || sessionContext.getUser().getCurrentAcademicSessionId() == null) return null;
removeSolver();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
// properties.setProperty("General.SolverGroupId", ownerIds);
properties.setProperty("General.OwnerPuid", sessionContext.getUser().getExternalUserId());
// if (solutionIds!=null) properties.setProperty("General.SolutionId",solutionIds);
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
// properties.setProperty("General.StartSolver", Boolean.toString(start));
String host = properties.getProperty("General.Host");
String warn = getSolverWarning(properties);
if (warn!=null)
properties.setProperty("General.SolverWarnings",warn);
else
properties.remove("General.SolverWarnings");
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
SolverProxy solver = solverServerService.createCourseSolver(host, sessionContext.getUser().getExternalUserId(), properties);
solver.load(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to start the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例10: reload
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public SolverProxy reload(DataProperties properties) {
try {
SolverProxy solver = getSolver();
if (solver == null) return createSolver(properties);
DataProperties oldProperties = solver.getProperties();
properties.setProperty("General.SessionId", sessionContext.getUser().getCurrentAcademicSessionId().toString());
properties.setProperty("General.SolverGroupId",oldProperties.getProperty("General.SolverGroupId"));
properties.setProperty("General.OwnerPuid", oldProperties.getProperty("General.OwnerPuid"));
properties.setProperty("General.StartTime", String.valueOf((new Date()).getTime()));
String warn = getSolverWarning(properties);
if (warn!=null)
properties.setProperty("General.SolverWarnings",warn);
else
properties.remove("General.SolverWarnings");
String instructorFormat = sessionContext.getUser().getProperty(UserProperty.NameFormat);
if (instructorFormat != null)
properties.setProperty("General.InstructorFormat",instructorFormat);
solver.reload(properties);
return solver;
} catch (Exception e) {
sLog.error("Failed to reload the solver: " + e.getMessage(), e);
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
}
示例11: main
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
/**
* RPP test.
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
try {
Progress.getInstance().addProgressListener(new ProgressWriter(System.out));
File inputCfg = new File(args[0]);
DataProperties properties = ToolBox.loadProperties(inputCfg);
if (properties.getProperty("INCLUDE_REGEXP") != null) {
if (args.length > 1)
properties.setProperty("General.Output", args[1]);
test(inputCfg, null, null, properties.getProperty("INCLUDE_REGEXP"), (args.length > 1 ? args[1] : null));
} else {
String outDir = properties.getProperty("General.Output", ".") + File.separator
+ inputCfg.getName().substring(0, inputCfg.getName().lastIndexOf('.')) + File.separator
+ sDateFormat.format(new Date());
if (args.length > 1)
outDir = args[1] + File.separator + (sDateFormat.format(new Date()));
(new File(outDir)).mkdirs();
properties.setProperty("General.Output", outDir.toString());
System.out.println("Output folder: " + properties.getProperty("General.Output"));
ToolBox.configureLogging(outDir, null);
boolean mpp = properties.getPropertyBoolean("General.MPP", false);
if (mpp)
testMPP(properties);
else
test(properties);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: main
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Progress.getInstance().addProgressListener(new ProgressWriter(System.out));
File inputCfg = new File(args[0]);
DataProperties properties = ToolBox.loadProperties(inputCfg);
String outDir = properties.getProperty("General.Output", ".") + File.separator + inputCfg.getName().substring(0, inputCfg.getName().lastIndexOf('.')) + File.separator + sDateFormat.format(new Date());
(new File(outDir)).mkdirs();
properties.setProperty("General.Output", outDir.toString());
ToolBox.configureLogging(outDir, null);
test(properties);
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: createConfig
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public DataProperties createConfig(Long settingsId, Map<Long, String> options) {
DataProperties properties = new DataProperties();
// Load properties
for (SolverParameterDef def: (List<SolverParameterDef>)SolverPredefinedSettingDAO.getInstance().getSession().createQuery(
"from SolverParameterDef where group.type = :type").setInteger("type", SolverParameterGroup.SolverType.EXAM.ordinal()).list()) {
if (def.getDefault() != null) properties.put(def.getName(), def.getDefault());
if (options != null && options.containsKey(def.getUniqueId()))
properties.put(def.getName(), options.get(def.getUniqueId()));
}
SolverPredefinedSetting settings = SolverPredefinedSettingDAO.getInstance().get(settingsId);
for (SolverParameter param: settings.getParameters()) {
if (!param.getDefinition().isVisible() || param.getDefinition().getGroup().getSolverType() != SolverParameterGroup.SolverType.EXAM) continue;
properties.put(param.getDefinition().getName(),param.getValue());
if (options != null && options.containsKey(param.getDefinition().getUniqueId()))
properties.put(param.getDefinition().getName(), options.get(param.getDefinition().getUniqueId()));
}
properties.setProperty("General.SettingsId", settings.getUniqueId().toString());
// Generate extensions
String ext = properties.getProperty("Extensions.Classes", "");
if (properties.getPropertyBoolean("ExamGeneral.CBS", true)) {
if (!ext.isEmpty()) ext += ";";
ext += ConflictStatistics.class.getName();
properties.setProperty("ConflictStatistics.Print","true");
}
String mode = properties.getProperty("ExamBasic.Mode","Initial");
if ("MPP".equals(mode))
properties.setProperty("General.MPP","true");
properties.setProperty("Extensions.Classes", ext);
// Interactive mode?
if (properties.getPropertyBoolean("Basic.DisobeyHard",false))
properties.setProperty("General.InteractiveMode", "true");
// When finished?
if ("No Action".equals(properties.getProperty("ExamBasic.WhenFinished"))) {
properties.setProperty("General.Save","false");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","false");
} else if ("Save".equals(properties.getProperty("ExamBasic.WhenFinished"))) {
properties.setProperty("General.Save","true");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","false");
} else if ("Save and Unload".equals(properties.getProperty("ExamBasic.WhenFinished"))) {
properties.setProperty("General.Save","true");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","true");
}
// XML save/load properties
properties.setProperty("Xml.ShowNames", "true");
properties.setProperty("Exam.GreatDeluge", ("Great Deluge".equals(properties.getProperty("Exam.Algorithm","Great Deluge"))?"true":"false"));
properties.setProperty("Search.GreatDeluge", ("Great Deluge".equals(properties.getProperty("Exam.Algorithm","Great Deluge"))?"true":"false"));
// Distances Matrics
if (properties.getProperty("Distances.Ellipsoid") == null || properties.getProperty("Distances.Ellipsoid").equals("DEFAULT"))
properties.setProperty("Distances.Ellipsoid", ApplicationProperties.getProperty(ApplicationProperty.DistanceEllipsoid));
if (properties.getProperty("Parallel.NrSolvers") == null) {
properties.setProperty("Parallel.NrSolvers", String.valueOf(Math.max(1, Runtime.getRuntime().availableProcessors() / 2)));
}
properties.setProperty("General.UseAmPm", CONSTANTS.useAmPm() ? "true" : "false");
properties.expand();
return properties;
}
示例14: createConfig
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public DataProperties createConfig(Long settingsId, Map<Long, String> options) {
DataProperties properties = new DataProperties();
try {
InputStream is = getClass().getClassLoader().getResourceAsStream("org/cpsolver/instructor/default.properties");
if (is != null) properties.load(is);
} catch (IOException e) {
sLog.warn("Failed to load configuration defaults:" + e.getMessage());
}
// Load properties
for (SolverParameterDef def: (List<SolverParameterDef>)SolverPredefinedSettingDAO.getInstance().getSession().createQuery(
"from SolverParameterDef where group.type = :type").setInteger("type", SolverParameterGroup.SolverType.INSTRUCTOR.ordinal()).list()) {
if (def.getDefault() != null) properties.put(def.getName(), def.getDefault());
if (options != null && options.containsKey(def.getUniqueId()))
properties.put(def.getName(), options.get(def.getUniqueId()));
}
SolverPredefinedSetting settings = SolverPredefinedSettingDAO.getInstance().get(settingsId);
for (SolverParameter param: settings.getParameters()) {
if (!param.getDefinition().isVisible() || param.getDefinition().getGroup().getSolverType() != SolverParameterGroup.SolverType.INSTRUCTOR) continue;
properties.put(param.getDefinition().getName(),param.getValue());
if (options != null && options.containsKey(param.getDefinition().getUniqueId()))
properties.put(param.getDefinition().getName(), options.get(param.getDefinition().getUniqueId()));
}
properties.setProperty("General.SettingsId", settings.getUniqueId().toString());
// Generate extensions
String ext = properties.getProperty("Extensions.Classes", "");
if (properties.getPropertyBoolean("General.CBS", true)) {
if (!ext.isEmpty()) ext += ";";
ext += ConflictStatistics.class.getName();
properties.setProperty("ConflictStatistics.Print","true");
}
String mode = properties.getProperty("Basic.Mode","Initial");
if ("MPP".equals(mode))
properties.setProperty("General.MPP","true");
properties.setProperty("Extensions.Classes", ext);
// Interactive mode?
if (properties.getPropertyBoolean("Basic.DisobeyHard", false))
properties.setProperty("General.InteractiveMode", "true");
// When finished?
if ("No Action".equals(properties.getProperty("Basic.WhenFinished"))) {
properties.setProperty("General.Save","false");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","false");
} else if ("Save".equals(properties.getProperty("Basic.WhenFinished"))) {
properties.setProperty("General.Save","true");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","false");
} else if ("Save and Unload".equals(properties.getProperty("Basic.WhenFinished"))) {
properties.setProperty("General.Save","true");
properties.setProperty("General.CreateNewSolution","false");
properties.setProperty("General.Unload","true");
}
// XML save/load properties
properties.setProperty("Xml.ShowNames", "true");
properties.setProperty("Search.GreatDeluge", ("Great Deluge".equals(properties.getProperty("General.Algorithm","Great Deluge"))?"true":"false"));
// Distances Matrics
if (properties.getProperty("Distances.Ellipsoid") == null || properties.getProperty("Distances.Ellipsoid").equals("DEFAULT"))
properties.setProperty("Distances.Ellipsoid", ApplicationProperties.getProperty(ApplicationProperty.DistanceEllipsoid));
if (properties.getProperty("Parallel.NrSolvers") == null) {
properties.setProperty("Parallel.NrSolvers", "1"); // String.valueOf(Math.max(1, Runtime.getRuntime().availableProcessors() / 2))
}
properties.setProperty("General.UseAmPm", CONSTANTS.useAmPm() ? "true" : "false");
properties.expand();
return properties;
}
示例15: execute
import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public SectioningReportRpcResponse execute(SectioningReportRpcRequest request, SessionContext context) {
DataProperties parameters = new DataProperties(request.getParameters());
CSVFile csv = null;
boolean online = parameters.getPropertyBoolean("online", false);
parameters.setProperty("useAmPm", CONSTANTS.useAmPm() ? "true" : "false");
if (online) {
context.checkPermission(Right.SchedulingReports);
OnlineSectioningServer server = solverServerService.getOnlineStudentSchedulingContainer().getSolver(context.getUser().getCurrentAcademicSessionId().toString());
if (server == null)
throw new GwtRpcException("Online student scheduling is not enabled for " + context.getUser().getCurrentAuthority().getQualifiers("Session").get(0).getQualifierLabel() + ".");
OnlineSectioningLog.Entity user = OnlineSectioningLog.Entity.newBuilder()
.setExternalId(context.getUser().getExternalUserId())
.setName(context.getUser().getName() == null ? context.getUser().getUsername() : context.getUser().getName())
.setType(context.hasPermission(Right.StudentSchedulingAdvisor) ? OnlineSectioningLog.Entity.EntityType.MANAGER : OnlineSectioningLog.Entity.EntityType.STUDENT).build();
csv = server.execute(server.createAction(GenerateSectioningReport.class).withParameters(parameters), user);
} else {
context.checkPermission(Right.StudentSectioningSolver);
StudentSolverProxy solver = studentSectioningSolverService.getSolver();
if (solver == null)
throw new GwtRpcException("No student solver is running.");
csv = solver.getReport(parameters);
}
if (csv == null)
throw new GwtRpcException("No report was created.");
SectioningReportRpcResponse response = new SectioningReportRpcResponse();
String[] header = new String[csv.getHeader().getFields().size()];
for (int i = 0; i < csv.getHeader().getFields().size(); i++)
header[i] = csv.getHeader().getField(i).toString();
response.addLine(header);
if (csv.getLines() != null)
for (CSVLine line: csv.getLines()) {
String[] row = new String[line.getFields().size()];
for (int i = 0; i < line.getFields().size(); i++)
row[i] = line.getField(i).toString();
response.addLine(row);
}
return response;
}