96 lines
3.5 KiB
Java
96 lines
3.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.tridium.sys.transfer;
|
|
|
|
import com.tridium.sys.engine.EngineUtil;
|
|
import com.tridium.sys.schema.ComponentSlotMap;
|
|
import com.tridium.sys.transfer.CompToComp;
|
|
import com.tridium.sys.transfer.TransferResult;
|
|
import javax.baja.sync.Transaction;
|
|
import javax.baja.sys.BBoolean;
|
|
import javax.baja.sys.BComplex;
|
|
import javax.baja.sys.BComponent;
|
|
import javax.baja.sys.BFacets;
|
|
import javax.baja.sys.BObject;
|
|
import javax.baja.sys.BValue;
|
|
import javax.baja.sys.BasicContext;
|
|
import javax.baja.sys.Context;
|
|
import javax.baja.sys.LocalizableException;
|
|
import javax.baja.sys.Property;
|
|
import javax.baja.sys.Slot;
|
|
|
|
public class IntraCompSpaceMove
|
|
extends CompToComp {
|
|
public TransferResult transfer() throws Exception {
|
|
this.init();
|
|
this.copySource = false;
|
|
this.load();
|
|
this.name();
|
|
this.annotate();
|
|
this.move();
|
|
this.reactiveLinks();
|
|
return this.makeResult();
|
|
}
|
|
|
|
protected void move() throws Exception {
|
|
Object object;
|
|
BComponent bComponent = this.sourceParent;
|
|
BComponent bComponent2 = this.target.asComponent();
|
|
BObject[] bObjectArray = this.sourceValues;
|
|
int n = this.sourceValues.length;
|
|
int[] nArray = new int[n];
|
|
Property[] propertyArray = new Property[n];
|
|
int n2 = 0;
|
|
while (n2 < n) {
|
|
if (!bObjectArray[n2].isComplex()) {
|
|
throw new LocalizableException("baja", "CannotMoveSimples");
|
|
}
|
|
BComplex bComplex = (BComplex)bObjectArray[n2];
|
|
object = bComplex.getPropertyInParent();
|
|
if (object.isFrozen()) {
|
|
throw new LocalizableException("baja", "CannotMoveFrozen", new Object[]{bComplex.getDisplayName((Slot)object, this.context)});
|
|
}
|
|
propertyArray[n2] = object;
|
|
nArray[n2] = bComponent.getFlags((Slot)object);
|
|
++n2;
|
|
}
|
|
String string = bComponent2.getSlotPath().toString();
|
|
int n3 = 0;
|
|
while (n3 < n) {
|
|
if (bObjectArray[n3].isComponent() && (string.equals(object = bObjectArray[n3].asComponent().getSlotPath().toString()) || string.startsWith((String)object + '/'))) {
|
|
throw new LocalizableException("baja", "CannotMoveUnderSelf");
|
|
}
|
|
++n3;
|
|
}
|
|
ComponentSlotMap componentSlotMap = (ComponentSlotMap)bComponent2.fw(1);
|
|
int n4 = 0;
|
|
while (n4 < n) {
|
|
componentSlotMap.checkAdd(this.insertNames[n4], nArray[n4], (BValue)bObjectArray[n4], BFacets.NULL, this.context);
|
|
++n4;
|
|
}
|
|
BasicContext basicContext = new BasicContext(this.context, BFacets.make("niagaraRemoveLinks", BBoolean.FALSE));
|
|
Context context = Transaction.start(bComponent, basicContext);
|
|
int n5 = 0;
|
|
while (n5 < n) {
|
|
bComponent.remove(propertyArray[n5], context);
|
|
++n5;
|
|
}
|
|
Transaction.end(bComponent, context);
|
|
context = Transaction.start(bComponent2, this.context);
|
|
n5 = 0;
|
|
while (n5 < n) {
|
|
bComponent2.add(this.insertNames[n5], (BComplex)bObjectArray[n5], nArray[n5], context);
|
|
++n5;
|
|
}
|
|
Transaction.end(bComponent2, context);
|
|
}
|
|
|
|
protected void reactiveLinks() {
|
|
BComponent bComponent = this.target.asComponent();
|
|
BComponent bComponent2 = bComponent.getComponentSpace().getRootComponent();
|
|
EngineUtil.activateLinks(bComponent2);
|
|
}
|
|
}
|
|
|