leaf-analysis/src/simulation/ModelSpec.java
/**
     * Applies the input constraints BBM to the model spec.
     * Note: Can only be executed after all intentions, relationship, 
     * and function have been establish, then apply constraints.
     * @param constraints 	list of input constraint objects
     */
Applies the input constraints BBM to the model spec.
Note: Can only be executed after all intentions, relationship,
and function have been establish, then apply constraints.
@param constraints       list of input constraint objects
Applies the input constraints BBM to the model spec . Note : Can only be executed after all intentions relationship and function have been establish then apply constraints . @param constraints list of input constraint objects
public void applyConstraints(BIConstraint[] constraints){
    	List<BIConstraint> equalList = new ArrayList<BIConstraint>();
    	List<BIConstraint> lessThanList = new ArrayList<BIConstraint>();
    	for (BIConstraint item : constraints) {
    		if (item.getType().equals("=") || item.getType().equals("eq"))
    			equalList.add(item);
    		else {
    			lessThanList.add(item);
    		}   		
    	}
    	for (BIConstraint item : equalList) {    		
    		AbstractElement refEle1 = this.getElementByUniqueID(item.getSrcID());
    		AbstractElement refEle2 = this.getElementByUniqueID(item.getDestID());
			String refTP1 = this.getRefTP(refEle1, item.getSrcRefTP());
			String refTP2 = this.getRefTP(refEle2, item.getDestRefTP());			
			String mergeTP = refTP1 + "-" + refTP2;
			if (!changedTPNames.containsValue(refTP1)) {
				if (this.updateRefTP(refEle1, refTP1, mergeTP)) {
					this.changedTPElements.put(refTP1, refEle1);
					this.changedTPNames.put(refTP1, mergeTP);
				}else
					throw new RuntimeException(); 
			}else {
				List<String> affectedKeys = new ArrayList<String>();
				for	(Map.Entry<String,String> entry : changedTPNames.entrySet()) {
					if (entry.getValue().equals(refTP1)) 
						affectedKeys.add(entry.getKey());
				}
				for	(String key : affectedKeys) {
					if (this.updateRefTP(this.changedTPElements.get(key), this.changedTPNames.get(key), mergeTP)) {
						this.changedTPNames.put(key, mergeTP);
					}else
						throw new RuntimeException(); 
				}
			}
			if (!changedTPNames.containsValue(refTP2)) {
				if (this.updateRefTP(refEle2, refTP2, mergeTP)) {
					this.changedTPElements.put(refTP2, refEle2);
					this.changedTPNames.put(refTP2, mergeTP);
				}else
					throw new RuntimeException(); 
			}else {
				List<String> affectedKeys = new ArrayList<String>();
				for	(Map.Entry<String,String> entry : changedTPNames.entrySet()) {
					if (entry.getValue().equals(refTP2)) 
						affectedKeys.add(entry.getKey());
				}
				for	(String key : affectedKeys) {
					if (this.updateRefTP(this.changedTPElements.get(key), this.changedTPNames.get(key), mergeTP)) {
						this.changedTPNames.put(key, mergeTP);
					}else
						throw new RuntimeException(); 
				}
			}
    	}
    	for (BIConstraint item : lessThanList) {  
    		AbstractElement refEle1 = this.getElementByUniqueID(item.getSrcID());
    		AbstractElement refEle2 = this.getElementByUniqueID(item.getDestID());
			String refTP1 = this.getRefTP(refEle1, item.getSrcRefTP());
			String refTP2 = this.getRefTP(refEle2, item.getDestRefTP());
			if (refTP1 == null || refTP2 == null)
				throw new RuntimeException();  
			if (changedTPNames.containsKey(refTP1)) 
				refTP1 = changedTPNames.get(refTP1);
			if (changedTPNames.containsKey(refTP2)) 
				refTP2 = changedTPNames.get(refTP2);
			this.ltTPconstraints.add(new TPConstraint(refTP1, refTP2));
    	}
    }
public void applyConstraints ( BIConstraint [ ] constraints ) { List < BIConstraint > equalList = new ArrayList < BIConstraint > ( ) ; List < BIConstraint > lessThanList = new ArrayList < BIConstraint > ( ) ; for ( BIConstraint item : constraints ) { if ( item . getType ( ) . equals ( "=" ) || item . getType ( ) . equals ( "eq" ) ) equalList . add ( item ) ; else { lessThanList . add ( item ) ; } } for ( BIConstraint item : equalList ) { AbstractElement refEle1 = this . getElementByUniqueID ( item . getSrcID ( ) ) ; AbstractElement refEle2 = this . getElementByUniqueID ( item . getDestID ( ) ) ; String refTP1 = this . getRefTP ( refEle1 , item . getSrcRefTP ( ) ) ; String refTP2 = this . getRefTP ( refEle2 , item . getDestRefTP ( ) ) ; String mergeTP = refTP1 + "-" + refTP2 ; if ( ! changedTPNames . containsValue ( refTP1 ) ) { if ( this . updateRefTP ( refEle1 , refTP1 , mergeTP ) ) { this . changedTPElements . put ( refTP1 , refEle1 ) ; this . changedTPNames . put ( refTP1 , mergeTP ) ; } else throw new RuntimeException ( ) ; } else { List < String > affectedKeys = new ArrayList < String > ( ) ; for ( Map . Entry < String , String > entry : changedTPNames . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( refTP1 ) ) affectedKeys . add ( entry . getKey ( ) ) ; } for ( String key : affectedKeys ) { if ( this . updateRefTP ( this . changedTPElements . get ( key ) , this . changedTPNames . get ( key ) , mergeTP ) ) { this . changedTPNames . put ( key , mergeTP ) ; } else throw new RuntimeException ( ) ; } } if ( ! changedTPNames . containsValue ( refTP2 ) ) { if ( this . updateRefTP ( refEle2 , refTP2 , mergeTP ) ) { this . changedTPElements . put ( refTP2 , refEle2 ) ; this . changedTPNames . put ( refTP2 , mergeTP ) ; } else throw new RuntimeException ( ) ; } else { List < String > affectedKeys = new ArrayList < String > ( ) ; for ( Map . Entry < String , String > entry : changedTPNames . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( refTP2 ) ) affectedKeys . add ( entry . getKey ( ) ) ; } for ( String key : affectedKeys ) { if ( this . updateRefTP ( this . changedTPElements . get ( key ) , this . changedTPNames . get ( key ) , mergeTP ) ) { this . changedTPNames . put ( key , mergeTP ) ; } else throw new RuntimeException ( ) ; } } } for ( BIConstraint item : lessThanList ) { AbstractElement refEle1 = this . getElementByUniqueID ( item . getSrcID ( ) ) ; AbstractElement refEle2 = this . getElementByUniqueID ( item . getDestID ( ) ) ; String refTP1 = this . getRefTP ( refEle1 , item . getSrcRefTP ( ) ) ; String refTP2 = this . getRefTP ( refEle2 , item . getDestRefTP ( ) ) ; if ( refTP1 == null || refTP2 == null ) throw new RuntimeException ( ) ; if ( changedTPNames . containsKey ( refTP1 ) ) refTP1 = changedTPNames . get ( refTP1 ) ; if ( changedTPNames . containsKey ( refTP2 ) ) refTP2 = changedTPNames . get ( refTP2 ) ; this . ltTPconstraints . add ( new TPConstraint ( refTP1 , refTP2 ) ) ; } }
Applies the input constraints BBM to the model spec.
Applies the input constraints BBM to the model spec .
//Note: '<' is now 'lt' and '=' is now 'eq' // Update refTPs for '=' constraints. // Maybe have already been updated. // Update refTP1 //this.changedTPNames.remove(key); // Update refTP2 //this.changedTPNames.remove(key); // Create constraint objects for '<' constraints.