@Override public void referenceModified(RefObject target, PropertyChangeEvent evt) { if (((RefObject) evt.getNewValue()).refMetaObject().refGetValue("name").equals("Model")) return; if (!(makeKuaba(evt.getPropertyName()))) return; RefObject source = (RefObject) evt.getSource(); if (!KuabaSubsystem.facade.existsDomainIdea(target)) { PropertyChangeEvent nameEvt = new PropertyChangeEvent(target, "name", "", target.refGetValue("name")); PropertyChangeListener listener = KuabaSubsystem.eventPump.getObserver(target); if (listener == null) { listener = this.createListener(target); if (listener == null) return; KuabaSubsystem.eventPump.addModelElementObserver(listener, target); } listener.propertyChange(nameEvt); Reference ref = MofHelper.getReference(evt.getPropertyName(), (MofClass) source.refMetaObject()); if (!(ref == null)) { String otherSide = MofHelper.getExposedEndName(ref); try { PropertyChangeEvent referenceEvt = new PropertyChangeEvent(target, otherSide, null, target.refGetValue(otherSide)); listener.propertyChange(referenceEvt); } catch (Exception e) { // TODO: handle exception } } } // para evitar a criação do feature if (evt.getPropertyName().equals("feature")) return; // aqui que cria as outras questões do tipo participant e owner Decision d = KuabaSubsystem.facade.referenceChanged( (RefObject) evt.getSource(), target, evt.getPropertyName()); Idea sourceDomainIdea = KuabaHelper.getDomainIdea( modelRepository(), KuabaSubsystem.resolver.resolveXmiId((RefObject) evt.getSource()), this.getNamePropertyValue((RefObject) evt.getSource())); Idea sourceDesignIdea = KuabaHelper.getAcceptedDesignIdea( sourceDomainIdea, (String) ((RefObject) evt.getSource()).refMetaObject().refGetValue("name")); askReferenceChangeArguments( d.getConcludes(), (Question) KuabaHelper.getReasoningElementInTree(sourceDesignIdea, evt.getPropertyName() + "?"), evt); // tirando as ideias de dominio extras if (sourceDesignIdea.getHasText().equals("AssociationEnd")) { sourceDomainIdea.listSuggests().next().remove(); sourceDomainIdea.remove(); } }
protected void removedElement(RefObject source) { KuabaSubsystem.eventPump.removeObservers(source); Idea domainIdea = KuabaSubsystem.facade.getIdeaOnSession(KuabaSubsystem.resolver.resolveXmiId(source)); Question howModelQuestion = (Question) domainIdea.listSuggests().next(); List<Idea> acceptedDesignIdeas = KuabaHelper.getAcceptedAddressedIdeas(howModelQuestion); for (Idea idea : acceptedDesignIdeas) { ArgumentController controller = new ObjectsToArgumentController(null, new Idea[] {idea}, howModelQuestion); controller.render(); } KuabaSubsystem.facade.domainIdeaDesconsidered(domainIdea); KuabaSubsystem.facade.domainIdeaSubTreeCycleDecision(domainIdea, false, 1); // KuabaSubsystem.facade.makeDecisionRootElements(domainIdea,false); }
@Override protected void nameChanged( String newName, String oldName, String designIdeaText, String elementId) { // Se e a primeira ideia if (oldName.equals("newAttr")) { boolean isDomainIdea = false; // Percorre a lista de ideias de dominio para ver se ele ja existe for (Idea domainIdea : KuabaSubsystem.facade.getRootQuestion().getIsAddressedBy()) { if (domainIdea.getHasText().equals(newName)) { // Se existir, considera a ideia de dominio e armazena o argumento boolean isExistent = KuabaSubsystem.facade.reAcceptDomainIdea(domainIdea, "Attribute"); Idea acceptedDesignIdea = null; if (isExistent) acceptedDesignIdea = KuabaHelper.getAcceptedDesignIdea(domainIdea, designIdeaText); else { acceptedDesignIdea = KuabaSubsystem.facade.createIdea( domainIdea.getSuggests().iterator().next(), "Attribute"); KuabaSubsystem.facade.makeDecision( domainIdea.getSuggests().iterator().next(), acceptedDesignIdea, true); } KuabaHelper.getAcceptedDesignIdea(domainIdea, designIdeaText); AttributeObserver.lastAccDmnIdeaId = domainIdea.getId(); ArgumentController controller = new InFavorArgumentController(new Idea[] {acceptedDesignIdea}, null); isDomainIdea = true; controller.render(); } } if (!isDomainIdea) { Idea domainIdea = KuabaSubsystem.facade.domainIdeaAdded(newName, designIdeaText, elementId); Idea acceptedDesignIdea = KuabaHelper.getAcceptedDesignIdea(domainIdea, designIdeaText); if (!(newName.equals(""))) { ArgumentController controller = new InFavorArgumentController(new Idea[] {acceptedDesignIdea}, null); controller.render(); } } } // Se nao for a primeira ideia else if (!oldName.equals("")) { Boolean isDomainIdea = false; // Percorre a lista de ideias de dominio para ver se ele ja existe for (Idea domainIdea : KuabaSubsystem.facade.getRootQuestion().getIsAddressedBy()) { if (domainIdea.getHasText().equals(newName)) { // Se existir, considera a ideia de dominio e armazena o argumento // KuabaSubsystem.facade.domainIdeaConsidered(domainIdea); isDomainIdea = true; Idea acceptedDesignIdea = KuabaHelper.getAcceptedDesignIdea(domainIdea, designIdeaText); ArgumentController controller = new InFavorArgumentController(new Idea[] {acceptedDesignIdea}, null); controller.render(); } } // Se nao existir, cria uma ideia de dominio para a nova ideia if (!isDomainIdea) { Idea domainIdea = KuabaSubsystem.facade.domainIdeaAdded(newName, designIdeaText, elementId); Idea acceptedDesignIdea = KuabaHelper.getAcceptedDesignIdea(domainIdea, designIdeaText); ArgumentController controller = new InFavorArgumentController(new Idea[] {acceptedDesignIdea}, null); controller.render(); // Obtem a ideia de dominio rejeitada e a remove da lista de ideias de dominio aprovadas Idea rejectedDomainIdea = KuabaSubsystem.getSession().unitOfWork().getConsideredIdeaByName(oldName); Idea rejectedDesignIdea = KuabaHelper.getAcceptedDesignIdea(rejectedDomainIdea, "Attribute"); // Recusa a decisao e copia as questoes rejectedDesignIdea .getAddress() .iterator() .next() .getHasDecision() .iterator() .next() .setIsAccepted(false); KuabaSubsystem.facade.copyQuestions(rejectedDesignIdea, acceptedDesignIdea, 1); // Obtem a ideia de dominio que e o "owner" da ideia de design aceita // ps:Percorri a estrutura -> atributo -> (Owner?) -> Class e chamei a func de KuabaHelper // pra me buscar a ideia de dominio correspondente a Class obtida Idea owner = KuabaHelper.getDomainIdea( acceptedDesignIdea .getSuggests() .iterator() .next() .getIsAddressedBy() .iterator() .next()); String text = "Why make " + owner.getHasText() + " owner of " + KuabaHelper.getDomainIdea(acceptedDesignIdea).getHasText() + "?"; controller = new InFavorArgumentController( new Idea[] {acceptedDesignIdea}, null, text, acceptedDesignIdea.getSuggests().iterator().next()); controller.render(); KuabaSubsystem.facade.domainIdeaDesconsidered(rejectedDomainIdea); controller = new ObjectsToArgumentController(null, new Idea[] {rejectedDesignIdea}); controller.render(); } // Se ja existir, entao deve inverter as decisoes da subarvore else { // Primeiro verifico se ja existia uma ideia de design. Caso nao existisse, devo copiar esta // subarvore para a ideia de dominio, // senao, devo apenas percorrer a subarvore mudando a decisao Idea rejectedDomain = KuabaSubsystem.getSession().unitOfWork().getConsideredIdeaByName(oldName); Idea rejectedDesign = KuabaSubsystem.facade.getDesignIdea(rejectedDomain, "Attribute"); // newName esta na lista de ideias consideradas porque foi inserido mais acima. Preciso ler // de la Idea acceptedDomain = KuabaSubsystem.getSession().unitOfWork().getConsideredIdeaByName(newName); Idea acceptedDesign = KuabaSubsystem.facade.getDesignIdea(acceptedDomain, "Attribute"); // Se a ideia de dominio existia, mas a ideia de design nao, devo copiar a ideia de design // da ideia de dominio rejeitada // e enderecar para a questao sugerida pela ideia de dominio aceita. if (acceptedDesign == null) { acceptedDesign = KuabaSubsystem.facade.copyIdea(rejectedDesign); acceptedDesign.addAddress(acceptedDomain.getSuggests().iterator().next()); KuabaSubsystem.facade.copyQuestions(rejectedDesign, acceptedDesign, 1); KuabaSubsystem.facade.domainIdeaDesconsidered(rejectedDomain); } // Se ja existe ideia de design, devo percorrer a arvore modificando a decisao else KuabaSubsystem.facade.rejectAndAcceptOwnership(rejectedDesign, acceptedDesign); } // Se houver uma ideia de dominio com o nome antigo, deve rejeita-lo Idea rejectedDomainIdea = KuabaSubsystem.facade.findDomainIdea(oldName, "Class"); if (rejectedDomainIdea != null) { KuabaSubsystem.facade.domainIdeaDesconsidered(rejectedDomainIdea); Idea rejectedDesignIdea = KuabaHelper.getRejectedDesignIdea(rejectedDomainIdea, "Attribute"); Question howModelQuestion = (Question) rejectedDomainIdea.listSuggests().next(); ArgumentController controller = new ObjectsToArgumentController( null, new Idea[] {rejectedDesignIdea}, howModelQuestion); controller.render(); } } }