本文整理汇总了Java中com.mendix.core.Core.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Core.delete方法的具体用法?Java Core.delete怎么用?Java Core.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mendix.core.Core
的用法示例。
在下文中一共展示了Core.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: handleMembers
import com.mendix.core.Core; //导入方法依赖的package包/类
private void handleMembers(IContext context, IMetaObject metaObject, IMendixObject curObject) throws CoreException
{
Map<String,IMendixObject> membersByName = new HashMap<String, IMendixObject>();
List<IMendixObject> existingMembers = Core.retrieveXPathQuery(context, "//" + MxObjectMember.getType() + "[" + MxObjectMember.MemberNames.MxObjectMember_MxObjectType + "='" + curObject.getId().toLong() + "']");
for(IMendixObject obj : existingMembers)
membersByName.put((String)obj.getValue(context, MxObjectMember.MemberNames.AttributeName.toString()), obj);
List<IMendixObject> memberList = new ArrayList<IMendixObject>();
for(IMetaPrimitive metaPrimitive : metaObject.getMetaPrimitives())
{
String name = metaPrimitive.getName();
if(metaPrimitive.getType() == PrimitiveType.Enum)
{
if(membersByName.containsKey(name))
{
IMendixObject curMember = membersByName.get(name);
if(MxObjectEnum.getType().equals(curMember.getType()))
{
memberList.add(this.handleEnumMember(context, curMember, metaPrimitive, curObject));
membersByName.remove(name);
}
else
{
Core.delete(context, curMember);
memberList.add(this.handleEnumMember(context, null, metaPrimitive, curObject));
}
}
else
memberList.add(this.handleEnumMember(context, null, metaPrimitive, curObject));
}
else
{
processMember(context, curObject, membersByName, memberList, metaPrimitive, name);
}
}
Core.commit(context, memberList);
this.builder.removeDeletedObjects(context, membersByName);
}
示例3: processMember
import com.mendix.core.Core; //导入方法依赖的package包/类
public void processMember(IContext context, IMendixObject curObject, Map<String, IMendixObject> membersByName, List<IMendixObject> memberList, IMetaPrimitive metaPrimitive, String name) throws CoreException {
IMendixObject curMember;
IDataType memberType = Core.createDataType(metaPrimitive.getType().toString());
if( !membersByName.containsKey(name) )
{
curMember = Core.instantiate(context, MxObjectMember.getType());
curMember.setValue(context, MxObjectMember.MemberNames.AttributeName.toString(), name);
curMember.setValue(context, MxObjectMember.MemberNames.AttributeType.toString(), metaPrimitive.getType().toString());
curMember.setValue(context, MxObjectMember.MemberNames.AttributeTypeEnum.toString(),
this.builder.getPrimitiveTypesFromPrimitiveType(metaPrimitive.getType()) != null ? this.builder.getPrimitiveTypesFromPrimitiveType(metaPrimitive.getType()).toString() : null);
curMember.setValue(context, MxObjectMember.MemberNames.MxObjectMember_MxObjectType.toString(), curObject.getId());
curMember.setValue(context, MxObjectMember.MemberNames.MxObjectMember_Type.toString(), this.builder.getTypeId(context, memberType));
curMember.setValue(context, MxObjectMember.MemberNames.FieldLength.toString(), metaPrimitive.getLength());
curMember.setValue(context, MxObjectMember.MemberNames.IsVirtual.toString(), metaPrimitive.isVirtual());
memberList.add(curMember);
}
else
{
curMember = membersByName.get(name);
if(MxObjectEnum.getType().equals(curMember.getType()))
{
Core.delete(context, curMember);
curMember = Core.instantiate(context, MxObjectMember.getType());
curMember.setValue(context, MxObjectMember.MemberNames.AttributeName.toString(), name);
curMember.setValue(context, MxObjectMember.MemberNames.MxObjectMember_MxObjectType.toString(), curObject.getId());
}
curMember.setValue(context, MxObjectMember.MemberNames.MxObjectMember_Type.toString(), this.builder.getTypeId(context, memberType));
curMember.setValue(context, MxObjectMember.MemberNames.AttributeType.toString(), metaPrimitive.getType().toString());
curMember.setValue(context, MxObjectMember.MemberNames.AttributeTypeEnum.toString(),
this.builder.getPrimitiveTypesFromPrimitiveType(metaPrimitive.getType()) != null ? this.builder.getPrimitiveTypesFromPrimitiveType(metaPrimitive.getType()).toString() : null);
curMember.setValue(context, MxObjectMember.MemberNames.FieldLength.toString(), metaPrimitive.getLength());
curMember.setValue(context, MxObjectMember.MemberNames.IsVirtual.toString(), metaPrimitive.isVirtual());
memberList.add(curMember);
membersByName.remove(name);
}
}
示例4: removeDeletedObjects
import com.mendix.core.Core; //导入方法依赖的package包/类
protected void removeDeletedObjects(IContext context, Map<String,IMendixObject> objects) throws CoreException {
String attrName = null;
for(Entry<String, IMendixObject> entry : objects.entrySet()) {
IMendixObject entryObj = entry.getValue();
if( attrName == null ) {
if( Parameter.entityName.equals(entryObj.getType()) )
attrName = "Name";
else
attrName = "CompleteName";
}
this._logNode .debug("Removing: " + entryObj.getValue(context, attrName));
Core.delete(context, entryObj);
}
}
示例5: deleteAll
import com.mendix.core.Core; //导入方法依赖的package包/类
public boolean deleteAll() throws CoreException
{
this.limit(1000);
List<IMendixObject> objs = allMendixObjects();
while (!objs.isEmpty()) {
if (!Core.delete(context, objs.toArray(new IMendixObject[objs.size()])))
return false; //TODO: throw?
objs = allMendixObjects();
}
return true;
}
示例6: executeAction
import com.mendix.core.Core; //导入方法依赖的package包/类
@Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
ISession session = getContext().getSession();
IContext newContext = session.createContext();
Core.delete(newContext, objectList);
newContext.endTransaction();
return true;
// END USER CODE
}
示例7: syncDatabaseWithCollection
import com.mendix.core.Core; //导入方法依赖的package包/类
/**
* Given a current collection of primitive values, checks if for each value in the collection an object in the database exists.
* It creates a new object if needed, and removes any superfluos objects in the database that are no longer in the collection.
*
* @param currentCollection The collection that act as reference for the objects that should be in this database in the end.
* @param comparisonAttribute The attribute that should store the value as decribed in the collection
* @param autoDelete Automatically remove any superfluous objects form the database
* @param keysAndValues Constraints that should hold for the set of objects that are deleted or created. Objects outside this constraint are not processed.
*
* @return A pair of lists. The first list contains the newly created objects, the second list contains the objects that (should be or are) removed.
* @throws CoreException
*/
public <U> ImmutablePair<List<T>, List<T>> syncDatabaseWithCollection(Collection<U> currentCollection, Object comparisonAttribute, boolean autoDelete, Object... keysAndValues) throws CoreException {
if (builder.length() > 0)
throw new IllegalStateException("syncDatabaseWithCollection can only be used on XPath which do not have constraints already");
List<T> added = new ArrayList<T>();
List<T> removed = new ArrayList<T>();
Set<U> col = new HashSet<U>(currentCollection);
for(int i = 0; i < keysAndValues.length; i+= 2)
eq(keysAndValues[i], keysAndValues[i + 1]);
for(IMendixObject existingItem : this.allMendixObjects()) {
//Item is still available
if (col.remove(existingItem.getValue(context, String.valueOf(comparisonAttribute))))
continue;
//No longer available
removed.add(createProxy(context, this.proxyClass, existingItem));
if (autoDelete)
Core.delete(context, existingItem);
}
//Some items where not found in the database
for(U value : col) {
//In apache lang3, this would just be: ArrayUtils.addAll(keysAndValues, comparisonAttribute, value)
Object[] args = new Object[keysAndValues.length + 2];
for(int i = 0; i < keysAndValues.length; i++)
args[i] = keysAndValues[i];
args[keysAndValues.length] = comparisonAttribute;
args[keysAndValues.length + 1] = value;
T newItem = constructInstance(true, args);
added.add(newItem);
}
//Oké, stupid, Pair is also only available in apache lang3, so lets use a simple pair implementation for now
return ImmutablePair.of(added, removed);
}