Java Code Examples for org.dom4j.Element.attributeValue()

The following are Jave code examples for showing how to use attributeValue() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: uflo   File: EndParser.java   View Source Code Vote up 6 votes
public Object parse(Element element,long processId,boolean parseChildren) {
	EndNode node=new EndNode();
	node.setProcessId(processId);
	parseNodeCommonInfo(element, node);
	String terminate=element.attributeValue("terminate");
	if(StringUtils.isNotEmpty(terminate)){
		node.setTerminate(Boolean.valueOf(terminate));
	}
	NodeDiagram diagram=parseDiagram(element);
	if(node.isTerminate()){
		diagram.setIcon("/icons/end-terminate.svg");
	}else{
		diagram.setIcon("/icons/end.svg");
	}
	diagram.setShapeType(ShapeType.Circle);
	diagram.setBorderWidth(1);
	node.setDiagram(diagram);
	return node;
}
 
Example 2
Project: unitimes   File: ExamConflictStatisticsInfo.java   View Source Code Vote up 6 votes
CBSVariable(Element element) {
	iExamId = Long.parseLong(element.attributeValue("exam"));
	iName = element.attributeValue("name");
	iPref = element.attributeValue("pref");
	for (Iterator i=element.elementIterator("val");i.hasNext();)
		iValues.add(new CBSValue(this,(Element)i.next())); 
}
 
Example 3
Project: atlas   File: ManifestFileUtils.java   View Source Code Vote up 6 votes
/**
 * Replace the original application in the manifest nameFor AtlasBridgeApplication
 * The original name has been written in meta-data
 */
private static void replaceManifestApplicationName(Document document) {
    // Write meta-data information
    Element root = document.getRootElement();// Get the root node
    Element applicationElement = root.element("application");
    String realApplicationClassName = applicationElement.attributeValue("name");

    if (null == realApplicationClassName) {
        realApplicationClassName = "";
    }

    applicationElement.addAttribute(StringUtils.isEmpty(realApplicationClassName) ? "android:name" : "name",
                                    "android.taobao.atlas.startup.AtlasBridgeApplication");

    Element metaData = applicationElement.addElement("meta-data");
    metaData.addAttribute("android:name", "REAL_APPLICATION");
    metaData.addAttribute("android:value", realApplicationClassName);
}
 
Example 4
Project: uflo   File: SequenceFlowParser.java   View Source Code Vote up 6 votes
public Object parse(Element element,long processId,boolean parseChildren) {
	SequenceFlowImpl flow=new SequenceFlowImpl();
	flow.setProcessId(processId);
	flow.setName(unescape(element.attributeValue("name")));
	flow.setToNode(unescape((element.attributeValue("to"))));
	String conditionType=element.attributeValue("condition-type");
	if(StringUtils.isNotEmpty(conditionType)){
		flow.setConditionType(ConditionType.valueOf(conditionType));			
		flow.setExpression(element.attributeValue("expression"));
		flow.setHandlerBean(element.attributeValue("handler-bean"));
	}
	flow.setDiagram(parseDiagram(element));
	String g=element.attributeValue("g");
	if(StringUtils.isNotBlank(g)){
		int pos=g.indexOf(":");
		if(pos>-1){
			g=g.substring(0,pos);
			g=g.replaceAll(";", ",");
		}else{
			g=null;
		}
	}
	flow.setG(g);
	return flow;
}
 
Example 5
Project: lams   File: Configuration.java   View Source Code Vote up 6 votes
private void findClassNames(String defaultPackage, Element startNode, Set<String> names) {
	// if we have some extends we need to check if those classes possibly could be inside the
	// same hbm.xml file...
	Iterator[] classes = new Iterator[4];
	classes[0] = startNode.elementIterator( "class" );
	classes[1] = startNode.elementIterator( "subclass" );
	classes[2] = startNode.elementIterator( "joined-subclass" );
	classes[3] = startNode.elementIterator( "union-subclass" );

	Iterator classIterator = new JoinedIterator( classes );
	while ( classIterator.hasNext() ) {
		Element element = ( Element ) classIterator.next();
		String entityName = element.attributeValue( "entity-name" );
		if ( entityName == null ) {
			entityName = getClassName( element.attribute( "name" ), defaultPackage );
		}
		names.add( entityName );
		findClassNames( defaultPackage, element, names );
	}
}
 
Example 6
Project: lams   File: JPAOverriddenAnnotationReader.java   View Source Code Vote up 6 votes
private static void buildQueryHints(List<Element> elements, AnnotationDescriptor ann){
	List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
	for ( Element hint : elements ) {
		AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
		String value = hint.attributeValue( "name" );
		if ( value == null ) {
			throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
		}
		hintDescriptor.setValue( "name", value );
		value = hint.attributeValue( "value" );
		if ( value == null ) {
			throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
		}
		hintDescriptor.setValue( "value", value );
		queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
	}
	ann.setValue( "hints", queryHints.toArray( new QueryHint[queryHints.size()] ) );
}
 
Example 7
Project: joai-project   File: SchemaHelper.java   View Source Code Vote up 5 votes
/**
 *  multiselect iff
 *  <ul>
 *    <li> isComplex</li>
 *    <li> hasSequenceCompositor</li>
 *    <ul>
 *      <li> containing a single multiSelect element</li>
 *    </ul>
 *
 *  </ul>
 *
 *
 * @param  schemaNode  NOT YET DOCUMENTED
 * @return             NOT YET DOCUMENTED
 */
public boolean hasMultiSelect(SchemaNode schemaNode) {
	// prtln ("\nhasMultiSelect()");
	// prtln ("schemaNode: " + schemaNode.toString());
	if (!schemaNode.isElement()) {
		return false;
	}

	GlobalDef typeDef = getGlobalDef(schemaNode);
	if (typeDef == null) {
		// prtln(" ... unable to find type def for " + schemaNode.getDataTypeName());
		return false;
	}
	if (!typeDef.isComplexType()) {
		// prtln(" ... is not complexType");
		return false;
	}

	ComplexType cType = (ComplexType) typeDef;
	if (cType.getCompositorType() == Compositor.SEQUENCE) {
		List seqNodes = cType.getElement().selectNodes(NamespaceRegistry.makeQualifiedName(cType.getXsdPrefix(), "sequence") + "/*");
		if (seqNodes.size() != 1) {
			// prtln(" ... more than one sequence elements found - returning false");
			return false;
		}

		// There is only one element contained in the sequence. If this elsment is an enumeration
		// then return true ...
		Element seqElement = (Element) seqNodes.get(0);
		String typeName = seqElement.attributeValue("type");
		return isEnumerationType(typeName);
	}
	else {
		// prtln(" ... non-sequence compositor - returning false");
		return false;
	}
}
 
Example 8
Project: urule   File: FlowDefinitionReferenceUpdater.java   View Source Code Vote up 5 votes
public boolean contain(String path, String xml) {
	try{
		Document doc=DocumentHelper.parseText(xml);
		Element element=doc.getRootElement();
		for(Object obj:element.elements()){
			if(!(obj instanceof Element)){
				continue;
			}
			Element ele=(Element)obj;
			String name=ele.getName();
			boolean match=false;
			if(name.equals("import-variable-library")){
				match=true;
			}else if(name.equals("import-constant-library")){
				match=true;
			}else if(name.equals("import-action-library")){
				match=true;
			}else if(name.equals("import-parameter-library")){
				match=true;
			}
			if(!match){
				continue;
			}
			String filePath=ele.attributeValue("path");
			if(filePath.endsWith(path)){
				return true;
			}
		}
		return false;
	}catch(Exception ex){
		throw new RuleException(ex);
	}
}
 
Example 9
Project: bdf2   File: TransitionConverter.java   View Source Code Vote up 5 votes
public JpdlInfo toJpdl(Element element) {
	BaseElement targetElement=new BaseElement("transition");
	String name=this.buildCommonJpdlElement(element, targetElement);
	String fromShapeLabel=element.attributeValue("fromShapeLabel");
	String toShapeLabel=element.attributeValue("toShapeLabel");
	targetElement.addAttribute("to", toShapeLabel);
	targetElement.addAttribute("fromShapeLabel", fromShapeLabel);
	JpdlInfo info=new JpdlInfo();
	info.setName(name);
	info.setElement(targetElement);
	return info;
}
 
Example 10
Project: unitimes   File: PreferencesImport.java   View Source Code Vote up 5 votes
protected Department lookupDepartment(Element element) {
	if (iDepartments == null)
		iDepartments = (List<Department>)getHibSession().createQuery(
     		"select distinct d from Department d left join fetch d.preferences p where d.session.uniqueId = :sessionId")
     		.setLong("sessionId", iSession.getUniqueId()).list();
	String deptCode = element.attributeValue("code", "not-set");
	for (Iterator<Department> i = iDepartments.iterator(); i.hasNext(); ) {
		Department department = i.next();
		if (deptCode.equals(department.getDeptCode())) { return department; }
	}
	warn("Department " + deptCode + " does not exist.");
	return null;
}
 
Example 11
Project: lams   File: JPAOverriddenAnnotationReader.java   View Source Code Vote up 5 votes
/**
 * Adds an @Id annotation to the specified annotationList if the specified element has the id
 * attribute set to true. This should only be the case for many-to-one or one-to-one
 * associations.
 */
private void getAssociationId(List<Annotation> annotationList, Element element) {
	String attrVal = element.attributeValue( "id" );
	if ( "true".equals( attrVal ) ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( Id.class );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example 12
Project: unitimes   File: BaseImport.java   View Source Code Vote up 5 votes
protected String getOptionalStringAttribute(Element element, String attributeName) {		
	String attributeValue = element.attributeValue(attributeName);
	if (attributeValue == null || attributeValue.trim().length() == 0){
		attributeValue = null;
	} else {
		attributeValue = attributeValue.trim().replace('\u0096', ' ').replace('\u0097', ' ');
	}						
	return(attributeValue);		
}
 
Example 13
Project: lams   File: HbmBinder.java   View Source Code Vote up 5 votes
public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	// transfer an explicitly defined entity name
	// handle the lazy attribute
	Attribute lazyNode = node.attribute( "lazy" );
	boolean lazy = lazyNode == null ?
			mappings.isDefaultLazy() :
			"true".equals( lazyNode.getValue() );
	// go ahead and set the lazy here, since pojo.proxy can override it.
	persistentClass.setLazy( lazy );

	String entityName = node.attributeValue( "entity-name" );
	if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
	if ( entityName==null ) {
		throw new MappingException( "Unable to determine entity name" );
	}
	persistentClass.setEntityName( entityName );
	persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) );

	bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
	bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
	bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );

	Iterator itr = node.elementIterator( "fetch-profile" );
	while ( itr.hasNext() ) {
		final Element profileElement = ( Element ) itr.next();
		parseFetchProfile( profileElement, mappings, entityName );
	}

	bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
}
 
Example 14
Project: unitimes   File: Suggestion.java   View Source Code Vote up 5 votes
public static BtbInstructorInfo fromXml(Element element) {
	BtbInstructorInfo s = new BtbInstructorInfo();
	if (element.element("first")!=null)
		s.iFirst = Hint.fromXml(element.element("first"));
	if (element.element("second")!=null)
		s.iSecond = Hint.fromXml(element.element("second"));
	s.iPref = Integer.parseInt(element.attributeValue("pref"));
	s.iInsturctor = element.attributeValue("instructor");
	return s;
}
 
Example 15
Project: ureport   File: DatasourceParser.java   View Source Code Vote up 5 votes
private List<Field> parseFields(Element element){
	List<Field> fields=new ArrayList<Field>();
	for(Object obj:element.elements()){
		if(obj==null || !(obj instanceof Element)){
			continue;
		}
		Element ele=(Element)obj;
		if(!ele.getName().equals("field")){
			continue;
		}
		Field field=new Field(ele.attributeValue("name"));
		fields.add(field);
	}
	return fields;
}
 
Example 16
Project: urule   File: VariableAssignActionParser.java   View Source Code Vote up 5 votes
public Action parse(Element element) {
	VariableAssignAction action=new VariableAssignAction();
	String referenceName=element.attributeValue("reference-name");
	if(StringUtils.isNotEmpty(referenceName)){
		action.setReferenceName(referenceName);
	}
	String variable=element.attributeValue("var");
	if(StringUtils.isEmpty(variable)){
		variable=element.attributeValue("property-name");
	}
	action.setVariableName(variable);
	String variableLabel=element.attributeValue("var-label");
	if(StringUtils.isEmpty(variableLabel)){
		variableLabel=element.attributeValue("property-label");
	}
	action.setVariableLabel(variableLabel);
	String variableCategory=element.attributeValue("var-category");
	action.setVariableCategory(variableCategory);
	String datatype=element.attributeValue("datatype");
	if(StringUtils.isNotEmpty(datatype)){
		action.setDatatype(Datatype.valueOf(datatype));
	}
	String type=element.attributeValue("type");
	if(StringUtils.isNotEmpty(type)){
		action.setType(LeftType.valueOf(type));
	}
	for(Object obj:element.elements()){
		if(obj==null || !(obj instanceof Element)){
			continue;
		}
		Element ele=(Element)obj;
		if(valueParser.support(ele.getName())){
			action.setValue(valueParser.parse(ele));
			break;
		}
	}
	return action;
}
 
Example 17
Project: uflo   File: TaskParser.java   View Source Code Vote up 4 votes
public Object parse(Element element,long processId,boolean parseChildren) {
	TaskNode node=new TaskNode();
	node.setProcessId(processId);
	parseNodeCommonInfo(element, node);
	node.setSequenceFlows(parseFlowElement(element,processId,parseChildren));
	String countersignMultiplicity=element.attributeValue("countersign-multiplicity");
	if(StringUtils.isNotEmpty(countersignMultiplicity)){
		node.setCountersignMultiplicity(Integer.valueOf(countersignMultiplicity));			
	}
	String countersignPercentMultiplicity=element.attributeValue("countersign-percent-multiplicity");
	if(StringUtils.isNotEmpty(countersignPercentMultiplicity)){
		node.setCountersignPercentMultiplicity(Integer.valueOf(countersignPercentMultiplicity));			
	}
	String countersignExpression=element.attributeValue("countersign-expression");
	if(StringUtils.isNotEmpty(countersignExpression)){
		node.setCountersignExpression(countersignExpression);
	}
	String countersignHandler=element.attributeValue("countersign-handler");
	if(StringUtils.isNotEmpty(countersignHandler)){
		node.setCountersignHandler(countersignHandler);
	}
	String taskListenerBean=element.attributeValue("task-listener-bean");
	if(StringUtils.isNotEmpty(taskListenerBean)){
		node.setTaskListenerBean(taskListenerBean);
	}
	node.setAssignmentType(AssignmentType.valueOf(element.attributeValue("assignment-type")));
	node.setAssignmentHandlerBean(unescape(element.attributeValue("assignment-handler-bean")));
	node.setSwimlane(unescape(element.attributeValue("swimlane")));
	node.setExpression(unescape(element.attributeValue("expression")));
	if(node.getAssignmentType().equals(AssignmentType.Assignee)){
		node.setAssignees(parserAssignees(element));
	}
	
	String allowSpecifyAssigne=element.attributeValue("allow-specify-assignee");
	if(StringUtils.isNotEmpty(allowSpecifyAssigne)){
		node.setAllowSpecifyAssignee(Boolean.valueOf(allowSpecifyAssigne));
	}
	String taskType=element.attributeValue("task-type");
	if(StringUtils.isNotEmpty(taskType)){
		node.setTaskType(TaskType.valueOf(taskType));			
	}
	node.setUrl(unescape(element.attributeValue("url")));
	node.setFormTemplate(unescape(element.attributeValue("form-template")));
	node.setTaskName(unescape(element.attributeValue("task-name")));
	node.setComponentAuthorities(parseComponentAuthorities(element));
	node.setDueDefinition(parseDueDefinition(element));
	node.setFormElements(parseFormElements(element));
	node.setUserData(parseUserData(element));
	NodeDiagram diagram=parseDiagram(element);
	if(TaskType.Countersign.equals(node.getTaskType())){
		diagram.setIcon("/icons/task-countersign.svg");						
	}else{
		diagram.setIcon("/icons/task.svg");			
	}
	diagram.setShapeType(ShapeType.Rectangle);
	diagram.setBorderWidth(1);
	diagram.setBorderColor("3, 104, 154");
	diagram.setBackgroundColor("250, 250, 250");
	node.setDiagram(diagram);
	return node;
}
 
Example 18
Project: unitimes   File: ImportPreferences.java   View Source Code Vote up 4 votes
public void importSchedulingSubpartStructure(Element element,SchedulingSubpart parent,InstrOfferingConfig cfg,Hashtable classTable) {
	ClassHash subpartHash = new ClassHash(
			cfg.getControllingCourseOffering().getSubjectAreaAbbv(),
			cfg.getControllingCourseOffering().getCourseNbr(),
			element.attributeValue("itype"), -1, element.attributeValue("suffix"));
	SchedulingSubpart subpart = (SchedulingSubpart)iAllSubparts.get(subpartHash);
	if (subpart==null) {
		subpart = new SchedulingSubpart();
		subpart.setItype(
				(ItypeDesc)hibSession.
				createQuery("select i from ItypeDesc i where i.abbv=:abbv").
				setString("abbv", element.attributeValue("itype")).
				uniqueResult());
		subpart.setParentSubpart(parent);
		subpart.setInstrOfferingConfig(cfg);
		subpart.setMinutesPerWk(Integer.valueOf(element.attributeValue("minutesPerWk")));
		hibSession.save(subpart);
		iAllSubparts.put(subpartHash,subpart);
		sLog.info("  -- subpart "+subpartHash+" imported");
		hibSession.flush();
		hibSession.refresh(subpart);
	}
	for (Iterator i=element.elementIterator("class");i.hasNext();) {
		Element x = (Element)i.next();
		ClassHash clazzHash = new ClassHash(
				cfg.getControllingCourseOffering().getSubjectAreaAbbv(),
				cfg.getControllingCourseOffering().getCourseNbr(),
				subpart.getItypeDesc(),
				Integer.parseInt(x.attributeValue("sectionNumber")),
				element.attributeValue("suffix"));
		Class_ clazz = (Class_)iAllClasses.get(clazzHash);
		if (clazz==null) {
			clazz = new Class_();
			clazz.setSchedulingSubpart(subpart);
			clazz.setCancelled(false);
			if (x.attributeValue("manager")!=null) {
				clazz.setManagingDept(getDepartment(x.attributeValue("manager")));
			}
			int expectedCapacity = Integer.parseInt(x.attributeValue("expectedCapacity"));
			int maxExpectedCapacity = expectedCapacity;
			int numberOfRooms = Integer.parseInt(x.attributeValue("nbrRooms"));
			float roomRatio = 1.0f;
			if (x.attributeValue("roomRatio")!=null) {
				roomRatio = Float.parseFloat(x.attributeValue("roomRatio"));
				maxExpectedCapacity = Integer.parseInt(x.attributeValue("maxExpectedCapacity"));
			} else {
				int roomCapacity = Integer.parseInt(x.attributeValue("roomCapacity"));
				if (expectedCapacity==0) {
					roomRatio = 0.0f;
					expectedCapacity = roomCapacity;
				} else {
					roomRatio = ((float)roomCapacity)/expectedCapacity;
				}
			}
			clazz.setExpectedCapacity(new Integer(expectedCapacity));
			clazz.setMaxExpectedCapacity(new Integer(maxExpectedCapacity));
			clazz.setRoomRatio(new Float(roomRatio));
			clazz.setNbrRooms(new Integer(numberOfRooms));
			clazz.setDisplayInstructor(Boolean.TRUE);
			clazz.setEnabledForStudentScheduling(Boolean.TRUE);
			if (x.attributeValue("parent")!=null)
				clazz.setParentClass((Class_)classTable.get(Long.valueOf(x.attributeValue("parent"))));
			hibSession.save(clazz);
			hibSession.flush();
			hibSession.refresh(clazz);
			sLog.info("    -- class "+clazzHash+" imported");
			iAllClasses.put(clazzHash, clazz);
		}
		classTable.put(Long.valueOf(x.attributeValue("uniqueId")),clazz);
	}
	
	for (Iterator i=element.elementIterator("schedulingSubpart");i.hasNext();)
		importSchedulingSubpartStructure((Element)i.next(),subpart,cfg,classTable);
}
 
Example 19
Project: parabuild-ci   File: Binder.java   View Source Code Vote up 4 votes
protected static void propertiesFromXML(Element node, PersistentClass model, Mappings mappings) throws MappingException {

		Table table = model.getTable();

		Iterator iter = node.elementIterator();
		while( iter.hasNext() ) {
			Element subnode = (Element) iter.next();
			String name = subnode.getName();
			String propertyName = subnode.attributeValue("name");

			CollectionType collectType = CollectionType.collectionTypeFromString(name);
			Value value = null;
			if (collectType!=null) {
				Collection collection = collectType.create(subnode, model.getName(), propertyName, model, mappings);
				mappings.addCollection(collection);
				value = collection;
			}
			else if ( "many-to-one".equals(name) ) {
				value = new ManyToOne(table);
				bindManyToOne(subnode, (ManyToOne) value, propertyName, true, mappings);
			}
			else if ( "any".equals(name) ) {
				value = new Any(table);
				bindAny(subnode, (Any) value, true, mappings);
			}
			else if ( "one-to-one".equals(name) ) {
				OneToOne oneToOne = new OneToOne( table, model.getIdentifier() );
				bindOneToOne(subnode, oneToOne, true, mappings);
				value = oneToOne;
			}
			else if ( "property".equals(name) ) {
				value = new SimpleValue(table);
				bindSimpleValue(subnode, (SimpleValue) value, true, propertyName, mappings);
			}
			else if ( "component".equals(name) || "dynamic-component".equals(name) ) {
				Class reflectedClass = ReflectHelper.reflectedPropertyClass( model.getMappedClass(), propertyName );
				value = new Component(model);
				bindComponent(subnode, (Component) value, reflectedClass, model.getName(), propertyName, true, mappings);
			}
			else if ( "subclass".equals(name) ) {
				handleSubclass(model, mappings, subnode);
			}
			else if ( "joined-subclass".equals(name) ) {
				handleJoinedSubclass(model, mappings, subnode);
			}
			
			if ( value!=null) model.addNewProperty( createProperty(value, propertyName, model.getMappedClass(), subnode, mappings) );
		}
	}
 
Example 20
Project: joai-project   File: ComplexType.java   View Source Code Vote up 2 votes
/**
 *  Gets the name of the restriction base type for complex types that derive by
 *  restriction.
 *
 * @return    The restrictionBase value or null if not found.
 */
public String getRestrictionBase() {
	Element extn = getRestrictionElement();
	return (extn == null ? null : extn.attributeValue("base"));
}