本文整理汇总了Java中com.mendix.core.Core类的典型用法代码示例。如果您正苦于以下问题:Java Core类的具体用法?Java Core怎么用?Java Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Core类属于com.mendix.core包,在下文中一共展示了Core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateModule
import com.mendix.core.Core; //导入依赖的package包/类
protected Object validateModule(IContext context, String moduleName) throws CoreException {
this.activeModule.add(moduleName);
if (!this.moduleMap.containsKey(moduleName)) {
this.moduleMap.put(moduleName, null);
IMendixObject obj = Core.instantiate(context, Module.getType());
obj.setValue(context, Module.MemberNames.ModuleName.toString(), moduleName);
if (this.allNewModules) {
this.moduleMap.put(moduleName, obj);
obj.setValue(context, Module.MemberNames.SynchronizeObjectsWithinModule.toString(), true);
}
Core.commit(context, obj);
}
return this.moduleMap.get(moduleName);
}
示例2: messageArrived
import com.mendix.core.Core; //导入依赖的package包/类
@Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
try {
logger.info(String.format("messageArrived: %s, %s, %s", topic, new String(mqttMessage.getPayload()), client.getClientId()));
IContext ctx = Core.createSystemContext();
ISession session = ctx.getSession();
MqttSubscription subscription = getSubscriptionForTopic(topic);
if (subscription != null) {
String microflow = subscription.getOnMessageMicroflow();
logger.info(String.format("Calling onMessage microflow: %s, %s", microflow, client.getClientId()));
final ImmutableMap map = ImmutableMap.of("Topic", topic, "Payload", new String(mqttMessage.getPayload()));
logger.info("Parameter map: " + map);
//Core.execute(ctx, microflow, true, map);
Core.executeAsync(ctx, microflow, true, map);
} else {
logger.error(String.format("Cannot find microflow for message received on topic %s", topic));
}
} catch (Exception e) {
logger.error(e);
}
}
示例3: getFileSize
import com.mendix.core.Core; //导入依赖的package包/类
public static Long getFileSize(IContext context, IMendixObject document)
{
final int BUFFER_SIZE = 4096;
long size = 0;
if (context != null) {
InputStream inputStream = null;
byte[] buffer = new byte[BUFFER_SIZE];
try {
inputStream = Core.getFileDocumentContent(context, document);
int i;
while ((i = inputStream.read(buffer)) != -1)
size += i;
} catch (IOException e) {
Core.getLogger("FileUtil").error(
"Couldn't determine filesize of FileDocument '" + document.getId());
} finally {
IOUtils.closeQuietly(inputStream);
}
}
return size;
}
示例4: getUserProfile
import com.mendix.core.Core; //导入依赖的package包/类
public static profileservice.proxies.UserProfile getUserProfile(IContext context, java.lang.String _openID, java.lang.String _environmentUUID, java.lang.String _environmentPassword)
{
try
{
Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
params.put("OpenID", _openID);
params.put("EnvironmentUUID", _environmentUUID);
params.put("EnvironmentPassword", _environmentPassword);
IMendixObject result = (IMendixObject)Core.execute(context, "ProfileService.GetUserProfile", params);
return result == null ? null : profileservice.proxies.UserProfile.initialize(context, result);
}
catch (CoreException e)
{
throw new MendixRuntimeException(e);
}
}
示例5: findOrCreateSynchronized
import com.mendix.core.Core; //导入依赖的package包/类
public T findOrCreateSynchronized(Object... keysAndValues) throws CoreException, InterruptedException {
T res = findFirst(keysAndValues);
if (res != null) {
return res;
} else {
synchronized (Core.getMetaObject(entity)) {
IContext synchronizedContext = context.getSession().createContext().createSudoClone();
try {
synchronizedContext.startTransaction();
res = createProxy(synchronizedContext, proxyClass, XPath.create(synchronizedContext, entity).findOrCreate(keysAndValues));
synchronizedContext.endTransaction();
return res;
} catch (CoreException e) {
if (synchronizedContext.isInTransaction()) {
synchronizedContext.rollbackTransAction();
}
throw e;
}
}
}
}
示例6: updateConversationContext
import com.mendix.core.Core; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, Object> updateConversationContext(IContext context, ConversationContext conversationContext, MessageResponse response) throws CoreException {
deleteCurrentDialogStack(conversationContext);
conversationContext.setConversationId(context, response.getContext().get("conversation_id").toString());
Map<String, Object> responseContext = response.getContext();
Map<String, Object> resposeSystemContext = (Map<String, Object>) responseContext.get("system");
conversationContext.setDialogTurnCounter(new BigDecimal(resposeSystemContext.get("dialog_turn_counter").toString()));
conversationContext.setDialogRequestCounter(new BigDecimal(resposeSystemContext.get("dialog_request_counter").toString()));
List<String> dialogStack = (List<String>) resposeSystemContext.get("dialog_stack");
for(String dialogNode : dialogStack){
final IMendixObject dialogNodeObject = Core.instantiate(context, DialogNode.entityName );
dialogNodeObject.setValue(context, DialogNode.MemberNames.Name.toString(), dialogNode);
final List<IMendixIdentifier> conversationContextList = new ArrayList<IMendixIdentifier>();
conversationContextList.add(conversationContext.getMendixObject().getId());
dialogNodeObject.setValue(context, DialogNode.MemberNames.Dialog_Stack.toString(), conversationContextList);
Core.commit(context, dialogNodeObject);
}
conversationContext.commit();
return resposeSystemContext;
}
示例7: getRolesForOpenID
import com.mendix.core.Core; //导入依赖的package包/类
public static java.util.List<permissionsapi.proxies.AppRole> getRolesForOpenID(IContext context, java.lang.String _openID, java.lang.String _environmentID, java.lang.String _environmentPassword)
{
try
{
Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
params.put("OpenID", _openID);
params.put("EnvironmentID", _environmentID);
params.put("EnvironmentPassword", _environmentPassword);
java.util.List<IMendixObject> objs = Core.execute(context, "PermissionsAPI.GetRolesForOpenID", params);
java.util.List<permissionsapi.proxies.AppRole> result = null;
if (objs != null)
{
result = new java.util.ArrayList<permissionsapi.proxies.AppRole>();
for (IMendixObject obj : objs)
result.add(permissionsapi.proxies.AppRole.initialize(context, obj));
}
return result;
}
catch (CoreException e)
{
throw new MendixRuntimeException(e);
}
}
示例8: removeInactiveModules
import com.mendix.core.Core; //导入依赖的package包/类
public void removeInactiveModules(IContext context) throws CoreException {
for (Entry<String, IMendixObject> entry : this.moduleMap.entrySet()) {
if (!this.activeModule.contains(entry.getKey())) {
if (entry.getValue() != null)
Core.delete(context, entry.getValue());
else
Core.delete(context, Core.retrieveXPathQuery(context, "//" + Module.getType() + "[" + Module.MemberNames.ModuleName + "='" + entry.getKey() + "']").get(0));
}
}
this.moduleMap.clear();
this.activeModule.clear();
}
示例9: findMicroflowUnitTests
import com.mendix.core.Core; //导入依赖的package包/类
public List<String> findMicroflowUnitTests(TestSuite testRun)
{
List<String> mfnames = new ArrayList<String>();
String basename1 = (testRun.getModule() + "." + TEST_MICROFLOW_PREFIX_1).toLowerCase();
String basename2 = (testRun.getModule() + "." + TEST_MICROFLOW_PREFIX_2).toLowerCase();
//Find microflownames
for (String mf : Core.getMicroflowNames())
if (mf.toLowerCase().startsWith(basename1) || mf.toLowerCase().startsWith(basename2))
mfnames.add(mf);
//Sort microflow names
Collections.sort(mfnames);
return mfnames;
}
示例10: findAllTests
import com.mendix.core.Core; //导入依赖的package包/类
public synchronized void findAllTests(IContext context) throws CoreException {
/*
* Find modules
*/
Set<String> modules = new HashSet<String>();
for(String name : Core.getMicroflowNames())
modules.add(name.split("\\.")[0]);
/*
* Update modules
*/
for(String module : modules) {
TestSuite testSuite = XPath.create(context, TestSuite.class).findOrCreate(TestSuite.MemberNames.Module, module);
updateUnitTestList(context, testSuite);
}
/*
* Remove all modules without tests
*/
XPath.create(context, TestSuite.class).not().hasReference(UnitTest.MemberNames.UnitTest_TestSuite, UnitTest.entityName).close().deleteAll();
}
示例11: executeAction
import com.mendix.core.Core; //导入依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
this.testRun = __testRun == null ? null : unittesting.proxies.TestSuite.initialize(getContext(), __testRun);
// BEGIN USER CODE
try {
//Run tests in a new context without transaction!
TestManager.instance().runTestSuite(Core.createSystemContext(), testRun);
}
catch(Exception e) {
TestManager.LOG.error("An error occurred while trying to run the unit tests: " + ExceptionUtils.getRootCauseMessage(e), e);
return false;
}
return true;
// END USER CODE
}
示例12: getCloneOfObject
import com.mendix.core.Core; //导入依赖的package包/类
private static IMendixIdentifier getCloneOfObject(IContext ctx, IMendixObject src,
List<String> toskip, List<String> tokeep, List<String> revAssoc,
List<String> skipEntities, List<String> skipModules,
Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
{
String objType = src.getMetaObject().getName();
String modName = src.getMetaObject().getModuleName();
// if object is already being cloned, return ref to clone
if (mappedObjects.containsKey(src.getId())) {
return mappedObjects.get(src.getId());
// if object should be skipped based on module or entity, return source object
} else if (skipEntities.contains(objType) || skipModules.contains(modName)) {
return src.getId();
// if not already being cloned, create clone
} else {
IMendixObject clone = Core.instantiate(ctx, src.getType());
duplicate(ctx, src, clone, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
return clone.getId();
}
}
示例13: runMicroflowAsyncInQueue
import com.mendix.core.Core; //导入依赖的package包/类
public static Boolean runMicroflowAsyncInQueue(final String microflowName)
{
MFSerialExecutor.instance().execute(new Runnable() {
@Override
public void run()
{
try
{
Future<Object> future = Core.executeAsync(Core.createSystemContext(), microflowName, true, new HashMap<String,Object>()); //MWE: somehow, it only works with system context... well thats OK for now.
future.get();
}
catch (Exception e)
{
throw new RuntimeException("Failed to run Async: "+ microflowName + ": " + e.getMessage(), e);
}
}
});
return true;
}
示例14: executeAction
import com.mendix.core.Core; //导入依赖的package包/类
@Override
public java.lang.Boolean executeAction() throws Exception
{
this.testRun = __testRun == null ? null : unittesting.proxies.TestSuite.initialize(getContext(), __testRun);
// BEGIN USER CODE
try {
//Run tests in a new context without transaction!
TestManager.instance().runTestSuite(Core.createSystemContext(), testRun);
}
catch(Exception e) {
TestManager.LOG.error("An error occurred while trying to run the unit tests: " + ExceptionUtils.getRootCauseMessage(e), e);
return false;
}
return true;
// END USER CODE
}
示例15: findOrCreateSynchronized
import com.mendix.core.Core; //导入依赖的package包/类
public T findOrCreateSynchronized(Object... keysAndValues) throws CoreException, InterruptedException {
T res = findFirst(keysAndValues);
if (res != null) {
return res;
} else {
synchronized (Core.getMetaObject(entity)) {
IContext synchronizedContext = context.getSession().createContext().getSudoContext();
try {
synchronizedContext.startTransaction();
res = createProxy(synchronizedContext, proxyClass, XPath.create(synchronizedContext, entity).findOrCreate(keysAndValues));
synchronizedContext.endTransaction();
return res;
} catch (CoreException e) {
if (synchronizedContext.isInTransaction()) {
synchronizedContext.rollbackTransAction();
}
throw e;
}
}
}
}