Warning: session_start(): open(/var/lib/php/sessions/sess_gc8p51e0toh4q770ri4hij5se7, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
extend BEAObject {
bool canReactWith(BEAObject o) {
ret isInstanceOfAny(o, (Cl) reactableWithClasses());
}
Cl> reactableWithClasses() {
ret singleArgumentMethodTypesSubclassing(this, "reactWith", BEAObject);
}
}
beaConcept BInput {
S text;
toString { ret "[\*id*/] Input " + quote(text); }
}
beaConcept BOutput {
S text;
toString { ret "[\*id*/] Output " + quote(text); }
}
beaConcept BPattern {
S text;
toString { ret "[\*id*/] " + shortDynName(this) + " " + quote(text); }
void reactWith(BInput input) {}
@Override void _doneLoading2 :: after {
crenameField(this, "pattern", "text");
}
}
beaConcept BStarPattern > BPattern {
void reactWith(BInput input) {
LS mapping = matchesToStringList(flexMatchIC_first(text, input.text));
if (mapping == null) ret;
uniqPeer BEAObject(this,
type := "match",
+input,
pattern := this,
+mapping);
}
}
beaConcept BAngleVarPattern > BPattern {
void reactWith(BInput input) {
SS mapping = flexMatchAngleBracketVarsIC_first(text, input.text);
if (mapping == null) ret;
uniqPeer BEAObject(this,
type := "match",
+input,
pattern := this,
+mapping);
}
}
beaConcept BMatch {
new Ref pattern;
SS mapping;
}
beaConcept BMatchToScenario {
void reactWith(BMatch match) {
uniqPeer(BEAObject, this,
/*fromReaction_1 := this,
fromReaction_2 := match,*/
fromReaction := ll(this, match),
type := "scenario",
text := mapToLines(match.mapping,
(a, b) -> b + " is a " + a));
}
}
beaConcept BScenarioToOutput {
bool canReactWith(BEAObject o) {
ret o.typeIs("scenario");
}
void reactWith(BEAObject scenario) {
uniqPeer(BOutput, this,
fromReaction := ll(this, scenario),
type := "Output",
text := getString text(scenario));
}
}
cmodule2 > DynCRUD_v2 {
transient Map> beaClasses = calcBEAClasses();
start {
print(+beaClasses);
crud.tableFontSize = 20f;
crud.tableRowHeight = 30;
crud.humanizeFieldNames = false;
crud.showBackRefs = true;
crud.specialFieldsForItem = a -> {
MapSO map = litorderedmap(crud.hID, str(a.id));
S j = crud.javaClassDescForItem(a);
mapPut(map, "Class/Type", joinUniqueNemptiesCI("/", j, a.type()));
ret map;
};
thread {
uniq BMatchToScenario();
uniq BScenarioToOutput();
uniq BInput(text := "UBports community delivers 'second-largest release of Ubuntu Touch ever'");
//uniq BPattern(text := "* delivers *");
uniq BAngleVarPattern(text := " delivers ");
}
}
afterVisualize {
tablePopupMenuFirst(table(), (menu, row) -> {
BEAObject o = getItem(row);
print("Item: " + o);
if (o == null) ret;
Class extends BEAObject> targetClass = defaultCustomClass(o);
print(+targetClass);
if (targetClass != null && targetClass != _getClass(o)) pcall-short {
migrateConceptToClass(targetClass, o);
addMenuItem(menu, "Convert to " + shortName(targetClass), r {
replaceConceptAndUpdateRefs(o, migrateConceptToClass(targetClass, o));
});
}
pcall {
L partners = filter(list(BEAObject),
partner -> o.canReactWith(partner));
if (nempty(partners))
addScrollingSubMenu(menu, "React with", menu2 -> {
for (BEAObject p : partners)
addMenuItem(menu2, str(p), rThread {
call(o, 'reactWith, p);
});
});
}
});
}
// e.g. "Input" => BInput
Map> calcBEAClasses() {
ret ciMapToKeys(c -> dropPrefix("B", shortClassName(c)),
listMinusItem(BEAObject, myNonAbstractClassesImplementing(BEAObject)));
}
Class extends BEAObject> defaultCustomClass(BEAObject o) {
ret beaClasses.get(o.type());
}
A migrateConceptToClass(Class c, BEAObject in) {
A out = unlisted(c);
for (S field : conceptFields(in)) try {
continue if eq(field, "type");
cset(out, field, cget(in, field));
// TODO: check Ref types
} catch e {
fail("Can't convert field " + field, e);
}
ret out;
}
}