code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected static synchronized void registerAllowedParentClass(Class<? extends ElementBase> clazz,
Class<? extends ElementBase> parentClass) {
allowedParentClasses.addCardinality(clazz, parentClass, 1);
} | java |
protected static synchronized void registerAllowedChildClass(Class<? extends ElementBase> clazz,
Class<? extends ElementBase> childClass,
int maxOccurrences) {
allowedChildClasses.ad... | java |
public static boolean canAcceptChild(Class<? extends ElementBase> parentClass, Class<? extends ElementBase> childClass) {
return allowedChildClasses.isRelated(parentClass, childClass);
} | java |
public static boolean canAcceptParent(Class<? extends ElementBase> childClass,
Class<? extends ElementBase> parentClass) {
return allowedParentClasses.isRelated(childClass, parentClass);
} | java |
protected void addChild(ElementBase child, boolean doEvent) {
if (!child.canAcceptParent(this)) {
CWFException.raise(child.rejectReason);
}
if (!canAcceptChild(child)) {
CWFException.raise(rejectReason);
}
if (doEvent) {
befor... | java |
public void removeChild(ElementBase child, boolean destroy) {
if (!children.contains(child)) {
return;
}
boolean isLocked = child.isLocked() || child.getDefinition().isInternal();
if (destroy) {
child.removeChildren();
if... | java |
private void updateParent(ElementBase newParent) {
ElementBase oldParent = this.parent;
if (oldParent != newParent) {
beforeParentChanged(newParent);
this.parent = newParent;
if (oldParent != null) {
oldParent.updateState();
... | java |
public void removeChildren() {
for (int i = children.size() - 1; i >= 0; i--) {
removeChild(children.get(i), true);
}
} | java |
public void setDefinition(PluginDefinition definition) {
if (this.definition != null) {
if (this.definition == definition) {
return;
}
CWFException.raise("Cannot modify plugin definition.");
}
this.definition = definition;... | java |
public void setDesignMode(boolean designMode) {
this.designMode = designMode;
for (ElementBase child : children) {
child.setDesignMode(designMode);
}
updateState();
} | java |
public void editProperties() {
try {
PropertyGrid.create(this, null);
} catch (Exception e) {
DialogUtil.showError("Displaying property grid: \r\n" + e.toString());
}
} | java |
@SuppressWarnings("unchecked")
public <T extends ElementBase> T getChild(Class<T> clazz, ElementBase last) {
int i = last == null ? -1 : children.indexOf(last);
for (i++; i < children.size(); i++) {
if (clazz.isInstance(children.get(i))) {
return (T) children.get... | java |
public <T extends ElementBase> Iterable<T> getChildren(Class<T> clazz) {
return MiscUtil.iterableForType(children, clazz);
} | java |
public int getChildCount(Class<? extends ElementBase> clazz) {
if (clazz == ElementBase.class) {
return getChildCount();
}
int count = 0;
for (ElementBase child : children) {
if (clazz.isInstance(child)) {
count++;
}
... | java |
@SuppressWarnings("unchecked")
public <T extends ElementBase> T findChildElement(Class<T> clazz) {
for (ElementBase child : getChildren()) {
if (clazz.isInstance(child)) {
return (T) child;
}
}
for (ElementBase child : getChildren()) {
... | java |
public boolean hasAncestor(ElementBase element) {
ElementBase child = this;
while (child != null) {
if (element.hasChild(child)) {
return true;
}
child = child.getParent();
}
return false;
} | java |
public void moveChild(int from, int to) {
if (from != to) {
ElementBase child = children.get(from);
ElementBase ref = children.get(to);
children.remove(from);
to = children.indexOf(ref);
children.add(to, child);
afterMoveChild(child, ref);
... | java |
public void setIndex(int index) {
ElementBase parent = getParent();
if (parent == null) {
CWFException.raise("Element has no parent.");
}
int currentIndex = parent.children.indexOf(this);
if (currentIndex < 0 || currentIndex == index) {
... | java |
protected void moveChild(BaseUIComponent child, BaseUIComponent before) {
child.getParent().addChild(child, before);
} | java |
public boolean canAcceptChild() {
if (maxChildren == 0) {
rejectReason = getDisplayName() + " does not accept any children.";
} else if (getChildCount() >= maxChildren) {
rejectReason = "Maximum child count exceeded for " + getDisplayName() + ".";
} else {
rej... | java |
public boolean canAcceptChild(Class<? extends ElementBase> childClass) {
if (!canAcceptChild()) {
return false;
}
Cardinality cardinality = allowedChildClasses.getCardinality(getClass(), childClass);
int max = cardinality.getMaxOccurrences();
if (max == 0) {... | java |
public boolean canAcceptParent(Class<? extends ElementBase> clazz) {
if (!canAcceptParent(getClass(), clazz)) {
rejectReason = getDisplayName() + " does not accept " + clazz.getSimpleName() + " as a parent.";
} else {
rejectReason = null;
}
return rejectR... | java |
public boolean canAcceptParent(ElementBase parent) {
if (!canAcceptParent()) {
return false;
}
if (!canAcceptParent(getClass(), parent.getClass())) {
rejectReason = getDisplayName() + " does not accept " + parent.getDisplayName() + " as a parent.";
} else... | java |
public ElementBase getRoot() {
ElementBase root = this;
while (root.getParent() != null) {
root = root.getParent();
}
return root;
} | java |
@SuppressWarnings("unchecked")
public <T extends ElementBase> T getAncestor(Class<T> clazz) {
ElementBase parent = getParent();
while (parent != null && !clazz.isInstance(parent)) {
parent = parent.getParent();
}
return (T) parent;
} | java |
private void processResources(boolean register) {
CareWebShell shell = CareWebUtil.getShell();
for (IPluginResource resource : getDefinition().getResources()) {
resource.register(shell, this, register);
}
} | java |
public void notifyParent(String eventName, Object eventData, boolean recurse) {
ElementBase ele = parent;
while (ele != null) {
recurse &= ele.parentListeners.notify(this, eventName, eventData);
ele = recurse ? ele.parent : null;
}
} | java |
public void notifyChildren(String eventName, Object eventData, boolean recurse) {
notifyChildren(this, eventName, eventData, recurse);
} | java |
private static IInfoPanel searchChildren(ElementBase parent, ElementBase exclude, boolean activeOnly) {
IInfoPanel infoPanel = null;
if (parent != null) {
for (ElementBase child : parent.getChildren()) {
if ((child != exclude) && ((infoPanel = getInfoPanel(child, act... | java |
private static IInfoPanel getInfoPanel(ElementBase element, boolean activeOnly) {
if (element instanceof ElementPlugin) {
ElementPlugin plugin = (ElementPlugin) element;
if ((!activeOnly || plugin.isActivated()) && (plugin.getDefinition().getId().equals("infoPanelPlugin"))) ... | java |
public static void associateEvent(BaseComponent component, String eventName, Action action) {
getActionListeners(component, true).add(new ActionListener(eventName, action));
} | java |
private static List<ActionListener> getActionListeners(BaseComponent component, boolean forceCreate) {
@SuppressWarnings("unchecked")
List<ActionListener> ActionListeners = (List<ActionListener>) component.getAttribute(EVENT_LISTENER_ATTR);
if (ActionListeners == null && forceCreate) {
... | java |
@Override
public boolean validate(XmlObject formObject, List<AuditError> errors, String formName) {
final List<String> formErrors = new ArrayList<>();
final boolean result = validateXml(formObject, formErrors);
errors.addAll(formErrors.stream()
.map(validationError -> s2SEr... | java |
public Map<String, Long> resetRetryCounter() {
Map<String, Long> result = retryCounter.asMap();
retryCounter.clear();
return result;
} | java |
protected boolean _queueWithRetries(Connection conn, IQueueMessage<ID, DATA> msg,
int numRetries, int maxRetries) {
try {
Date now = new Date();
msg.setNumRequeues(0).setQueueTimestamp(now).setTimestamp(now);
return putToQueueStorage(conn, msg);
} catch (D... | java |
protected boolean _requeueWithRetries(Connection conn, IQueueMessage<ID, DATA> msg,
int numRetries, int maxRetries) {
try {
jdbcHelper.startTransaction(conn);
conn.setTransactionIsolation(transactionIsolationLevel);
if (!isEphemeralDisabled()) {
re... | java |
protected void _finishWithRetries(Connection conn, IQueueMessage<ID, DATA> msg, int numRetries,
int maxRetries) {
try {
if (!isEphemeralDisabled()) {
removeFromEphemeralStorage(conn, msg);
}
} catch (DaoException de) {
if (de.getCause() ins... | java |
protected IQueueMessage<ID, DATA> _takeWithRetries(Connection conn, int numRetries,
int maxRetries) {
try {
jdbcHelper.startTransaction(conn);
conn.setTransactionIsolation(transactionIsolationLevel);
boolean result = true;
IQueueMessage<ID, DATA> msg ... | java |
private void setQuestionnareAnswerForResearchTrainingPlan(
ResearchTrainingPlan researchTrainingPlan) {
researchTrainingPlan.setHumanSubjectsIndefinite(YesNoDataType.N_NO);
researchTrainingPlan.setVertebrateAnimalsIndefinite(YesNoDataType.N_NO);
researchTrainingPlan.setHumanSubjectsIndefinite(Ye... | java |
private String transformKey(String key, String src, String tgt) {
StringBuilder sb = new StringBuilder();
String[] srcTokens = src.split(WILDCARD_DELIM_REGEX);
String[] tgtTokens = tgt.split(WILDCARD_DELIM_REGEX);
int len = Math.max(srcTokens.length, tgtTokens.length);
int pos = ... | java |
@Override
protected void afterMoveChild(ElementBase child, ElementBase before) {
ElementTreePane childpane = (ElementTreePane) child;
ElementTreePane beforepane = (ElementTreePane) before;
moveChild(childpane.getNode(), beforepane.getNode());
} | java |
public void setSelectionStyle(ThemeUtil.ButtonStyle selectionStyle) {
if (activePane != null) {
activePane.updateSelectionStyle(this.selectionStyle, selectionStyle);
}
this.selectionStyle = selectionStyle;
} | java |
@Override
protected void afterRemoveChild(ElementBase child) {
if (child == activePane) {
setActivePane((ElementTreePane) getFirstChild());
}
super.afterRemoveChild(child);
} | java |
@Override
public void activateChildren(boolean activate) {
if (activePane == null || !activePane.isVisible()) {
ElementBase active = getFirstVisibleChild();
setActivePane((ElementTreePane) active);
}
if (activePane != null) {
activePane.activate(a... | java |
protected void setActivePane(ElementTreePane pane) {
if (pane == activePane) {
return;
}
if (activePane != null) {
activePane.makeActivePane(false);
}
activePane = pane;
if (activePane != null) {
activePane.ma... | java |
@Override
public AliasType get(String key) {
key = key.toUpperCase();
AliasType type = super.get(key);
if (type == null) {
register(type = new AliasType(key));
}
return type;
} | java |
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (StringUtils.isEmpty(propertyFile)) {
return;
}
for (String pf : propertyFile.split("\\,")) {
loadAliases(applicationContext, pf);
}
if (fil... | java |
private void loadAliases(ApplicationContext applicationContext, String propertyFile) {
if (propertyFile.isEmpty()) {
return;
}
Resource[] resources;
try {
resources = applicationContext.getResources(propertyFile);
} catch (IOException e) {
lo... | java |
private void register(String key, String alias) {
String[] pcs = key.split(PREFIX_DELIM_REGEX, 2);
if (pcs.length != 2) {
throw new IllegalArgumentException("Illegal key value: " + key);
}
register(pcs[0], pcs[1], alias);
} | java |
public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> Comparator<Pair<T1, T2>> naturalOrder() {
return new Comparator<Pair<T1,T2>>() {
@Override
public int compare(Pair<T1, T2> lhs, Pair<T1, T2> rhs) {
return compareTo(lhs, rhs);
}
};
... | java |
protected AttachedFileDataType[] getAppendixAttachedFileDataTypes() {
return pdDoc.getDevelopmentProposal().getNarratives().stream()
.filter(narrative -> narrative.getNarrativeType().getCode() != null && Integer.parseInt(narrative.getNarrativeType().getCode()) == APPENDIX)
.map(t... | java |
public Document nodeToDom(org.w3c.dom.Node node) throws S2SException {
try {
javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer xf = tf.newTransformer();
javax.xml.transform.dom.DOMResult dr = new ... | java |
public Document stringToDom(String xmlSource) throws S2SException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new Input... | java |
public String docToString(Document node) throws S2SException {
try {
DOMSource domSource = new DOMSource(node);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
... | java |
protected void addSubAwdAttachments(BudgetSubAwardsContract budgetSubAwards) {
List<? extends BudgetSubAwardAttachmentContract> subAwardAttachments = budgetSubAwards.getBudgetSubAwardAttachments();
for (BudgetSubAwardAttachmentContract budgetSubAwardAttachment : subAwardAttachments) {
Attach... | java |
@SuppressWarnings("unchecked")
private List<BudgetSubAwardsContract> findBudgetSubawards(String namespace, BudgetContract budget,boolean checkNull) {
List<BudgetSubAwardsContract> budgetSubAwardsList = new ArrayList<>();
for (BudgetSubAwardsContract subAwards : budget.getBudgetSubAwards()) {
... | java |
public static PerformanceMetrics createNew(String action, String descriptor, String correlationId) {
return new PerformanceMetrics(KEY_GEN.getAndIncrement(), 0, action, null, descriptor, correlationId);
} | java |
public Action0 getStartAction() {
return new Action0() {
@Override
public void call() {
if (startTime == null) {
startTime = new Date().getTime();
}
}
};
} | java |
public static Path createTempFolder(String prefix) throws IOException {
Path parent = Paths.get(System.getProperty("java.io.tmpdir"));
if (!Files.isDirectory(parent)) {
throw new IOException("java.io.tmpdir points to a non-existing folder: " + parent);
}
Path ret = null;
int i = 0;
do {
ret = parent.r... | java |
public static void deleteRecursive(Path start, boolean deleteStart) throws IOException {
Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
... | java |
@Override
public void afterInitialized(BaseComponent comp) {
super.afterInitialized(comp);
propertyGrid = PropertyGrid.create(null, comp, true);
getPlugin().registerProperties(this, "provider", "group");
} | java |
public void setProvider(String beanId) {
provider = getAppContext().getBean(beanId, ISettingsProvider.class);
providerBeanId = beanId;
init();
} | java |
private void init() {
if (provider != null) {
propertyGrid.setTarget(StringUtils.isEmpty(groupId) ? null : new Settings(groupId, provider));
}
} | java |
private void addCollectionProviderFixtureType(Class<?> clazz, List<FixtureType> listFixtureType, Set<Method> methods) {
for (Method method : methods) {
if (Collection.class.isAssignableFrom(method.getReturnType())) {
FixtureType fixtureType = new FixtureType();
if (m... | java |
public void unbind(BaseUIComponent component) {
if (componentBindings.remove(component)) {
keyEventListener.registerComponent(component, false);
CommandUtil.updateShortcuts(component, shortcutBindings, true);
setCommandTarget(component, null);
}
} | java |
private void shortcutChanged(String shortcut, boolean unbind) {
Set<String> bindings = new HashSet<>();
bindings.add(shortcut);
for (BaseUIComponent component : componentBindings) {
CommandUtil.updateShortcuts(component, bindings, unbind);
}
} | java |
private void setCommandTarget(BaseComponent component, BaseComponent commandTarget) {
if (commandTarget == null) {
commandTarget = (BaseComponent) component.removeAttribute(getTargetAttributeName());
if (commandTarget != null && commandTarget.hasAttribute(ATTR_DUMMY)) {
... | java |
private BaseComponent getCommandTarget(BaseComponent component) {
BaseComponent commandTarget = (BaseComponent) component.getAttribute(getTargetAttributeName());
return commandTarget == null ? component : commandTarget;
} | java |
public static String getLocalizedId(String id, Locale locale) {
String locstr = locale == null ? "" : ("_" + locale.toString());
return id + locstr;
} | java |
public static String computeAttachmentHash(byte[] attachment) {
byte[] rawDigest = MESSAGE_DIGESTER.digest(attachment);
return Base64.encode(rawDigest);
} | java |
@SuppressWarnings("unchecked")
@VisibleForTesting
Map<String, Class<? extends Service>> mapEventSources() throws IOException {
/* Obtains all classpath's top level classes */
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Set<ClassPath.ClassInfo> classes = Cla... | java |
public static String getClientId(Connection connection) {
String clientId = null;
try {
clientId = connection == null ? null : connection.getClientID();
} catch (JMSException e) {}
return clientId;
} | java |
public static String getMessageSelector(String eventName, IPublisherInfo publisherInfo) {
StringBuilder sb = new StringBuilder(
"(JMSType='" + eventName + "' OR JMSType LIKE '" + eventName + ".%') AND (Recipients IS NULL");
if (publisherInfo != null) {
for (String se... | java |
private static void addRecipientSelector(String value, StringBuilder sb) {
if (value != null) {
sb.append(" OR Recipients LIKE '%,").append(value).append(",%'");
}
} | java |
private HttpHandler getAggregationHandler() throws ServletException {
DeploymentInfo deploymentInfo = Servlets
.deployment()
.setClassLoader(JashingServer.class.getClassLoader())
.setContextPath("/")
.setDeploymentName("jashing")
.a... | java |
public static String[] loadLibFiles(String fileSuffix, String... libAbsoluteClassPaths) {
Set<String> failedDllPaths = new HashSet<String>();
for (String libAbsoluteClassPath : libAbsoluteClassPaths) {
String libraryName = libAbsoluteClassPath
.substring(libAbsoluteCl... | java |
public Cardinalities getCardinalities(Class<? extends ElementBase> sourceClass) {
Class<?> clazz = sourceClass;
Cardinalities cardinalities = null;
while (cardinalities == null && clazz != null) {
cardinalities = map.get(clazz);
clazz = clazz == ElementBase.class... | java |
private Cardinalities getOrCreateCardinalities(Class<? extends ElementBase> sourceClass) {
Cardinalities cardinalities = map.get(sourceClass);
if (cardinalities == null) {
map.put(sourceClass, cardinalities = new Cardinalities());
}
return cardinalities;
... | java |
public void addCardinality(Class<? extends ElementBase> sourceClass, Class<? extends ElementBase> targetClass,
int maxOccurrences) {
Cardinality cardinality = new Cardinality(sourceClass, targetClass, maxOccurrences);
getOrCreateCardinalities(sourceClass).addCardinality(ca... | java |
public int getTotalCardinality(Class<? extends ElementBase> sourceClass) {
Cardinalities cardinalities = getCardinalities(sourceClass);
return cardinalities == null ? 0 : cardinalities.total;
} | java |
public boolean isRelated(Class<? extends ElementBase> sourceClass, Class<? extends ElementBase> targetClass) {
return getCardinality(sourceClass, targetClass).maxOccurrences > 0;
} | java |
public Cardinality getCardinality(Class<? extends ElementBase> sourceClass, Class<? extends ElementBase> targetClass) {
Cardinalities cardinalities = getCardinalities(sourceClass);
Cardinality cardinality = cardinalities == null ? null : cardinalities.getCardinality(targetClass);
return cardinal... | java |
@Override
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
if (this.appContext != null) {
throw new ApplicationContextException("Attempt to reinitialize application context.");
}
this.appContext = appContext;
} | java |
public synchronized boolean unregisterObject(Object object) {
int i = MiscUtil.indexOfInstance(registeredObjects, object);
if (i > -1) {
registeredObjects.remove(i);
for (IRegisterEvent onRegister : onRegisterList) {
onRegister.unregisterObje... | java |
public synchronized Object findObject(Class<?> clazz, Object previousInstance) {
int i = previousInstance == null ? -1 : MiscUtil.indexOfInstance(registeredObjects, previousInstance);
for (i++; i < registeredObjects.size(); i++) {
Object object = registeredObjects.get(i);
... | java |
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
registerObject(bean);
return bean;
} | java |
@Override
public void afterInitialize(boolean deserializing) throws Exception {
super.afterInitialize(deserializing);
if (linked) {
internalDeserialize(false);
}
initializing = false;
} | java |
private void internalDeserialize(boolean forced) {
if (!forced && loaded) {
return;
}
lockDescendants(false);
removeChildren();
loaded = true;
try {
if (linked) {
checkForCircularReference();
}
... | java |
private void checkForCircularReference() {
ElementLayout layout = this;
while ((layout = layout.getAncestor(ElementLayout.class)) != null) {
if (layout.linked && layout.shared == shared && layout.layoutName.equals(layoutName)) {
CWFException.raise("Circular reference... | java |
private void lockDescendants(Iterable<ElementBase> children, boolean lock) {
for (ElementBase child : children) {
child.setLocked(lock);
lockDescendants(child.getChildren(), lock);
}
} | java |
public void setLinked(boolean linked) {
if (linked != this.linked) {
this.linked = linked;
if (!initializing) {
internalDeserialize(true);
getRoot().activate(true);
}
}
} | java |
public static BigDecimal getSelfConfigDecimal(String configAbsoluteClassPath, IConfigKey key) {
OneProperties configs = otherConfigs.get(configAbsoluteClassPath);
if (configs == null) {
addSelfConfigs(configAbsoluteClassPath, null);
configs = otherConfigs.get(configAbsoluteCl... | java |
public static boolean isHavePathSelfConfig(IConfigKeyWithPath key) {
String configAbsoluteClassPath = key.getConfigPath();
return isSelfConfig(configAbsoluteClassPath, key);
} | java |
public static void modifySystemConfig(IConfigKey key, String value) throws IOException {
systemConfigs.modifyConfig(key, value);
} | java |
private void hostSubscribe(String eventName, boolean subscribe) {
if (globalEventDispatcher != null) {
try {
globalEventDispatcher.subscribeRemoteEvent(eventName, subscribe);
} catch (Throwable e) {
log.error(
"Error " + (subscribe ? "s... | java |
public AbstractQueueFactory<T, ID, DATA> setDefaultObserver(
IQueueObserver<ID, DATA> defaultObserver) {
this.defaultObserver = defaultObserver;
return this;
} | java |
protected void initQueue(T queue, QueueSpec spec) throws Exception {
queue.setObserver(defaultObserver);
queue.init();
} | java |
protected T createAndInitQueue(QueueSpec spec) throws Exception {
T queue = createQueueInstance(spec);
queue.setQueueName(spec.name);
initQueue(queue, spec);
return queue;
} | java |
private BudgetYear1DataType getBudgetYear1DataType(
BudgetPeriodDto periodInfo) {
BudgetYear1DataType budgetYear = BudgetYear1DataType.Factory
.newInstance();
budgetYear.setBudgetPeriodStartDate(s2SDateTimeService
.convertDateToCalendar(periodInfo.getStartDate()));
budgetYear.setBudgetPeriodEndDate(s2... | java |
private BudgetSummary getBudgetSummary(BudgetSummaryDto budgetSummaryData) {
BudgetSummary budgetSummary = BudgetSummary.Factory.newInstance();
// Set default values for mandatory fields
budgetSummary
.setCumulativeTotalFundsRequestedSeniorKeyPerson(BigDecimal.ZERO);
budgetSummary
.setCumulativeTotalFu... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.