Warning: session_start(): open(/var/lib/php/sessions/sess_duj515d3td82bnfmegmnp9hjgc, 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
beaConcept BInput {
S text;
toString { ret "[\*id*/] Input " + quote(text); }
}
beaConcept BPattern {
S pattern;
toString { ret "[\*id*/] " + shortDynName(this) + " " + quote(pattern); }
void reactWith(BInput input) {}
}
beaConcept BStarPattern > BPattern {
void reactWith(BInput input) {
LS mapping = matchesToStringList(flexMatchIC_first(pattern, 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(pattern, 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,
type := "scenario",
text := mapToLines(match.mapping,
(a, b) -> b + " is a " + a));
}
}
cmodule2 > DynCRUD_v2 {
transient Map> beaClasses = calcBEAClasses();
start {
print(+beaClasses);
crud.humanizeFieldNames = false;
crud.showBackRefs = true;
crud.specialFieldsForItem = a -> {
MapSO map = litorderedmap(crud.hID, str(a.id));
S j = crud.javaClassDescForItem(a);
S type = getStringOpt type(a);
mapPut(map, "Class/Type", joinUniqueNemptiesCI("/", j, type));
ret map;
};
thread {
uniq BInput(text := "UBports community delivers 'second-largest release of Ubuntu Touch ever'");
//uniq BPattern(pattern := "* delivers *");
uniq BAngleVarPattern(pattern := " delivers ");
reactAll();
}
}
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)) ret;
pcall-short {
migrateConceptToClass(targetClass, o);
addMenuItem(menu, "Convert to " + shortName(targetClass), r {
BEAObject converted = migrateConceptToClass(targetClass, o);
/*registerConcept(converted);
cset(converted, _convertedFrom := o);
cset(o, _convertedTo := converted);*/
replaceConceptAndUpdateRefs(o, converted);
});
}
});
}
void reactAll {
for (BPattern p)
for (BInput i) pcall {
p.reactWith(i);
}
}
// e.g. "Input" => BInput
Map> calcBEAClasses() {
ret ciMapToKeys(c -> dropPrefix("B", shortClassName(c)),
listMinusItem(BEAObject, myNonAbstractClassesImplementing(BEAObject)));
}
Class extends BEAObject> defaultCustomClass(BEAObject o) {
S type = getStringOpt type(o);
ret beaClasses.get(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;
}
}